Skip to content

Instantly share code, notes, and snippets.

@rghavlin
Created June 22, 2018 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rghavlin/110c06bccb06ca578161c7973ad34942 to your computer and use it in GitHub Desktop.
Save rghavlin/110c06bccb06ca578161c7973ad34942 to your computer and use it in GitHub Desktop.
RPG Maker MV plugin to put a common event command in the main menu
//=============================================================================
// menuCommonEvent.js
//=============================================================================
/*:
* @plugindesc Run a common event from the main menu
* @author robhav
*
* @param Common Event Number
* @desc Number of the common event to run
* @default 1
*
* @param Command Name
* @desc Name of the menu command
* @default Common Event
*
* @param Show Event
* @desc Show Event in menu? true or false
* @default true
*
* @help
* Choose number of common event and the name of the menu command.
* True or false to have it show in the menu.
* --------------------------------------------------------------------------------
* Terms of Use:
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version: 1.0
*/
(function() {
var eventNumber = Number(PluginManager.parameters('menuCommonEvent')['Common Event Number']);
var eventName = String(PluginManager.parameters('menuCommonEvent')['Command Name']);
var showEvent = String(PluginManager.parameters('menuCommonEvent')['Show Event']);
var eventSymbol = 'common';
var makeCommandListCommonEvt = Window_MenuCommand.prototype.makeCommandList;
Window_MenuCommand.prototype.makeCommandList = function() {
this.addMainCommands();
this.addFormationCommand();
this.addOriginalCommands();
this.addOptionsCommand();
this.addCommonEvtCommand();
this.addSaveCommand();
this.addGameEndCommand();
//makeCommandListCommonEvt.call(this);
};
Window_MenuCommand.prototype.addCommonEvtCommand = function() {
if (showEvent) {
this.addCommand(eventName, eventSymbol, showEvent);
}
};
Scene_Menu.prototype.callCommonEvent = function() {
$gameTemp.reserveCommonEvent(eventNumber);
this.popScene();
};
var commonCreateCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
commonCreateCommandWindow.call(this);
this._commandWindow.setHandler(eventSymbol, this.callCommonEvent.bind(this));
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment