Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
283 bytes added ,  09:29, 25 August 2007
imported>ShadowDancer
imported>Haama
 
===Multiple Menus in a Spell Script===
A spell presents several challenges for multiple menus, but it can be done. Most importantly, you will need to set a high duration on the spell (see [[GetButtonPressed#GameMode or MenuMode?]]). However, the player could still open enough menus to run down the duration, no matter how long. To cover this scenario, all of the menu variables will be copied to a persistent object (in this case, the quest MenuVariables) when the spell runs out, and the spell will be recast.
Below is an example of multiple menus in a spell script. '''Step''' is used to control the stages of [[ScriptEffectUpdate]] for the '''MessageBox''' and the '''GetButtonPressed''' functions. While the initial '''MessageBox''' for the spell could have been in the [[ScriptEffectStart]], it is in the '''ScriptEffectUpdate''' block for clarity. Most of the button names as well as scripting have been left out so that the basics of manipulating multiple '''MessageBox''' functions can be seen.
 
This leads to one more small problem - if the variables are left set, then every time the spell is cast the menu would start more it left off before (well, ok, this could be cool, but I'll assume it's undesirable). To solve this, all of the external menu variables will be reset when the player exits the menu.
<pre> ScriptName ExampleScript
 
Note also that, as of now, this hasn't been tested for multiple menus.
Short Step
 
Short ButtonChoice1
The quest script:
Short ButtonChoice2
<pre>scn MenuVariablesScript
{Set Other Variables}
 
Short Choosing
Short Choice</pre>
Begin ScriptEffectStart
 
The spell script:
{Set up start of Spell}
<pre>Short Choosing
Set Step to 1
Short Choice
 
End
 
 
Begin ScriptEffectUpdateSpellEffectStart
if MenuVariables.Choosing
Set Choosing to MenuVariables.Choosing
If Step == 1
Set Choice to MenuVariables.Choice
Messagebox "What do you want to do?", ["Button0"], ..., ["Button8"], "Next Page"
else
Set Step to 2
Set Choosing to -1
EndIf
endif
End
If Step == 2
 
Set ButtonChoice1 to GetButtonPressed
 
If ButtonChoice1 == 0
 
{script to do whatever button is for}
Begin SpellEffectUpdate
Set Step to 0
If (Choosing == 0) ;meaning it shouldn't be running
ElseIf ButtonChoice1 == 1
set MenuVariables.Choosing to 0
{script to do whatever button is for}
set Set StepMenuVariables.Choice to 0
Return
ElseIf ButtonChoice1 == 2
 
{script to do whatever button is for}
 
Set Step to 0
Elseif (Choosing == -1) ;Display your menu
ElseIf ButtonChoice1 == 3
Messagebox "What do you want to do?", ["Button0"], ..., ["Button8"], "Next Page"
{script to do whatever button is for}
Set StepChoosing to 01
Set Choice to GetButtonPressed
ElseIf ButtonChoice1 == 4
Return
{script to do whatever button is for}
 
Set Step to 0
Elseif (Choosing == 1)
ElseIf ButtonChoice1 == 5
If (Choice == -1) ;No choice yet
{script to do whatever button is for}
Set StepChoice to 0GetButtonPressed
Return
ElseIf ButtonChoice1 == 6
Elseif (Choice == 0) ;Button0
{script to do whatever button is for}
;Whatever Setyou Stepwant to 0do
ElseIf ButtonChoice1Set ==Choosing 7to 0
...
{script to do whatever button is for}
Elseif (Choice == Set8) Step to 0;Button8
;Whatever you want to do
ElseIf ButtonChoice1 == 8
Set {scriptChoosing to do whatever button is for}0
Elseif (Choice == Set9) Step;Next to 0Page
Set Choosing to -2 ;Following menu (choosing == -2)
ElseIf ButtonChoice1 == 9
Endif
Set Step to 3
EndIfReturn
 
EndIf
Elseif (Choosing == -2) ;Gold menu
Messagebox "What do you want to do?", ["Button0"], ..., ["Button8"], "Exit"
If Step == 3
Set Choosing to 2
Messagebox "What do you want to do?", ["Button0"], ..., ["Button2"], "Quit"
Set StepChoice to 4GetButtonPressed
EndIf Return
 
Elseif If Step(Choosing == 42)
If (Choice == -1) ;No choice yet
Set ButtonChoice2 to GetButtonPressed
Set Choice to GetButtonPressed
If ButtonChoice2 == 0
Elseif (Choice == 0) ;Button0
{script to do whatever button is for}
;Whatever Setyou Stepwant to 0do
ElseIf ButtonChoice2set ==Choosing 1to 0
...
{script to do whatever button is for}
Elseif (Choice == Set8) Step to 0;Button8
;Whatever you want to do
ElseIf ButtonChoice2 == 2
Set {scriptChoosing to do whatever button is for}0
Elseif (Choice == Set9) Step to 0;Exit
Set Choosing to 0 ;to close the menus
ElseIf ButtonChoice2 == 3
Endif
Set Step to 0
EndIfReturn
 
EndIf
 
Endif
End</pre>
End
 
 
 
begin ScriptEffectFinish
if Choosing
set MenuVariables.Choosing to Choosing
set MenuVariables.Choice to Choice
player.Cast Spell
endif
end</pre>
 
'''Notes:'''
Anonymous user

Navigation menu