Menu Command Manager


Menu Command Manager
by
MobiusXVI
​

Release Notes
Sep 2015 - v. 1.0 Initial Release
Jan 2016 - v. 1.5 Support for Common Events
Aug 2017 - v. 1.6 Fixed bugged paralysis states not working
Apr 2023 - v. 1.7 Add ability to disable commands via switches


Introduction
This script allows you to add custom commands to the menu, remove existing commands, and order them however you like!

Features
- Easily add new commands to the menu
- Remove un-needed commands from the menu
- Helps custom scripts come back to the menu correctly
- Add Common Event calls to your menu


How to Use
Copy the script into the script editor below the default scripts but above Main. If you're using other scripts which affect the menu, I recommend placing this script above them in the script editor. Follow the instructions and configuration guidance within the script itself.

Script

Spoiler
Code:
#===============================================================================
# Mobius' Menu Command Manager
# Author: Mobius XVI
# Version: 1.7
# Date: 20 APR 2023
#===============================================================================
#
# Introduction:
#
#   This script allows you to add custom commands to the menu, remove existing
#   commands, and order them however you like. The script can also help
#   custom commands come back to the menu correctly.
#
# Instructions:
#
#  - Place this script below all the default scripts but above main.
#    If you're using other scripts which affect the menu, I recommend
#    placing this script above them in the script editor.
#
#  - The customization section below has additional instructions on
#    how to set up and organize the commands.
#
# Issues/Bugs/Possible Bugs:
#
#   - As this script replaces the default menu system scripts, it
#     may be incompatible with other menu system scripts.
#
#
#  Credits/Thanks:
#    - Mobius XVI, author
#    - Zeus81, for his 'Bitmap Export' script which brought the background_sprite
#      snapshot functionality to RMXP
#
#  License
#
#    This script is available in its entirety for commercial and non-commercial
#    use. View the specific license terms below.
#
#    The portions of this script written by me is licensed under the MIT License:
#
#    The MIT License (MIT)
#
#      Copyright (c) 2023 darmes
#
#       Permission is hereby granted, free of charge, to any person obtaining a copy
#       of this software and associated documentation files (the "Software"), to deal
#       in the Software without restriction, including without limitation the rights
#       to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#       copies of the Software, and to permit persons to whom the Software is
#       furnished to do so, subject to the following conditions:
#
#       The above copyright notice and this permission notice shall be included in all
#       copies or substantial portions of the Software.
#
#       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#       IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#       FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#       AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#       LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#       OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#       SOFTWARE.
#
#      Further, if you do decide to use this script in a commercial product,
#      I'd ask that you let me know via a forum post or a PM. Thanks.
#
#    Zeus81's script is licensed under CC BY 4.0. View the full license text here:
#    http://creativecommons.org/licenses/by/4.0/
#    The script is only a portion of the original as I removed those features
#    that weren't necessary for this script to function. You can get the full
#    script here:
#    http://forums.rpgmakerweb.com/index.php?/topic/21633-bitmap-export/
#
#==============================================================================
# ** CUSTOMIZATION START
#==============================================================================
module Mobius
  module Menu_Commands
    # MENU LOOK OPTIONS #
    # These options let you change how the menu looks

    # MENU_OPACITY is used to make the menu somewhat transparent so that
    # the background can be seen behind it. You can set this to an interger
    # value between 0 (completely transparent) and 255 (completely opaque).
    MENU_OPACITY = 128

    # The BACKGROUND_BLENDING_COLOR is used to darken the background map
    # picture so that it is less intrusive. I recommend leaving this as is,
    # but if you want to change it, you can set the four numbers to any
    # integer values in the range 0-255. The numbers are RGBA.
    BACKGROUND_BLENDING_COLOR = Color.new(16, 16, 16, 128)

    ######################################################################

    # COMMAND OPTIONS #
    # These options allow you to configure all of the menu commands.
    # Big picture: Every command has a 'command key' associated it with.
    # This allows you to link several different settings to the same command.
    # The keys are all of the type ':key_name'. That is a colon followed
    # by the key's name. As a rule, the keys should be all lowercase.
    # Additionally every command will need a key placed in the COMMAND_ORDER,
    # COMMAND_NAMES, and COMMAND_CALLS options below. It's optional for
    # COMMAND_ACTOR_SELECT, and COMMAND_ACTOR_REQUIRED.

    # Order of Commands #
    # Place all of your command keys in between the two square brackets.
    # Each key should be separated from the others with a comma.
    # The order in which these keys are placed will determine their order
    # in game, i.e. the first (top) key will be the first (top) command.
    COMMAND_ORDER = [
                    :item,
                    :skill,                   
                    :equip,
                    :status,
                    :save,
                    :common_event,
                    :end_game,                   
                    ]
 
    # Command Display Names #
    # This links your command keys to their display text in game.
    # In general, these will be the same but they might vary a little.
    # Think of this like setting a 'word' in the database. In fact,
    # this overwrites the database setting, so be sure to define them here.
    # Each entry is a pair like this - :command_key => "Display Name"
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_NAMES = {
                    :item         => "Item",
                    :skill        => "Skill",
                    :equip        => "Equip",
                    :status       => "Status",
                    :save         => "Save",
                    :common_event => "Common Event 1",
                    :end_game     => "End Game",                   
                    }
               
    # Command Script Calls #
    # This links your command keys to their script call.
    # In general, these will be very similar to their key.
    # If a script says you can call it by doing this:
    # $scene = Scene_CustomScript.new
    # You will likely need the 'Scene_CustomScript' part.
    # You can also use numbers to indicate that you want to call
    # a common event. Simply put the ID (as seen in the database) of
    # the common event you want to call instead of a script call.
    # Each entry is a pair like this - :command_key => Script_Call
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_CALLS = {
                    :item         => Scene_Item,
                    :skill        => Scene_Skill,
                    :equip        => Scene_Equip,
                    :status       => Scene_Status,
                    :save         => Scene_Save,
                    :end_game     => Scene_End,
                    :common_event => 1,
                    }

    # Does Command Need Actor Select? #
    # This sets which commands need to select an actor in the menu
    # before moving to the next scene. In the default scripts, the
    # skills, equip, and status commands need to know which actor
    # you want to set before they move to their scenes. It's possible
    # some custom commands may need this as well. Just place the
    # command keys that need it here. If it doesn't need it, just
    # leave it out. The order of these entries does NOT affect
    # the order in game.
    COMMAND_ACTOR_SELECT = [
                           :skill,
                           :equip,
                           :status,
                           ]

    # Disable Command When Party Size Is Zero? #
    # This sets which commands should be disabled when the party size
    # is zero. In the default scripts, the item, skills, equip, and
    # status commands are disabled when this is the case.
    # It's possible some custom commands may need this as well.
    # Just place the command keys that need it here. If it doesn't
    # need it, just leave it out. The order of these entries
    # does NOT affect the order in game.
    COMMAND_ACTOR_REQUIRED = [
                             :item,
                             :skill,
                             :equip,
                             :status,
                             ]

    # Disable Actor Abilities when paralyzed ? #
    # This sets which commands should be disabled when an actor is 'paralyzed'
    # (or has a similar type of state). In the default scripts, the skills
    # command is disabled when this is the case.
    # It's possible some custom commands may need this as well.
    # Just place the command keys that need it here. If it doesn't
    # need it, just leave it out. The order of these entries
    # does NOT affect the order in game.
    COMMAND_ACTOR_ABILITIES = [
                              :skill
                              ]

    # Disable Commands Via Switches #
    # This allows you to disable individual commands via a switch.
    # Adding an entry here will link the command to the chosen switch
    # so that when you toggle the switch via events, it will enable
    # or disable the connected command.
    # Note that a switch being set to ON means that a command is ENABLED.
    # If you don't need to disable a command then you can omit it.
    # Each entry is a pair like this - :command_key => Switch_ID
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_DISABLE_SWITCH = {
                             :skill => 1,
                             }

    # Save Command Key Is? #
    # This sets which command key is the 'save' command key, so
    # that it can be disabled whenever you disable saving via events.
    # In general, you can leave the default save key alone in the
    # above options and therefore leave this one alone too.
    SAVE_COMMAND = :save
  end
end
#==============================================================================
# ** CUSTOMIZATION END
#------------------------------------------------------------------------------
# ** EDIT BELOW THIS LINE AT OWN RISK!!!
#==============================================================================
#==============================================================================
# ** Scene_Base
#==============================================================================
class Scene_Base
  #--------------------------------------------------------------------------
  # * Play Decision SE
  #--------------------------------------------------------------------------
  def play_decision_se
    $game_system.se_play($data_system.decision_se)
  end
  #--------------------------------------------------------------------------
  # * Play Cancel SE
  #--------------------------------------------------------------------------
  def play_cancel_se
    $game_system.se_play($data_system.cancel_se)
  end
  #--------------------------------------------------------------------------
  # * Play Buzzer SE
  #--------------------------------------------------------------------------
  def play_buzzer_se
    $game_system.se_play($data_system.buzzer_se)
  end
end
#==============================================================================
# ** Scene_Menu
#==============================================================================
class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Configuration Binding
  #--------------------------------------------------------------------------
  include Mobius::Menu_Commands
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = determine_starting_menu_index(menu_index)
    @disabled_commands = []
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create all windows
    create_windows
    # Disable commands that apply
    disable_commands
    # 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
    dispose_windows
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @gold_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      on_exit
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      on_command
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when status window is active)
  #--------------------------------------------------------------------------
  def update_status
    # If B button was pressed
    if Input.trigger?(Input::B)
      on_status_exit
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      on_status_command
      return
    end
  end
  #--------------------------------------------------------------------------
  # * On Exit
  #--------------------------------------------------------------------------
  def on_exit
    # Play cancel SE
    play_cancel_se
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * On Command
  #--------------------------------------------------------------------------
  def on_command
    # Get index and key
    index = @command_window.index
    key = command_index_to_key(index)
    # Exit processing if command is disabled
    if command_disabled?(index)
      command_fail
    else
      command_success(key)
    end   
  end
  #--------------------------------------------------------------------------
  # * Command Success
  #--------------------------------------------------------------------------
  def command_success(key)
    play_decision_se
    # If command needs actor selection
    if COMMAND_ACTOR_SELECT.include?(key)
      # Make status window active
      activate_status_window
    else
      # Switch to new screen
      process_command_call(key)
    end
  end
  #--------------------------------------------------------------------------
  # * Command Fail
  #--------------------------------------------------------------------------
  def command_fail
    play_buzzer_se
  end
  #--------------------------------------------------------------------------
  # * Activate Status Window
  #--------------------------------------------------------------------------
  def activate_status_window
    @command_window.active = false
    @status_window.active  = true
    @status_window.index   = 0
  end
  #--------------------------------------------------------------------------
  # * On Status Exit
  #--------------------------------------------------------------------------
  def on_status_exit
    play_cancel_se
    # Make command window active
    @command_window.active = true
    @status_window.active = false
    @status_window.index = -1
  end
  #--------------------------------------------------------------------------
  # * On Status Command
  #--------------------------------------------------------------------------
  def on_status_command
    # Get index and key
    index = @command_window.index
    key = command_index_to_key(index)
    # If this actor's action limit is 2 or more
    if actor_unable?(key)
      # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
      return
    end
    # Play decision SE
    play_decision_se     
    # Switch to new screen
    process_command_call(key, true)
  end
#--------------------------------------------------------------------------
  # * Actor Able?
  #--------------------------------------------------------------------------
  def actor_unable?(key)
    # If this command should be disabled when the actor is 'paralyzed'
    # and if the actor's action limit is 2 or more (is paralyzed)
    (COMMAND_ACTOR_ABILITIES.include?(key)) and
    ($game_party.actors[@status_window.index].restriction >= 2)
  end
  #--------------------------------------------------------------------------
  # * Process Command Call
  #--------------------------------------------------------------------------
  def process_command_call(key, status_window = false)
    # Get command call
    call = COMMAND_CALLS[key]
    # If call is a Class, treat as a scene class
    if call.is_a?(Class)
      # If call was made from the status window, pass in the status window index
      if status_window
        $scene = call.new(@status_window.index)
      else
        $scene = call.new
      end
    # If call is a number, treat as a Common Event ID
    elsif call.is_a?(Integer) and call > 0
      # Common event call reservation
      $game_temp.common_event_id = call
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Create Windows
  #--------------------------------------------------------------------------
  def create_windows
    create_command_window
    create_status_window
    create_gold_window
    create_background_sprite
  end
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    commands = COMMAND_ORDER.collect { |cmd| COMMAND_NAMES[cmd] }
    # Make command window
    @command_window = Window_Command.new(160, commands)
    @command_window.index = @menu_index
    @command_window.opacity = MENU_OPACITY
  end
  #--------------------------------------------------------------------------
  # * Create Status Window
  #--------------------------------------------------------------------------
  def create_status_window
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    @status_window.opacity = MENU_OPACITY
  end
  #--------------------------------------------------------------------------
  # * Create Gold Window
  #--------------------------------------------------------------------------
  def create_gold_window
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @gold_window.opacity = MENU_OPACITY
  end
  #--------------------------------------------------------------------------
  # * Create Background Sprite
  #--------------------------------------------------------------------------
  def create_background_sprite
    @background_sprite = Sprite.new
    @background_sprite.bitmap = $game_temp.background_sprite
    @background_sprite.color = BACKGROUND_BLENDING_COLOR
  end
  #--------------------------------------------------------------------------
  # * Dispose Windows
  #--------------------------------------------------------------------------
  def dispose_windows
    # Dispose of windows
    @command_window.dispose
    @gold_window.dispose
    @status_window.dispose   
    @background_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Disable Commands
  #--------------------------------------------------------------------------
  def disable_commands
    # Check/Execute disable of party items
    disable_on_zero_party?
    # Check/Execute disable of saving
    disable_save?
    # Disable arbitrary commands if they have a switch
    disable_switched?
  end
  #--------------------------------------------------------------------------
  # * Disable On Zero Party
  #--------------------------------------------------------------------------
  def disable_on_zero_party?
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable all items in command_actor_required
      COMMAND_ACTOR_REQUIRED.each { |cmd_key| disable_command(cmd_key) }
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Save?
  #--------------------------------------------------------------------------
  def disable_save?
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      save_command_key = SAVE_COMMAND
      disable_command(save_command_key)
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Switched?
  #--------------------------------------------------------------------------
  def disable_switched?
    COMMAND_DISABLE_SWITCH.each do |cmd_key, switch_id|
      if not $game_switches[switch_id]
        disable_command(cmd_key)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Disable Command
  #--------------------------------------------------------------------------
  def disable_command(key)
    # Get command index
    index = command_key_to_index(key)
    # Set text to disabled
    @command_window.disable_item(index)
    # Add index to disabled commands
    @disabled_commands.push(index).uniq!
  end
  #--------------------------------------------------------------------------
  # * Enable Command
  #--------------------------------------------------------------------------
  def enable_command(key)
    # Get comand index
    index = command_key_to_index(key)
    # Set text to disabled
    @command_window.disable_item(index)
    # Add index to disabled commands
    @disabled_commands.delete(index)
  end
  #--------------------------------------------------------------------------
  # * Command Disabled?
  #--------------------------------------------------------------------------
  def command_disabled?(index)
    return @disabled_commands.include?(index)
  end
  #--------------------------------------------------------------------------
  # * Command Key to Index
  #--------------------------------------------------------------------------
  def command_key_to_index(key)
    return COMMAND_ORDER.index(key)
  end
  #--------------------------------------------------------------------------
  # * Command Index to Key
  #--------------------------------------------------------------------------
  def command_index_to_key(index)
    return COMMAND_ORDER.at(index)
  end
  #--------------------------------------------------------------------------
  # * Determine Starting Menu Index
  #--------------------------------------------------------------------------
  def determine_starting_menu_index(menu_index)
    # Get the previous scene type
    last_scene = $scene.class
    # Does the previous scene type match one
    # of the command calls that we know?
    if COMMAND_CALLS.has_value?(last_scene)
      # Get the key for that scene type
      key = COMMAND_CALLS.index(last_scene)
      # Use key to get menu index
      return COMMAND_ORDER.index(key)
    else
      # return whatever was passed/the default value of 0
      return menu_index
    end
  end
end

#==============================================================================
# ** Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :background_sprite # for saving a snapshot of the game map
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias mobius_initialize initialize
  def initialize
    mobius_initialize
    @background_sprite = nil
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  alias mobius_call_menu call_menu
  def call_menu
    mobius_call_menu
    $game_temp.background_sprite = Graphics.snap_to_bitmap
  end
end

# Bitmap Export v5.4 for XP, VX and VXace by Zeus81
# Free for commercial use
# Licence : http://creativecommons.org/licenses/by/4.0/
# Contact : [email hidden]
# Original script trimmed to just 'Graphics.snap_to_bitmap'
module Graphics

  FindWindow             = Win32API.new('user32', 'FindWindow'            , 'pp'       , 'i')
  GetDC                  = Win32API.new('user32', 'GetDC'                 , 'i'        , 'i')
  ReleaseDC              = Win32API.new('user32', 'ReleaseDC'             , 'ii'       , 'i')
  BitBlt                 = Win32API.new('gdi32' , 'BitBlt'                , 'iiiiiiiii', 'i')
  CreateCompatibleBitmap = Win32API.new('gdi32' , 'CreateCompatibleBitmap', 'iii'      , 'i')
  CreateCompatibleDC     = Win32API.new('gdi32' , 'CreateCompatibleDC'    , 'i'        , 'i')
  DeleteDC               = Win32API.new('gdi32' , 'DeleteDC'              , 'i'        , 'i')
  DeleteObject           = Win32API.new('gdi32' , 'DeleteObject'          , 'i'        , 'i')
  GetDIBits              = Win32API.new('gdi32' , 'GetDIBits'             , 'iiiiipi'  , 'i')
  SelectObject           = Win32API.new('gdi32' , 'SelectObject'          , 'ii'       , 'i')

  def self.snap_to_bitmap
    bitmap  = Bitmap.new(width, height)
    info    = [40,width,height,1,32,0,0,0,0,0,0].pack('LllSSLLllLL')
    hDC     = GetDC.call(hwnd)
    bmp_hDC = CreateCompatibleDC.call(hDC)
    bmp_hBM = CreateCompatibleBitmap.call(hDC, width, height)
    bmp_obj = SelectObject.call(bmp_hDC, bmp_hBM)
    BitBlt.call(bmp_hDC, 0, 0, width, height, hDC, 0, 0, 0xCC0020)
    GetDIBits.call(bmp_hDC, bmp_hBM, 0, height, bitmap.last_row_address, info, 0)
    SelectObject.call(bmp_hDC, bmp_obj)
    DeleteObject.call(bmp_hBM)
    DeleteDC.call(bmp_hDC)
    ReleaseDC.call(hwnd, hDC)
    bitmap
  end
 
  class << self
    def hwnd() @hwnd ||= FindWindow.call('RGSS Player', nil) end
    def width()  640 end unless method_defined?(:width)
    def height() 480 end unless method_defined?(:height)
  end
 
end

class Bitmap
  RtlMoveMemory = Win32API.new('kernel32', 'RtlMoveMemory', 'ppi', 'i')
  def last_row_address
    return 0 if disposed?
    RtlMoveMemory.call(buf=[0].pack('L'), __id__*2+16, 4)
    RtlMoveMemory.call(buf, buf.unpack('L')[0]+8 , 4)
    RtlMoveMemory.call(buf, buf.unpack('L')[0]+16, 4)
    buf.unpack('L')[0]
  end
end



FAQ
Q. Can this do _______?
A. Maybe! Leave a post on the forum, and I might just add the feature if it can't already do it.


Q. My persistent states don't work properly anymore. Help!
A. This was a known bug in previous versions. This was fixed in version 1.6; update to it to fix this problem!


Credits and Thanks
- MobiusXVI, author
- Zeus81, for his 'Bitmap Export' script


License
This script is available in its entirety for commercial and non-commercial use. View the full license terms in the script header.
You can use this script to easily add my Quest Journal script to the main menu. Here's a pre-configured customization section for it. Just replace the customization section of the default script with this one, and you'll be good to go!

Spoiler
Code:
#==============================================================================#
** CUSTOMIZATION START
#==============================================================================
module Mobius
    module Menu_Commands
        # MENU LOOK OPTIONS #
        # These options let you change how the menu looks
               
        # MENU_OPACITY is used to make the menu somewhat transparent so that
        # the background can be seen behind it. You can set this to an integer
        # value between 0 (completely transparent) and 255 (completely opaque).
        MENU_OPACITY = 128
        # The BACKGROUND_BLENDING_COLOR is used to darken the background map
        # picture so that it is less intrusive. I recommend leaving this as is,
        # but if you want to change it, you can set the four numbers to any
        # integer values in the range 0-255. The numbers are RGBA.
        BACKGROUND_BLENDING_COLOR = Color.new(16, 16, 16, 128)

        ######################################################################
        # COMMAND OPTIONS #
        # These options allow you to configure all of the menu commands.
        # Big picture: Every command has a 'command key' associated it with.
        # This allows you to link several different settings to the same command.
        # The keys are all of the type ':key_name'. That is a colon followed
        # by the key's name. As a rule, the keys should be all lowercase.
        # Additionally every command will need a key placed in the COMMAND_ORDER,
        # COMMAND_NAMES, and COMMAND_CALLS options below. It's optional for
        # COMMAND_ACTOR_SELECT, and COMMAND_ACTOR_REQUIRED.

        # Order of Commands #
        # Place all of your command keys in between the two square brackets.
        # Each key should be separated from the others with a comma.
        # The order in which these keys are placed will determine their order
        # in game, i.e. the first (top) key will be the first (top) command.
        COMMAND_ORDER = [
                        :item,
                        :skill,
                        :equip,
                        :status,
                        :quest,
                        :save,
                        :end_game,
                                                ]
        # Command Display Names #
        # This links your command keys to their display text in game.
        # In general, these will be the same but they might vary a little.
        # Think of this like setting a 'word' in the database. In fact,
        # this overwrites the database setting, so be sure to define them here.
        # Each entry is a pair like this - :command_key => "Display Name"
        # Separate entries with commas. The order of these entries does NOT
        # affect the order in game.
         COMMAND_NAMES = {
                        :item      => "Item",
                        :skill     => "Skill",
                        :equip     => "Equip",
                        :status    => "Status",
                        :save      => "Save",
                        :end_game  => "End Game",
                        :quest     => "Quests",
                        }
        # Command Script Calls #
        # This links your command keys to their script call.
        # In general, these will be very similar to their key.
        # If a script says you can call it by doing this:
        # $scene = Scene_CustomScript.new
        # You will likely need the 'Scene_CustomScript' part.
        # Each entry is a pair like this - :command_key => "Script_Call"
        # Separate entries with commas. The order of these entries does NOT
        # affect the order in game.
        COMMAND_CALLS = {
                        :item      => Scene_Item,
                        :skill     => Scene_Skill,
                        :equip     => Scene_Equip,
                        :status    => Scene_Status,
                        :save      => Scene_Save,
                        :end_game  => Scene_End,
                        :quest     => Scene_Quest,
                        }
        # Does Command Need Actor Select? #
        # This sets which commands need to select an actor in the menu
        # before moving to the next scene. In the default scripts, the
        # skills, equip, and status commands need to know which actor
        # you want to set before they move to their scenes. It's possible
        # some custom commands may need this as well. Just place the
        # command keys that need it here. If it doesn't need it, just
        # leave it out. The order of these entries does NOT affect
        # the order in game.
        COMMAND_ACTOR_SELECT = [
                        :skill,
                        :equip,
                        :status,
                        ]
        # Disable Command When Party Size Is Zero? #
        # This sets which commands should be disabled when the party size
        # is zero. In the default scripts, the item, skills, equip, and
        # status commands are disabled when this is the case.
        # It's possible some custom commands may need this as well.
        # Just place the command keys that need it here. If it doesn't
        # need it, just leave it out. The order of these entries
        # does NOT affect the order in game.
        COMMAND_ACTOR_REQUIRED = [
                        :item,
                        :skill,
                        :equip,
                        :status,
                        ]
        # Disable Actor Abilities when paralyzed ? #
        # This sets which commands should be disabled when an actor is 'paralyzed'
        # (or has a similar type of state). In the default scripts, the skills
        # command is disabled when this is the case.
        # It's possible some custom commands may need this as well.
        # Just place the command keys that need it here. If it doesn't
        # need it, just leave it out. The order of these entries
        # does NOT affect the order in game.
        COMMAND_ACTOR_ABILITIES = [
                        :skill
                        ]
        # Save Command Key Is? #
        # This sets which command key is the 'save' command key, so
        # that it can be disabled whenever you disable saving via events.
        # In general, you can leave the default save key alone in the
        # above options and therefore leave this one alone too.
        SAVE_COMMAND = :save
    end
end
Can these commands be used to call common events?
Can these commands be used to call common events?
They can't, but that's a great idea! I'll look to add it in the next version.
When I tried to use this with your Quest Journal script, everything went fine.  That is until I tried to actually click on the option.  Then the game spat out an error at me.


"Scrip 'Menu Comand Manager' line 350: NoMethodError occurred.


undefined method 'new' for <Scene_Quest:0x2875768


@return_scene=NilClass>"
When I tried to use this with your Quest Journal script, everything went fine.  That is until I tried to actually click on the option.  Then the game spat out an error at me.


"Scrip 'Menu Comand Manager' line 350: NoMethodError occurred.


undefined method 'new' for <Scene_Quest:0x2875768


@return_scene=NilClass>"

If you're using the customization section I posted for use with my Quest Journal script, everything should work fine. I'd recommend going through this popular troubleshooting guide: How to use a script. It'll solve the problem 90% of the time. If you're still having problems, let me know and we can investigate further.
Ah, I hadn't noticed the pre-made customization thing.  Thank you!  It works perfectly now.
Can these commands be used to call common events?

Version 1.5 is released! The script now provides support for calling common events!
Version 1.7 released. Added ability to disable individual commands via switches. Additionally, if you'd like to be able to call the game's load menu using this script, then here's a small script to let you do that. Just setup a command to call "Scene_LoadMenu".
Spoiler
Ruby:
class Scene_LoadMenu < Scene_Load
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Save off $game_temp so that we can restore it
    gt = $game_temp
    super
    gt.last_file_index = $game_temp.last_file_index
    $game_temp = gt
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Switch to title screen
    $scene = Scene_Menu.new
  end
end
Hi Mobius,

First of all, thank you for this wonderful menu script - I always wanted to just have a simple customization of the menu, and yours did just that. And then I discovered your quest/journal script, which again, was exactly what I was looking for. And then you very kindly showed how to combine them!

However, I have a problem. On their own, they worked perfectly. Then I followed your instructions of adding the quest/journal segment into the menu script, and this error pops up:

1709022539300.png


I double checked with a brand new project file (just in case any of my current scripts were incompatible), but the same error message still appears. Any ideas? :LZYhuh:

1709022704318.png


I do have the Scene_Quest script there, as per your demo, so I'm stumped >.<

1709022742086.png
Hi Mobius,

First of all, thank you for this wonderful menu script - I always wanted to just have a simple customization of the menu, and yours did just that. And then I discovered your quest/journal script, which again, was exactly what I was looking for. And then you very kindly showed how to combine them!

However, I have a problem. On their own, they worked perfectly. Then I followed your instructions of adding the quest/journal segment into the menu script, and this error pops up:

View attachment 296633

I double checked with a brand new project file (just in case any of my current scripts were incompatible), but the same error message still appears. Any ideas? :LZYhuh:

View attachment 296636

I do have the Scene_Quest script there, as per your demo, so I'm stumped >.<

View attachment 296637
Hi, rosetyler (great username btw)! Try moving the Menu Command Manager script to be below the Quest Journal script. The error you're getting happens when you try to use a constant or variable (in this case 'Scene_Quest') before it's been defined by a script. RMXP runs each script in order from top to bottom, so if you want to use something from one script in another script then you need to have them in the correct order. If that doesn't fix your problem, let me know and we can troubleshoot further.
(haha thank you! Huge DW fan here)

Thanks for the prompt response, Mobius! I did what you suggested and it made that particular error go away, but a new one popped up:

1709102310785.png


Here it is in the script editor:

1709102353139.png
Ah, I see the problem! The customization section I posted for use with my Quest script is outdated, and doesn't work with the latest version of my menu script. You can manually add this chunk to your customization section to fix the problem or grab my updated section below.
Spoiler
Ruby:
    # Disable Commands Via Switches #
    # This allows you to disable individual commands via a switch.
    # Adding an entry here will link the command to the chosen switch
    # so that when you toggle the switch via events, it will enable
    # or disable the connected command. 
    # Note that a switch being set to ON means that a command is ENABLED.
    # If you don't need to disable a command then you can omit it.
    # Each entry is a pair like this - :command_key => Switch_ID
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_DISABLE_SWITCH = {
                    :skill => 1,
                    }

For future users of my script, here's a fresh version of that pre-configured customization section for it. Just replace the customization section of the default script with this one, and you'll be good to go!
Spoiler
Ruby:
#==============================================================================
# ** CUSTOMIZATION START
#==============================================================================
module Mobius
  module Menu_Commands
    # MENU LOOK OPTIONS #
    # These options let you change how the menu looks
           
    # MENU_OPACITY is used to make the menu somewhat transparent so that
    # the background can be seen behind it. You can set this to an integer
    # value between 0 (completely transparent) and 255 (completely opaque).
    MENU_OPACITY = 128
    # The BACKGROUND_BLENDING_COLOR is used to darken the background map
    # picture so that it is less intrusive. I recommend leaving this as is,
    # but if you want to change it, you can set the four numbers to any
    # integer values in the range 0-255. The numbers are RGBA.
    BACKGROUND_BLENDING_COLOR = Color.new(16, 16, 16, 128)

    ######################################################################
    # COMMAND OPTIONS #
    # These options allow you to configure all of the menu commands.
    # Big picture: Every command has a 'command key' associated it with.
    # This allows you to link several different settings to the same command.
    # The keys are all of the type ':key_name'. That is a colon followed
    # by the key's name. As a rule, the keys should be all lowercase.
    # Additionally every command will need a key placed in the COMMAND_ORDER,
    # COMMAND_NAMES, and COMMAND_CALLS options below. It's optional for
    # COMMAND_ACTOR_SELECT, and COMMAND_ACTOR_REQUIRED.

    # Order of Commands #
    # Place all of your command keys in between the two square brackets.
    # Each key should be separated from the others with a comma.
    # The order in which these keys are placed will determine their order
    # in game, i.e. the first (top) key will be the first (top) command.
    COMMAND_ORDER = [
                    :item,
                    :skill,
                    :equip,
                    :status,
                    :quest,
                    :save,
                    :end_game,
                    ]
    # Command Display Names #
    # This links your command keys to their display text in game.
    # In general, these will be the same but they might vary a little.
    # Think of this like setting a 'word' in the database. In fact,
    # this overwrites the database setting, so be sure to define them here.
    # Each entry is a pair like this - :command_key => "Display Name"
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
     COMMAND_NAMES = {
                    :item      => "Item",
                    :skill     => "Skill",
                    :equip     => "Equip",
                    :status    => "Status",
                    :save      => "Save",
                    :end_game  => "End Game",
                    :quest     => "Quests",
                    }
    # Command Script Calls #
    # This links your command keys to their script call.
    # In general, these will be very similar to their key.
    # If a script says you can call it by doing this:
    # $scene = Scene_CustomScript.new
    # You will likely need the 'Scene_CustomScript' part.
    # Each entry is a pair like this - :command_key => "Script_Call"
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_CALLS = {
                    :item      => Scene_Item,
                    :skill     => Scene_Skill,
                    :equip     => Scene_Equip,
                    :status    => Scene_Status,
                    :save      => Scene_Save,
                    :end_game  => Scene_End,
                    :quest     => Scene_Quest,
                    }
    # Does Command Need Actor Select? #
    # This sets which commands need to select an actor in the menu
    # before moving to the next scene. In the default scripts, the
    # skills, equip, and status commands need to know which actor
    # you want to set before they move to their scenes. It's possible
    # some custom commands may need this as well. Just place the
    # command keys that need it here. If it doesn't need it, just
    # leave it out. The order of these entries does NOT affect
    # the order in game.
    COMMAND_ACTOR_SELECT = [
                    :skill,
                    :equip,
                    :status,
                    ]
    # Disable Command When Party Size Is Zero? #
    # This sets which commands should be disabled when the party size
    # is zero. In the default scripts, the item, skills, equip, and
    # status commands are disabled when this is the case.
    # It's possible some custom commands may need this as well.
    # Just place the command keys that need it here. If it doesn't
    # need it, just leave it out. The order of these entries
    # does NOT affect the order in game.
    COMMAND_ACTOR_REQUIRED = [
                    :item,
                    :skill,
                    :equip,
                    :status,
                    ]
    # Disable Actor Abilities when paralyzed ? #
    # This sets which commands should be disabled when an actor is 'paralyzed'
    # (or has a similar type of state). In the default scripts, the skills
    # command is disabled when this is the case.
    # It's possible some custom commands may need this as well.
    # Just place the command keys that need it here. If it doesn't
    # need it, just leave it out. The order of these entries
    # does NOT affect the order in game.
    COMMAND_ACTOR_ABILITIES = [
                    :skill
                    ]
    # Disable Commands Via Switches #
    # This allows you to disable individual commands via a switch.
    # Adding an entry here will link the command to the chosen switch
    # so that when you toggle the switch via events, it will enable
    # or disable the connected command. 
    # Note that a switch being set to ON means that a command is ENABLED.
    # If you don't need to disable a command then you can omit it.
    # Each entry is a pair like this - :command_key => Switch_ID
    # Separate entries with commas. The order of these entries does NOT
    # affect the order in game.
    COMMAND_DISABLE_SWITCH = {
                    :skill => 1,
                    }
    # Save Command Key Is? #
    # This sets which command key is the 'save' command key, so
    # that it can be disabled whenever you disable saving via events.
    # In general, you can leave the default save key alone in the
    # above options and therefore leave this one alone too.
    SAVE_COMMAND = :save
  end
end
Sorry for the late reply! Real life caught up with me. Anyways just wanted to let you know, it worked beautifully! I would hug you if I could! The quest script worked as well! You are a champ, Mobius, you really are! Thanks for being so patient with me 😀
This can be used to remove menu options, right? Cuz whenever I remove a command key, I get this error when opening the menu. Am I stupid?

auuughhhh.png
This can be used to remove menu options, right? Cuz whenever I remove a command key, I get this error when opening the menu. Am I stupid?
Hey Squishkitt, to answer your question: yes, it can be used to remove commands. So let's troubleshoot.
  • Did you place the script below all the default scripts but above main?
  • When you removed the command key, did you remove it from `COMMAND_ORDER`?
If you answered yes to both and still have the problem, post your customization section from "CUSTOMIZATION START" to "CUSTOMIZATION END" here so I can troubleshoot with you further.
Hey Squishkitt, to answer your question: yes, it can be used to remove commands. So let's troubleshoot.
  • Did you place the script below all the default scripts but above main?
  • When you removed the command key, did you remove it from `COMMAND_ORDER`?
If you answered yes to both and still have the problem, post your customization section from "CUSTOMIZATION START" to "CUSTOMIZATION END" here so I can troubleshoot with you further.
Thanks for the help, I forgor to remove it from the Command order,,,

Original thread: https://forums.rpgmakerweb.com/threads/menu-command-manager.45303/