Can I close menus activated by Button Common Events with the same key I used to open them?

Frigg

Quiet
Member
Joined
Jun 15, 2017
Messages
8
Reaction score
2
First Language
English
Primarily Uses
RMMV
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?
 

Featherbrain

Prehistoric Gamer
Veteran
Joined
Jan 12, 2020
Messages
100
Reaction score
181
First Language
English
Primarily Uses
RMMV
Would 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.
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,773
Reaction score
1,193
First Language
Portuguese - Br
Primarily Uses
RMMZ
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.
 

Frigg

Quiet
Member
Joined
Jun 15, 2017
Messages
8
Reaction score
2
First Language
English
Primarily Uses
RMMV
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?
 

Featherbrain

Prehistoric Gamer
Veteran
Joined
Jan 12, 2020
Messages
100
Reaction score
181
First Language
English
Primarily Uses
RMMV
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.
 

Frigg

Quiet
Member
Joined
Jun 15, 2017
Messages
8
Reaction score
2
First Language
English
Primarily Uses
RMMV
Okay. Thank you both for your help!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Who would think putting a power button on a side of a laptop is a good thing? You want to move the laptop and you suddenly press the button.
The second draft of my script is almost done, and I don't think I'm going to write a third draft. I'll make changes to dialogue here and there, but I'm happy with the series of events the way they are.
How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)

Forum statistics

Threads
107,526
Messages
1,030,279
Members
139,652
Latest member
jasasewamobilbali
Top