Simple Custom Menu Command

This tutorial assumes you understand at least the basics of RGSS coding. Such as aliasing methods, classes, variables, etc..
It is also slightly different to my simple param mod tutorial in the sense that I have simply coded the method and explained why I have done each piece of code in an easy to understand guide. You can also copy/paste the tutorial into your script editor for increased readability and an adequate testing environment. I think I will be continuing this style of tutorial…

If anyone has any issues, let me know.
Would be happy to answer any queries on THIS scenario you may have 🙂

 

#===============================================================================
# Info [ 1 ] = Creates aliased method. used to recall previous method data.
# Info [ 2 ] = Calls alias data, ie - old method data. 
# Info [ 3 ] = Adds new visible command to menu command window.
# Info [ 4 ] = Creates local variable 'handle_name' 
# Info [ 5 ] = Creates local variable 'method_name'
# Info [ 6 ] = Tells the command window to call 'method_name' when 'handle_name'
#              has been selected and activated (pressed)
# Info [ 7 ] = Creates new method. Has the name name as 'method_name' defined in
#              Info [ 5 ]. This method is what is called when the command is 
#              activated.
# Info [ 8 ] = Calls a scene. In this example, I have called 'Scene_Item'.
#              You could call any scene you wanted - usually not Scene_Item :p
#===============================================================================
class Window_MenuCommand < Window_Command
#===============================================================================
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
  alias :aoc_menu_command_tutorial_alias :add_original_commands # See Info [ 1 ]
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
  def add_original_commands
    aoc_menu_command_tutorial_alias                             # See Info [ 2 ]
    add_command("Menu Command Name", :custom_command_handler)   # See Info [ 3 ]
  end
end
#===============================================================================
class Scene_Menu < Scene_MenuBase
#===============================================================================
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
  alias :ccw_menu_command_tutorial_alias :create_command_window # See Info [ 1 ]
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
  def create_command_window
    ccw_menu_command_tutorial_alias                             # See Info [ 2 ]
    handle_name = :custom_command_handler                       # See Info [ 4 ]
    method_name = :custom_command_method_name                   # See Info [ 5 ]
    @command_window.set_handler(handle_name,method(method_name))# See Info [ 6 ]
  end
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
  def custom_command_method_name                                # See Info [ 7 ]
    SceneManager.call( Scene_Item )                             # See Info [ 8 ]
  end
  #-----------------------------------------------------------------------------
  # 
  #-----------------------------------------------------------------------------
end

One thought on “Simple Custom Menu Command

  1. knighteen says:

    PT BR translation
    tradução PT BR
    # ================================================= ==============================
    # Info [1] = Cria o método aliased. Costumava lembrar dados do método anterior.
    # Info [2] = Dados de alias de chamadas, ou seja, dados de métodos antigos.
    # Info [3] = Adiciona o novo comando visível à janela de comando do menu.
    # Info [4] = Cria a variável local ‘handle_name’
    # Info [5] = Cria a variável local ‘method_name’
    # Info [6] = Indica a janela de comando para chamar ‘method_name’ quando ‘handle_name’
    # Foi selecionado e ativado (pressionado)
    # Info [7] = Cria novo método. O nome do nome como ‘method_name’ definido em
    # Info [5]. Este método é o chamado quando o comando é
    # ativado.
    # Info [8] = Chama uma cena. Neste exemplo, liguei para ‘Scene_Item’.
    # Você poderia chamar qualquer cena que você queria – geralmente não Scene_Item: p
    # ================================================= ==============================

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s