Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
1,360 bytes added ,  00:32, 15 September 2007
→‎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 ChoosingWorking
Short Choosing
Short Choice
short Reset
 
 
 
Begin onActivate
Set ResetWorking to 1
Set Choosing to -1
If (GetInSameCell player == 0)
MoveTo player
Endif
End
 
 
Begin GameMode
If Working
If (Choosing == 0) ;meaning it shouldn't be running
If (Choosing == 0) ;meaning it shouldn't be running
If Reset
Set ResetWorking to 0
Endif
If (GetInSameCell YourXMarker == 0)
MoveTo YourXMarker
Endif
 
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 == -111) ;Display yourGold menu
Messagebox "WhatHow much Gold would you like to donate?" "Gold" "Food" "Blood" "Cancel25"
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'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 == 11-12) ;Food menu
Messagebox "How much food would you like to donate?" "An apple"
If (Choice == -1) ;No choice yet
"Two apples"
...
"Cancel"
Set Choosing to 12
Set Choice to GetButtonPressed
Elseif (ChoiceChoosing == 012) ;25
If (player.GetGoldChoice >== 25-1) ;No choice yet
Set Choice to GetButtonPressed
Player.RemoveItem Gold001 25
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
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 == -1213) ;FoodBlood menu
Messagebox "How much foodblood would you like to donate?" "Options1 HP"
"More2 OptionsHP"
...
"Cancel"
Set Choosing to 1213
Set Choice to GetButtonPressed
 
Elseif (Choosing == 3)
If (Choice == -1) ;No choice yet
Set Choice to GetButtonPressed
Elseif (ChoiceChoosing == 013) ;Options
If (Choice == -1) ;No choice yet
...
Set Choice to GetButtonPressed
Elseif (Choice == 9) ;Cancel
SetElseif Choosing(Choice to== 0) ;1 HP
player.ModAV Health -1 ;don't actually use this, just an easy example
Endif
set Choosing to -1 ;to return to the main menu
Return
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==
Anonymous user

Navigation menu