Difference between revisions of "MessageBox Tutorial"
Jump to navigation
Jump to search
→Moving Between Multiple Menus: Rewrite2
imported>Haama (→Moving Between Multiple Menus: Rewrite) |
imported>Haama (→Moving Between Multiple Menus: Rewrite2) |
||
|
==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 "
Set Choosing to 1
Set Choice to
Elseif (Choosing == 1)
If (Choice == -1) ;No choice yet
Set Choice to GetButtonPressed
Elseif (Choice == 0) ;Gold
Set Choosing to -
Elseif (Choice == 1) ;Food
Set Choosing to -
Elseif (Choice == 2) ;Blood
Set Choosing to -
Elseif (Choice == 3) ;Cancel
Set Choosing to 0 ;to close the menus
Endif
Elseif (Choosing == -
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
Set Choice to
Elseif (Choosing ==
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 -
Elseif (Choice == 3) ; I've changed my mind, I'll donate blood
Set Choosing to -
Elseif (Choice == 4) ; I've changed my mind, I won't donate anything
Set Choosing to 0 ;to close the menus
Endif
Elseif (Choosing == -
Messagebox "How much food would you like to donate?" "Options"
"More Options"
...
"Cancel"
Set Choosing to
Set Choice to GetButtonPressed
Elseif (Choosing == 3)
Set Choosing to 99
Set Choice to GetButtonPressed
Elseif (Choosing == 99)
Set Choosing to -1
Endif
| |||