Hello! I've been using Yanfly's Button Common Events and their Key Config plugins as hotkeys for certain menu scenes. These scenes have been called with scripts in their respective common events. It would be nice if you could exit the scene by pressing the key used to open them instead of ESC. Is this possible?
Can I close menus activated by Button Common Events with the same key I used to open them?
RPG Maker MV SupportWould this work? Put a conditional with an else case into the button common event. Have it check for a switch, e.g. "buttonEvent". Cut/paste the current contents of the button event into the "else" case, an turn on the "buttonEvent" switch during the else case. For the "if ButtonEvent = ON" case, add the commands/scripts to close the menu, and turn OFF the buttonEvent switch. So basically, the first time you push the button, it should open the menu and turn on the "buttonEvent" switch; the second time you push it, since the switch is now on, it will run the other case and close the menus. This essentially turns the button command event to an on/off functionality. I think Yanfly actually uses an example like this somewhere in the documentation or demo if this explanation doesn't make sense.
ETA: If it's possible to open the menus in question through other means than pushing the common event button, you'd run into problems with this method. In that case you would need a method to track whether the menus are currently open and base the conditional on that, i.e. the button common event runs the commands to close the menus if the menu is currently open, and vice versa.
ETA: If it's possible to open the menus in question through other means than pushing the common event button, you'd run into problems with this method. In that case you would need a method to track whether the menus are currently open and base the conditional on that, i.e. the button common event runs the commands to close the menus if the menu is currently open, and vice versa.
Hi!
By default, common events are not executed inside menu scenes.
So you have to add the functionality of a specific key to be able to close the menu when pressed.
By default, common events are not executed inside menu scenes.
So you have to add the functionality of a specific key to be able to close the menu when pressed.
I tried the first listed method, and unfortunately, it didn't work. I'll recheck Yanfly's video about it, though.
Would you know how to add the functionality of that key to close the menu?
Would you know how to add the functionality of that key to close the menu?
Yeah, sorry about that, I didn't think about what Eliaquim said about common events and the menu scene. The method I gave won't work in this situation because the common event won't activate while the menu scene is active.
That seems to leave two options: either bypassing the common event functionality altogether by hard-coding this functionality to a certain key, or make the common events activate while the menu scene is active. Unfortunately I don't know how to do either, nor do I know if plugins that already do so exist. That means you could be in for some javascript coding or commissioning something.
If you're up for attempting it yourself, to hard-code a function onto a key/button, you might start by looking at the functions in rpg_core.js related to the input class... But again, that's a bit beyond my knowledge.
That seems to leave two options: either bypassing the common event functionality altogether by hard-coding this functionality to a certain key, or make the common events activate while the menu scene is active. Unfortunately I don't know how to do either, nor do I know if plugins that already do so exist. That means you could be in for some javascript coding or commissioning something.
If you're up for attempting it yourself, to hard-code a function onto a key/button, you might start by looking at the functions in rpg_core.js related to the input class... But again, that's a bit beyond my knowledge.
Okay. Thank you both for your help!
Original thread: https://forums.rpgmakerweb.com/threads/can-i-close-menus-activated-by-button-common-events-with-the-same-key-i-used-to-open-them.130207/