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,755
Reaction score
14,507
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

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,867
Reaction score
14,520
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

Veteran
Veteran
Joined
Jul 10, 2017
Messages
795
Reaction score
2,900
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

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
294
Reaction score
73
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

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
294
Reaction score
73
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
689
Reaction score
448
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

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
294
Reaction score
73
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
689
Reaction score
448
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

Reforged is laughable
Veteran
Joined
Nov 17, 2019
Messages
294
Reaction score
73
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
 

Latest Threads

Latest Profile Posts

Jeez...
I finally decide, after several ppl asking me to, to create a gamethread about project M... And my internet craps out on me halfway through the process :(
making my first game is like trying to stuff all my experience with old games into one
so its slow and painful when i dont get it right... i bet the next game is gonna be finished earlier!
When you don't find any time to work... :kaocry:
First Ten Minutes of my Caretaker inspired game

Finally, I got a good Gmail message [from smg5urded]
"This game does look a bit plain, but, I'm sure this does not destroy the experience as a whole. Monsters fit your style of game-play, mapping looks crude but I'm sure you can make it better if you do a remake of Forgotten Eclipse"

Forum statistics

Threads
110,397
Messages
1,052,970
Members
143,458
Latest member
KyN19
Top