Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Advance Menu Option

Rue

Member

What I need is a part of script(not a new whole CMS script). I will add that part to the default menu system so an option there will be like as shown above. Do you know the code?
 
I'm no scripter, either. But I learned how to make sub command window while reading Diego's CMS code.

First, make sub command window:
Code:
class Scene_Menu
......
  def main
  ......
    o1 = 'SubOption1'
    o2 = 'SubOption2'
    o3 = 'SubOption3'
    @sub_command_window = Window_Command.new(160, [o1,o2,o3])
    @sub_command_window.visible = false
    @sub_command_window.active = false
    @sub_command_window.x = 100
    @sub_command_window.y = 210
    ......
    @sub_command_window.dispose
  end
  def update
    @sub_command_window.update
    ......
    if @sub_command_window.active
      @sub_command_window.z = +500
    end
    ......
    # If Sub Command window is active: call update_sub_command
    if @sub_command_window.active
      update_sub_command
      return
    end    
  end
Though I prefer make it as seperated method..(because it looks more organized)

Next, assign command action like this:
Code:
  def update_command
    ......
    #This calls Sub Command Window
    when (your command index, or command name)
      $game_system.se_play($data_system.decision_se)
      @sub_command_window.active = true
      @sub_command_window.visible = true
      @command_window.active = false  
    ...... 
  end
  def update_sub_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @sub_command_window.active = false
      @sub_command_window.visible = false
      @sub_command_window.index = 0
      @sub_command_window.z = -500
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      #Assign your sub command here
      case @sub_command_window.index
      when 0
        .........
      when 1
        .........
      when 2
        .........
      end
    return
    end
  end
If you did it correctly, you'll get working sub commands for any menu commands.
 

Rue

Member

Where should I put the command action?

Never mind. I figured it out. I'm currently working on it. please standby if I find some errors.
Thanks you! You save dme.
 

Rue

Member

Okay I think I messed it up.
Error on line 99

Code:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make command window
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Limit"
    s6 = "Save"
    s7 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
      @command_window.disable_item(4)
    
    o1 = 'SubOption1'
    o2 = 'SubOption2'
    o3 = 'SubOption3'
    @sub_command_window = Window_Command.new(160, [o1,o2,o3])
    @sub_command_window.visible = false
    @sub_command_window.active = false
    @sub_command_window.x = 100
    @sub_command_window.y = 210  
      end
    
   
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(5)
    end
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 320
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @playtime_window.dispose
    @gold_window.dispose
    @status_window.dispose
    @sub_command_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @playtime_window.update
    @gold_window.update
    @status_window.update
    @sub_command_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
       if @sub_command_window.active
      @sub_command_window.z = +500
    end
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      if @sub_command_window.active
      update_sub_command
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 5
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # limit
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0              
      when 5  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 6  # end game
      $game_system.se_play($data_system.decision_se)
      @sub_command_window.active = true
      @sub_command_window.visible = true
      @command_window.active = false  
      end
      end
      return
    end
  end
 def update_sub_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @sub_command_window.active = false
      @sub_command_window.visible = false
      @sub_command_window.index = 0
      @sub_command_window.z = -500
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      #Assign your sub command here
      case @sub_command_window.index
      when 0
       
      when 1
        
      when 2
        
      end
    return
    end
  end
  
  
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Make command window active
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new(@status_window.index)
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equipment screen
        $scene = Scene_Equip.new(@status_window.index)
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new(@status_window.index)
      when 4  # limits
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_LimitMenu.new(@status_window.index)      
      end
      return
    end
  end
end


Please could you make a DMS with your code on it as an example?
I would really appreciate it.
 
It should be:
Code:
def main
    # Make command window
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Limit"
    s6 = "Save"
    s7 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
    @command_window.index = @menu_index
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
      @command_window.disable_item(4)
    end
    o1 = 'SubOption1'
    o2 = 'SubOption2'
    o3 = 'SubOption3'
    @sub_command_window = Window_Command.new(160, [o1,o2,o3])
    @sub_command_window.visible = false
    @sub_command_window.active = false
    @sub_command_window.x = 100
    @sub_command_window.y = 210  
    ......
  def update
    ......
    if @sub_command_window.active
      @sub_command_window.z = +500
    end
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    if @sub_command_window.active
      update_sub_command
      return
    end
    .......
Seems you messed up position of 'end'.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top