Autosave script ¿it is possible? ¿exists?

sebarz

Call me Seba
Member
Joined
Feb 12, 2016
Messages
14
Reaction score
1
First Language
Spanish
Primarily Uses
N/A
Hello everybody, i hope you're doing well.

I wondering if there exists any script to enable an autosave on my project.

Any type of script or similar thing it helps alot.

Thanks in advance.
Regards
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,528
Reaction score
12,837
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.

 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,352
Reaction score
11,942
First Language
English
Primarily Uses
RMMV
What type of autosave? You should probably be a bit more specific about when you want the saves to occur.
 

sebarz

Call me Seba
Member
Joined
Feb 12, 2016
Messages
14
Reaction score
1
First Language
Spanish
Primarily Uses
N/A
Hello and sorry!

I will more careful the next time.

About Shaz comment:

i want a way to trigger a autosave. What i mean is. I want the game itself automactlly saves the adventure in determinates moments: Before a scene, passing by a event or from a script call.

Instead to make a manual save:
----menu > save game.
I would like the system automatically save the game responding to certain triggers

I hope is more understable now
 

FleshToDust

Eventer, Disliker of Plugins
Veteran
Joined
Jul 10, 2017
Messages
526
Reaction score
2,623
First Language
English
Primarily Uses
RMMV
You could always have it save in specific events at those critical points. Don't even need to open the save menu.
All you need is a script call. It'll happen automatically. You can just put a small animation to let the player know it's saving.

Code:
$gameSystem.onBeforeSave();
DataManager.saveGame( 1 );
 

sebarz

Call me Seba
Member
Joined
Feb 12, 2016
Messages
14
Reaction score
1
First Language
Spanish
Primarily Uses
N/A
A-Moonless-Night, hello!

Yes, thats right. Is for RPG Maker VX, no VX ACE
 

kyonides

Veteran
Veteran
Joined
Nov 17, 2019
Messages
53
Reaction score
12
First Language
English
Primarily Uses
RMXP
Code:
# * Script Call *
#  GameFile.save

module GameFile
  FILENAME = 'AutoSaveGame' # Actual save game filename no extension
  def self.save
    File.open(FILENAME + '.rvdata', 'wb'){|file| write_data(file) }
  end

  def self.write_data(file)
    characters = []
    $game_party.members.each do |actor|
      characters.push([actor.character_name, actor.character_index])
    end
    $game_system.auto_save_count += 1
    $game_system.version_id = $data_system.version_id
    @last_bgm = RPG::BGM::last
    @last_bgs = RPG::BGS::last
    Marshal.dump(characters,           file)
    Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(@last_bgm,            file)
    Marshal.dump(@last_bgs,            file)
    Marshal.dump($game_system,         file)
    Marshal.dump($game_message,        file)
    Marshal.dump($game_switches,       file)
    Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches,  file)
    Marshal.dump($game_actors,         file)
    Marshal.dump($game_party,          file)
    Marshal.dump($game_troop,          file)
    Marshal.dump($game_map,            file)
    Marshal.dump($game_player,         file)
    additional_data(file)
  end
  # Add as many lines of code here as needed
  # Format: Marshal.dump(object, file)
  # where "object" is any kind of game variable
  def self.additional_data(file)
    # Replace with actual code in case you need a customized save file
  end
end

class Game_System
  alias :kyon_gm_sys_init :initialize
  def initialize
    kyon_gm_sys_init
    @auto_save_count = 0
  end
end
 

sebarz

Call me Seba
Member
Joined
Feb 12, 2016
Messages
14
Reaction score
1
First Language
Spanish
Primarily Uses
N/A
@kyonides hi! Sorry for the delay je...

I tried your script, i have a little error:
1579324963971.png
I guess is something about the slot assignement or the moment that this is defined, but to be honest... no idea. So i let here my error, i hope you can helpe me but no hurries.

Thanks again.
Regards
 

kyonides

Veteran
Veteran
Joined
Nov 17, 2019
Messages
53
Reaction score
12
First Language
English
Primarily Uses
RMXP
For the time being you could just place a pound symbol # right before that line that includes it, that's what we usually call to comment out some darn line.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
545
Reaction score
382
First Language
English
Primarily Uses
RMVXA
You just need to add an attr_accessor call:
Ruby:
class Game_System
    attr_accessor :auto_save_count
end
 
Last edited:

kyonides

Veteran
Veteran
Joined
Nov 17, 2019
Messages
53
Reaction score
12
First Language
English
Primarily Uses
RMXP
Nah, that would make it worse since the variable is equal to nil not zero 0 so it's easier to skip the $game_system.autosave_count line since it's not mandatory to include it in sebarz's game AFAIK.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
545
Reaction score
382
First Language
English
Primarily Uses
RMVXA
@kyonides But you've already set the variable to zero in the initialize method in the script you posted. The error is coming from GameFile.write_data trying to add to the variable and Game System not having a getter or setter method for it.
 

kyonides

Veteran
Veteran
Joined
Nov 17, 2019
Messages
53
Reaction score
12
First Language
English
Primarily Uses
RMXP
Try this scriptlet. It also includes the load saved game file feature.

Code:
# * AutoSave GameFile
#   Scripter : Kyonides Arkanthes

# * Script Calls *
#  GameFile.save
#  GameFile.load

module GameFile
  FILENAME = 'AutoSaveGame' # Actual save game filename no extension
  def self.save
    File.open(FILENAME + '.rvdata', 'wb'){|file| write_data(file) }
  end

  def self.load
    File.open(FILENAME + '.rvdata', 'rb'){|file| read_data(file) }
  end

  def self.write_data(file)
    characters = []
    $game_party.members.each do |actor|
      characters << [actor.character_name, actor.character_index]
    end
    Marshal.dump(characters,           file)
    Marshal.dump(Graphics.frame_count, file)
    Marshal.dump(RPG::BGM.last,        file)
    Marshal.dump(RPG::BGS.last,        file)
    Marshal.dump($game_system,         file)
    Marshal.dump($game_message,        file)
    Marshal.dump($game_switches,       file)
    Marshal.dump($game_variables,      file)
    Marshal.dump($game_self_switches,  file)
    Marshal.dump($game_actors,         file)
    Marshal.dump($game_party,          file)
    Marshal.dump($game_troop,          file)
    Marshal.dump($game_map,            file)
    Marshal.dump($game_player,         file)
    save_additional_data(file)
  end
  # Add as many lines of code here as needed
  # Format: Marshal.dump(object, file)
  # where "object" is any kind of game variable
  def self.save_additional_data(file)
    # Replace with actual code in case you need a customized save file
  end

  def self.read_data(file)
    characters = Marshal.load(file)
    Graphics.frame_count = Marshal.load(file)
    bgm = Marshal.load(file)
    bgs = Marshal.load(file)
    $game_system = Marshal.load(file)
    $game_message = Marshal.load(file)
    $game_switches = Marshal.load(file)
    $game_variables = Marshal.load(file)
    $game_self_switches = Marshal.load(file)
    $game_actors = Marshal.load(file)
    $game_party = Marshal.load(file)
    $game_troop = Marshal.load(file)
    $game_map = Marshal.load(file)
    $game_player = Marshal.load(file)
    load_additional_data(file)
    $game_map.setup($game_map.map_id)
    $game_player.center($game_player.x, $game_player.y)
    $scene = Scene_Map.new
    RPG::BGM.fade(1500)
    Graphics.fadeout(60)
    Graphics.wait(40)
    bgm.play
    bgs.play
  end
  # Add as many lines of code here as needed
  # Format: object = Marshal.load(file)
  # where "object" is any kind of game variable
  def self.load_additional_data(file)
    # Replace with actual code in case you need to load customized data
  end
end
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I'm having such a hard time thinking of an interesting battle system. and not being a coder, certain things I wanna do seem a lot harder lol.
Created a character outline with some code. I have no use for this. I'm....bored.....
Having lots of fun using different PS brushes to add a lil' texture to the floors and walls in my maps.
Setup a system to cull enemies that are too far from the player to matter, and to spawn new ones just outside of view. Take that lag! :LZSexcite:

Forum statistics

Threads
93,719
Messages
914,897
Members
123,321
Latest member
harmlessgamedev
Top