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.

'Loading from Menu' Problem...

I edited my menu script for SDK2, and now I got a problem. First, here's menu script:
Code:
#============================================================================
#L's Custom Menu - Simple DMS Edit SDK2 ver.
#============================================================================

#--------------------------------------------------------------------------
# * Begin SDK Log
#--------------------------------------------------------------------------
SDK.log("L's CMS", 'L', '???', '2007-03-17')

#--------------------------------------------------------------------------
# * Begin SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2.0, [1])

#--------------------------------------------------------------------------
# * Begin SDK Enable Test
#--------------------------------------------------------------------------
if SDK.enabled?("L's CMS")

module SDK::Scene_Commands
  #============================================================================
  # ** Scene_Menu
  #============================================================================
  module Scene_Menu
    Item     = 'Item'
    Skill    = 'Skill'
    Equip    = 'Equip'
    Status   = 'Status'
    Save     = 'Save'
    Load     = 'Load'
    End_Game = 'Exit'
    
    Order    = 'Order'
    Party    = 'Party'
    Option   = 'Option'
    Quest    = 'Quest'
    System   = 'System'
  end
end


if SDK.enabled?('Map Info')

#============================================================================== 
# â–  Game_Map 
#============================================================================== 
class Game_Map    
  def name
     $data_mapinfos[@map_id].name
  end   
end

else
#------------
#------------------------------------------------------------------------------
#  Game_Map
#------------------------------------------------------------------------------
class Game_Map
#------------------------------------------------------------------------------
#  Name
#------------------------------------------------------------------------------
  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

#-----------------
end


class Window_Infos < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 160, 130)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)     
    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
    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



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 < SDK::Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
    party_order_init
  end
  #--------------------------------------------------------------------------
  # * Party Order Change Initiation
  #--------------------------------------------------------------------------
  def party_order_init
    @changer = 0 #Change Party Order by Yargovish
    @where = 0 #
    @checker = 0  #
  end
  #--------------------------------------------------------------------------
  # * Main Processing : Window Initialization
  #--------------------------------------------------------------------------
  def main_window
    super
    # Make main command window
    main_command_window
    # 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 Processing : Window Initialization : Main Command
  #--------------------------------------------------------------------------
  def main_command_window
    # Make command window
    s1 = SDK::Scene_Commands::Scene_Menu::Item
    s2 = SDK::Scene_Commands::Scene_Menu::Skill
    s3 = SDK::Scene_Commands::Scene_Menu::Equip
    s4 = SDK::Scene_Commands::Scene_Menu::Status
    s5 = SDK::Scene_Commands::Scene_Menu::Order
    s6 = SDK::Scene_Commands::Scene_Menu::Load
    s7 = SDK::Scene_Commands::Scene_Menu::Save
    s8 = SDK::Scene_Commands::Scene_Menu::End_Game
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8])
    @command_window.index = @menu_index
    @command_window.height = 256
    # 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 #
      #Disable change party order
      @command_window.disable_item(4)
    end 
    check_save_available
    check_load_available
  end 
  #-----------------
  def check_save_available
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(6)
    end
  end
  #-----------------
  def check_load_available
    #Check if saved file exists
    @load_enabled = false
    for i in 0..3
      if (FileTest.exist?("Save#{i+1}.rxdata"))        
        @load_enabled = true
      end
    end  
    if !@load_enabled
      #Put your @command_window.disable_item(index)
      @command_window.disable_item(5)
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    # If status window is active: call update_status
    elsif @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)
      # Return if Disabled Command
      if disabled_main_command?
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Command Input
      main_command_input
      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)
      # Return if Disabled Command
      if disabled_main_command?
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Command Input
      sub_command_input
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Disabled Main Command? Test
  #--------------------------------------------------------------------------
  def disabled_main_command?
    # Gets Current Command
    command = @command_window.command
    # Gets SDK Scene_Menu Commands
    c = SDK::Scene_Commands::Scene_Menu
    # If 0 Party Size
    if $game_party.actors.size == 0
      # If Item, Skill, Equip or Status Selected
      if [c::Item, c::Skill, c::Equip, c::Status].include?(command)
        return true
      end
    end
    if $game_party.actors.size <= 1
      if [c::Order].include?(command)
        return true
      end
    end
    # If Save Disabled && Command is Save
    return true if $game_system.save_disabled && command == c::Save
    # If Load Disabled && Command is Load
    return true if !@load_enabled && command == c::Load
    return false
  end
  #--------------------------------------------------------------------------
  # * Main Command Input
  #--------------------------------------------------------------------------
  def main_command_input
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Branch by command window cursor position
    case @command_window.command
    when SDK::Scene_Commands::Scene_Menu::Item      # item
      command_item
    when SDK::Scene_Commands::Scene_Menu::Skill     # skill
      command_skill
    when SDK::Scene_Commands::Scene_Menu::Equip     # equipment
      command_equip
    when SDK::Scene_Commands::Scene_Menu::Status    # status
      command_status
    when SDK::Scene_Commands::Scene_Menu::Order      # order
      command_order
    when SDK::Scene_Commands::Scene_Menu::Option    #option
      command_option
    when SDK::Scene_Commands::Scene_Menu::Save  #save
      command_save
    when SDK::Scene_Commands::Scene_Menu::Load  #load
      command_load
    when SDK::Scene_Commands::Scene_Menu::End_Game  #end game
      command_endgame 
    end
  end
  #--------------------------------------------------------------------------
  # * Disabled Sub Command? Test
  #--------------------------------------------------------------------------
  def disabled_sub_command?
    # If Skill Selected
    if @command_window.command == SDK::Scene_Commands::Scene_Menu::Skill
      # If this actor's action limit is 2 or more
      if $game_party.actors[@status_window.index].restriction >= 2
        return true
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # * Sub Command Input
  #--------------------------------------------------------------------------
  def sub_command_input
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Branch by command window cursor position
    case @command_window.command
    when SDK::Scene_Commands::Scene_Menu::Skill     # skill
      command_skill
    when SDK::Scene_Commands::Scene_Menu::Equip     # equipment
      command_equip
    when SDK::Scene_Commands::Scene_Menu::Status    # status
      command_status
    when SDK::Scene_Commands::Scene_Menu::Order      # order
      command_order
    end
  end
  #--------------------------------------------------------------------------
  # * Command : Item
  #--------------------------------------------------------------------------
  def command_item
    # Switch to item screen
    $scene = Scene_Item.new
  end
  #--------------------------------------------------------------------------
  # * Command : Skill
  #--------------------------------------------------------------------------
  def command_skill
    # If Main Command Active
    if @command_window.active
      # Activate Status Window
      active_status_window
      return
    end
    # Switch to skill screen
    $scene = Scene_Skill.new(@status_window.index)
  end
  #--------------------------------------------------------------------------
  # * Command : Equip
  #--------------------------------------------------------------------------
  def command_equip
    # If Main Command Active
    if @command_window.active
      # Activate Status Window
      active_status_window
      return
    end
    # Switch to equipment screen
    $scene = Scene_Equip.new(@status_window.index)
  end
  #--------------------------------------------------------------------------
  # * Command : Status
  #--------------------------------------------------------------------------
  def command_status
    # If Main Command Active
    if @command_window.active
      # Activate Status Window
      active_status_window
      return
    end
    # Switch to status screen
    $scene = Scene_Status.new(@status_window.index)
  end
  #--------------------------------------------------------------------------
  # * Command : Order
  #--------------------------------------------------------------------------
  def command_order
    # If Main Command Active
    if @command_window.active
      # Activate Status Window
      active_status_window
      @checker = 0
      return
    end
    #Change Party Order by Yargovish
    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
  #--------------------------------------------------------------------------
  # * Command : Party
  #--------------------------------------------------------------------------
  def command_party
    # Switch to party change screen
    #Put your Party Change Scene here
  end
  #--------------------------------------------------------------------------
  # * Command : Option
  #--------------------------------------------------------------------------
  def command_option
    # Switch to option screen
    #Put your Option Scene here
  end
  #--------------------------------------------------------------------------
  # * Command : Quest
  #--------------------------------------------------------------------------
  def command_quest
    # Switch to quest screen
    #Put your Quest Scene here
  end
  #--------------------------------------------------------------------------
  # * Command : Save
  #--------------------------------------------------------------------------
  def command_save
    # Switch to save screen
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # * Command : Load
  #--------------------------------------------------------------------------
  def command_load
    # Switch to load screen
    $scene = Scene_Load.new
  end
  #--------------------------------------------------------------------------
  # * Command : End Game
  #--------------------------------------------------------------------------
  def command_endgame
    # Switch to end game screen
    $scene = Scene_End.new
  end
  #--------------------------------------------------------------------------
  # * Activate Status Window
  #--------------------------------------------------------------------------
  def active_status_window
    # Make status window active
    @command_window.active = false
    @status_window.active = true
    @status_window.index = 0
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end
It works well, and it doesn't seem to have any bugs. But, when you try to load your save via menu command, look, you'll get this message:
http://img291.imageshack.us/img291/9995 ... r01kv9.png[/IMG]
unless you're using non-SDK2 save script.. I didn't notice this until today. Is there any solution for this?

**Of course, calling load scene from map or title works normally.
 
Try going to that line and putting something like:
Code:
@window_name_here.dispose if !@window_name_here.disposed?

Of course, that´s not the correct solution. Maybe it´s just one more of those SDK bugs.
 
Yeah, that would not be the correct solution. The line is in 'update' method.(if you remove this from menu script, or alias that, the error message will point to Scene_Menu::Update at SDK part 3)
 

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