Disable or enable a menu option by variable or switch.

I am configuring the title screen menu to add new options that are unlocked after completing the game.
The problem is that I have not found a way to hide the new options, since as I said, these should appear in the title screen menu once the player completes the main story.

Now, I have the Preserve Data script, so that this function is kept permanently, but as I said, I still lack a way to keep the new option hidden until the player by a variable or switch activated at the end, is unlocked so that it appears in the menu.

I don't know if this is possible, but I would like to know if it is possible to do this.
I wrote a small script to control the commands displayed by switches:

Ruby:
#==============================================================================
# Hide Main Menu Commands
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 27/04/2025
#
# Allows to control by swicthes which menus are displayed
# Note that it does not add new menus, you must first add the menu commands 
# by another script
# This script will just filter the added menu commands.
#
# Term of uses: free for non-commercial and commercial, credit is not mandatory
#==============================================================================

module HideMenuCommands
  CONTROL_SWICTHES = {
    #command_symbol => control_swicth_id
    :item => 1,      #$game_swicth 1 must be true for this command to be displayed
    :skill => 0,     #putting 0 means the command is always displayed
    :equip => 1,
    :status => 1,
    :formation => 1,
    :save => 1,
    #:game_end => 0, #you can comment or remove commands that you always show
  } #don't remove
  
  #--------------------------------------------------------------------------
  # method: reveal_command? -> return true iff the command can be shown
  # By default, the command will be hidden if the swicth provided is false
  # If no swicth is provided (<= 0) or no entry, then show the command
  #--------------------------------------------------------------------------
  def self.reveal_command?(symbol)
    s_id = CONTROL_SWICTHES[symbol]
    return $game_switches[s_id] if s_id && s_id > 0
    return true #don't hide it
  end
end #HideMenuCommands

  
#==============================================================================
# Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # alias method: add_command
  #--------------------------------------------------------------------------
  alias hmc_add_command add_command
  def add_command(name, symbol, enabled = true, ext = nil)
    hmc_add_command(name,symbol,enabled,ext) if HideMenuCommands.reveal_command?(symbol)
  end
end #Window_MenuCommand
I wrote a small script to control the commands displayed by switches:

Ruby:
#==============================================================================
# Hide Main Menu Commands
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 27/04/2025
#
# Allows to control by swicthes which menus are displayed
# Note that it does not add new menus, you must first add the menu commands
# by another script
# This script will just filter the added menu commands.
#
# Term of uses: free for non-commercial and commercial, credit is not mandatory
#==============================================================================

module HideMenuCommands
  CONTROL_SWICTHES = {
    #command_symbol => control_swicth_id
    :item => 1,      #$game_swicth 1 must be true for this command to be displayed
    :skill => 0,     #putting 0 means the command is always displayed
    :equip => 1,
    :status => 1,
    :formation => 1,
    :save => 1,
    #:game_end => 0, #you can comment or remove commands that you always show
  } #don't remove
 
  #--------------------------------------------------------------------------
  # method: reveal_command? -> return true iff the command can be shown
  # By default, the command will be hidden if the swicth provided is false
  # If no swicth is provided (<= 0) or no entry, then show the command
  #--------------------------------------------------------------------------
  def self.reveal_command?(symbol)
    s_id = CONTROL_SWICTHES[symbol]
    return $game_switches[s_id] if s_id && s_id > 0
    return true #don't hide it
  end
end #HideMenuCommands

 
#==============================================================================
# Window_MenuCommand
#==============================================================================
class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # alias method: add_command
  #--------------------------------------------------------------------------
  alias hmc_add_command add_command
  def add_command(name, symbol, enabled = true, ext = nil)
    hmc_add_command(name,symbol,enabled,ext) if HideMenuCommands.reveal_command?(symbol)
  end
end #Window_MenuCommand
I had to change the class to Window_TitleCommand < Window_Command, since it had no effect, but ok.
What would be the way to change the 1 to 0 of the switch?
@OmegaSC see this part:
Ruby:
module HideMenuCommands
  CONTROL_SWICTHES = {
    #command_symbol => control_swicth_id
    :item => 1,      #$game_swicth 1 must be true for this command to be displayed
    :skill => 0,     #putting 0 means the command is always displayed
    :equip => 1,
    :status => 1,
    :formation => 1,
    :save => 1,
    #:game_end => 0, #you can comment or remove commands that you always show
  } #don't remove

This script affects the player menu and not the title screen. He probably got confused because of the subject of your thread.
@OmegaSC see this part:


This script affects the player menu and not the title screen. He probably got confused because of the subject of your thread.
Yes, that's why I had to change that line so that it would take effect.
The good thing is that now it works, We only need to know the switch
The script itself works when the player is on the map and not in the title, because the title does not check the Switch before starting the "New Game" command or loading a SaveFile, this script by itself does not do anything related to this

Probably the best thing to do is wait since it is not one or two more lines that will solve the problem, and then see the solution with events that I mentioned in the other topic, just for study purposes
Sorry I thought it was simply the main menu that needed editing! Here is another version that will impact the Title Menu instead! (note that you can use it along with the first script without interference in theory)

Beware that I am not familiar with Tsukihime's Preserve Data (I did download the script to test mine quickly) so I cannot guarantee the behavior of this script in case of manual save file deletion.

Ruby:
#==============================================================================
# Hide Title Menu Commands
#------------------------------------------------------------------------------
# Author: Timtrack
# date: 28/04/2025
#
# requires: Tsukihime's Preserve Data to use switches from a save file.
#
# Allows to control by switches which commands are displayed in the title menu.
# Note that it does not add new commands, you must first add them with another
# script. This script will just filter the added commands.
#
# Term of uses: free for non-commercial and commercial, credit is not mandatory
#==============================================================================

module HideTitleMenuCommands
  CONTROL_SWICTHES = {
    #command_symbol => control_swicth_id
    :continue => 1,      #$game_swicth 1 must be true for this command to be displayed
    :new_game => 0,     #putting 0 means the command is always displayed
    #:shutdown => 0, #you can comment or remove commands that you always show
  } #don't remove
 
  #--------------------------------------------------------------------------
  # method: reveal_command? -> return true iff the command can be shown
  # By default, the command will be hidden if the swicth provided is false
  # If no swicth is provided (<= 0) or no entry, then show the command
  #--------------------------------------------------------------------------
  def self.reveal_command?(symbol)
    s_id = CONTROL_SWICTHES[symbol]
    return $game_switches[s_id] if s_id && s_id > 0
    return true #don't hide it
  end
end #HideMenuCommands

#==============================================================================
# Window_TitleCommand
#==============================================================================
class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # alias method: add_command
  #--------------------------------------------------------------------------
  alias htmc_add_command add_command
  def add_command(name, symbol, enabled = true, ext = nil)
    htmc_add_command(name,symbol,enabled,ext) if HideTitleMenuCommands.reveal_command?(symbol)
  end
end #Window_MenuCommand

#===============================================================================
# Scene_Title
#===============================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # alias method: start -> asks the DataManager to load the switches
  #--------------------------------------------------------------------------
  alias htmc_scene_title_start start
  def start
    DataManager.load_preserved_switches
    htmc_scene_title_start
  end
end #Scene_Title

#===============================================================================
# DataManager -> deals with loading preserved switches
#===============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # alias method: init
  #--------------------------------------------------------------------------
  class <<self; alias htmc_data_manager_init init; end
  def self.init
    htmc_data_manager_init
    @last_savefile_index = latest_savefile_index #make sure that the last save file is most recent one at start
  end
  #--------------------------------------------------------------------------
  # new method: load_preserved_switches
  #--------------------------------------------------------------------------
  def self.load_preserved_switches
    $game_temp.preserving_data = true
    $game_switches = Game_Switches.new unless $game_switches
    filename = make_filename(last_savefile_index)
    return unless File.exist?(filename)
    header = {}
    contents = {}
    File.open(make_filename(last_savefile_index), "rb") do |file|
      header = Marshal.load(file)
      contents = Marshal.load(file)
    end
    # Update switches data
    TH::Preserve_Data::Switches.each {|id|
      $game_switches[id] = contents[:switches][id]
    }
    $game_temp.preserving_data = false
  end
end #DataManager

Original thread: https://forums.rpgmakerweb.com/threads/disable-or-enable-a-menu-option-by-variable-or-switch.177260/