Jump to content

Script doesn't work


RellioN

Recommended Posts

I'm new to scripting. I made this by looking at other scripts and the GECK wiki.

 

This is attached to an autodoc, a message pops up and this script is supposed to define what the options do when you click on them. The menu is there, but the buttons in the menu do nothing, and if i give button 0 a function, it's actions always runs when the message starts. (button 0 is now "Cancel").

 

scn JVaultAutodocScript

short Button

begin OnActivate

if IsActionRef player
	
	ShowMessage JVaultAutodocMsg
	
endif

end

begin MenuMode 1001

if (Button == 1)

	player.resethealth

endif	

if (Button == 2)

	player.RestoreAV RadiationRads 1000

endif

if (Button == 3)

	RemoveSpell WithdrawalAlcohol
	RemoveSpell WithdrawalBuffout
	RemoveSpell WithdrawalHydra
	RemoveSpell WithdrawalJet
	RemoveSpell WithdrawalMentats
	RemoveSpell WithdrawalMorphine
	RemoveSpell WithdrawalPsycho
	RemoveSpell WithdrawalQuantumNukacola
	RemoveSpell WithdrawalRebound
	RemoveSpell WithdrawalSteady
	RemoveSpell WithdrawalTobacco
	RemoveSpell WithdrawalTurbo

endif

if (Button == 4)

	ShowPlasticSurgeonMenu

endif

end

Edited by RellioN
Link to comment
Share on other sites

Heya, looks like you'd need to catch which button is actually pressed when your message shows in menu mode.

 

Use GetButtonPressed to do this.

 

In your script, right underneath "begin MenuMode 1001" add;

Set Button to GetButtonPressed
   IF Button == -1 
         Return

 

Button will be set to -1 by GetButtonPressed as long as no button is pressed.

You use Return to keep scanning for a button press, and unleash the rest of the script as soon as it gets set to another value by an actual button press on your message.

Remember that the first button in a message is always 0, then second is 1 and so forth. Replace the current IFs in your script with Elseif statements, to set what should happen when any of the buttons is pressed for the remainder of the script. Elseif's are not closed with endif's so remove those as well. Also dont forget to close the first IF with an ENDIF at the end. Should work. :)

Edited by Oes10
Link to comment
Share on other sites

Heya, looks like you'd need to catch which button is actually pressed when your message shows in menu mode.

 

Use GetButtonPressed to do this.

 

In your script, right underneath "begin MenuMode 1001" add;

Set Button to GetButtonPressed
   IF Button == -1 
         Return

 

Button will be set to -1 by GetButtonPressed as long as no button is pressed.

You use Return to keep scanning for a button press, and unleash the rest of the script as soon as it gets set to another value by an actual button press on your message.

Remember that the first button in a message is always 0, then second is 1 and so forth. Replace the current IFs in your script with Elseif statements, to set what should happen when any of the buttons is pressed for the remainder of the script. Elseif's are not closed with endif's so remove those as well. Also dont forget to close the first IF with an ENDIF at the end. Should work. :)

 

I don't use the MenuMode block often if ever actually (for my own personal needs) however I have set up several scenarios similar to what you are trying to accomplish

 

The previous poster is correct you need to be using GetButonPressed in order to catch the input from the message box. The script also need to be constantly checking for this input which is why you should be running your verification in the gamemode block once the user inputs the button the MenuMode block will cease to continue.

 

Also of note message box selection options being with 0 you are starting your check at 1. The first button = 0 second button = 1 etc. You can verify the index when creating the the message box in the properties window

 

 

 

try the following

scn JVaultAutodocScript

int Button

begin OnActivate

       if (IsActionRef player)
               
               ShowMessage JVaultAutodocMsg
               
       endif

end

begin gamemode

       set button to GetButtonPressed     ; If no button has been pressed yet it will continually return -1

        if (Button == 0)

               player.resethealth

       endif   

       if (Button == 1)

               player.RestoreAV RadiationRads 1000

       endif

       if (Button == 2)

               RemoveSpell WithdrawalAlcohol
               RemoveSpell WithdrawalBuffout
               RemoveSpell WithdrawalHydra
               RemoveSpell WithdrawalJet
               RemoveSpell WithdrawalMentats
               RemoveSpell WithdrawalMorphine
               RemoveSpell WithdrawalPsycho
               RemoveSpell WithdrawalQuantumNukacola
               RemoveSpell WithdrawalRebound
               RemoveSpell WithdrawalSteady
               RemoveSpell WithdrawalTobacco
               RemoveSpell WithdrawalTurbo

       endif

       if (Button == 3)

               ShowPlasticSurgeonMenu

       endif

end

 

Also note this method will only work with a single message box, if you start setting up a system where you need multiple inputs things will begin to get a lot more complex due to how the blocks run. Also I am not 100% certain this will work for you, as this is the method i use since I typically do this type of thing off of a Quest script. Not an Object Script, so you may need to use MenuMode block but the process should still be the same.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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