lordneverar Posted June 14, 2008 Share Posted June 14, 2008 im making a message box choice where you click on ether "yes" or "no" but whenever I go to save the script it says "button" is an invalid variable. here is my script if it will help any... scn LORDtheonering10unequip Begin OnActivate Messagebox "Do you wish to take off the One Ring?", "Yes", "No"Set button to GetButtonPressed If ( button == -1 ) Return ElseIf ( button == 2) MessageBox "You take the ring off." Setstage theringofpower 20 Else MessageBox "You leave the ring on." EndIf EndIfEnd Link to comment Share on other sites More sharing options...
herosinger Posted June 14, 2008 Share Posted June 14, 2008 Add the line "short button" scn LORDtheonering10unequip short button Begin OnActivate Messagebox "Do you wish to take off the One Ring?", "Yes", "No" Set button to GetButtonPressed If ( button == -1 ) Return ElseIf ( button == 2) MessageBox "You take the ring off." Setstage theringofpower 20 Else MessageBox "You leave the ring on." EndIf EndIf End Link to comment Share on other sites More sharing options...
lordneverar Posted June 14, 2008 Author Share Posted June 14, 2008 Add the line "short button" scn LORDtheonering10unequip short button Begin OnActivate Messagebox "Do you wish to take off the One Ring?", "Yes", "No" Set button to GetButtonPressed If ( button == -1 ) Return ElseIf ( button == 2) MessageBox "You take the ring off." Setstage theringofpower 20 Else MessageBox "You leave the ring on." EndIf EndIf Endtyvm! Link to comment Share on other sites More sharing options...
Vagrant0 Posted June 14, 2008 Share Posted June 14, 2008 Message boxes require an additional frame to run before any action taken by those button presses can be done. Since Onactivate only runs for one frame, you will need to include any actions within a seperate block (menumode, gamemode) that only becomes active once the activate block has run (by using a variable and an IF statement). Additionally, message boxes don't run reliably while in inventory. And for the most part, when someone goes to remove a ring, there is usually intention behind it. Meaning that although this might be a good learning experience from a scripting standpoint, it may make your mod seem less playable since they would be prompted every time they equipped/removed the ring. Oh, and Onactivate doesn't work for inventory items. Onactivate will only trigger when the item is placed in world, and an attempt is made to pick it up. What you need instead is a OnEquip (despite the fact that you want this triggered when you want the ring removed since Onequip happens when in inventory, and before the item is unequiped, when an attempt to unequip is made (I think)). And, an action within an Unequip block will be run when the item is removed via scripting, which might lead to some looping in your script. So it's um... Complicated. Link to comment Share on other sites More sharing options...
nosisab Posted June 14, 2008 Share Posted June 14, 2008 im making a message box choice where you click on ether "yes" or "no" but whenever I go to save the script it says "button" is an invalid variable. here is my script if it will help any... scn LORDtheonering10unequip Begin OnActivate Messagebox "Do you wish to take off the One Ring?", "Yes", "No"Set button to GetButtonPressed If ( button == -1 ) Return ElseIf ( button == 2) MessageBox "You take the ring off." Setstage theringofpower 20 Else MessageBox "You leave the ring on." EndIf EndIfEndEven without trying understanding the complete logic ... as it is this script don't even compiles and the reason is said in the message. Button is not 'defined' as variable ... define it as short and the this problem is gone. Yet the logic is strange... The test is wrong. getbuttonpressed returns 0 to the first one, 1 to the second.... and -1 if none, you never get 2 there.Since messagebox stop time the -1 is better used to force it being presented again (if some other message box overlap it, for example) PS edit: You are advised reading a bit more about name conventions and some others little things, in a little mod may not be problem, but in larger projects you get lost quickly and easily. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.