Injecting commands at specific specific locations in the command window?

consider the following:

Window_MenuCommand.prototype.makeCommandList = function () { this.addMainCommands(); this.addFormationCommand(); this.addOriginalCommands(); this.addOptionsCommand(); this.addCommand('Something', 'Something'); this.addSaveCommand(); this.addGameEndCommand(); }If I do this, along with the other required code to create a new command in the main menu of the game, I am stopping other people from adding there commands to mine.

How ever if I do:

var oldGameMenu = Window_MenuCommand.prototype.makeCommandList; Window_MenuCommand.prototype.makeCommandList = function () { oldGameMenu.call(this); this.addCommand('Something', 'Something'); }My new command is appended AFTER the game end command. Is there a a way to create a custom ordering but still keep other peoples scripts working when they add there own stuff to the menu list?
Yes. As you can see in the default makeCommandList call, several functions are called to create the commands in order. You can alias any one of these and put your code in there to reorder it. Additionally, you don't need to call the alias at the first line. With your current code, you can put your Something command above the alias, and have your custom command first.

However, one thing I forgot to mention last time I mentioned how to add commands to the window is the addOriginalCommands function. This is intentionally empty, and is intended for plugin creators to alias and add their commands to so that they'll be in the middle. That was my mistake, sorry.

But, like I said, you can alias any of those functions to have better control over where your command shows up.

Original thread: https://forums.rpgmakerweb.com/threads/injecting-commands-at-specific-specific-locations-in-the-command-window.47071/