[SOLVED] Image-based menu: how to stop button press loop from continuing when menu is open
RPG Maker MV Supportyou'll need either switches or a variable to store the current menu status, and in the reaction to each button press you check that to decide if it does something or not.
I tried using a switch, but am lost on what to put in the Button[OK] branch to allow selections to happen within the CE menu again. Do you have an idea of what code to use? Thank you!
you're using the switches wrong.
when a menu part becomes active, then you control switch.
in the if button is pressed, you check the switch/variable after that:
If button OK is pressed
- if switch (allowed to press OK) is ON
- - do whatever
when a menu part becomes active, then you control switch.
in the if button is pressed, you check the switch/variable after that:
If button OK is pressed
- if switch (allowed to press OK) is ON
- - do whatever
EDIT: I'm still having trouble getting it to work properly because I don't know what to put under if CEMENUOPEN is ON conditional branch 🙁, the loop has stopped though! Ijust want the menu to work normally as a condition
bump!
If CEMENUOPEN is ON, nothing should happen in the current menu. If you can't navigate CEMenu when the CEMENUOPEN switch is on, then something is wrong with whatever event is handling the navigation for CEMenu.
And right now the current menu is still running, so basically whenever you press OK while CEMENUOPEN is on, you're telling it to run all the commands in Common Event 48 again
And right now the current menu is still running, so basically whenever you press OK while CEMENUOPEN is on, you're telling it to run all the commands in Common Event 48 again
What can I do to fix it? I still have no idea how to do it, and also based on the behaviour of how it stopped looping when I am in the menu but still can't actually select things from the menu I don't think its actually running the commands again when the menu is open.. Sorry for the confusion but I'm really lost on this.. Thank you in advance
Sorry, youre right on this part. I misread it. The event page is still running but not that section.
Could you post the updated full event page from the first post?
Thank you for the reply! I hope this is what you mean, if not let me know what you need 🙂
For reference, the left and right button presses is to go left and right in the image-based menu for other options. The relevant bit is the button ok part 😅
You have no way to cancel out of your menu because the player has to be pressing ok at the same time to trigger the cancel.
I’m very open to suggestions on how to do it correctly, even if I have to rewrite the code!
Make a new line outside of the conditionals
If: CEMENUOPEN is ON
and cut and paste the If: Button [Cancel] is pressed down statement into it
I'll just add that it's very difficult to visualize how your menu structure is set up and you should've clarified you were using Yanfly Common Event Menu
Common Event Menu (YEP) - Yanfly.moe Wiki
Edit: I'm a silly goose - I answered a question that wasn't the one being asked. I'm just going to leave this here in case it comes up, helps somebody else, or makes a nice break from relevant discussion...but I am going to stick the whole thing in a spoiler to save on space.
I evented my own title menu, and I doubt I did it anything like what you're wanting to do, but I'll post some screenshots and try to explain what I did. Because I'm a gentleman, I'll even mark on them to point out specific areas when it seems helpful. Hopefully that'll get you in the right direction to do what you want.
Some notes before you dive in: my menu is pretty busy and the events are pretty messy. A lot of what you're going to see is specific to my project and safe to ignore. I'll try to point some of that stuff out, but you'll need some understanding of events to make sense of this anyway, I think. I don't suggest copying things just like I have them, because some of this stuff gets pretty clunky. Also, there are undoubtedly better ways to do what we're doing. This is mostly just intended to get you thinking.
One more word of caution: I used MZ and an MZ plugin or two (which also means not the same title eventing plugin you're using), so things might look a little different (not much?), but I think it'll function the same.
This event is only used to display the menu buttons and doesn't have anything to do with the controls. Here's the breakdown:
1 - I set this as Autorun so that it'd run once when the map is loaded. It's done after that.
2 - These Show Picture commands put the images for my menu buttons on screen. There's a picture for when the button is highlighted and one for when it's inactive for each option (my menu has 6 options, so 12 pictures).
3 - You don't need this. You might notice I placed all the buttons in as completely transparent; this makes all the inactive buttons visible (none are initially highlighted).
4 - You also don't need this. This is a plugin that ships with MZ that lets players click on the buttons; that's literally all it does. Each button calls a common event when you click it that either moves focus to the button clicked or opens a scene. I won't cover those common events here as you really don't need them and I don't see any indication that you're making the menu clickable anyway.
5 - This variable controls which item in the menu is active/highlighted. You'll see more of how that works in the next event. In this case, "TITLEMENU = 1" means that the first menu button will be active...eventually. Again, that's handled by the next event.
6 - This is just to be thorough; I won't need this event again until the map is reloaded, so as soon as the buttons are in place, the plugin is set, and the variable is assigned, POOF.
This event is pretty large, but mostly just does the same stuff over and over. This one allows different options to be highlighted as we scroll up and down and makes each one start a scene (basically the same functions as the common events my ButtonPicture plugin references above).
1 - This event has to be Parallel so that it can listen for button presses.
2 - Here's the variable that controls what option is selected again. The last event sets that to 1 (which is the first/top option), so when this event runs, it starts by asking if the variable is indeed set to 1.
3 - If this event finds out that the variable is set to 1 (and the last event promises that it always is when the menu map is loaded), the inactive menu item picture goes invisible and is replaced with one that looks the same but is highlighted.
4 - This part says that, if the variable is 1 and the first option is highlighted, none of the others should be. I had to include them all because I gave the option to click between any of them without scrolling; if you're only using up/down or left/right to select a choice, you only need to un-highlight the adjacent options.
5 - While the variable is set to select this menu option, we start listening for buttons. If you press the down button, the variable changes to 2 (for the second option). You're also treated to a sound effect and a brief wait for the transition. The wait is actually shorter than the animation. Why? Because who cares?
6 - If we press up from the first option, the selection cycles from the top of the list back to the bottom, so we change the variable to 6 (the 6th option, see?). Otherwise this is exactly the same as the last conditional statement.
7 - So what if we press 'OK'? The first option is 'new game,' so we hit the player with a sound effect, fade out the screen, and move them to the new game scene. All that plugin does is allow the player to control their character; I took that ability away with the same plugin in an event you can't see here just to simplify making this menu.
8 - You may notice that this big chunk here looks a lot like the one above it. That's because they're virtually identical. This one says that if the second option is highlighted (variable = 2) then we do the same sort of stuff, exept in a different place, and we can load a game instead of starting a new one. There's a different plugin shown here that has literally nothing to do with the menu; I randomly put filters over elements of the title screen, and this erases them - don't worry about it.
9 - This last line is actually pretty important. If your parallel event is running every single frame, you're gonna be pretty laggy. Just waiting 5 frames before repeating the cycle means it won't miss much but still runs 5x less often.
Yours won't (and shouldn't) look like this, but hopefully just a quick clip will help make sense of that essay above.
I hope some of that helps. I know a lot of it wasn't even relevant and I also dumped a ton of info on you, but it could help you avoid some problems. As for the issue with cancelling out of the menu, do you need it? Most title menu stuff can be handled by sending players to a different scene, which generally means normal controls are restored. I could probably help more if I knew what you were trying to do with this specifically, so feel free to fill in the blanks for us. In either case, good luck, and thanks for giving me a space to rant!
Some notes before you dive in: my menu is pretty busy and the events are pretty messy. A lot of what you're going to see is specific to my project and safe to ignore. I'll try to point some of that stuff out, but you'll need some understanding of events to make sense of this anyway, I think. I don't suggest copying things just like I have them, because some of this stuff gets pretty clunky. Also, there are undoubtedly better ways to do what we're doing. This is mostly just intended to get you thinking.
One more word of caution: I used MZ and an MZ plugin or two (which also means not the same title eventing plugin you're using), so things might look a little different (not much?), but I think it'll function the same.
1 - I set this as Autorun so that it'd run once when the map is loaded. It's done after that.
2 - These Show Picture commands put the images for my menu buttons on screen. There's a picture for when the button is highlighted and one for when it's inactive for each option (my menu has 6 options, so 12 pictures).
3 - You don't need this. You might notice I placed all the buttons in as completely transparent; this makes all the inactive buttons visible (none are initially highlighted).
4 - You also don't need this. This is a plugin that ships with MZ that lets players click on the buttons; that's literally all it does. Each button calls a common event when you click it that either moves focus to the button clicked or opens a scene. I won't cover those common events here as you really don't need them and I don't see any indication that you're making the menu clickable anyway.
5 - This variable controls which item in the menu is active/highlighted. You'll see more of how that works in the next event. In this case, "TITLEMENU = 1" means that the first menu button will be active...eventually. Again, that's handled by the next event.
6 - This is just to be thorough; I won't need this event again until the map is reloaded, so as soon as the buttons are in place, the plugin is set, and the variable is assigned, POOF.
This event is pretty large, but mostly just does the same stuff over and over. This one allows different options to be highlighted as we scroll up and down and makes each one start a scene (basically the same functions as the common events my ButtonPicture plugin references above).
1 - This event has to be Parallel so that it can listen for button presses.
2 - Here's the variable that controls what option is selected again. The last event sets that to 1 (which is the first/top option), so when this event runs, it starts by asking if the variable is indeed set to 1.
3 - If this event finds out that the variable is set to 1 (and the last event promises that it always is when the menu map is loaded), the inactive menu item picture goes invisible and is replaced with one that looks the same but is highlighted.
4 - This part says that, if the variable is 1 and the first option is highlighted, none of the others should be. I had to include them all because I gave the option to click between any of them without scrolling; if you're only using up/down or left/right to select a choice, you only need to un-highlight the adjacent options.
5 - While the variable is set to select this menu option, we start listening for buttons. If you press the down button, the variable changes to 2 (for the second option). You're also treated to a sound effect and a brief wait for the transition. The wait is actually shorter than the animation. Why? Because who cares?
6 - If we press up from the first option, the selection cycles from the top of the list back to the bottom, so we change the variable to 6 (the 6th option, see?). Otherwise this is exactly the same as the last conditional statement.
7 - So what if we press 'OK'? The first option is 'new game,' so we hit the player with a sound effect, fade out the screen, and move them to the new game scene. All that plugin does is allow the player to control their character; I took that ability away with the same plugin in an event you can't see here just to simplify making this menu.
8 - You may notice that this big chunk here looks a lot like the one above it. That's because they're virtually identical. This one says that if the second option is highlighted (variable = 2) then we do the same sort of stuff, exept in a different place, and we can load a game instead of starting a new one. There's a different plugin shown here that has literally nothing to do with the menu; I randomly put filters over elements of the title screen, and this erases them - don't worry about it.
9 - This last line is actually pretty important. If your parallel event is running every single frame, you're gonna be pretty laggy. Just waiting 5 frames before repeating the cycle means it won't miss much but still runs 5x less often.
Yours won't (and shouldn't) look like this, but hopefully just a quick clip will help make sense of that essay above.
I hope some of that helps. I know a lot of it wasn't even relevant and I also dumped a ton of info on you, but it could help you avoid some problems. As for the issue with cancelling out of the menu, do you need it? Most title menu stuff can be handled by sending players to a different scene, which generally means normal controls are restored. I could probably help more if I knew what you were trying to do with this specifically, so feel free to fill in the blanks for us. In either case, good luck, and thanks for giving me a space to rant!
The OP has a picture reel that can be navigated by pressing left, right, and ok to make a selection, which brings up a Yanfly Common Event Menu that uses this layout
The picture reel is in a parallel event on the map with event pages to represent each picture. The common event menu is generated in a common event.
The picture reel is in a parallel event on the map with event pages to represent each picture. The common event menu is generated in a common event.
Oh, thanks! That's very different from what I was thinking of, so my last post is a lot less applicable than I had hoped, but I'll leave it as is in case there's anything valuable in there.
Given my new insight to the problem, the post above my last was the simplest answer for getting out of it:
That will do the trick IF you include it outside of other conditionals, just like was covered up yonder ^. As it is, your event checks first if the OK button is being pressed; if it is, that's when it starts looking for the cancel button to be pressed.
Thanks again! Good luck again!
Thank you for your suggestions @BenSD and @AquaEcho !
I managed to get the [cancel] button working by making a completely new parallel event when CEMENOPEN = ON. For some reason it didn't work in the form of that conditional you suggested, i'm not sure why? But with this method it works perfectly now!
I managed to get the [cancel] button working by making a completely new parallel event when CEMENOPEN = ON. For some reason it didn't work in the form of that conditional you suggested, i'm not sure why? But with this method it works perfectly now!
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Original thread: https://forums.rpgmakerweb.com/threads/solved-image-based-menu-how-to-stop-button-press-loop-from-continuing-when-menu-is-open.159408/