Help - Search - Members - Calendar
Full Version: Message box
The Nexus Forums > Specific Games > Oblivion > Oblivion Modifications > Mod Troubleshooting
lordneverar
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
EndIf
End
herosinger
Add the line "short button"

CODE
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
lordneverar
QUOTE(herosinger @ Jun 14 2008, 12:51 AM) *
Add the line "short button"

CODE
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

tyvm!
Vagrant0
QUOTE(lordneverar @ Jun 14 2008, 12:40 AM) *

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.
nosisab
QUOTE(lordneverar @ Jun 14 2008, 12:40 AM) *
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
EndIf
End

Even 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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.