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.

[RMXP] Disabling Scene Options while the Game is Running

This is quite simple (and yet I can't seem to find a solution :blank: )
::The Script I'm using::


Script This is the whole Script
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 = "Statistics"

    s5 = "Save Progess"

    s6 = "Quit Game"

    s7 = "Distribute"

    s8 = "Class Change"

    s9 = "Skill Change" 

    s10 = "Achievements"

    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10])

    @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(6)

      @command_window.disable_item(7)

      @command_window.disable_item(8)

    end

    # If save is forbidden

    if $game_system.save_disabled

      # Disable save

      @command_window.disable_item(4)

    end

    # Make play time window

    @playtime_window = Window_PlayTime.new

    @playtime_window.x = 0

    @playtime_window.y = 340

    # 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

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    @command_window.update

    @playtime_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)

      # 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

      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

      when 6 # Distribute Stats

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to Distribute Stats Screen

        $scene = Scene_Points.new

      when 7 # Class Change

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to Class Change Screen

        $scene = Scene_ClassChange.new

      when 8 # Class Change

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to Class Change Screen

        $scene = Scene_SkillChange.new

      when 9 # Achievements

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Opens the Achievement Scene

        $scene = Scene_Achievements.new

      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

        # If this actor's action limit is 2 or more

        if $game_party.actors[@status_window.index].restriction >= 2

          # 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 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)

      end

      return

    end

  end

end

 


My Problem
When I start the game, I'm trying to figure out how to disable certain Scene Menu Options.
In this case, 'Skill Change', 'Class Change', and 'Distribute'.
In the script, disabling these Scene Options are:
@command_window.disable_item(6)
@command_window.disable_item(7)
@command_window.disable_item(8)

Now, all I need is to find out how to disable this but through the process of an Event; Which is the "Script..." Button. :crazy:


What I Need
Just a line that is able to be put into that Process.
If you have any ideas but can't seem to test it out just tell me and I'll test it :smile:
Again
This is quite simple
Simple Simple Simple Simple Simple Simple Simple Simple Simple Simple Simple Simple :haha:
Thank Yuh :biggrin:
 
Take an example from save, and how save is disabled.
Add variables in Game_system: disable_distribute, etc. Make them attr_accessor, so
Then in an event you can do
script: $game_system.disable_distribute = true
I believe @command_window.disable_item(6) on its own only makes the menu option look grey.
You also need to check if the option is disabled, and act accordingly (see save option in update_command)

Code:
class Game_System

  attr_accessor :skill_change_disabled

  attr_accessor :distribute_disabled

  attr_accessor :class_change_disabled

  alias old_init initialize

  def initialize

    old_init

    skill_change_disabled = false

    distribute_disabled = false

    class_change_disabled = false

  end

  

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 = "Statistics"

    s5 = "Save Progess"

    s6 = "Quit Game"

    s7 = "Distribute"

    s8 = "Class Change"

    s9 = "Skill Change"

    s10 = "Achievements"

    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10])

    @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(6)

      @command_window.disable_item(7)

      @command_window.disable_item(8)

    end

    # If save is forbidden

    if $game_system.save_disabled

      # Disable save

      @command_window.disable_item(4)

    end

    # Make play time window

    @playtime_window = Window_PlayTime.new

    @playtime_window.x = 0

    @playtime_window.y = 340

    # 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

  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

      if $game_system.distribute_disabled

         @command_window.disable_item(6)

       end

       if $game_system.class_change_disabled

        @command_window.disable_item(7)

      end

      if $game_system.skill_change_disabled

        @command_window.disable_item(8)

      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  # 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

      when 6 # Distribute Stats

        if $game_system.distribute_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 Distribute Stats Screen

        $scene = Scene_Points.new

      when 7 # Class Change

        if $game_system.class_change_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 Class Change Screen

        $scene = Scene_ClassChange.new

      when 8 # Class Change

        if $game_system.skill_change_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 Class Change Screen

        $scene = Scene_SkillChange.new

      when 9 # Achievements

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Opens the Achievement Scene

        $scene = Scene_Achievements.new

      end

      return

    end

  end

  

end

 

 
 
Okay Silver, I read what you said, and fortunely, I know some stuff about scripter (Somewhere in between a Begginer and Experienced Scripter). Now...
I went to Game_System and tweaked the script to your reply.
Now this is the script I have,
Code:
 

#==============================================================================

# ** Game_System

#------------------------------------------------------------------------------

#  This class handles data surrounding the system. Backround music, etc.

#  is managed here as well. Refer to "$game_system" for the instance of 

#  this class.

#==============================================================================

 

class Game_System

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :map_interpreter          # map event interpreter

  attr_reader   :battle_interpreter       # battle event interpreter

  attr_accessor :timer                    # timer

  attr_accessor :timer_working            # timer working flag

  attr_accessor :save_disabled            # save forbidden

  attr_accessor :menu_disabled            # menu forbidden

  attr_accessor :encounter_disabled       # encounter forbidden

  attr_accessor :message_position         # text option: positioning

  attr_accessor :message_frame            # text option: window frame

  attr_accessor :save_count               # save count

  attr_accessor :magic_number             # magic number

  attr_accessor :disable_distribute       # Distibute Forbidden

  attr_accessor :disable_skillchange      # Skill Change Forbidden

  attr_accessor :disable_classchange      # Class Change Forbidden

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    @map_interpreter = Interpreter.new(0, true)

    @battle_interpreter = Interpreter.new(0, false)

    @timer = 0

    @timer_working = false

    @save_disabled = false

    @menu_disabled = false

    @disable_distribute = false

    @disable_skillchange = false

    @disable_classchange = false

    @encounter_disabled = false

    @message_position = 2

    @message_frame = 0

    @save_count = 0

    @magic_number = 0

  end

  #--------------------------------------------------------------------------

  # * Play Background Music

  #     bgm : background music to be played

  #--------------------------------------------------------------------------

  def bgm_play(bgm)

    @playing_bgm = bgm

    if bgm != nil and bgm.name != ""

      Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)

    else

      Audio.bgm_stop

    end

    Graphics.frame_reset

  end

  #--------------------------------------------------------------------------

  # * Stop Background Music

  #--------------------------------------------------------------------------

  def bgm_stop

    Audio.bgm_stop

  end

  #--------------------------------------------------------------------------

  # * Fade Out Background Music

  #     time : fade-out time (in seconds)

  #--------------------------------------------------------------------------

  def bgm_fade(time)

    @playing_bgm = nil

    Audio.bgm_fade(time * 1000)

  end

  #--------------------------------------------------------------------------

  # * Background Music Memory

  #--------------------------------------------------------------------------

  def bgm_memorize

    @memorized_bgm = @playing_bgm

  end

  #--------------------------------------------------------------------------

  # * Restore Background Music

  #--------------------------------------------------------------------------

  def bgm_restore

    bgm_play(@memorized_bgm)

  end

  #--------------------------------------------------------------------------

  # * Play Background Sound

  #     bgs : background sound to be played

  #--------------------------------------------------------------------------

  def bgs_play(bgs)

    @playing_bgs = bgs

    if bgs != nil and bgs.name != ""

      Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume, bgs.pitch)

    else

      Audio.bgs_stop

    end

    Graphics.frame_reset

  end

  #--------------------------------------------------------------------------

  # * Fade Out Background Sound

  #     time : fade-out time (in seconds)

  #--------------------------------------------------------------------------

  def bgs_fade(time)

    @playing_bgs = nil

    Audio.bgs_fade(time * 1000)

  end

  #--------------------------------------------------------------------------

  # * Background Sound Memory

  #--------------------------------------------------------------------------

  def bgs_memorize

    @memorized_bgs = @playing_bgs

  end

  #--------------------------------------------------------------------------

  # * Restore Background Sound

  #--------------------------------------------------------------------------

  def bgs_restore

    bgs_play(@memorized_bgs)

  end

  #--------------------------------------------------------------------------

  # * Play Music Effect

  #     me : music effect to be played

  #--------------------------------------------------------------------------

  def me_play(me)

    if me != nil and me.name != ""

      Audio.me_play("Audio/ME/" + me.name, me.volume, me.pitch)

    else

      Audio.me_stop

    end

    Graphics.frame_reset

  end

  #--------------------------------------------------------------------------

  # * Play Sound Effect

  #     se : sound effect to be played

  #--------------------------------------------------------------------------

  def se_play(se)

    if se != nil and se.name != ""

      Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)

    end

  end

  #--------------------------------------------------------------------------

  # * Stop Sound Effect

  #--------------------------------------------------------------------------

  def se_stop

    Audio.se_stop

  end

  #--------------------------------------------------------------------------

  # * Get Playing Background Music

  #--------------------------------------------------------------------------

  def playing_bgm

    return @playing_bgm

  end

  #--------------------------------------------------------------------------

  # * Get Playing Background Sound

  #--------------------------------------------------------------------------

  def playing_bgs

    return @playing_bgs

  end

  #--------------------------------------------------------------------------

  # * Get Windowskin File Name

  #--------------------------------------------------------------------------

  def windowskin_name

    if @windowskin_name == nil

      return $data_system.windowskin_name

    else

      return @windowskin_name

    end

  end

  #--------------------------------------------------------------------------

  # * Set Windowskin File Name

  #     windowskin_name : new windowskin file name

  #--------------------------------------------------------------------------

  def windowskin_name=(windowskin_name)

    @windowskin_name = windowskin_name

  end

  #--------------------------------------------------------------------------

  # * Get Battle Background Music

  #--------------------------------------------------------------------------

  def battle_bgm

    if @battle_bgm == nil

      return $data_system.battle_bgm

    else

      return @battle_bgm

    end

  end

  #--------------------------------------------------------------------------

  # * Set Battle Background Music

  #     battle_bgm : new battle background music

  #--------------------------------------------------------------------------

  def battle_bgm=(battle_bgm)

    @battle_bgm = battle_bgm

  end

  #--------------------------------------------------------------------------

  # * Get Background Music for Battle Ending

  #--------------------------------------------------------------------------

  def battle_end_me

    if @battle_end_me == nil

      return $data_system.battle_end_me

    else

      return @battle_end_me

    end

  end

  #--------------------------------------------------------------------------

  # * Set Background Music for Battle Ending

  #     battle_end_me : new battle ending background music

  #--------------------------------------------------------------------------

  def battle_end_me=(battle_end_me)

    @battle_end_me = battle_end_me

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # reduce timer by 1

    if @timer_working and @timer > 0

      @timer -= 1

    end

  end

end

 
1. I tweaked the Game_System just like you said. Easy.
2. I copied the Object Initialization and so to the part it should be in Scene_Menu
*Test Play!*
Start Game option selected
Error! Sentence 210, okay, the ends were messed up but that was because of the whole code thingy.
Okay, fixed it. Still an error. I don't deal with this stuff. If you could give me some advice on that.
This is the last part and it says Error.
Lines 205-209
Code:
      end

      return

    end

  end

end
And one more thing, thanks for redoing the Frame Update for me. :smile: I'm too lazy to do that :shades:
 
silver wind":20mxc2cc said:
You're welcome. ^^
It sounds like there's still a missing 'end' or one too many.
Okay, finally you got on,
Now it's saying that the update in the script line 69, is
a undefined local variable or method 'update' for #<Scene_Menu:0x3accff8>
This happens right when I call up the menu in the game. I have not set up the Event to disable the Distribute, Class & Skill Change.
If you need, I can show a list of custom scripts I'm using.
 
Um.. don't replace Scene_menu, paste a new page with your script below scene_menu and above main. That way, your methods will over-write the original ones. I didn't copy the method update, as it doesn't need to be overwritten.
 

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