Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,132
Reaction score
706
First Language
English
Primarily Uses
RMVXA
Auto Save / Auto Load v1.10
by Roninator2​

Introduction
A script requested to perform auto save on specific maps and auto load

Features
- Decide to use switch to control auto save or not
- Specify number of save slots used
- Specify if you want auto load from the start of the game of when pressing continue on the title screen
- add in what maps you want auto save to work on
- must have only 1 save slot specified for auto load to work.
- if using more than 1 save file then saving will use the last save file used.


How to Use
Put below ▼ Materials

Images
I don't think any is required

Script
Ruby:
# ╔═════════════════════════════════════╦════════════════════╗
# ║ Title: Auto Save / Load             ║  Version: 1.10     ║
# ║ Author: Roninator2                  ║                    ║
# ╠═════════════════════════════════════╬════════════════════╣
# ║ Function: Requested by kiriyubel    ║   Date Created     ║
# ║                                     ╠════════════════════╣
# ║ Allows auto saving and auto loading ║    21 Jan 2021     ║
# ╚═════════════════════════════════════╩════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Requires: nil                                            ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Script provides auto save and auto load features         ║
# ║ Can be used for multiple save slots.                     ║
# ║ Autosave is designed to work for specific maps.          ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Updates:                                                 ║
# ║ 1.00 - 21 Jan 2021 - Initial publish                     ║
# ║ 1.10 - 06 Mar 2021 - Removed 1 slot restriction          ║
# ╚══════════════════════════════════════════════════════════╝
# ╔══════════════════════════════════════════════════════════╗
# ║ Terms of use:                                            ║
# ║ Free for all RPG Maker uses                              ║
# ╚══════════════════════════════════════════════════════════╝

module R2_AutoSave_AutoLoad
  Switch_Save = 6 # switch to enable auto save
  Use_switch = false # turns switch feature on if true
  
  Save_Maps = [1, 2] 
  # add as many maps as you want to use autosave feature with
  Save_Slots = 16
  # change the number for how many slot you wish to use.
  
  Auto_load = false
  # if true will load the saved game without going to the title
  Continue_load = true
  # if true this will load the latest saved game when 
    # selecting continue
end

module DataManager
  def self.savefile_max
    return R2_AutoSave_AutoLoad::Save_Slots
  end
end

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  alias r2_autostart_autoload start
  def start
    @saves = []
    @last = 0
    if DataManager.save_file_exists?
      for i in 0..DataManager.savefile_max
        i += 1
        if i > 9
          if !Dir.glob("Save#{i}.rvdata2").empty?
            i -= 1
            @saves << i
          end
        else
          if !Dir.glob("Save0#{i}.rvdata2").empty?
            i -= 1
            @saves << i
          end
        end
      end
      @last = @saves[0]
      @saves.each do |i|
        if DataManager.savefile_time_stamp(i) > DataManager.savefile_time_stamp(@last)
          @last = i
        end
      end
      if R2_AutoSave_AutoLoad::Auto_load
        super
        SceneManager.clear
        fadeout_all
        DataManager.load_game(@last)
        SceneManager.goto(Scene_Map)
      else
        r2_autostart_autoload
      end
    else
      r2_autostart_autoload
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias r2_autosave_load_terminate  terminate
  def terminate
    if R2_AutoSave_AutoLoad::Auto_load == true
      if DataManager.save_file_exists?
        super
      else
        r2_autosave_load_terminate
      end
    else
      r2_autosave_load_terminate
    end
  end
  #--------------------------------------------------------------------------
  # * [Continue] Command
  #--------------------------------------------------------------------------
  def command_continue
    if R2_AutoSave_AutoLoad::Continue_load == true
      DataManager.load_game(@last)
      fadeout_all
      RPG::BGM.fade(30)
      $game_map.autoplay
      SceneManager.goto(Scene_Map)
    else
      close_command_window
      SceneManager.call(Scene_Load)
    end
  end
  
end

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Post Processing for Transferring Player
  #--------------------------------------------------------------------------
  alias r2_autosave_post_transfer   post_transfer
  def post_transfer
    r2_autosave_post_transfer
    @saves = []
    @last = 0
    if DataManager.save_file_exists?
      for i in 0..DataManager.savefile_max
        i += 1
        if i > 9
          if !Dir.glob("Save#{i}.rvdata2").empty?
            i -= 1
            @saves << i
          end
        else
          if !Dir.glob("Save0#{i}.rvdata2").empty?
            i -= 1
            @saves << i
          end
        end
      end
      @last = @saves[0]
      @saves.each do |i|
        if DataManager.savefile_time_stamp(i) > DataManager.savefile_time_stamp(@last)
          @last = i
        end
      end
    end
    if R2_AutoSave_AutoLoad::Use_switch == true && 
      $game_switches[R2_AutoSave_AutoLoad::Switch_Save] == true
      if R2_AutoSave_AutoLoad::Save_Maps.include?($game_map.map_id)
        DataManager.save_game(@last)
      end
    elsif R2_AutoSave_AutoLoad::Save_Maps.include?($game_map.map_id) && 
      R2_AutoSave_AutoLoad::Use_switch == false
      DataManager.save_game(@last)
    end
  end
end

Credit and Thanks
- Roninator2

Terms of use
Free for all RPG Maker VX Ace uses
 
Last edited:

RedRose190

Anna/Misty190
Veteran
Joined
Oct 9, 2018
Messages
100
Reaction score
44
First Language
Greek
Primarily Uses
RMVXA
Thank you for this useful script!

i have a small issue, when i load the load file with those settings (continue load false):

11.png

This pop up

222.png

Edit: I was doing something wrong the script works just fine!
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,132
Reaction score
706
First Language
English
Primarily Uses
RMVXA
Maybe I DO something wrong i am sorry
Are you loading a saved game? try starting a new game and save over your save file then try to load from the title again.
 

RedRose190

Anna/Misty190
Veteran
Joined
Oct 9, 2018
Messages
100
Reaction score
44
First Language
Greek
Primarily Uses
RMVXA
So it turns out that the script work just fine. I tested it on other project and it's working
I am doing something wrong..
Very nice script anyway! thank you again!
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
3,132
Reaction score
706
First Language
English
Primarily Uses
RMVXA
Script updated. Removed 1 save slot restriction.
Now works for as many save slot as you want.
When auto loading, it will load the newest save file.
 

Latest Threads

Latest Posts

Latest Profile Posts

how it looks from the top
Hike was successful guys! I made it to the top!
Add Film-like Visual Effects During Test-Play, Deploy Games with Electron | RPG Maker News #69

brain broken as soon as i figure out whats wrong with my game im taking a long nap
Hey guys anyone is interested in playing my game? Just PM me and I'll give you a Steam key! Here's my latest video! ->

Forum statistics

Threads
112,184
Messages
1,066,434
Members
145,779
Latest member
ilseby
Top