Difference between revisions of "MessageBox Tutorial"
Jump to navigation
Jump to search
→Example script: Minor edits, Using Variable-Loaded method now
imported>Haama |
imported>Haama (→Example script: Minor edits, Using Variable-Loaded method now) |
||
|
===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)
<pre>Short
Short Choosing
Short Choice
Begin onActivate
Set
Set Choosing to -1
End
Begin GameMode
If Working
If (Choosing == 0) ;meaning it shouldn't be running
Set
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 == -
Messagebox "
"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 won't donate anything"
Set Choosing to 11
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 ==
Messagebox "How much food would you like to donate?" "An apple"
"Two apples"
...
"Cancel"
Set Choosing to 12
Set Choice to GetButtonPressed
Elseif (
If (
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
Endif
Elseif (Choosing == -
Messagebox "How much
"
...
"Cancel"
Set Choosing to
Set Choice to GetButtonPressed
Elseif (
If (Choice == -1) ;No choice yet
Set Choice to GetButtonPressed
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
Set Choosing to 99
Set Choice to GetButtonPressed
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
Set Working to 1
Endif
End</pre>
==Extras==
| |||