So I have a script that does a thing. The script works, and is currently executed in a common event called from a testing event. I want to move it to a button/key command on the map scene. I've found the input key map, that part's not the problem. I've found a few scenes in the base code that essentially listen for a keypress, uses a bind function. I don't really understand how binding works and how to use it, but I can probably get it to work.
The problem is that I'm not sure where to PUT my code. The map scene doesn't seem to have anything for handling inputs other than some stuff for the menu button, and even that seems to only involve touch input.
Currently I intend to use two buttons already in the input table, as long as they don't already do something on the map screen. But I need to FIND where that stuff is defined/handled. Any help would be appreciated! Thanks in advance!
There are two ways to approach this.
Way 1 is to have a parallel process running on the map. You can do Conditional Branch -> Tab 4 -> Button to detect key presses, then execute your common event.
The other is to use a plugin that allows you to directly set a given key to call a specific common event. MV had Yanfly's Button Common Events, MZ must have an equivalent by now.
I'd prefer to avoid a parallel event setup, then I'd have to make sure it's running on EVERY map, and ONLY on the maps, I don't need it running during menus and such. The feature involved is going to be semi-integral to the gameplay, so it needs to be available on every map. Technically it's just a shortcut for something you can already do, but given how often a player may need to do it, I'd like to minimize how many times a player needs to dip into the menu for something absurdly simple when a quick key press can do the same thing. Less menu-navigating, more playing.
I'd also like to make sure I keep my use of parallel processes to an absolute minimum. I have no idea at this stage how much is going to go into the game, and I don't believe that this feature is going to need such a process, when the code totals about a dozen lines and is intended to be triggered just like moving on the map is, via a dedicated pair of buttons.
As for the plugin... I'm trying to write it myself to AVOID having to get a plugin for just this. For such a small thing, it'd be relatively trivial for me to implement it myself. My issue is finding WHERE in the code I need to put my functions. The rest is either done or just waiting on function placement.
Then just search the game code for the Input.keymapper table and see which functions reference it and call other methods based on its value.
I'd probably add it to _onKeyDown(), but there might be a lower level method that's more appropriate.