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.

New Menu Option

How can you make a new option in the main menu. For example, instead of having:

Item
Skill
Equip
Status
Save
End Game

You could have:

Item
Skill
Equip
Status
Option X
Save
End Game

And if Option X was clicked on, then Script X xould run.

Thanks in advance

Micklo
 
Just change this:
Code:
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])

to

Code:
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Option X" #just rename it if you want
    s6 = "Save"
    s7 = "End Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])

Then search for this lines of code:
Code:
      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  # 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 5  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end

and change it to

Code:
      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
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to script x
        $scene = Scene_X.new #look at the script how the Scene is called
      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 5  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
 
You'd probably have to change the windows beneath it (that is, assuming you're using the default menu system) because adding another option would expand the command window. Alternatively you could replace one of the existing options.
 
How could you have it so the option (option x) will appear in the menu when you have an item. Example like a Monster Database, Item would be Monster Book and when you recive it it makes the new menu item appear?
 

khmp

Sponsor

Killer Klowns":51ar2fxj said:
How could you have it so the option (option x) will appear in the menu when you have an item. Example like a Monster Database, Item would be Monster Book and when you recive it it makes the new menu item appear?

There are two constants you will want to mess with to get it the way you want.
Code:
SPECIAL_ITEM_ID = 12
Change that to the id of the item that represents your monster database item.
Code:
SPECIAL_OPTION = 'Monster Book
Change that to whatever you want the string of text to be when you have the item above.

Lastly if you select this option it calls the following method:
Code:
command_special_option
It's all the way at the bottom. Alter this method to do whatever work you want it to do.

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

class Scene_Menu
  SPECIAL_ITEM_ID = 12
  SPECIAL_OPTION = 'Monster Book'
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Define the array that will hold the possible choices in the command
    # window.
    menu_options = 
    [ 
      $data_system.words.item,
      $data_system.words.skill,
      $data_system.words.equip
    ]
    # If the special item is currently in the party's inventory.
    if $game_party.item_number(SPECIAL_ITEM_ID) > 0
      menu_options << SPECIAL_OPTION
    end
    menu_options += ['Status', 'Save', 'End Game']
    @command_window = Window_Command.new(160, menu_options)
    @command_window.index = @menu_index
    # Cap the height of the command window so it doesn't draw on top of
    # Play time or gold.
    @command_window.height = 224
    # 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)
      if $game_party.item_number(SPECIAL_ITEM_ID) > 0
        @command_window.disable_item(menu_options.index[SPECIAL_OPTION])
      end
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(menu_options.index['Save'])
    end
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    # Make steps window
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_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
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  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 < 4
        # 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
      end
      if $game_party.item_number(SPECIAL_ITEM_ID) > 0
        case @command_window.index
        when 4  # SPECIAL_OPTION
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          # SPECIAL_OPTION stuff.
          command_special_option
        when 5  # end game
          # 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
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          # Switch to end game screen
          $scene = Scene_End.new
        end
      else
        case @command_window.index
        when 4  # 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 5  # end game
          # Play decision SE
          $game_system.se_play($data_system.decision_se)
          # Switch to end game screen
          $scene = Scene_End.new
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Command: Special Option Stuff
  #--------------------------------------------------------------------------
  def command_special_option
    # Do whatever work you want done for this.
  end
end

Merry Christmas and good luck with it! :thumb:
 

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