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.

Option menu selection window.

I was wandering what is the line of codes used to determine say a small window were you can change the window skin of the menu system, and also turn on/off music, turn on/off sound.
-=Screenshot of what I mean=-

this is the script I'm using(edited with errors)
Code:
#==============================================================================
# Window_Gold
#==============================================================================
class Window_Gold < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization 
  #--------------------------------------------------------------------------
  def initialize
    super(439, 413, 200, 64)
    #Create Bitmap
    self.contents = Bitmap.new(width - 32, height - 32)
    #Z-Pos
    self.z = 100
    #Refresh and add the contents to window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh 
  #--------------------------------------------------------------------------
  def refresh
    #Advanced Gold Display mini-script by Dubealex.
    self.contents.clear     
    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 = system_color 
    gold_word = $data_system.words.gold.to_s + " /"
    cx = contents.text_size(gold_word).width
    cx2=contents.text_size(gold.to_s).width
    self.contents.draw_text(4, 0, 160-cx-2, 32, gold_word)
    self.contents.font.color = text_color(0) 
    self.contents.draw_text(164-cx2+2, 0, cx2, 32, gold.to_s, 2)
  end
end


#==============================================================================
# Window_PlayTime
#==============================================================================
class Window_PlayTime < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization 
  #--------------------------------------------------------------------------
  def initialize
    super(239, 413, 200, 64)
    #Create Bitmap
    self.contents = Bitmap.new(width - 32, height - 32)
    #Z-Pos
    self.z = 100
    #Refresh and add the contents to window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh 
  #--------------------------------------------------------------------------
  def refresh
    #Clear Bitmap
    self.contents.clear
    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, 160, 32, text, 2)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
end


#============================================================================== 
# **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_MapName
#==============================================================================
class Window_MapName < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization 
  #--------------------------------------------------------------------------
  def initialize
    super(0, 413, 239, 64)
    #Create Bitmap
    self.contents = Bitmap.new(width - 32, height - 32)
    #Z-Pos
    self.z = 100
    #Refresh and add the contents to window
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh 
  #--------------------------------------------------------------------------
  def refresh
    #Clear Bitmap
    self.contents.clear    
    self.contents.font.color = normal_color
    #if $scene.current_location = ""
      self.contents.draw_text(4, 0, 200, 32, $game_map.name.to_s, 1)
    #else
      #self.contents.draw_text(4, 32, 120, 32, $scene.current_location.to_s, 1)
    #end
  end  
end


#==============================================================================
# Window_MenuStatus
#==============================================================================
class Window_MenuStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization 
  #--------------------------------------------------------------------------
  def initialize
    $game_party.actors.size < 4 ? i = 14 : i = 0
    $game_party.actors.size == 1 ? i = 24 : i = i
    super(177, 0, 462, ($game_party.actors.size * 72)+i)
    #Create Bitmap
    self.contents = Bitmap.new(width - 32, height - 32)
    #Z-Pos
    self.z = 100
    #Refresh and add the contents to window    
    refresh
    self.active = false
    self.index = -1
  end
  #--------------------------------------------------------------------------
  # * Refresh 
  #--------------------------------------------------------------------------
  def refresh
    #Clear Bitmap
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 16
      y = i*64
      actor = $game_party.actors[i]
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)      
      draw_actor_state(actor, x + 260, y )
      draw_actor_level(actor, x, y + 32)
      draw_actor_hp(actor, x + 98, y + 32)
      draw_actor_sp(actor, x + 254, y + 32)
    end
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 64, self.width - 32, 64)
    end
  end
end


#==============================================================================
# Scene_Menu
#==============================================================================
class Scene_Menu
  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 = "Option"
    o2 = "Help"
    o3 = "Save"
    o4 = "Load"
    o5 = "Exit"
    @system_commands.push(o1, o2, o3, o4, o5).flatten!
    
    @option_commands = []
    z1 = "Window Skin"
    z2 = "Music"
    z3 = "Sound"
    @option_commands.push(z1, z2, z3).flatten!
  end
  #--------------------------------------------------------------------------
  # * Main - Handles drawing/disposing windows and the main loop 
  #--------------------------------------------------------------------------
  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 Background
    @background = Spriteset_Map.new
    #Draw Windows   
    @gold_window = Window_Gold.new
    @gold_window.x = 439
    @gold_window.y = 413
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 239
    @playtime_window.y = 413    
    @map_window = Window_MapName.new
    @map_window.x = 0
    @map_window.y = 413
    @map_window.z = 100
    @status_window = Window_MenuStatus.new        
  end
  #--------------------------------------------------------------------------
  # * Main Command Window
  #--------------------------------------------------------------------------
  def main_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 $game_party.actors.size <= 1 #
      @command_window.disable_item(4)
    end   
  end
    
  def system_command_window
    @load_enabled = false
    @sys_command_window = Window_Command.new(160, @system_commands)
    @sys_command_window.visible = false
    @sys_command_window.active = false
    @sys_command_window.x = 100
    @sys_command_window.y = 180
    @sys_command_window.z = 0
    if $game_system.save_disabled
      @sys_command_window.disable_item(2)
    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(3)
    end
  end
  
  def system_options_window
  @sys_options_window = Window_Options.new(160, @option_commands)
  @sys_options_window.visaible = false
  @sys_options_window.active = false
  @sys_options_window.x = 50
  @sys_options_window.y = 90
  @sys_options_window.z = 0
  end
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 Background
    @background.dispose
    # Dispose All Windows
    @gold_window.dispose
    @playtime_window.dispose
    @map_window.dispose
    @status_window.dispose
    @command_window.dispose
    @sys_command_window.dispose
    @sys_option_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Main Loop 
  #--------------------------------------------------------------------------
  def main_loop
    # Update game screen
    Graphics.update
    # Update input information
    Input.update
    # Frame update
    update
  end
  #--------------------------------------------------------------------------
  # * Update 
  #--------------------------------------------------------------------------
  def update
    # Update Windows
    update_windows
    #update_command if @command_window.active and @command_window.visible
    #update_sys_command if @sys_command_window.active and @sys_command_window.visible
    #update_status if @status_window.active
    #update_option if @option_window.active
    
    if @sys_command_window.active
      @sys_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 status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
    # If option window is active: call update_option
    if @options_window.active
      update_options
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Window Update 
  #--------------------------------------------------------------------------
  def update_windows    
    @command_window.update if @command_window.visible
    @sys_command_window.update if @sys_command_window.visible
    @gold_window.update
    @playtime_window.update
    @map_window.update
    @status_window.update
  end
  #--------------------------------------------------------------------------
  # * Update Command Window
  #--------------------------------------------------------------------------
  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 # Equip
        # 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 # System
        $game_system.se_play($data_system.decision_se)
        @sys_command_window.active = true
        @sys_command_window.visible = true
        @command_window.active = false         
      end
    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
        $game_system.se_play($data_system.decision_se)
        @sys_options_window.active = true
        @sys_options_window.visible = true
        @options_window.active = false         
      when 1
        # Play decision SE
        #$game_system.se_play($data_system.decision_se)
        #Put your Help/Tutorial Scene here
      when 2
        # # 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 3
        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 4
        # 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 SysOption Window
  #--------------------------------------------------------------------------
  def update_sys_options
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @options_window.active = true
      @sys_options_window.active = false
      @sys_options_window.visible = false
      @sys_options_window.index = 0
      @sys_options_window.z = 0
      return
    end
    
    if Input.trigger?(Input::C)
      case @sys_command_window.index      
      when 0
        #$game_system.se_play($data_system.decision_se)
        #place the window skin selection here
      when 1
        # Play decision SE
        #$game_system.se_play($data_system.decision_se)
        #Put your Help/Tutorial Scene here
      when 2
        # Play decision SE
        #$game_system.se_play($data_system.decision_se)
        #Put your Help/Tutorial Scene here
          return
        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
        #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_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
The error happens on line 406
saying nomethoderror occurred. undefined method `visible' for nil:nilclass.
what and how can I fix this?
 

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