Adding a New Menu Command in VX Ace

What I want to do is add a custom menu command to the commands already listed in the menu. For example I want to add a codex command. I'm using Estriole's notebook system to make said codex. I know there are some scripts that let me do this like Galv's Menu Themes and Yanfly's Menu but is there a way to add a new command onto the RTP menu? I don't really know anything about scripting so if you could answer with as much detail as possible it would be greatly appreciated.

Edit link to script: http://www.rpgmakervxace.net/topic/5776-est-notebook-system/
What those scripts do is also add things to the RTP menu...


You'd do the same if you want to do it, you'd edit the methods that adds those commands.


On the window script itself there is a method which says add_command, that is the one used to add new commands


then on the Scene script where the window is used, you will need to find where it creates the window, then add a handler method for the command you made above.


You will also need to know how to call the codex scene.


Could you put a link to the codex script?
[Github Link]

The first thing we want to do is create a data structure to store and 

 

represent what a "command" really is:

 

Code:
Scene_Command = Struct.new(:symbol, :name, :scene)

 

 

Next, we need to define a collection to store the new commands.  We will do 

 

this in a namespace I call "Demo".

Code:
module ::Demo  New_Commands = []end # ::Demo

 

Then, you can add commands to the collection:

Code:
Demo::New_Commands << Scene_Command.new(:symbol, "Game Over", ::Scene_Gameover)

 

This still won't do anything or even have them show up on the menu.

So, we will have to add them to the menu:

Code:
class ::Window_MenuCommand  alias :demo_add_main_commands :add_main_commands  def add_main_commands    demo_add_main_commands    ::Demo::New_Commands.each { |x|      add_command(x.name, x.symbol, main_commands_enabled)    }  endend # ::Window_MenuCommand

 

This should now show the commands, but still won't do anything.  To make it 

 

go to the registered scene, we need to handle the command in Scene_Menu:

 

Code:
class ::Scene_Menu  alias :demo_create_command_window :create_command_window  def create_command_window    demo_create_command_window    ::Demo::New_Commands.each { |x|      @command_window.set_handler(x.symbol, method(:command_custom))    }  end  def command_custom    commands = Hash[::Demo::New_Commands.collect { |x| [x.symbol, x] }]    current_symbol = @command_window.current_symbol    if commands.has_key?(current_symbol)      scene = commands[current_symbol].scene      SceneManager.call(scene)    end  endend # ::Scene_Menu
I'd say that's overkill for something as simple as adding a command to the main menu... And quite confusing for a beginner too.
:S

Was trying to make it as simple as possible.  I honestly don't know how you could add more scene commands without overriding both Scene_Menu and Window_MenuCommand.

I admit that my use of structs and arrays be not be immediately apparent to beginners, but it allows for necessary extensibility in case I didn't exactly meet his needs.  That being said, if there is something that I could clarify that you think I have missed, I would be happy to elaborate.
You can basically do the last two code blocks that you made without making those structs etc...


I do know how "better" that design could be, but in the case of a simple problem I do think it just makes things complicated (if he at least knows how to do it the normal way, then that's the time to go to the next level if he wants it). It's simply that we don't want anybody thinking that it is the easiest way to go about this. I do think it's better to let him learn the basics of adding commands first.
I got it to work! Thank you both so much for your help and explaing in detail even if it was a tad confusing the first read through. But again thank you both so much for your help I really do appreciate it.

Original thread: https://forums.rpgmakerweb.com/threads/adding-a-new-menu-command-in-vx-ace.35019/