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)
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
short Reset






Begin onActivate
Begin onActivate
   Set Reset to 1
   Set Working to 1
   Set Choosing to -1
   Set Choosing to -1
  If (GetInSameCell player == 0)
    MoveTo player
  Endif
End
End


Line 423: Line 420:


Begin GameMode
Begin GameMode
   If (Choosing == 0) ;meaning it shouldn't be running
   If Working
    If Reset
    If (Choosing == 0) ;meaning it shouldn't be running
       Set Reset to 0
       Set Working 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 == -1) ;Display your menu
     Elseif (Choosing == -11) ;Gold menu
     Messagebox "What would you like to donate?" "Gold" "Food" "Blood" "Cancel"
       Messagebox "How much Gold would you like to donate?" "25"
    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 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 == 11)
    Elseif (Choosing == -12) ;Food menu
    If (Choice == -1) ;No choice yet
      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) ;25
     Elseif (Choosing == 12)
       If (player.GetGold > 25)
      If (Choice == -1) ;No choice yet
         Player.RemoveItem Gold001 25
        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
      Else
        Set Choosing to -99 ;a message that the player doesn't have enough
       Endif
       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
    Elseif (Choosing == -13) ;Blood menu
    Messagebox "How much food would you like to donate?" "Options"
      Messagebox "How much blood would you like to donate?" "1 HP"
                                                        "More Options"
                                                            "2 HP"
                                                        ...
                                                            ...
                                                        "Cancel"
                                                            "Cancel"
    Set Choosing to 12
      Set Choosing to 13
    Set Choice to GetButtonPressed
 
  Elseif (Choosing == 3)
    If (Choice == -1) ;No choice yet
       Set Choice to GetButtonPressed
       Set Choice to GetButtonPressed
     Elseif (Choice == 0)  ;Options
     Elseif (Choosing == 13)
...
      If (Choice == -1) ;No choice yet
    Elseif (Choice == 9)  ;Cancel
        Set Choice to GetButtonPressed
      Set Choosing to 0
      Elseif (Choice == 0)  ;1 HP
    Endif
        player.ModAV Health -1 ;don't actually use this, just an easy example
    Return
        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
      If (Choice == -1) ;No choice yet
      Set Choice to GetButtonPressed
        Set Choice to GetButtonPressed
    Elseif (Choice == 0) ;player pressed "Done", return to main menu
      Elseif (Choice == 0) ;player pressed "Done", return to main menu
      Set Choosing to -1
        Set Choosing to -1
      Endif
     Endif
     Endif


 
    Set Working to 1
   Endif
   Endif
End</pre>
End</pre>


==Extras==
==Extras==
Anonymous user

Navigation menu