Difference between revisions of "MessageBox Tutorial"
Jump to navigation
Jump to search
→Applying it all: Updated
imported>Haama (→Extras: Centralizing Menu Exits no longer needed) |
imported>Haama (→Applying it all: Updated) |
||
Line 542: | Line 542: | ||
<pre>scn YourMenuScript | <pre>scn YourMenuScript | ||
Short Working | |||
Short Choosing | Short Choosing | ||
Short Choice | Short Choice | ||
;GameMode and MenuMode variables | ;GameMode and MenuMode variables | ||
Line 553: | Line 551: | ||
;Ensuring Your Menu Is Read variables | ;Ensuring Your Menu Is Read variables | ||
Short MessageCounter | |||
Short | |||
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 | 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 | Endif | ||
End | End | ||
Line 573: | Line 568: | ||
Begin GameMode | Begin GameMode ;Running menus in both GameMode and MenuMode | ||
If (Choosing == 0) | If Working | ||
If (Choosing == 0) | |||
Set GMRun to 0 | |||
Set Working to 0 | |||
Set MessageCounter to 0 ;Ensuring your menu is seen | |||
;Add anything that needs to be re-initialized | |||
Elseif GMRun | |||
Set GMRun to 0 | |||
Set ExitButton to 0 | |||
Messagebox "Exiting options..." | |||
Elseif (Choice == -1) ;Ensuring your menus are seen | |||
if (MessageCounter < 30) | |||
set Choice to GetButtonPressed | |||
if (Choice == -1) | |||
if (MenuMode 1001 == 0) | |||
if (MenuMode 1004 == 0) && (MenuMode 1005 == 0) && (MenuMode 1006 == 0) && | |||
(MenuMode 1010 == 0) && (MenuMode 1011 == 0) && (MenuMode 1013 == 0) && | |||
(MenuMode 1015 == 0) && (MenuMode 1016 == 0) && (MenuMode 1017 == 0) && | |||
(MenuMode 1018 == 0) && (MenuMode 1019 == 0) && (MenuMode 1020 == 0) && | |||
(MenuMode 1021 == 0) && (MenuMode 1024 == 0) && (MenuMode 1038 == 0) && | |||
(MenuMode 1039 == 0) && (MenuMode 1044 == 0) && (MenuMode 1045 == 0) && | |||
(MenuMode 1046 == 0) && (MenuMode 1047 == 0) && (MenuMode 1057 == 0) | |||
set MessageCounter to (MessageCounter + 1) | |||
endif | |||
else ;MenuMode 1001 | |||
set MessageCounter to 0 | |||
endif | |||
else ;Choice > -1 | |||
set MessageCounter to 0 | |||
endif | |||
else ;Display menu again | |||
set Choosing to -(Choosing) | |||
set MessageCounter to 0 | |||
message "Trying menu again..." | |||
endif | |||
Elseif (Choice != ExitButton) | |||
Set | Set ExitButton to 0 | ||
Messagebox "Exiting options..." | Messagebox "Exiting options..." | ||
Elseif (Choice == ExitButton) | |||
Set Choosing to 0 | |||
Endif | Endif | ||
Set Working to 1 | |||
Set | |||
Endif | Endif | ||
End | End | ||
Line 622: | Line 617: | ||
Begin MenuMode | Begin MenuMode | ||
If (Choosing == 0) | If Working | ||
If (Choosing == 0) | |||
; | Set GMRun to 0 ;Running menus in both GameMode and MenuMode | ||
Set | Set Working to 0 | ||
Set MessageCounter to 0 ;Ensuring your menu is seen | |||
;Add anything that needs to be re-initialized | |||
;Ensuring your menu is seen | |||
;Centralizing your menu decisions | |||
Elseif (Choosing > 0) && (Choice == -1) ;No choice yet | |||
if (MessageCounter < 30) | |||
set Choice to GetButtonPressed | |||
if (Choice == -1) | |||
if (MenuMode 1001 == 0) | |||
if (MenuMode 1004 == 0) && (MenuMode 1005 == 0) && (MenuMode 1006 == 0) && | |||
(MenuMode 1010 == 0) && (MenuMode 1011 == 0) && (MenuMode 1013 == 0) && | |||
(MenuMode 1015 == 0) && (MenuMode 1016 == 0) && (MenuMode 1017 == 0) && | |||
(MenuMode 1018 == 0) && (MenuMode 1019 == 0) && (MenuMode 1020 == 0) && | |||
(MenuMode 1021 == 0) && (MenuMode 1024 == 0) && (MenuMode 1038 == 0) && | |||
(MenuMode 1039 == 0) && (MenuMode 1044 == 0) && (MenuMode 1045 == 0) && | |||
(MenuMode 1046 == 0) && (MenuMode 1047 == 0) && (MenuMode 1057 == 0) | |||
set MessageCounter to (MessageCounter + 1) | |||
endif | |||
else ;MenuMode 1001 | |||
set MessageCounter to 0 | |||
endif | |||
else ;Choice > -1 | |||
set MessageCounter to 0 | |||
endif | |||
else ;Display menu again | |||
set Choosing to -(Choosing) | |||
set MessageCounter to 0 | |||
message "Trying menu again..." | |||
endif | |||
Elseif (Choosing == -1) ;Display your menu | |||
Set ExitButton to 1 ;Running menus in both GameMode and MenuMode | |||
Messagebox "What would you like to do?" "First Option" "Exit Menu" | |||
Set Choosing to 1 | |||
Set Choice to -1 | |||
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 | |||
;Allowing the player to set any number | |||
short NumNewIngsDefault | |||
elseif (Choosing == -2) | |||
set ExitButton to -2 ;Running menus in both GameMode and MenuMode | |||
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 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 | |||
Endif | Endif | ||
End</pre> | End</pre> | ||
[[Category: Scripting Tutorials]] | [[Category: Scripting Tutorials]] |