Help with custom menu options?

Discussion in 'Learning Ruby and RGSSx' started by Tagger101, Jun 29, 2014.

  1. Tagger101

    Tagger101 Veteran Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    New York
    First Language:
    English
    I don't have much scripting knowledge, and what I do know is self-taught through custom scripts, so I basically have no idea what I'd be doing when it comes to playing around with the base RGSS3 coding. I'd like to add an option to the menu, specifically a "Tutorials" option, where I could compile a collection of text explaining certain things about my game to players. I've been reading that I'd have to play around in the Scene_Menu and Window_MenuCommand sections, which I've tried, but again I have no knowledge about this sort of thing. Is there any way for someone like me to achieve this? If I haven't explained what I'm trying to do with enough detail, please tell me and I'll try to explain further. Any and all help will be appreciated! :)
     
    #1
  2. SoulPour777

    SoulPour777 Crownless King Veteran

    Messages:
    1,093
    Likes Received:
    104
    Location:
    Philippines
    First Language:
    English
    Primarily Uses:
    N/A
    Yes, you'll have to work around those two. First, you'll need to know how to generate texts. You can generate it in different ways, the easiest one would be to call a common event or game messages. However, its a bit tricky if you don't want your menu to stop and want it to hang up so the tutorials section would come in just fine. I will teach you the easiest route to achieve what you want, so let's get started. I will teach you the Common Event way.

    Before we start, I would require you to install Tsukihime's Scene Interpreter script, as this script allows to run Interpreter commands via the Menu or any other scene. Now, how can we add a command on our menu? I will show you the easier way rather than modifying a lot on the menu, so you won't get confused, assuming you're new to RGSS3 like me, I'm a noob, really.

    I am going to use the add_original_commands section.

    class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # * For Adding Original Commands #-------------------------------------------------------------------------- def add_original_commands add_command("Tutorials", :tutorials) endendI will now be updating my Scene Menu with this as its script:

    class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # * For Adding Original Commands #-------------------------------------------------------------------------- def add_original_commands add_command("Tutorials", :tutorials) endendclass Scene_Menu < Scene_MenuBase COMMON_EVENT_NUMBER = 1 #which common event should run when you do the # tutorials? #-------------------------------------------------------------------------- # * Create Command Window #-------------------------------------------------------------------------- def create_command_window @command_window = Window_MenuCommand.new @command_window.set_handler:)item, method:)command_item)) @command_window.set_handler:)skill, method:)command_personal)) @command_window.set_handler:)equip, method:)command_personal)) @command_window.set_handler:)status, method:)command_personal)) @command_window.set_handler:)tutorials, method:)command_tutorials)) @command_window.set_handler:)formation, method:)command_formation)) @command_window.set_handler:)save, method:)command_save)) @command_window.set_handler:)game_end, method:)command_game_end)) @command_window.set_handler:)cancel, method:)return_scene)) end def command_tutorials $game_temp.reserve_common_event(COMMON_EVENT_NUMBER) end endBut remember, Tsukihime's script should be on top of all this script. On your common event, do this:

    [​IMG]

    the <run_scene: current> is needed to run our text messages even inside the Menu. This is the result:

    [​IMG]

    [​IMG]

    Full Code of this:

    Code:
    =begin#=============================================================================== Title: Scene Interpreter Author: Hime Date: Sep 5, 2013-------------------------------------------------------------------------------- ** Change log Sep 5, 2013   - fixed bug where common events returning to map did not execute properly Apr 24, 2013   - fixed bug where game crashed when no common events were reserved Apr 3, 2013   - Added comment to determine scene to run common event Mar 30, 2013   - Initial release--------------------------------------------------------------------------------    ** Terms of Use * Free to use in non-commercial projects * Contact me for commercial use * No real support. The script is provided as-is * Will do bug fixes, but no compatibility patches * Features may be requested but no guarantees, especially if it is non-trivial * Credits to Hime Works in your project * Preserve this header-------------------------------------------------------------------------------- ** Description  This script adds an interpreter and message window to every scene so that you can run common events in any scene. -------------------------------------------------------------------------------- ** Installation  Place this below Materials and above Main. You should place this above other custom scripts.-------------------------------------------------------------------------------- ** Usage   If you would like a common event to run in the current scene, create a comment in the common event command list with this string    <run scene: current>  #================================================================================end$imported = {} if $imported.nil?$imported["TH_SceneInterpreter"] = true#===============================================================================# ** Configuration#===============================================================================module TH  module Scene_Interpreter        # Run common events directly in scene without going to map    No_Return_Scene = true        Run_Regex = /<run[-_ ]scene:\s*(\w+)/i  endend#===============================================================================# ** Rest of Script#===============================================================================module RPG  class CommonEvent        #---------------------------------------------------------------------------    # Which scene to run this common event    #---------------------------------------------------------------------------    def run_scene      return @run_scene unless @run_scene.nil?      parse_comments_scene_interpreter      return @run_scene    end        #---------------------------------------------------------------------------    # Parse the commands for a Run Scene comment    #---------------------------------------------------------------------------    def parse_comments_scene_interpreter      # just an arbitrary default value      @run_scene = :map       @list.each do |cmd|        if cmd.code == 108 && cmd.parameters[0] =~ TH::Scene_Interpreter::Run_Regex          @run_scene = $1.downcase.to_sym        end      end    end  endendclass Scene_Base   attr_reader :interpreter    alias :th_scene_interpreter_start :start  def start    th_scene_interpreter_start    create_interpreter    create_message_window  end    #-----------------------------------------------------------------------------  # Create scene interpreter  #-----------------------------------------------------------------------------  def create_interpreter    @interpreter = Game_Interpreter.new  end    #-----------------------------------------------------------------------------  # Create message window  #-----------------------------------------------------------------------------  def create_message_window    @message_window = Window_SceneMessage.new  end    alias :th_scene_interpreter_update :update  def update    th_scene_interpreter_update    update_interpreter  end    #-----------------------------------------------------------------------------  # Run any common events  #-----------------------------------------------------------------------------  def update_interpreter    loop do      @interpreter.update      return if @interpreter.running?            # Don't setup the common event if it doesn't run in the current scene      return if $game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene != :current      return unless @interpreter.setup_reserved_common_event    end  endendclass Scene_ItemBase < Scene_MenuBase  alias :th_scene_interpreter_check_common_event :check_common_event  def check_common_event    return if !$game_temp.common_event_reserved? || ($game_temp.common_event_reserved? && $data_common_events[$game_temp.common_event_id].run_scene == :current)    th_scene_interpreter_check_common_event   endendclass Window_SceneMessage < Window_Message    #-----------------------------------------------------------------------------  # These are all random z values  #-----------------------------------------------------------------------------  alias :th_scene_interpreter_initialize :initialize  def initialize    th_scene_interpreter_initialize    self.z = 500    @gold_window.z = 500    @item_window.z = 500    @number_window.z = 500    @choice_window.z = 500  endendclass Window_MenuCommand < Window_Command  #--------------------------------------------------------------------------  # * For Adding Original Commands  #--------------------------------------------------------------------------  def add_original_commands    add_command("Tutorials", :tutorials)  endendclass Scene_Menu < Scene_MenuBase  COMMON_EVENT_NUMBER = 1 #which common event should run when you do the  # tutorials?  #--------------------------------------------------------------------------  # * Create Command Window  #--------------------------------------------------------------------------  def create_command_window    @command_window = Window_MenuCommand.new    @command_window.set_handler(:item,      method(:command_item))    @command_window.set_handler(:skill,     method(:command_personal))    @command_window.set_handler(:equip,     method(:command_personal))    @command_window.set_handler(:status,    method(:command_personal))    @command_window.set_handler(:tutorials,    method(:command_tutorials))    @command_window.set_handler(:formation, method(:command_formation))    @command_window.set_handler(:save,      method(:command_save))    @command_window.set_handler(:game_end,  method(:command_game_end))    @command_window.set_handler(:cancel,    method(:return_scene))  end    def command_tutorials    $game_temp.reserve_common_event(COMMON_EVENT_NUMBER)  end  end 
     
    Last edited by a moderator: Jun 30, 2014
    #2
  3. Tagger101

    Tagger101 Veteran Veteran

    Messages:
    30
    Likes Received:
    1
    Location:
    New York
    First Language:
    English
    Wow! What a response! Thank you very much SoulPour! I copied everything at the end into my game and have been playing around to try to get it to work. Added the common event as well. It works, but for some reason it keeps freezing after the tutorial text pops up... any idea what I'm doing wrong?

    Thank you for all that useful information! :D
     
    #3
  4. SoulPour777

    SoulPour777 Crownless King Veteran

    Messages:
    1,093
    Likes Received:
    104
    Location:
    Philippines
    First Language:
    English
    Primarily Uses:
    N/A
    You can do this:

    Code:
     def command_tutorials    $game_temp.reserve_common_event(COMMON_EVENT_NUMBER) # Calls the Common Event    SceneManager.call(Scene_Map) # Calls the Scene Map before running the common event    $game_map.autoplay   #plays everything in the map and refresh end
     
    Last edited by a moderator: Jun 30, 2014
    #4

Share This Page