Difference between revisions of "Messagebox Tutorial/Set Variables"

Jump to navigation Jump to search
no edit summary
imported>Haama
imported>Haama
Line 1: Line 1:
Though not a necessary part of every menu, this is a nice bit of code. This 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)
Though not a necessary part of every menu, this is a nice bit of code. This 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>       elseif (Choosing == -22)
<pre>...
        elseif (Choosing == -22)
           messagebox "Set the default number of essences to be created.
           messagebox "Set the default number of essences to be created.
                     (Currently %g)", NumNewIngsDefault,
                     (Currently %g)", NumNewIngsDefault,
Line 58: Line 59:
             set Choosing to -2
             set Choosing to -2
             return
             return
           endif</pre>
           endif
...</pre>
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:
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:
<pre>       elseif (Choosing == -22)
<pre>...
        elseif (Choosing == -22)
           if (NumNewIngsDefault < 0)
           if (NumNewIngsDefault < 0)
             set NumNewIngsDefault to 0
             set NumNewIngsDefault to 0
Line 69: Line 72:
You have 2 options for the other, variable-changing options ('''''-2''''', '''''-1''''', '''''+1''''', '''''+2'''''):
You have 2 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>         elseif (Choice == 2) ;-2
<pre>...
          elseif (Choice == 2) ;-2
             set NumNewIngsDefault to (NumNewIngsDefault - 2)
             set NumNewIngsDefault to (NumNewIngsDefault - 2)
             if (NumNewIngsDefault < 0)
             if (NumNewIngsDefault < 0)
Line 75: Line 79:
             endif
             endif
             set Choosing to -21
             set Choosing to -21
             return</pre>
             return
...</pre>
*Place the check(s) in a menu that all of them run through. In this case, all of these '''''Choice'''''s run through '''''Choosing == -21''''', so all of the checks(s) can be placed immediately before the [[MessageBox]] function of that menu, as such:
*Place the check(s) in a menu that all of them run through. In this case, all of these '''''Choice'''''s run through '''''Choosing == -21''''', so all of the checks(s) can be placed immediately before the [[MessageBox]] function of that menu, as such:
<pre>       elseif (Choosing == -21)
<pre>...
        elseif (Choosing == -21)
           if (NumNewIngsDefault < 0)
           if (NumNewIngsDefault < 0)
             set NumNewIngsDefault to 0
             set NumNewIngsDefault to 0
Anonymous user

Navigation menu