Difference between revisions of "MessageBox Tutorial"

27 bytes removed ,  12:33, 29 August 2007
imported>Haama
imported>Haama
Line 395: Line 395:


==Moving Between Multiple Menus==
==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:
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>...
<pre>...
Line 412: Line 413:
from anywhere else in the script.
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.  
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.
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)
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
short Reset






Begin onActivate
Begin onActivate
  Set Reset to 1
   Set Choosing to -1
   Set Choosing to -1
   If (GetInSameCell player == 0)
   If (GetInSameCell player == 0)
Line 433: Line 438:
Begin GameMode
Begin GameMode
   If (Choosing == 0) ;meaning it shouldn't be running
   If (Choosing == 0) ;meaning it shouldn't be running
    If Reset
      Set Reset to 0
    Endif
     If (GetInSameCell YourXMarker == 0)
     If (GetInSameCell YourXMarker == 0)
       MoveTo YourXMarker
       MoveTo YourXMarker
Line 439: Line 447:


   Elseif (Choosing == -1) ;Display your menu
   Elseif (Choosing == -1) ;Display your menu
     Messagebox "Would you like to donate gold or food?" "Gold" "Food"
     Messagebox "What would you like to donate?" "Gold" "Food" "Blood" "Cancel"
                                                        "Blood" "Cancel"
     Set Choosing to 1
     Set Choosing to 1
     Set Choice to GetButtonPressed
     Set Choice to -1
    Return
 
   Elseif (Choosing == 1)
   Elseif (Choosing == 1)
     If (Choice == -1) ;No choice yet
     If (Choice == -1) ;No choice yet
       Set Choice to GetButtonPressed
       Set Choice to GetButtonPressed
      Return
     Elseif (Choice == 0) ;Gold
     Elseif (Choice == 0) ;Gold
       Set Choosing to -2 ;to open the Gold menu
       Set Choosing to -11 ;to open the Gold menu
     Elseif (Choice == 1) ;Food
     Elseif (Choice == 1) ;Food
       Set Choosing to -3 ;to open the Food menu
       Set Choosing to -12 ;to open the Food menu
     Elseif (Choice == 2) ;Blood
     Elseif (Choice == 2) ;Blood
       Set Choosing to -4 ;to open the Blood menu
       Set Choosing to -13 ;to open the Blood menu
     Elseif (Choice == 3) ;Cancel
     Elseif (Choice == 3) ;Cancel
       Set Choosing to 0 ;to close the menus
       Set Choosing to 0 ;to close the menus
     Endif
     Endif
    Return


   Elseif (Choosing == -2) ;Gold menu
   Elseif (Choosing == -11) ;Gold menu
     Messagebox "How much Gold would you like to donate?" "25"
     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've changed my mind, I'll donate Food"
             "I've changed my mind, I'll donate Blood"
             "I've changed my mind, I'll donate Blood"
             "I've changed my mind, I won't donate anything"  
             "I've changed my mind, I won't donate anything"  
     Set Choosing to 2
     Set Choosing to 11
     Set Choice to GetButtonPressed
     Set Choice to -1
    Return


   Elseif (Choosing == 2)
   Elseif (Choosing == 11)
     If (Choice == -1) ;No choice yet
     If (Choice == -1) ;No choice yet
       Set Choice to GetButtonPressed
       Set Choice to GetButtonPressed
Line 482: Line 484:
       Set Choosing to -1 ;to return to the opening menu
       Set Choosing to -1 ;to return to the opening menu
     Elseif (Choice == 2) ; I've changed my mind, I'll donate food
     Elseif (Choice == 2) ; I've changed my mind, I'll donate food
       Set Choosing to -3 ;to open the food menu
       Set Choosing to -12 ;to open the food menu
     Elseif (Choice == 3) ; I've changed my mind, I'll donate blood
     Elseif (Choice == 3) ; I've changed my mind, I'll donate blood
       Set Choosing to -4 ;to open the blood menu
       Set Choosing to -13 ;to open the blood menu
     Elseif (Choice == 4) ; I've changed my mind, I won't donate anything
     Elseif (Choice == 4) ; I've changed my mind, I won't donate anything
       Set Choosing to 0 ;to close the menus
       Set Choosing to 0 ;to close the menus
     Endif
     Endif
    Return


   Elseif (Choosing == -3) ;Food menu
   Elseif (Choosing == -12) ;Food menu
     Messagebox "How much food would you like to donate?" "Options"
     Messagebox "How much food would you like to donate?" "Options"
                                                         "More Options"
                                                         "More Options"
                                                         ...
                                                         ...
                                                         "Cancel"
                                                         "Cancel"
     Set Choosing to 3
     Set Choosing to 12
     Set Choice to GetButtonPressed
     Set Choice to GetButtonPressed
    Return


   Elseif (Choosing == 3)
   Elseif (Choosing == 3)
Line 514: Line 514:
       Set Choosing to 99
       Set Choosing to 99
       Set Choice to GetButtonPressed
       Set Choice to GetButtonPressed
      Return


     Elseif (Choosing == 99)
     Elseif (Choosing == 99)
Line 522: Line 521:
       Set Choosing to -1
       Set Choosing to -1
     Endif
     Endif
    Return




Anonymous user