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.

Modify Menu Script

I was trying to create a sub-Cat for the skill system, into 3 diff options. Techs/Spells/Overdrive.

But having a problem with the window part keep getting undefined errors.
I am also using DVV Overdrive skill, along with the Limit Menu that goes with it. So far the system works on the script, but cant seem to find the porblem with the skills.

Here is the script fresh out of my game. You might have to get the Overdrive/Menu too to test it out.

Code:
#============================================================================== 
# **Game_Map 
#============================================================================== 
class Game_Map    
  def name
     $map_infos[@map_id]
  end   
end


#========================================
# **Scene_Title
#--------------------------------------------------------------------------------
# Setting functions for the Title
#========================================
class Scene_Title
  $map_infos = load_data("Data/MapInfos.rxdata")
  for key in $map_infos.keys
    $map_infos[key] = $map_infos[key].name
  end
end

#==============================================================================
# **Window_Infos
#==============================================================================
class Window_Infos < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 130)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    #---Show Time
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Time")
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    text = sprintf("%02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120, 32, text, 2)
    #---Show Steps
    self.contents.font.color = system_color
    self.contents.draw_text(4, 25, 120, 32, "Steps")
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 42, 120, 32, $game_party.steps.to_s, 2)
    #---Show Money
    #Advanced Gold Display mini-script by Dubealex.
    case $game_party.gold
      when 0..9999
        gold = $game_party.gold
      when 10000..99999
        gold = $game_party.gold.to_s
        array = gold.split(//)
        gold = array[0].to_s+array[1].to_s+","+array[2].to_s+array[3].to_s+array[4].to_s
      when 100000..999999 
        gold = $game_party.gold.to_s
        array = gold.split(//)
        gold = array[0].to_s+array[1].to_s+array[2].to_s+","+array[3].to_s+array[4].to_s+array[5].to_s
      when 1000000..9999999 
        gold = $game_party.gold.to_s
        array = gold.split(//)
        gold = array[0].to_s+","+array[1].to_s+array[2].to_s+array[3].to_s+","+array[4].to_s+array[5].to_s+array[6].to_s
    end
    
    self.contents.font.color = normal_color     
    cx = contents.text_size($data_system.words.gold).width    
    self.contents.draw_text(4, 67, 120-cx-2, 32, gold.to_s, 2)
    self.contents.font.color = system_color 
    self.contents.draw_text(124-cx, 67, cx, 32, $data_system.words.gold, 2)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
end


#==============================================================================
# **Window_MapName
#==============================================================================
class Window_MapName < Window_Base
 def initialize
   super(0, 0, 160, 96)
   self.contents = Bitmap.new(width - 32, height - 32)   
   refresh
 end
 def refresh
   self.contents.clear
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 120, 32, "Location")
   self.contents.font.color = normal_color
   self.contents.draw_text(4, 32, 120, 32, $game_map.name.to_s, 2)
 end
end


#==============================================================================
# ** 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    
    commands_init
    @changer = 0 #Change Party Order by Yargovish
    @where = 0 #
    @checker = 0  #
  end
  #--------------------------------------------------------------------------
  # * Set Commands
  #--------------------------------------------------------------------------
  def commands_init
    # MenuCommand
    @commands = []
    s1 = "Item"
    s2 = "Skill"
    s3 = "Equip"
    s4 = "Status" 
    s5 = "Order"
    s6 = "System"
    @commands.push(s1, s2, s3, s4, s5, s6).flatten!
    
    @system_commands = []
    o1 = "Save"
    o2 = "Load"
    o3 = "Exit"
    @system_commands.push(o1, o2, o3).flatten!
    
    @skills_commands = []
    t1 = "Techs"
    t2 = "Spells"
    t3 = "Overdrive"
    @skills_commands.push(t1, t2, t3).flatten!
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    #Draw Windows
    main_command_window
    system_command_window
    main_draw
    #Execute transition
    Graphics.transition
    #Main Loop
    loop do
      #Main Loop
      main_loop
      break if main_scenechange?
    end
    #Prepare for transition
    Graphics.freeze
    #Dispose Windows
    main_dispose
  end
  #--------------------------------------------------------------------------
  # * Main Draw - Handles drawing windows
  #--------------------------------------------------------------------------
  def main_draw
    #Draw Windows
    # Make Info Window
    @infos_window = Window_Infos.new
    @infos_window.x = 0
    @infos_window.y = 255
    # Make map name window
    @mapname_window = Window_MapName.new
    @mapname_window.x = 0
    @mapname_window.y = 384
    # Make status window
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0     
    end
  #--------------------------------------------------------------------------
  # * Main Command Window
  #--------------------------------------------------------------------------
  def main_command_window 
    # Make command window    
    @command_window = Window_Command.new(160, @commands)
    @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)
    end
    # If save is forbidden
    #if $game_system.save_disabled
      # Disable save
      #@command_window.disable_item(4)      
    #end
    if $game_party.actors.size <= 1 #
      @command_window.disable_item(4)
    end
  end
  #--------------------------------------------------------------------------
  # * System Command Window
  #--------------------------------------------------------------------------
  def system_command_window
    @load_enabled = false
    @sys_command_window = Window_Command.new(128, @system_commands)
    @sys_command_window.visible = false
    @sys_command_window.active = false
    @sys_command_window.x = 100
    @sys_command_window.y = 210
    @sys_command_window.z = 0
    if $game_system.save_disabled
      @sys_command_window.disable_item(0)
    end
    for i in 0..3
      if (FileTest.exist?("Save#{i+1}.rxdata"))        
        @load_enabled = true
      end
    end  
    if !@load_enabled
      @sys_command_window.disable_item(1)
    end
  end    
  #--------------------------------------------------------------------------
  # * Skill Command Window
  #--------------------------------------------------------------------------
  def skill_command_window
    @skill_command_window = Window_Command.new(128, @skills_commands)
    @skill_command_window.visible = false
    @skill_command_window.active = false
    @skill_command_window.x = 100
    @skill_command_window.y = 210
    @skill_command_window.z = 0
    
    
  end    
  #--------------------------------------------------------------------------
  # * Main Scene Change 
  #--------------------------------------------------------------------------
  def main_scenechange?
    # Abort loop if screen is changed
    if $scene != self
      return true
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Main Dispose 
  #--------------------------------------------------------------------------
  def main_dispose
    # Dispose All Windows
    @command_window.dispose
    @sys_command_window.dispose
    @skill_command_window.dispose
    @infos_window.dispose
    @mapname_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Main Loop 
  #--------------------------------------------------------------------------
  def main_loop
    # Update game screen
    Graphics.update
    # Update input information
    Input.update
    # Frame update
    update
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update Windows
    update_windows
    
    if @sys_command_window.active
      @sys_command_window.z = +500
    end
    
#    if @skill_command_window.active
#      @skill_command_window.z = +500
#    end
    
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If system window is active: call update_sys_command
    if @sys_command_window.active
      update_sys_command
      return
    end
    # If skill window is active: call update_command
    if @skill_command_window.active
      update_skill_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Window Update 
  #--------------------------------------------------------------------------
  def update_windows    
    @command_window.update if @command_window.visible
    @sys_command_window.update if @sys_command_window.visible
#    @skill_command_window.update if @skill_command_window.visible
    @infos_window.update
    @status_window.update
    @mapname_window.update
  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  #Call skill Menu
        $game_system.se_play($data_system.decision_se)
        @skill_command_window.active = true
        @skill_command_window.visible = true
        @command_window.active = false        
      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  # Order
        #Change Party Order by Yargovish
        $game_system.se_play($data_system.decision_se)
        @checker = 0
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0      
      when 5  #Call System Menu
        $game_system.se_play($data_system.decision_se)
        @sys_command_window.active = true
        @sys_command_window.visible = true
        @command_window.active = false        
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Update SysCommand Window
  #--------------------------------------------------------------------------
  def update_sys_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @sys_command_window.active = false
      @sys_command_window.visible = false
      @sys_command_window.index = 0
      @sys_command_window.z = 0
      return
    end
    
    if Input.trigger?(Input::C)
      case @sys_command_window.index      
      when 0  #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 1  #Load
        #When there are no saved files
        if !@load_enabled
          # 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 load screen
        $scene = Scene_Load.new
      when 2  #Quit
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Update SkillCommand Window
  #--------------------------------------------------------------------------
  def update_skill_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @skill_command_window.active = false
      @skill_command_window.visible = false
      @skill_command_window.index = 0
      @skill_command_window.z = 0
      return
    end
    
    if Input.trigger?(Input::C)
      case @skill_command_window.index      
      when 0  #Techs
        # 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 1  #Spells
        # 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  #Overdrive
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_LimitMenu.new(@status_window.index)
      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)
      when 4  #Order
        #Change Party Order by Yargovish
        $game_system.se_play($data_system.decision_se)
        if @checker == 0
          @changer = $game_party.actors[@status_window.index]
          @where = @status_window.index
          @checker = 1
        else           
          $game_party.actors[@where] = $game_party.actors[@status_window.index]
          $game_party.actors[@status_window.index] = @changer
          @checker = 0
          @status_window.refresh
          $game_player.refresh #
        end
      end
      return
    end
  end    
end


class Scene_Save < Scene_File
  alias save_on_decision on_decision
  alias save_on_cancel on_cancel
  #--------------------------------------------------------------------------
  # * Decision Processing
  #--------------------------------------------------------------------------
  def on_decision(filename)
    save_on_decision(filename)
    $scene = Scene_Menu.new(6)
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    save_on_cancel
    $scene = Scene_Menu.new(6)
  end
end


class Scene_Load < Scene_File
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias load_initialize initialize
  alias load_on_cancel on_cancel
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @scene = $scene
    load_initialize
  end
  #--------------------------------------------------------------------------
  # * Cancel Processing
  #--------------------------------------------------------------------------
  def on_cancel
    load_on_cancel
    $scene = @scene
  end
end

going to contiue messing with it, just maybe someone could push me in the right direction.
Thanks
 

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