Difference between revisions of "MessageBox Tutorial"
→Moving Between Multiple Menus: Rewrite
imported>Haama (→Activator: Why an activator) |
imported>Haama (→Moving Between Multiple Menus: Rewrite) |
||
Line 395: | Line 395: | ||
==Moving Between Multiple Menus== | ==Moving Between Multiple Menus== | ||
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>... | |||
if (Choosing == -1) | |||
messagebox "What would you like to do?" | |||
set Choosing to 1 | |||
...</pre> | |||
while the positive number refers to the code to return the player's choice: | |||
<pre>... | |||
elseif (Choosing == 1) | |||
if (Choice == -1) | |||
set Choice to GetButtonPressed | |||
elseif (Choice == 0) | |||
...</pre> | |||
You can start up any menu by setting Choice to the corresponding negative number: | |||
<pre>set Choosing to -1</pre> | |||
from anywhere else in the script. | |||
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. | |||
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 | <pre>Short Choosing | ||
Short Choice | Short Choice | ||
Line 506: | Line 527: | ||
Endif | Endif | ||
End</pre> | End</pre> | ||
===Multiple Menus in a Spell Script=== | ===Multiple Menus in a Spell Script=== |