Autosave script ¿it is possible? ¿exists?

sebarz

Call me Seba
Member
Joined
Feb 12, 2016
Messages
19
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
13,224
Reaction score
13,760
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
39,652
Reaction score
13,264
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
19
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

I make youtube videos
Veteran
Joined
Jul 10, 2017
Messages
710
Reaction score
2,838
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
19
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
166
Reaction score
35
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
19
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
166
Reaction score
35
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
647
Reaction score
423
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
166
Reaction score
35
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
647
Reaction score
423
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
166
Reaction score
35
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

ESAMarathon on Twitch, now streaming "Eat Girl". Yep, that's the title of a game... Apparently it's a Pacman knockoff.... Which is of course the only logical conclusion one would get from a name like "Eat Girl". :kaopride: I can't believe anybody would think anything else! :kaoback:
Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.

Forum statistics

Threads
100,607
Messages
977,781
Members
132,220
Latest member
lightnvs
Top