SadDoubts

Villager
Member
Joined
Jan 8, 2019
Messages
9
Reaction score
3
First Language
Portuguese
Primarily Uses
RMMV
Hey, I wanted the item menu and the options, Game end, skills (etc) menu to be accessed in different ways. The former using the X key, and the latter using the C key. I was able to call the Scene Menu (the latter) by hititng the C key, but I want this menu to be closed by also hitting the C key , and I don't know how.
Basically, it works like this:
  • Use C to open Scene Menu
  • Have to use X to close menu (want to change this)
Heres the code for better clarification:

//KeyMapping Input.keyMapper["67"] = "Menu" Scene_Map.prototype.isMenuCalled = function() { return Input.isTriggered('Menu') || TouchInput.isCancelled(); };

Scene_Menu.prototype.createCommandWindow = function() { this._commandWindow = new Window_MenuCommand(0, 0); this._commandWindow.setHandler('item', this.commandItem.bind(this)); this._commandWindow.setHandler('options', this.commandOptions.bind(this)); this._commandWindow.setHandler('save', this.commandSave.bind(this)); this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this)); //This is the thing I wanna change, clueless about how. this._commandWindow.setHandler('cancel', this.popScene.bind(this)); this.addWindow(this._commandWindow);

How do I go about this, really? Also, I want to change the cancel keybind to only this menu, the others can use X just fine.

Thanks in advance, and sorry for my gibberish english.
 
Last edited:

SadDoubts

Villager
Member
Joined
Jan 8, 2019
Messages
9
Reaction score
3
First Language
Portuguese
Primarily Uses
RMMV
Nevermind found the solution myself. You need to set Handlers, lemme show you.

  1. Set a Handler. They do nothing by themselves,so you need to add a function to them (bind); Here is how I did it (I chose my handler name to be "cancelMenu", but name it however you want. After choosing the name, bind the function you want the Handler to be attached to).
Scene_Menu.prototype.createCommandWindow = function() { [...] //Set handler(name,function) this._commandWindow.setHandler('cancelMenu', this.popScene.bind(this)); [...] };


2. Associate an Input Key from the KayMapper to the handler added. Otherwise, you wont be able to access it. Create a custom function as follows:

//Name the function however. for mine, I did "CancelMenuTriggered" Window_Selectable.prototype.isCancelMenuTriggered = function() { return Input.isRepeated('Menu'); //Put the name of your Input key in quotes here, defined in the Input Mapper; };

3.Create 2 custom functions, one checks whether the handler is enabled, the other, to call the handler

] //If it is enabled, name it however Window_Selectable.prototype.isCancelMenuEnabled = function() { return this.isHandled('cancelMenu');//Put your handler name here }; //To call Handler Window_Selectable.prototype.callCancelMenuHandler = function() { this.callHandler('cancelMenu'); //Put your handler name here };

4. Make a process function that basically calls the handler and process things such as input, and sound. Also, since mine closes the menu window, it deactivates the window. Havent checked, but, most likely, other process functions plays a sound and updates Input, so you should include those as well.

Window_Selectable.prototype.processCancelMenu = function() { SoundManager.playCancel(); //this just plays a sound, should include if you want sound. this.updateInputData(); //may need this to work this.deactivate(); this.callCancelMenuHandler(); };
5. Finally, you need to alias the ProcessHandling function and put your process function after calling the alias, like bellow:

var _aliasProcessHandling = Window_Selectable.prototype.processHandling; Window_Selectable.prototype.processHandling = function(){ _aliasProcessHandling.call(this); //Make an if statement putting your enabler and triggered functions as conditions, and the process function in the statement block. if (this.isCancelMenuEnabled() && this.isCancelMenuTriggered()){ this.processCancelMenu(); } }
 

Latest Threads

Latest Profile Posts

Firefly130984 wrote on WallCat's profile.
Hello, I would try to beta test your game.
Parallel I would write a guide.
I am already planning some games to make in Unite... I hope it gets a solid release date soon!
Remember to do even 0,01% progress on your game today! You can!

Forum statistics

Threads
122,130
Messages
1,146,773
Members
160,422
Latest member
AlftheflA
Top