Difference between revisions of "Messagebox Tutorial/Set Variables"
imported>Qazaaq (Unfinished Article) |
imported>Haama (Removed from category) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
This is a subsection of the [[MessageBox Tutorial]], and uses [[MessageBox_Tutorial#Activator_Script|this script]] as a base. The following code may or may not require certain aspects of that script to work, however the information should prove useful for any script (it will take a bit of care to make it work, though). | |||
---- | |||
This code allows the player to use a menu to set a variable to any number (I suppose it's limited by the short/long variable limits). Basically, the player is given the current number the variable is set to, and is allowed to change it from '''''-2''''' to '''''+2'''''. If they want to change it by more than that, they can modify it by '''''-10''''', '''''-5''''', '''''+5''''', or '''''+10''''' and then the menu is displayed again, with the new number. This allows the player to select any number (i.e., if they want -3, they would choose '''''-5''''' and then '''''+2'''''). Due to the limit of the number of choices available, there can only be one other option. For most, this option should be <u>'''''Return to Previous Menu'''''</u>. Here's an example: ('''''NumNewIngsDefault''''' is the variable that the player is setting. Also, due to wiki limitations, the messagebox has several line breaks even though these wouldn't be in the CS script) | This code allows the player to use a menu to set a variable to any number (I suppose it's limited by the short/long variable limits). Basically, the player is given the current number the variable is set to, and is allowed to change it from '''''-2''''' to '''''+2'''''. If they want to change it by more than that, they can modify it by '''''-10''''', '''''-5''''', '''''+5''''', or '''''+10''''' and then the menu is displayed again, with the new number. This allows the player to select any number (i.e., if they want -3, they would choose '''''-5''''' and then '''''+2'''''). Due to the limit of the number of choices available, there can only be one other option. For most, this option should be <u>'''''Return to Previous Menu'''''</u>. Here's an example: ('''''NumNewIngsDefault''''' is the variable that the player is setting. Also, due to wiki limitations, the messagebox has several line breaks even though these wouldn't be in the CS script) | ||
<pre>... | <pre>... | ||
Line 20: | Line 24: | ||
if (Choice == -1) | if (Choice == -1) | ||
set Choice to GetButtonPressed | set Choice to GetButtonPressed | ||
elseif (Choice == 0) ;10 fewer | elseif (Choice == 0) ;10 fewer | ||
set NumNewIngsDefault to (NumNewIngsDefault - 10) | set NumNewIngsDefault to (NumNewIngsDefault - 10) | ||
set Choosing to -22 | set Choosing to -22 | ||
elseif (Choice == 1) ;5 fewer | elseif (Choice == 1) ;5 fewer | ||
set NumNewIngsDefault to (NumNewIngsDefault - 5) | set NumNewIngsDefault to (NumNewIngsDefault - 5) | ||
set Choosing to -22 | set Choosing to -22 | ||
elseif (Choice == 7) ;5 more | elseif (Choice == 7) ;5 more | ||
set NumNewIngsDefault to (NumNewIngsDefault + 5) | set NumNewIngsDefault to (NumNewIngsDefault + 5) | ||
set Choosing to -22 | set Choosing to -22 | ||
elseif (Choice == 8) ;10 more | elseif (Choice == 8) ;10 more | ||
set NumNewIngsDefault to (NumNewIngsDefault + 10) | set NumNewIngsDefault to (NumNewIngsDefault + 10) | ||
set Choosing to -22 | set Choosing to -22 | ||
elseif (Choice == 2) ;-2 | elseif (Choice == 2) ;-2 | ||
set NumNewIngsDefault to (NumNewIngsDefault - 2) | set NumNewIngsDefault to (NumNewIngsDefault - 2) | ||
set Choosing to -21 | set Choosing to -21 | ||
elseif (Choice == 3) ;-1 | elseif (Choice == 3) ;-1 | ||
set NumNewIngsDefault to (NumNewIngsDefault - 1) | set NumNewIngsDefault to (NumNewIngsDefault - 1) | ||
set Choosing to -21 | set Choosing to -21 | ||
elseif (Choice == 4) ;Cancel | elseif (Choice == 4) ;Cancel | ||
set Choosing to -21 | set Choosing to -21 | ||
elseif (Choice == 5) ;+1 | elseif (Choice == 5) ;+1 | ||
set NumNewIngsDefault to (NumNewIngsDefault + 1) | set NumNewIngsDefault to (NumNewIngsDefault + 1) | ||
set Choosing to -21 | set Choosing to -21 | ||
elseif (Choice == 6) ;+2 | elseif (Choice == 6) ;+2 | ||
set NumNewIngsDefault to (NumNewIngsDefault + 2) | set NumNewIngsDefault to (NumNewIngsDefault + 2) | ||
set Choosing to -21 | set Choosing to -21 | ||
elseif (Choice == 9) ;Return to previous menu | elseif (Choice == 9) ;Return to previous menu | ||
set Choosing to -2 | set Choosing to -2 | ||
endif | endif | ||
...</pre> | ...</pre> | ||
Line 71: | Line 64: | ||
(Currently %g)", NumNewIngsDefault, | (Currently %g)", NumNewIngsDefault, | ||
...</pre> | ...</pre> | ||
You have | You have a few options for the other, variable-changing options ('''''-2''''', '''''-1''''', '''''+1''''', '''''+2'''''): | ||
*Place the check(s) inside each of those '''''Choice''''' sections, as such: | *Place the check(s) inside each of those '''''Choice''''' sections, as such: | ||
<pre>... | <pre>... | ||
Line 80: | Line 73: | ||
endif | endif | ||
set Choosing to -21 | set Choosing to -21 | ||
...</pre> | ...</pre> | ||
*Place the check(s) | *Place the check(s) right after all of the '''Choices''': | ||
<pre>... | <pre>... | ||
elseif (Choosing == -21) | elseif (Choosing == -21) | ||
Line 91: | Line 83: | ||
"Set default number of ingredients" | "Set default number of ingredients" | ||
...</pre> | ...</pre> | ||
Latest revision as of 18:08, 3 June 2008
This is a subsection of the MessageBox Tutorial, and uses this script as a base. The following code may or may not require certain aspects of that script to work, however the information should prove useful for any script (it will take a bit of care to make it work, though).
This code allows the player to use a menu to set a variable to any number (I suppose it's limited by the short/long variable limits). Basically, the player is given the current number the variable is set to, and is allowed to change it from -2 to +2. If they want to change it by more than that, they can modify it by -10, -5, +5, or +10 and then the menu is displayed again, with the new number. This allows the player to select any number (i.e., if they want -3, they would choose -5 and then +2). Due to the limit of the number of choices available, there can only be one other option. For most, this option should be Return to Previous Menu. Here's an example: (NumNewIngsDefault is the variable that the player is setting. Also, due to wiki limitations, the messagebox has several line breaks even though these wouldn't be in the CS script)
... elseif (Choosing == -22) messagebox "Set the default number of essences to be created. (Currently %g)", NumNewIngsDefault, "About 10 fewer (-12 to -8)" "About 5 fewer (-7 to -3)" "Default to that amount -2" "Default to that amount -1" "Default to that amount" "Default to that amount +1" "Default to that amount +2" "About 5 more (+3 to +7)" "About 10 more (+8 to +12)" "Return to previous menu" set Choosing to 22 set Choice to GetButtonPressed elseif (Choosing == 22) if (Choice == -1) set Choice to GetButtonPressed elseif (Choice == 0) ;10 fewer set NumNewIngsDefault to (NumNewIngsDefault - 10) set Choosing to -22 elseif (Choice == 1) ;5 fewer set NumNewIngsDefault to (NumNewIngsDefault - 5) set Choosing to -22 elseif (Choice == 7) ;5 more set NumNewIngsDefault to (NumNewIngsDefault + 5) set Choosing to -22 elseif (Choice == 8) ;10 more set NumNewIngsDefault to (NumNewIngsDefault + 10) set Choosing to -22 elseif (Choice == 2) ;-2 set NumNewIngsDefault to (NumNewIngsDefault - 2) set Choosing to -21 elseif (Choice == 3) ;-1 set NumNewIngsDefault to (NumNewIngsDefault - 1) set Choosing to -21 elseif (Choice == 4) ;Cancel set Choosing to -21 elseif (Choice == 5) ;+1 set NumNewIngsDefault to (NumNewIngsDefault + 1) set Choosing to -21 elseif (Choice == 6) ;+2 set NumNewIngsDefault to (NumNewIngsDefault + 2) set Choosing to -21 elseif (Choice == 9) ;Return to previous menu set Choosing to -2 endif ...
Mins and Maxs[edit | edit source]
If you want to use minimums and/or maximums for the variable, you'll need to run checks at a few key locations. To cover all of the -10, -5, +5, +10 options place the check right before the MessageBox function, as such:
... elseif (Choosing == -22) if (NumNewIngsDefault < 0) set NumNewIngsDefault to 0 endif messagebox "Set the default number of essences to be created. (Currently %g)", NumNewIngsDefault, ...
You have a few options for the other, variable-changing options (-2, -1, +1, +2):
- Place the check(s) inside each of those Choice sections, as such:
... elseif (Choice == 2) ;-2 set NumNewIngsDefault to (NumNewIngsDefault - 2) if (NumNewIngsDefault < 0) set NumNewIngsDefault to 0 endif set Choosing to -21 ...
- Place the check(s) right after all of the Choices:
... elseif (Choosing == -21) if (NumNewIngsDefault < 0) set NumNewIngsDefault to 0 endif messagebox "Creation Options:" "Set default number of ingredients" ...