Jump to content

I can has scripting help?


jovialAssassin

Recommended Posts

Evening gents (and ladies),

 

I'm trying to modify the Omnitool mod to activate the omnitool menu while wearing said item from a keypress instead of having to open the Pip-boy every time and equipping/unequipping it to access the menu (in this case, the key being N).

 

Seeing as GECK refuses to save it I'm lead to believe I'm making some sort of error in the coding.

 

Code spoiler'd due to size

 

ScriptName OmniToolMenuScript

int iButton
int iMenuLevel
short on
long Caps
long Omni
long Omni2
int Reap
short remenu
ref bIsNPressed

Begin OnEquip player
if bIsNPressed != IsKeyPressed 49
		set bIsNPressed to IsKeyPressed 49
			if bIsNPressed
				set on to 1
				set iMenuLevel to 0
				ShowMessage OmniToolMenuMessage
			endif
	endif
End

Begin GameMode
if on
	set iButton to GetButtonPressed
	if iButton == -1
		Return
	elseif iMenuLevel == 0
		if iButton == 0
			Set iMenuLevel to 1
			ShowMessage OmniToolMenuRepairMessage
			return
		elseif iButton == 1
			player.showrecipemenu WorkbenchRecipes
			set on to 0
			return
		elseif iButton == 2
			player.showrecipemenu ReloadingBenchRecipes
			set on to 0
			return
		elseif iButton == 3
			player.showrecipemenu CampfireRecipes
			set on to 0
			return
		elseif iButton == 4
			player.showrecipemenu OmniToolRecipes
			set on to 0
			return
		elseif iButton == 5
			set on to 0
			return
		endif
	elseif iMenuLevel == 1
		if iButton != 5
			set Caps to player.GetItemCount Caps001
			set Omni to player.GetItemCount OmniGel
			player.removeitem Caps001 Caps 1
			player.removeitem OmniGel Omni 1
			player.additem Caps001 Omni 1
			if iButton == 0
				OmniRepairmanREF.ForceAV Repair 25
			elseif iButton == 1
				OmniRepairmanREF.ForceAV Repair 50
			elseif iButton == 2
				OmniRepairmanREF.ForceAV Repair 75
			elseif iButton == 3
				OmniRepairmanREF.ForceAV Repair 100
			elseif iButton == 4
				set Reap to player.getav Repair + 10
				OmniRepairmanREF.ForceAV Repair Reap
			endif
			set remenu to 1
			OmniRepairmanREF.ShowRepairMenu
			set on to 0
			return
		elseif iButton == 5
			Set iMenuLevel to 0
			ShowMessage OmniToolMenuMessage
			return
		endif
	endif
endif
if remenu == 2
			OmniRepairmanREF.ResetInventory
			set Omni2 to player.GetItemCount Caps001
			player.removeitem Caps001 Omni 1
			player.additem OmniGel Omni2 1
			player.additem Caps001 Caps 1
			set remenu to 0
endif
End

Begin MenuMode 1058
if remenu == 1
Set remenu to 2
endif
End

 

 

And for reference, here's the author's original script

 

ScriptName OmniToolMenuScript

int iButton
int iMenuLevel
short on
long Caps
long Omni
long Omni2
int Reap
short remenu

Begin OnEquip player
set on to 1
set iMenuLevel to 0
ShowMessage OmniToolMenuMessage
End

Begin GameMode
if on
	set iButton to GetButtonPressed
	if iButton == -1
		Return
	elseif iMenuLevel == 0
		if iButton == 0
			Set iMenuLevel to 1
			ShowMessage OmniToolMenuRepairMessage
			return
		elseif iButton == 1
			player.showrecipemenu WorkbenchRecipes
			set on to 0
			return
		elseif iButton == 2
			player.showrecipemenu ReloadingBenchRecipes
			set on to 0
			return
		elseif iButton == 3
			player.showrecipemenu CampfireRecipes
			set on to 0
			return
		elseif iButton == 4
			player.showrecipemenu OmniToolRecipes
			set on to 0
			return
		elseif iButton == 5
			set on to 0
			return
		endif
	elseif iMenuLevel == 1
		if iButton != 5
			set Caps to player.GetItemCount Caps001
			set Omni to player.GetItemCount OmniGel
			player.removeitem Caps001 Caps 1
			player.removeitem OmniGel Omni 1
			player.additem Caps001 Omni 1
			if iButton == 0
				OmniRepairmanREF.ForceAV Repair 25
			elseif iButton == 1
				OmniRepairmanREF.ForceAV Repair 50
			elseif iButton == 2
				OmniRepairmanREF.ForceAV Repair 75
			elseif iButton == 3
				OmniRepairmanREF.ForceAV Repair 100
			elseif iButton == 4
				set Reap to player.getav Repair + 10
				OmniRepairmanREF.ForceAV Repair Reap
			endif
			set remenu to 1
			OmniRepairmanREF.ShowRepairMenu
			set on to 0
			return
		elseif iButton == 5
			Set iMenuLevel to 0
			ShowMessage OmniToolMenuMessage
			return
		endif
	endif
endif
if remenu == 2
			OmniRepairmanREF.ResetInventory
			set Omni2 to player.GetItemCount Caps001
			player.removeitem Caps001 Omni 1
			player.additem OmniGel Omni2 1
			player.additem Caps001 Caps 1
			set remenu to 0
endif
End

Begin MenuMode 1058
if remenu == 1
Set remenu to 2
endif
End

 

 

Any assistance would be greatly appreciated.

Link to comment
Share on other sites

Have you contacted the author?

 

I could take look at it tomorrow, looks like he put full permissions for modification on it. But I would still try the author first.

Tomorrow I'll be writing more dialog, and scripts for my quest and when I get stuck. I find it's better I just work on something completly different, then take my mouse, and put it through my monitor.

 

 

I just sent an email to him about modding his mod. Looks like he hasnt been here in 5 months though.

Edited by Floatsup
Link to comment
Share on other sites

To be honest, I haven't. Though in truth it was never my intent to release my changes to the public, this was just for my own use.

 

If you could take a look at it, that'd be awesome, thanks.

 

Edit: I've managed to get the script to save by changing

 

ref bIsNPressed

to:

int bIsNPressed

 

Doesn't have any effect on the item ingame, though.

Edited by jovialAssassin
Link to comment
Share on other sites

Sorry for the double post, but after much face-desking, rereading tutorials and a flash of insight, I've figured out what I was doing wrong and managed to get it to respond to a hotkey instead of the original method.

 

Here's the code if anyone wants to take a look at it for reference purposes

 

 

ScriptName OmniToolMenuScript

int iButton
int iMenuLevel
short on
short acti
long Caps
long Omni
long Omni2
int Reap
short remenu
int bIsNPressed

Begin OnEquip player
       set acti to 1
End

Begin GameMode
		if acti 
			if bIsNPressed != IsKeyPressed 49
				set bIsNPressed to IsKeyPressed 49
					if bIsNPressed
						set on to 1
						set iMenuLevel to 0
						ShowMessage OmniToolMenuMessage
				endif
			endif
		endif
       if on
               set iButton to GetButtonPressed
               if iButton == -1
                       Return
               elseif iMenuLevel == 0
                       if iButton == 0
                               Set iMenuLevel to 1
                               ShowMessage OmniToolMenuRepairMessage
                               return
                       elseif iButton == 1
                               player.showrecipemenu WorkbenchRecipes
                               set on to 0
                               return
                       elseif iButton == 2
                               player.showrecipemenu ReloadingBenchRecipes
                               set on to 0
                               return
                       elseif iButton == 3
                               player.showrecipemenu CampfireRecipes
                               set on to 0
                               return
                       elseif iButton == 4
                               player.showrecipemenu OmniToolRecipes
                               set on to 0
                               return
                       elseif iButton == 5
                               set on to 0
                               return
                       endif
               elseif iMenuLevel == 1
                       if iButton != 5
                               set Caps to player.GetItemCount Caps001
                               set Omni to player.GetItemCount OmniGel
                               player.removeitem Caps001 Caps 1
                               player.removeitem OmniGel Omni 1
                               player.additem Caps001 Omni 1
                               if iButton == 0
                                       OmniRepairmanREF.ForceAV Repair 25
                               elseif iButton == 1
                                       OmniRepairmanREF.ForceAV Repair 50
                               elseif iButton == 2
                                       OmniRepairmanREF.ForceAV Repair 75
                               elseif iButton == 3
                                       OmniRepairmanREF.ForceAV Repair 100
                               elseif iButton == 4
                                       set Reap to player.getav Repair + 10
                                       OmniRepairmanREF.ForceAV Repair Reap
                               endif
                               set remenu to 1
                               OmniRepairmanREF.ShowRepairMenu
                               set on to 0
                               return
                       elseif iButton == 5
                               Set iMenuLevel to 0
                               ShowMessage OmniToolMenuMessage
                               return
                       endif
               endif
       endif
       if remenu == 2
                               OmniRepairmanREF.ResetInventory
                               set Omni2 to player.GetItemCount Caps001
                               player.removeitem Caps001 Omni 1
                               player.additem OmniGel Omni2 1
                               player.additem Caps001 Caps 1
                               set remenu to 0
       endif
End

Begin MenuMode 1058
if remenu == 1
Set remenu to 2
endif
End

 

Link to comment
Share on other sites

thats because its not in the gammode block, it need to be updating constantly to check for keypresses.

but... the showmessage and variables may not register properly if theyr running on the same frame.. soo test it.

if it acts buggy but is initializing you are going to need to put a timer in there to interrupt the frame.

 

you can use this to interrupt the script if needed, test it first you may not need to:

 

 

float fTimer

ShowMessage OmniToolMenuMessage

set fTimer to .5

label 1

if fTimer > 0

set fTimer to fTimer - GetSecondsPassed

goto 1

endif

set on to 1

set iMenuLevel to 0

Edited by angelwraith
Link to comment
Share on other sites

Well i didn't expect my mod to be redigged after that long time ;p

 

I stopped playing with GECK long time ago and i decided to allow anyone to mess with it but i an grateful that jovialAssassin contacted me anyway ;p you have my full permission and endorsement to mess with it and make it better ;p

 

One thing i never got time to add was omnigel based lock breaking with price connected to how hard lock is to break ;p

 

and medigel based remote healing of teammates ;p

 

But if you want to make it work with NVSE it should be easier to make than for me messing with vanilla version ;p

 

Anyway good luck and have fun ;p

Link to comment
Share on other sites

Alright gentlemen, round 2 of, "What the hell am I doing wrong here?"

 

Here I'm trying to convince the game to output an amount of omnigel equaling the the amount of weight in the OmniStorage container multiplied by 10. GECK seems happy enough that it'll save it without a fuss, buuuut iButton 6, which is supposed to delete all the items and add an appropriate amount of omnigel to the player's inventory, is in fact not working.

 

Any ideas as to what I'm missing? And thanks for the help so far, and in the future.

 

 

ScriptName OmniToolMenuScript

int iButton
int iMenuLevel
float InvWt1
float InvWt2
float OmniConvert
float OmniConvert2
short on
short acti
long Caps
long Omni
long Omni2
int Reap
short remenu
int bIsNPressed

Begin OnEquip player
set acti to 1
End


Begin OnOpen OmniStorageREF
set InvWt1 to Player.GetActorValue InventoryWeight
End

Begin OnClose OmniStorageREF
set InvWt2 to Player.GetActorValue InventoryWeight
set OmniConvert to InvWt1 - InvWt2
set OmniConvert2 to (OmniConvert * 10)
End

Begin GameMode
if acti == 1
	if bIsNPressed != IsKeyPressed 49
		set bIsNPressed to IsKeyPressed 49
		if bIsNPressed
			set on to 1
			set iMenuLevel to 0
			ShowMessage OmniToolMenuMessage
		endif
	endif
endif
if on == 1
	set iButton to GetButtonPressed
	if iButton == -1
		Return
	elseif iMenuLevel == 0
		if iButton == 0
			Set iMenuLevel to 1
			ShowMessage OmniToolMenuRepairMessage
			return
		elseif iButton == 1
			player.showrecipemenu WorkbenchRecipes
			set on to 0
			return
		elseif iButton == 2
			player.showrecipemenu ReloadingBenchRecipes
			set on to 0
			return
		elseif iButton == 3
			player.showrecipemenu CampfireRecipes
			set on to 0
			return
		elseif iButton == 4
			player.showrecipemenu OmniToolRecipes
			set on to 0
			return
		elseif iButton == 5
			OmniStorageREF.Activate Player
			set on to 0
			return
		elseif iButton == 6
			AddItem OmniGel OmniConvert2 1
			RemoveAllItems OmniStorageREF
			set on to 0
			return
		elseif iButton == 7
			set on to 0
			return
		endif
	elseif iMenuLevel == 1
		if iButton != 7
			set Caps to player.GetItemCount Caps001
			set Omni to player.GetItemCount OmniGel
			player.removeitem Caps001 Caps 1
			player.removeitem OmniGel Omni 1
			player.additem Caps001 Omni 1
			if iButton == 0
				OmniRepairmanREF.ForceAV Repair 25
			elseif iButton == 1
				OmniRepairmanREF.ForceAV Repair 50
			elseif iButton == 2
				OmniRepairmanREF.ForceAV Repair 75
			elseif iButton == 3
				OmniRepairmanREF.ForceAV Repair 100
			elseif iButton == 4
				set Reap to player.getav Repair + 10
				OmniRepairmanREF.ForceAV Repair Reap
			endif
			set remenu to 1
			OmniRepairmanREF.ShowRepairMenu
			set on to 0
			return
		elseif iButton == 7
			Set iMenuLevel to 0
			ShowMessage OmniToolMenuMessage
			return
		endif
	endif
endif
if remenu == 2
	OmniRepairmanREF.ResetInventory
	set Omni2 to player.GetItemCount Caps001
	player.removeitem Caps001 Omni 1
	player.additem OmniGel Omni2 1
	player.additem Caps001 Caps 1
	set remenu to 0
endif
End

Begin OnUnEquip player
set acti to 0
End

Begin MenuMode 1058
if remenu == 1
	Set remenu to 2
endif
End

 

Link to comment
Share on other sites

the open and close blocks are being use incorrectly.

 

in fact i dont think it is even possible for onopen and onequip to be in the same script as you cant equip a container.

 

those are intended to be used on the container itself.

 

i would suggest using "if OmniStorageREF.getopenstate == 1" for open and "if OmniStorageREF.getopenstate == 3" for close in the gamemode block.

 

you may have to set up a toggle so it doesn't run twice.

 

 

there is another potentially huge problem; whats preventing me from dropping all my useless raider armors in that container to trick the inventory weight metering?

Edited by angelwraith
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...