Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
245 bytes added ,  12:28, 29 August 2007
imported>Haama
(→‎Activator: Why an activator)
imported>Haama
Line 395: Line 395:


==Moving Between Multiple Menus==
==Moving Between Multiple Menus==
Not only will the above code work, but it makes multiple menus easy to do. Remember that each menu has two parts: the display of the menu and catching the player's decision. So, each menu can be broken into two numbers, a negative number ('''''-1''''' in the example above) and a positive number ('''''1''''' in the example above). Use different numbers for each menu, and whenever you want to move to a new menu, use <u>'''''set Choosing to -#'''''</u>. 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 wouldn't have one)
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>
I suggest using numbers instead of other variables when setting '''''Choosing'''''. Numbers give more meaning than words in this case, as the negative and positive numbers separate which part of the menu you're dealing with. You can also use numbers to signify which layer of the menu you are in. For instance, '''''-1''''' was the first layer in the above example. For the sub-menus of the main menu (Gold, Food, Blood), you can use '''''-11''''', '''''-12''''', '''''-13'''''. And, for example, for the sub-menus of Food you can use '''''-121''''', '''''-122''''', '''''-123''''' such that the first number signifies the menu of the first layer, the second the menu of the second layer, etc.
 


===Multiple Menus in a Spell Script===
===Multiple Menus in a Spell Script===
Anonymous user

Navigation menu