Difference between revisions of "MessageBox Tutorial"
→Example script: Minor edits, Using Variable-Loaded method now
imported>Haama |
imported>Haama (→Example script: Minor edits, Using Variable-Loaded method now) |
||
Line 406: | Line 406: | ||
===Example script=== | ===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 Working | ||
Short Choosing | |||
Short Choice | Short Choice | ||
Begin onActivate | Begin onActivate | ||
Set | Set Working to 1 | ||
Set Choosing to -1 | Set Choosing to -1 | ||
End | End | ||
Line 423: | Line 420: | ||
Begin GameMode | Begin GameMode | ||
If (Choosing == 0) ;meaning it shouldn't be running | If Working | ||
If (Choosing == 0) ;meaning it shouldn't be running | |||
Set | Set Working to 0 | ||
Elseif (Choosing == -1) ;Display your menu | |||
Messagebox "What would you like to donate?" "Gold" "Food" "Blood" "Cancel" | |||
Set Choosing to 1 | |||
Set Choice to -1 | |||
Elseif (Choosing == 1) | |||
If (Choice == -1) ;No choice yet | |||
Set Choice to GetButtonPressed | |||
Elseif (Choice == 0) ;Gold | |||
Set Choosing to -11 ;to open the Gold menu | |||
Elseif (Choice == 1) ;Food | |||
Set Choosing to -12 ;to open the Food menu | |||
Elseif (Choice == 2) ;Blood | |||
Set Choosing to -13 ;to open the Blood menu | |||
Elseif (Choice == 3) ;Cancel | |||
Set Choosing to 0 ;to close the menus | |||
Endif | |||
Elseif (Choosing == -11) ;Gold menu | |||
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 11 | |||
Set Choice to -1 | Set Choice to -1 | ||
Elseif (Choosing == 11) | |||
If (Choice == -1) ;No choice yet | |||
Set Choice to GetButtonPressed | |||
Elseif (Choice == 0) ;25 | |||
If (player.GetGold > 25) | |||
Player.RemoveItem Gold001 25 | |||
Set Choosing to 0 | |||
Else | |||
Set Choosing to -99 ;a message that the player doesn't have enough | |||
Endif | |||
Elseif (Choice == 1) ; I've changed my mind | |||
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 -12 ;to open the food menu | |||
Elseif (Choice == 3) ; I've changed my mind, I'll donate blood | |||
Set Choosing to -13 ;to open the blood menu | |||
Elseif (Choice == 4) ; I've changed my mind, I won't donate anything | |||
Set Choosing to 0 ;to close the menus | |||
Endif | |||
Elseif (Choosing == -12) ;Food menu | |||
Messagebox "How much food would you like to donate?" "An apple" | |||
"Two apples" | |||
... | |||
"Cancel" | |||
Set Choosing to 12 | |||
Set Choice to GetButtonPressed | Set Choice to GetButtonPressed | ||
Elseif (Choice == 0) ; | Elseif (Choosing == 12) | ||
If (player. | If (Choice == -1) ;No choice yet | ||
Set Choice to GetButtonPressed | |||
Elseif (Choice == 0) ;An Apple | |||
If (player.GetItemCount Apple) | |||
player.RemoveItem Apple 1 | |||
Else | |||
set Choosing to -99 ;Go to special 'Not enough' menu | |||
Endif | |||
Set Choosing to -1 ;To return to main menu | |||
Elseif (Choice == 1) ;Two Apple | |||
If ((player.GetItemCount Apple) > 1) | |||
player.RemoveItem Apple 2 | |||
Else | |||
set Choosing to -99 ;Go to special 'Not enough' menu | |||
Endif | |||
Set Choosing to -1 ;To return to main menu | |||
;... | |||
Elseif (Choice == 9) ;Cancel | |||
Set Choosing to 0 | Set Choosing to 0 | ||
Endif | Endif | ||
Elseif (Choosing == -13) ;Blood menu | |||
Messagebox "How much blood would you like to donate?" "1 HP" | |||
"2 HP" | |||
... | |||
"Cancel" | |||
Set Choosing to 13 | |||
Set Choice to GetButtonPressed | Set Choice to GetButtonPressed | ||
Elseif (Choice == 0) ; | Elseif (Choosing == 13) | ||
... | If (Choice == -1) ;No choice yet | ||
Set Choice to GetButtonPressed | |||
Elseif (Choice == 0) ;1 HP | |||
player.ModAV Health -1 ;don't actually use this, just an easy example | |||
set Choosing to -1 ;to return to the main menu | |||
Elseif (Choice == 1) ;2 HP | |||
player.ModAV Health -2 ;don't actually use this, just an easy example | |||
set Choosing to -1 ;to return to the main menu | |||
;... | |||
Elseif (Choice == 9) ;Cancel | |||
Set Choosing to 0 | |||
Endif | |||
Elseif (Choosing == -99) ;Player-doesn't-have-enough menu | Elseif (Choosing == -99) ;Player-doesn't-have-enough menu | ||
Line 500: | Line 522: | ||
Set Choosing to 99 | Set Choosing to 99 | ||
Set Choice to GetButtonPressed | Set Choice to GetButtonPressed | ||
Elseif (Choosing == 99) | Elseif (Choosing == 99) | ||
If (Choice == -1) ;No choice yet | |||
Set Choice to GetButtonPressed | |||
Elseif (Choice == 0) ;player pressed "Done", return to main menu | |||
Set Choosing to -1 | |||
Endif | |||
Endif | Endif | ||
Set Working to 1 | |||
Endif | Endif | ||
End</pre> | End</pre> | ||
==Extras== | ==Extras== |