Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
27 bytes removed ,  12:33, 29 August 2007
imported>Haama
imported>Haama
 
==Moving Between Multiple Menus==
===Review===
As stated before, each menu has a pair of corresponding numbers. For clarity and to keep the two necessary halves of menus separate, those pairs of numbers have been set up a a negative number (i.e., -1) and a positive number (1). The negative number refers to the code that displays the menu:
<pre>...
from anywhere else in the script.
 
===Using numbers to track menu layers===
If you're making multi-layered menus, you can use the numbers to know which layer you're on and the previous menu(s). For the first layer (the main menu), use the pair -1/1. For the branching menus, use -11/11, -12/12, etc. If menu -11 has more branches, set them to -111/111, -112/112, etc.
 
Each new layer gets an extra number. For example, a sub-branch from menu -12 would be -121. The number on the right refers to the sub-branch, while the numbers on the left refer to the menu they branched from. This is recursive, so in this example -121 is the first sub-branch from menu -12, and -12 is the second sub-branch from the menu -1.
 
===Example script===
Here's several examples of menu switching: (also, please note that due to wiki limitations, the messageboxes below have been given line breaks, whereas in the CS they would be on one line)
<pre>Short Choosing
Short Choice
short Reset
 
 
 
Begin onActivate
Set Reset to 1
Set Choosing to -1
If (GetInSameCell player == 0)
Begin GameMode
If (Choosing == 0) ;meaning it shouldn't be running
If Reset
Set Reset to 0
Endif
If (GetInSameCell YourXMarker == 0)
MoveTo YourXMarker
 
Elseif (Choosing == -1) ;Display your menu
Messagebox "WouldWhat would you like to donate gold or food?" "Gold" "Food" "Blood" "Cancel"
"Blood" "Cancel"
Set Choosing to 1
Set Choice to GetButtonPressed-1
Return
 
Elseif (Choosing == 1)
If (Choice == -1) ;No choice yet
Set Choice to GetButtonPressed
Return
Elseif (Choice == 0) ;Gold
Set Choosing to -211 ;to open the Gold menu
Elseif (Choice == 1) ;Food
Set Choosing to -312 ;to open the Food menu
Elseif (Choice == 2) ;Blood
Set Choosing to -413 ;to open the Blood menu
Elseif (Choice == 3) ;Cancel
Set Choosing to 0 ;to close the menus
Endif
Return
 
Elseif (Choosing == -211) ;Gold menu
Messagebox "How much Gold would you like to donate?" "25"
"I've changed my mind" "I've changed my mind, I'll donate Food"
"I've changed my mind, I'll donate Blood"
"I've changed my mind, I won't donate anything"
Set Choosing to 211
Set Choice to GetButtonPressed-1
Return
 
Elseif (Choosing == 211)
If (Choice == -1) ;No choice yet
Set Choice to GetButtonPressed
Set Choosing to -1 ;to return to the opening menu
Elseif (Choice == 2) ; I've changed my mind, I'll donate food
Set Choosing to -312 ;to open the food menu
Elseif (Choice == 3) ; I've changed my mind, I'll donate blood
Set Choosing to -413 ;to open the blood menu
Elseif (Choice == 4) ; I've changed my mind, I won't donate anything
Set Choosing to 0 ;to close the menus
Endif
Return
 
Elseif (Choosing == -312) ;Food menu
Messagebox "How much food would you like to donate?" "Options"
"More Options"
...
"Cancel"
Set Choosing to 312
Set Choice to GetButtonPressed
Return
 
Elseif (Choosing == 3)
Set Choosing to 99
Set Choice to GetButtonPressed
Return
 
Elseif (Choosing == 99)
Set Choosing to -1
Endif
Return
 
 
Anonymous user

Navigation menu