Disable and Enable commands from the character menu from the game

A_noob_coder

Warper
Member
Joined
Oct 7, 2020
Messages
3
Reaction score
1
First Language
Spanish
Primarily Uses
RMVX
I want to disable some commands from the character's menu (one with the options save, end game, items, etc.) but I want it so that at some point in the game you can enable them again, by some variable, switch, etc. any script or idea of how to do it?
 

zeroscares

Veteran
Veteran
Joined
Oct 17, 2020
Messages
67
Reaction score
12
First Language
português
Primarily Uses
RMVXA
Window_MenuCommand:
Code:
  #--------------------------------------------------------------------------
  # * Add Main Commands to List [Example conditions]
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(Vocab::item,   :item,   main_commands_enabled && onswitch)
    add_command(Vocab::skill,  :skill,  onswitch)
    add_command(Vocab::equip,  :equip,  main_commands_enabled || onswitch)
    add_command(Vocab::status, :status, main_commands_enabled)
  end


  #--------------------------------------------------------------------------
  # * Get switch that enables commands
  #--------------------------------------------------------------------------
  def enableswitch
    $game_switches[1] == true
  end
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,660
Reaction score
563
First Language
English
Primarily Uses
RMVXA
What Zeroscares provided is an example, but also a confusing one.
The || (or) statement would only work if the main_commands_enabled was false otherwise the || onswitch condition will always be true.

Use this and change it as you need.
Ruby:
# specify what switch controls which command.
# can use same switch to turn multiple commands on or off
# You can remove parts of this script or set 1 switch to true and
# make every command that will not be disabled, set to that switch
# you can also change it to fit your needs

module R2_Main_commands_by_switch
    Formation = 10    # switch 10
    Save             =    11    # switch 11
    Gameend     =    12
    Item             =    13
    Skill         = 14
    Equip         = 15
    Status         = 16
end

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_main_commands
    add_formation_command if $game_switches[R2_Main_commands_by_switch::Formation] == true
    add_original_commands
    add_save_command if $game_switches[R2_Main_commands_by_switch::Save] == true
    add_game_end_command if $game_switches[R2_Main_commands_by_switch::Gameend] == true
  end
  #--------------------------------------------------------------------------
  # * Add Main Commands to List
  #--------------------------------------------------------------------------
  def add_main_commands
    add_command(Vocab::item,   :item,   main_commands_enabled) if $game_switches[R2_Main_commands_by_switch::Item] == true
    add_command(Vocab::skill,  :skill,  main_commands_enabled) if $game_switches[R2_Main_commands_by_switch::Skill] == true
    add_command(Vocab::equip,  :equip,  main_commands_enabled) if $game_switches[R2_Main_commands_by_switch::Equip] == true
    add_command(Vocab::status, :status, main_commands_enabled) if $game_switches[R2_Main_commands_by_switch::Status] == true
  end
end
 

A_noob_coder

Warper
Member
Joined
Oct 7, 2020
Messages
3
Reaction score
1
First Language
Spanish
Primarily Uses
RMVX
Thank you both zeroscares and Roninator2 I will try this scripts and see how it goes. I will notify you of any problem
 

A_noob_coder

Warper
Member
Joined
Oct 7, 2020
Messages
3
Reaction score
1
First Language
Spanish
Primarily Uses
RMVX
Update: the example from zeroscares helped me do a script that works, thank you both for the support, specially zeroscares. I promise that if this project that I am doing gets realeased you both get in the credits.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I am trying to get my game published with Aldorlea Games so that I make sales from their website and the game being on Steam. They have said that their published games rarely make less than a few hundred dollars.
DoubleXP wrote on Tonbi's profile.
Hello Wondering if you take commissions?
I should make an itch.io page one of these days...Maybe for my next large update.
whoops, forgot to get started with Advent posts! coming shortly!

Forum statistics

Threads
105,779
Messages
1,016,403
Members
137,472
Latest member
TatlTaelGamer
Top