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
Advertisements

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 )

Google+ photo

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

Connecting to %s