Kain Nobel
Member
There's a few problems I don't know how to overcome with this script, and its been awhile since I've even had a chance to work on it so its kind of dejavu of an old topic, but I forget what the hell I was crying about back then. Anybody not familiar, I'll brief you in on what it does.
This script is supposed to save your data whenever you visit a new map (at the very end of Game_Map.setup), so whenever you decide to randomly exit the game, you'll always be able to restart at the last point on the last map you visited. You can use this as an alternative to conventional Menu-saving or Save Point systems, and have it to where the last AutoSave file is deleted when loaded.
But thats where the problem begins and ends... the data doesn't save correctly, or isn't read correctly or something. Whenever your data is loaded from the AutoSave file, it brings you to the last map but you're placed at 0x0 on that map and your player graphic is blank, bgm/bgs/weather isn't playing, etc. This basically just uses Scene_Save/Scene_Load commands to execute saving/loading the AutoSave file, I'm not sure why its not working correctly. I especially made sure that its set at the end of the setup method.
Also, I tried to make it where when Scene_Title is first called in the game, the AutoSave is loaded via Scene_Load.on_decision if the file exists before anything else happens, so its supposed to skip title and take you directly to your last map. At one point it did it, but now it just seems to maybe initialize Scene_Title twice or something, I'm not sure whats going on here either.
Here is the script, really much hasn't changed I've been too busy to script lately, otherwise I would've fixed it on my own a long time ago.
This script is supposed to save your data whenever you visit a new map (at the very end of Game_Map.setup), so whenever you decide to randomly exit the game, you'll always be able to restart at the last point on the last map you visited. You can use this as an alternative to conventional Menu-saving or Save Point systems, and have it to where the last AutoSave file is deleted when loaded.
But thats where the problem begins and ends... the data doesn't save correctly, or isn't read correctly or something. Whenever your data is loaded from the AutoSave file, it brings you to the last map but you're placed at 0x0 on that map and your player graphic is blank, bgm/bgs/weather isn't playing, etc. This basically just uses Scene_Save/Scene_Load commands to execute saving/loading the AutoSave file, I'm not sure why its not working correctly. I especially made sure that its set at the end of the setup method.
Also, I tried to make it where when Scene_Title is first called in the game, the AutoSave is loaded via Scene_Load.on_decision if the file exists before anything else happens, so its supposed to skip title and take you directly to your last map. At one point it did it, but now it just seems to maybe initialize Scene_Title twice or something, I'm not sure whats going on here either.
Here is the script, really much hasn't changed I've been too busy to script lately, otherwise I would've fixed it on my own a long time ago.
Code:
#===============================================================================
# ~** Map.AutoSaveResume **~
#-------------------------------------------------------------------------------
# Written by : Kain Nobel
# Version   : 0.3
# Last Update : 09.24.2008
#-------------------------------------------------------------------------------
# * Description  :
#-------------------------------------------------------------------------------
#Â Â This is an AutoSave system for the map scene. Whenever you visit a new map,
#Â Â a file is saved within the game's Data directory. If you ever can't find a
#Â Â save point, and want to quit a game (as long as the script is enabled), you
#Â Â can simply close the game without saving and resume it at a later time.
#-------------------------------------------------------------------------------
# * Features   :
#-------------------------------------------------------------------------------
#Â Â - Create an AutoSave file in the games internal directory each time visiting
#Â Â Â a new map scene.
#Â Â - Close your game and open it at a later time from the entrance of the last
#Â Â Â map scene visited.
#Â Â - Author can toggle script activity with 'AutoSave::Enabled = true/false'
#-------------------------------------------------------------------------------
# * Requirements :
#-------------------------------------------------------------------------------
#Â Â - SDK version 2.0 or higher, at least parts 1 and 3
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Map.AutoSaveResume', 'Kain Nobel', 0.3, '09.24.2008')
#SDK.disable('Map.AutoSaveResume') if $DEBUG
#-------------------------------------------------------------------------------
# * SDK Enabled Test - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Map.AutoSaveResume')
#===============================================================================
# ~** AutoSave **~
#-------------------------------------------------------------------------------
#Â Â This module handles all the AutoSave methods.
#===============================================================================
module AutoSave
 #-----------------------------------------------------------------------------
 # * Customizable Constant
 #-----------------------------------------------------------------------------
 Filename = "Data/AutoSaveResume"
 #-----------------------------------------------------------------------------
 # * AutoSave.save_file
 #-----------------------------------------------------------------------------
 def self.save_file
  (Scene_Save.new).on_decision(filename)
  @loaded = true
 end
 #-----------------------------------------------------------------------------
 # * AutoSave.load_file
 #-----------------------------------------------------------------------------
 def self.load_file
  (Scene_Load.new).on_decision(filename)
  @loaded = true
 end
 #-----------------------------------------------------------------------------
 # * AutoSave.filename
 #-----------------------------------------------------------------------------
 def self.filename
  filename = Filename.is_a?(String) ? Filename : "AutoSave"
  unless filename.include?('.')
   filename += '.rxdata'
  end
  return filename
 end
 #-----------------------------------------------------------------------------
 # * AutoSave.exists?
 #-----------------------------------------------------------------------------
 def self.exists?
  return FileTest.exist?(filename)
 end
 #-----------------------------------------------------------------------------
 # * AutoSave.loaded
 #-----------------------------------------------------------------------------
 def self.loaded
  @loaded = false if @loaded.nil?
  return @loaded
 end
end
#===============================================================================
# ** Game_Player
#-------------------------------------------------------------------------------
#Â Â You encounter a bug with this script if you don't do this.
#===============================================================================
class Game_Player < Game_Character
 #-----------------------------------------------------------------------------
 # * Alias Listing
 #-----------------------------------------------------------------------------
 alias_method :autosave_game_character_encounter_count, :encounter_count
 #-----------------------------------------------------------------------------
 # * Encounter Count
 #-----------------------------------------------------------------------------
 def encounter_count
  if @encounter_count.nil?
   make_encounter_count
  end
  autosave_game_character_encounter_count
 end
end
#===============================================================================
# ** Scene_Title
#-------------------------------------------------------------------------------
#Â Â This class has been enhanced to load an AutoSave file (if it exists) apon
# opening the Game.exe later on after previously closing a game in progress.
#===============================================================================
class Scene_Title < SDK::Scene_Base
 #-----------------------------------------------------------------------------
 # * Alias Listing
 #-----------------------------------------------------------------------------
 alias_method :autosave_scene_title_main_database, :main_database
 #-----------------------------------------------------------------------------
 # * Main Database
 #-----------------------------------------------------------------------------
 def main_database
  autosave_scene_title_main_database
  if AutoSave.exists? && !AutoSave.loaded
   AutoSave.load_file
   return
  end
 end
end
#===============================================================================
# ** Game_Map
#-------------------------------------------------------------------------------
#Â Â Each time you visit a new map scene, the AutoSave file is written to so you
# can just close the game and open it later and start where you left off at.
#===============================================================================
class Game_Map
 #-----------------------------------------------------------------------------
 # * Alias Listing
 #-----------------------------------------------------------------------------
 alias_method :autosave_game_map_setup, :setup
 #-----------------------------------------------------------------------------
 # * Setup
 #-----------------------------------------------------------------------------
 def setup(map_id)
  autosave_game_map_setup(map_id)
  AutoSave.save_file
 end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end