MessageBox Tutorial/Ensuring Your Menu Is Seen
If another menu is shown before the player makes a decision, that other menu will overwrite your menu (the player will see the other menu), and any decision the player makes will be limited to that other menu. This leads to a few problems:
- Your script will continue to run, once a frame, at least these lines:
if (Choosing == 0) ... Elseif (Choosing > 0) && (Choice == -1) ;No choice yet Set Choice to GetButtonPressed Return
until the menu is started up again (activated again).
- Your script won't run through the exit if (Choosing == 0)
- Again, the player won't see or be able to answer your menus
To make sure your menu is read, after the player has finished with the other menu system so you won't disturb it's processing, replace:
Elseif (Choosing > 0) && (Choice == -1) ;No choice yet Set Choice to GetButtonPressed Return
with
float MessageTimer short MessageButton ... Elseif (Choosing > 0) && (Choice == -1) ;No choice yet if (MessageTimer > 0) || (MessageCounter > 0) set Choice to GetButtonPressed if (Choice > -1) return endif if (MenuMode 1001 == 0) if (MenuMode 1004) || (MenuMode 1005) || (MenuMode 1006) || (MenuMode 1010) || (MenuMode 1011) || (MenuMode 1013) || (MenuMode 1015) || (MenuMode 1016) || (MenuMode 1017) || (MenuMode 1018) || (MenuMode 1019) || (MenuMode 1020) || (MenuMode 1021) || (MenuMode 1024) || (MenuMode 1038) || (MenuMode 1039) || (MenuMode 1044) || (MenuMode 1045) || (MenuMode 1046) || (MenuMode 1047) || (MenuMode 1057) return else set MessageTimer to (MessageTimer - GetSecondsPassed) set MessageCounter to (MessageCounter - 1) return endif else ;MenuMode 1001 set MessageTimer to 1 set MessageCounter to 45 return endif else ;Display menu again message "Trying menu again..." set Choosing to -(Choosing) return endif
and whenever you display a menu, setup the MessageTimer to 1 and the MessageCounter to 45, as such:
Elseif (Choosing == -1) ;Display your menu Messagebox "Would you like to donate gold or food?" "Gold" "Food" "Blood" "Cancel" Set Choosing to 1 Set Choice to GetButtonPressed Set MessageTimer to 1 Set MessageCounter to 45 Return
And now I'm sure you want to know what all of that actually does, but some quick background first. When another menu overwrites yours, any response the player makes will be caught by the other script's GetButtonPressed, but not by your script's GetButtonPressed. That means Choice will always be =1. So, these extra lines will start a countdown once the player has left the menu screen (MenuMode 1001). If both 1 second and 45 frames pass and GetButtonPressed is still returning -1' then your menu is reset (with set Choosing to -(Choosing). The countdown won't run when the player presses <ESC> and looks through their options (that's what that whole mess of <u<if (MenuMode 1004)... is for). This won't disturb other menus, because the countdown is reset whenever a new menu is displayed. So, once the other mod's menus are out of the way, your menu will be shown again.