Adding Command To Menu and making it do something.

Joined
Feb 28, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
I goto select my new command for bestiary, but it won't do anything except freeze game even though i have common event set
to do something. Heres the code:


/*:
*
*@author ApocalympseGaming1992
*@plugindesc
*This is a custom menu for my game Dungeon Dweller.
*
*@help
*=======GUIDE:=======
*Goto the Common Events Page and add a PluginCommand for "EnemyBook open".(NO QUOTES OR PERIOD.)
*
*@param commandName
*@desc Name of command thats shows up on Menu.
*@default Bestiary
*
*/


var cmd = String(PluginManager.parameters('AG1992_D_D_Menu')['commandName']);
var transparent = 0;
(function(){


Window_MenuCommand.prototype.makeCommandList = function() {
this.addMainCommands();
this.addFormationCommand();
this.addOriginalCommands();
this.addOptionsCommand();
this.addSaveCommand();
this.addGameEndCommand();
};



Window_MenuCommand.prototype.addMainCommands = function() {
var enabled = this.areMainCommandsEnabled();
if (this.needsCommand('item')) {
this.addCommand(TextManager.item, 'item', enabled);
}
if (this.needsCommand('skill')) {
this.addCommand(TextManager.skill, 'skill', enabled);
}
if (this.needsCommand('equip')) {
this.addCommand(TextManager.equip, 'equip', enabled);
}
if (this.needsCommand('status')) {
this.addCommand(TextManager.status, 'status', enabled);
}
if (this.needsCommand('bestiary')) {
this.addCommand(cmd, 'bestiary', enabled);
}
};





Scene_Menu.prototype.createCommandWindow = function() {
this._commandWindow = new Window_MenuCommand(0, 0);
this._commandWindow.setHandler('item', this.commandItem.bind(this));
this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));
this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));
this._commandWindow.setHandler('status', this.commandPersonal.bind(this));
this._commandWindow.setHandler('formation', this.commandFormation.bind(this));
this._commandWindow.setHandler('options', this.commandOptions.bind(this));
this._commandWindow.setHandler('save', this.commandSave.bind(this));
this._commandWindow.setHandler('bestiary', this.commandBestiary.bind(this));
this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
this._commandWindow.setHandler('cancel', this.popScene.bind(this));
this.addWindow(this._commandWindow);
};





Scene_Menu.prototype.commandBestiary = function(){
$gameTemp.reserveCommonEvent(1);
};

})();
 

Gamefall Team

Nebula Games Leader
Veteran
Joined
Jan 10, 2017
Messages
348
Reaction score
472
First Language
Italian
Primarily Uses
RMMZ
Well, your code shoud be polished a little:

Code:
(function(){
// I suggest to insert all your methods inside the scope.

var parameters = PluginManager.parameters('AG1992_D_D_Menu') //Set the object parameters inside a variable. This way is easier to use for all the parameters you want.
var cmd = String(parameters['commandName']); //Call your parameters
var transparent = 0;

// No need of recalling the making of the command list, because you didn't make any edit to it.

//When you want to edit and old method, remember to ALIAS it. In js when you write a method with //the same name of the old one, it will be REPLACED. So, making an alias preserves all the contents //of the other methods and assure compatibility with other possible plugins.

var oldWindowMenuCommandAddMainCommands = Window_MenuCommand.prototype.addMainCommands
Window_MenuCommand.prototype.addMainCommands = function() {
oldWindowMenuCommandAddMainCommands.call(this)
this.addCommand(cmd, 'bestiary');
};

//Same Here

var oldCreateCommandWindow = Scene_Menu.prototype.createCommandWindow
Scene_Menu.prototype.createCommandWindow = function() {
oldCreateCommandWindow.call(this) //Calls the alias;
this._commandWindow.setHandler('bestiary', this.commandBestiary.bind(this));
};

// I'm not really sure about this approach, but if you want to load a common event that is processed on map, we can try to do this
Scene_Menu.prototype.commandBestiary = function(){
$gameTemp.reserveCommonEvent(1);
this.popScene() //Returns the map and processses the common event.
};
})();
Remember that is really important to alias methods which have importants information.
 

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

Latest Threads

Latest Profile Posts

Woke up on an awful nightmare of being banned here because some mod didn't liked me in a super-heroes freeform round robin RP where I used throwing normal hammer as power and it was qualified being too OP. XD Nice to read you all guys. Will not wait next nightmares.
Staring at all the RPG Maker versions I have and realizing that my project has been a long time coming. But, I finally feel like I have the knowledge and experience to make it into something good.
We're almost done with the jam game! :D
I get scam calls all the time so today I gave them a piece of my mind. They hung up on me. Sweet revenge.

Forum statistics

Threads
104,321
Messages
1,005,557
Members
135,844
Latest member
andrewshetty123
Top