Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
54 bytes added ,  11:07, 29 August 2007
m
imported>Haama
imported>Haama
Line 125: Line 125:
     messagebox "Which weapon would you like to repair?" "Blade" ... "Bow"
     messagebox "Which weapon would you like to repair?" "Blade" ... "Bow"
...</pre>
...</pre>
If the player selects "Armor" from the first menu, the second menu ("Which armor would you like to repair") will be displayed, but any choice the player makes will really be based on the first menu. For instance, if the player selects "Boots" in the second menu, the "Which weapons would you like to repair?" menu will be displayed.
If the player selects "Armor" from the first menu, the second menu ("Which armor would you like to repair") will be displayed, but any choice the player makes from the second menu will really be based on the first menu. For instance, if the player selects "Boots" in the second menu, the "Which weapons would you like to repair?" menu will be displayed.


Following the steps of the script, you can see why. The player will be shown the "What would you like to repair?" menu. They select "Armor". For a few frames GetButtonPressed sets Choice to -1. About 15 frames after the player makes their choice, GetButtonPressed will return 0. This will bring up the second menu "Which armor...?". Choice2 will be set to -1, as the player hasn't read it yet. The player selects "Boots". Again, there will be several frames between the menu, and when GetButtonPressed returns the player's choice. This means the script will be running from the beginning of the GameMode block again. This time, Choice is set to 9 (because "Boots" was the tenth button), and the "Which weapon...?" menu is opened.  
Following the steps of the script, you can see why. The player will be shown the "What would you like to repair?" menu. They select "Armor". For a few frames GetButtonPressed sets Choice to -1, and nothing happens. About 15 frames after the player makes their choice, GetButtonPressed will return 0. This will bring up the second menu "Which armor...?". Choice2 will be set to -1, as the player hasn't read it yet. The player selects "Boots". Again, there will be several frames between the menu, and when GetButtonPressed returns the player's choice. This means the script will be running from the beginning of the GameMode block again. This time, Choice is set to 9 (because "Boots" was the tenth button), and the "Which weapon...?" menu is displayed.  


To prevent this from happening, use the Choosing variable to keep menus separate:
To prevent this from happening, use the Choosing variable to keep menus separate:
Line 180: Line 180:
   endif
   endif
end</pre>
end</pre>
Note that each menu has a pair of corresponding numbers: Main menu, -1/1; Armor menu, -10/10; Weapon menu, -11/11. When you set Choosing to the corresponding number, that menu will be shown. See a better example of this in the [[MessageBox Tutorial#Moving Between Multiple Menus]].
Note that each menu has a pair of corresponding numbers: Main menu, -1/1; Armor menu, -10/10; Weapon menu, -11/11. When you set Choosing to the corresponding number, that menu will be shown. You can find more information in the [[MessageBox Tutorial#Moving Between Multiple Menus]] section.


===Running the same choice for multiple frames===
===Running the same choice for multiple frames===
Anonymous user

Navigation menu