Difference between revisions of "MessageBox Tutorial"

Jump to navigation Jump to search
2,622 bytes added ,  02:50, 15 September 2007
imported>Haama
(→‎Extras: Centralizing Menu Exits no longer needed)
imported>Haama
Line 542: Line 542:
<pre>scn YourMenuScript
<pre>scn YourMenuScript


Short Working
Short Choosing
Short Choosing
Short Choice
Short Choice
;Centralized Menu Exiting variable
Short Reset


;GameMode and MenuMode variables
;GameMode and MenuMode variables
Line 553: Line 551:


;Ensuring Your Menu Is Read variables
;Ensuring Your Menu Is Read variables
Float MessageTimer
Short MessageCounter
Short MessageButton






Begin onActivate
Begin onActivate
   If (Choosing >= 0)
   If (Choosing >= 0) ;Controlling the menu system via external scripts
     Set Choosing to -1
     Set Choosing to -1
   Endif
   Endif
   Set Reset to 1
   Set Working to 1
   If (MenuMode == 0)
  Set MessageCounter to 0 ;Ensuring your menus are seen
   If (MenuMode == 0) ;Running menus in both GameMode and MenuMode
     Set GMRun to 1
     Set GMRun to 1
  Endif
  If (GetInSameCell player == 0) ;always keep it near the player
    MoveTo player
   Endif
   Endif
End
End
Line 573: Line 568:




Begin GameMode
Begin GameMode ;Running menus in both GameMode and MenuMode
   If (Choosing == 0)
   If Working
    Set GMRun to 0
    If (Choosing == 0)
    If (GetInSameCell YourXMarker == 0)
      Set GMRun to 0
       MoveTo YourXMarker
      Set Working to 0
    Endif
       Set MessageCounter to 0 ;Ensuring your menu is seen
     Return
      ;Add anything that needs to be re-initialized
  Elseif GMRun
     Elseif GMRun
    Set GMRun to 0
      Set GMRun to 0
    Set ExitButton to 0
      Set ExitButton to 0
    Messagebox "Exiting options..."
      Messagebox "Exiting options..."
  Elseif (Choice == -1)
    Elseif (Choice == -1) ;Ensuring your menus are seen
    If (MessageTimer > 0) || (MessageCounter > 0)
      if (MessageCounter < 30)
      Set Choice to GetButtonPressed
        set Choice to GetButtonPressed
      If (Choice > -1)
        if (Choice == -1)
        Return
          if (MenuMode 1001 == 0)
      Endif
            if (MenuMode 1004 == 0) && (MenuMode 1005 == 0) && (MenuMode 1006 == 0) &&
      If (MenuMode 1001 == 0)
              (MenuMode 1010 == 0) && (MenuMode 1011 == 0) && (MenuMode 1013 == 0) &&
        If (MenuMode 1004) || (MenuMode 1005) || (MenuMode 1006) ||
              (MenuMode 1015 == 0) && (MenuMode 1016 == 0) && (MenuMode 1017 == 0) &&
          (MenuMode 1010) || (MenuMode 1011) || (MenuMode 1013) ||
              (MenuMode 1018 == 0) && (MenuMode 1019 == 0) && (MenuMode 1020 == 0) &&
          (MenuMode 1015) || (MenuMode 1016) || (MenuMode 1017) ||
              (MenuMode 1021 == 0) && (MenuMode 1024 == 0) && (MenuMode 1038 == 0) &&
          (MenuMode 1018) || (MenuMode 1019) || (MenuMode 1020) ||
              (MenuMode 1039 == 0) && (MenuMode 1044 == 0) && (MenuMode 1045 == 0) &&
          (MenuMode 1021) || (MenuMode 1024) || (MenuMode 1038) ||
              (MenuMode 1046 == 0) && (MenuMode 1047 == 0) && (MenuMode 1057 == 0)
          (MenuMode 1039) || (MenuMode 1044) || (MenuMode 1045) ||
              set MessageCounter to (MessageCounter + 1)
          (MenuMode 1046) || (MenuMode 1047) || (MenuMode 1057)
            endif
          Return
          else ;MenuMode 1001
        Else
            set MessageCounter to 0
          Set MessageTimer to (MessageTimer - GetSecondsPassed)
          endif
          Set MessageCounter to (MessageCounter - 1)
         else ;Choice > -1
        Endif
          set MessageCounter to 0
      Else ;MenuMode 1001
         endif
         Set MessageTimer to 1
       else ;Display menu again
        Set MessageCounter to 45
        set Choosing to -(Choosing)
         Return
        set MessageCounter to 0
       Endif
        message "Trying menu again..."
    Else ;Display menu again
      endif
      Message "Trying menu again..."
    Elseif (Choice != ExitButton)
       Set Choosing to -(Choosing)
       Set ExitButton to 0
       Messagebox "Exiting options..."
       Messagebox "Exiting options..."
    Elseif (Choice == ExitButton)
      Set Choosing to 0
     Endif
     Endif
  Elseif (Choice != ExitButton)
     Set Working to 1
     Set ExitButton to 0
    Messagebox "Exiting options..."
   Endif
   Endif
End
End
Line 622: Line 617:


Begin MenuMode
Begin MenuMode
   If (Choosing == 0)
   If Working
    If Reset
    If (Choosing == 0)
       ;reset whatever you need to
       Set GMRun to 0 ;Running menus in both GameMode and MenuMode
       Set Reset to 0
       Set Working to 0
    Endif
      Set MessageCounter to 0 ;Ensuring your menu is seen
    If (GetInSameCell YourXMarker == 0)
       ;Add anything that needs to be re-initialized
       MoveTo YourXMarker
    Endif




  Elseif (Choosing > 0) && (Choice == -1) ;No choice yet
    ;Ensuring your menu is seen
    If (MessageTimer > 0) || (MessageCounter > 0)
    ;Centralizing your menu decisions
      Set Choice to GetButtonPressed
    Elseif (Choosing > 0) && (Choice == -1) ;No choice yet
      If (Choice > -1)
      if (MessageCounter < 30)
        Return
        set Choice to GetButtonPressed
      Endif
        if (Choice == -1)
      If (MenuMode 1001 == 0)
          if (MenuMode 1001 == 0)
        If (MenuMode 1004) || (MenuMode 1005) || (MenuMode 1006) ||
            if (MenuMode 1004 == 0) && (MenuMode 1005 == 0) && (MenuMode 1006 == 0) &&
          (MenuMode 1010) || (MenuMode 1011) || (MenuMode 1013) ||
              (MenuMode 1010 == 0) && (MenuMode 1011 == 0) && (MenuMode 1013 == 0) &&
          (MenuMode 1015) || (MenuMode 1016) || (MenuMode 1017) ||
              (MenuMode 1015 == 0) && (MenuMode 1016 == 0) && (MenuMode 1017 == 0) &&
          (MenuMode 1018) || (MenuMode 1019) || (MenuMode 1020) ||
              (MenuMode 1018 == 0) && (MenuMode 1019 == 0) && (MenuMode 1020 == 0) &&
          (MenuMode 1021) || (MenuMode 1024) || (MenuMode 1038) ||
              (MenuMode 1021 == 0) && (MenuMode 1024 == 0) && (MenuMode 1038 == 0) &&
          (MenuMode 1039) || (MenuMode 1044) || (MenuMode 1045) ||
              (MenuMode 1039 == 0) && (MenuMode 1044 == 0) && (MenuMode 1045 == 0) &&
          (MenuMode 1046) || (MenuMode 1047) || (MenuMode 1057)
              (MenuMode 1046 == 0) && (MenuMode 1047 == 0) && (MenuMode 1057 == 0)
          Return
              set MessageCounter to (MessageCounter + 1)
        Else
            endif
          Set MessageTimer to (MessageTimer - GetSecondsPassed)
           else ;MenuMode 1001
          Set MessageCounter to (MessageCounter - 1)
            set MessageCounter to 0
           Return
          endif
        Endif
         else ;Choice > -1
      Else ;MenuMode 1001
          set MessageCounter to 0
         Set MessageTimer to 1
         endif
        Set MessageCounter to 45
       else ;Display menu again
         Return
        set Choosing to -(Choosing)
       Endif
        set MessageCounter to 0
    Else ;Display menu again
        message "Trying menu again..."
      Message "Trying menu again..."
       endif
       Set Choosing to -(Choosing)
      Return
    Endif




  Elseif (Choosing == -1) ;Display your menu
    Elseif (Choosing == -1) ;Display your menu
    Set ExitButton to # ;1 in this example
      Set ExitButton to 1 ;Running menus in both GameMode and MenuMode
    Messagebox "What would you like to do?" "First Option" ... "Exit Menu"
      Messagebox "What would you like to do?" "First Option" "Exit Menu"
    Set Choosing to 1
      Set Choosing to 1
    Set Choice to GetButtonPressed
      Set Choice to -1
     Return
     Elseif (Choosing == 1) ;Catch the player's decision
      If (Choice == 0) ;First Option
        ;run your code for the first decision
      Elseif (Choice == 1) ;Exit Menu
        ;run your code for the second descision
        Set Choosing to 0 ;to finish up
      Endif


  Elseif (Choosing == 1) ;Catch the player's decision
    ;Allowing the player to set any number
     Elseif (Choice == 0) ;First Option
    short NumNewIngsDefault
      ;run your code for the first decision
    elseif (Choosing == -2)
      Set Choosing to 0 ;to finish up
          set ExitButton to -2 ;Running menus in both GameMode and MenuMode
    Elseif (Choice == 1) ;Second Option
          messagebox "Set the default number of essences to be created.
      ;run your code for the second descision
                    (Currently %g)", NumNewIngsDefault,
      Set Choosing to 0 ;to finish up
                            "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 2
          set Choice to -1
     elseif (Choosing == 2)
          if (Choice == 0) ;10 fewer
            set NumNewIngsDefault to (NumNewIngsDefault - 10)
            set Choosing to -2
          elseif (Choice == 1) ;5 fewer
            set NumNewIngsDefault to (NumNewIngsDefault - 5)
            set Choosing to -2
          elseif (Choice == 7) ;5 more
            set NumNewIngsDefault to (NumNewIngsDefault + 5)
            set Choosing to -2
          elseif (Choice == 8) ;10 more
            set NumNewIngsDefault to (NumNewIngsDefault + 10)
            set Choosing to -2
          elseif (Choice == 2) ;-2
            set NumNewIngsDefault to (NumNewIngsDefault - 2)
            set Choosing to -1
          elseif (Choice == 3) ;-1
            set NumNewIngsDefault to (NumNewIngsDefault - 1)
            set Choosing to -1
          elseif (Choice == 4) ;Cancel
            set Choosing to -1
          elseif (Choice == 5) ;+1
            set NumNewIngsDefault to (NumNewIngsDefault + 1)
            set Choosing to -1
          elseif (Choice == 6) ;+2
            set NumNewIngsDefault to (NumNewIngsDefault + 2)
            set Choosing to -1
          elseif (Choice == 9) ;Return to previous menu
            set Choosing to -1
          endif
     Endif
     Endif


 
    Set Working to 1
  Elseif (Choosing == -2)
...
   Endif
   Endif
End</pre>
End</pre>
[[Category: Scripting Tutorials]]
[[Category: Scripting Tutorials]]
Anonymous user

Navigation menu