Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
QuesTMajoR

[REQUEST] Auto-save Script

Recommended Posts

Do you have one? Plug and Play ..

The auto-save script that saves everytime the map location is changing .. :) Thank you ..

Share this post


Link to post
Share on other sites

Here's my version. I recomend you to check Mark's link for a better one, but incase you just need a simpler one, then take mine :)

#==============================================================================
# Autosave by Black Mage
#------------------------------------------------------------------------------
#  This class performs save screen processing.
#==============================================================================
class Auto_Save
  def initialize
  end
  def main
    on_decision("Save1.rxdata")
    Graphics.freeze
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Decision Processing
  #--------------------------------------------------------------------------
  def on_decision(filename)
    file = File.open(filename, "wb")
    write_save_data(file)
    file.close
  end
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  def write_save_data(file)
    # Make character data for drawing save file
    characters = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      characters.push([actor.character_name, actor.character_hue])
    end
    # Write character data for drawing save file
    Marshal.dump(characters, file)
    # Wrire frame count for measuring play time
    Marshal.dump(Graphics.frame_count, file)
    # Increase save count by 1
    $game_system.save_count += 1
    # Save magic number
    # (A random value will be written each time saving with editor)
    $game_system.magic_number = $data_system.magic_number
    # Write each type of game object
    Marshal.dump($game_system, file)
    Marshal.dump($game_switches, file)
    Marshal.dump($game_variables, file)
    Marshal.dump($game_self_switches, file)
    Marshal.dump($game_screen, 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)
  end
end

This script will automaticaly save your game to the first slot, so yeah, it'll only work on a game that using 1 save file.

$scene = Auto_Save.new

Put this on script call everytime you change the map location to autosave the game.

Edited by black mage

Share this post


Link to post
Share on other sites

Let me make it a wee bit more convenient.

I took Lizzie's autosave script and made it to automatically save whenever the player leaves the map. This way you won't have to use any annoying calls to make it work.

 

 

=begin
I. Introduction.
II. Instructions.
III. Additional information.

I. Introduction.
This script adds autosaves in your game, additionally it saves the game
automatically every time the player leaves the map.

II. Instructions.
To install this script place it below all default scripts and above main.
Give the scripters their due credit in your game.
Visit the website specified bellow for help.

III. Additional information.
Website: gdunlimited.net
Original script: Lizzie
Modded by: Saltome
Script revision: 2
=end
class Game_Map
alias old_setup setup
def setup(map_id)
old_setup(map_id)
Autosave.save
end
end

module Autosave

def self.save
filename = make_filename(0)
file = File.open(filename, "wb")
write_save_data(file)
file.close
end

def self.write_save_data(file)
# Make character data for drawing save file
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors
characters.push([actor.character_name, actor.character_hue])
end
# Write character data for drawing save file
Marshal.dump(characters, file)
# Wrire frame count for measuring play time
Marshal.dump(Graphics.frame_count, file)
# Increase save count by 1
$game_system.save_count += 1
# Save magic number
# (A random value will be written each time saving with editor)
$game_system.magic_number = $data_system.magic_number
# Write each type of game object
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, 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)
end

def self.make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end


class Window_SaveFile < Window_Base
def refresh
self.contents.clear
self.contents.font.color = normal_color
if @file_index == 0
name = "Autosave"
if $scene.is_a?(Scene_Save)
self.contents.font.color = disabled_color
end
else
name = "File #{@file_index}"
self.contents.font.color = normal_color
end
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
if @file_exist
for i in 0...@characters.size
bitmap = RPG::Cache.character(@characters[0], @characters[1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 300 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 8, 600, 32, time_string, 2)
self.contents.font.color = normal_color
time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(4, 40, 600, 32, time_string, 2)
end
end
end

class Scene_Save < Scene_File

alias lizzie_autosave_ss_ondec on_decision

def on_decision(filename)
if filename.include?("Save1.rxdata")
$game_system.se_play($data_system.buzzer_se)
return
end
lizzie_autosave_ss_ondec(filename)
end
end

 

 

Edited by Saltome

Share this post


Link to post
Share on other sites

Let me make it a wee bit more convenient.

I took Lizzie's autosave script and made it to automatically save whenever the player leaves the map. This way you won't have to use any annoying calls to make it work.

 

 

=begin

I. Introduction.

II. Instructions.

III. Additional information.

 

I. Introduction.

This script adds autosaves in your game, additionally it saves the game

automatically every time the player leaves the map.

 

II. Instructions.

To install this script place it below all default scripts and above main.

Give the scripters their due credit in your game.

Visit the website specified bellow for help.

 

III. Additional information.

Website: gdunlimited.net

Original script: Lizzie

Modded by: Saltome

Script revision: 2

=end

class Game_Map

alias old_setup setup

def setup(map_id)

old_setup(map_id)

Autosave.save

end

end

 

module Autosave

 

def self.save

filename = make_filename(0)

file = File.open(filename, "wb")

write_save_data(file)

file.close

end

 

def self.write_save_data(file)

# Make character data for drawing save file

characters = []

for i in 0...$game_party.actors.size

actor = $game_party.actors

characters.push([actor.character_name, actor.character_hue])

end

# Write character data for drawing save file

Marshal.dump(characters, file)

# Wrire frame count for measuring play time

Marshal.dump(Graphics.frame_count, file)

# Increase save count by 1

$game_system.save_count += 1

# Save magic number

# (A random value will be written each time saving with editor)

$game_system.magic_number = $data_system.magic_number

# Write each type of game object

Marshal.dump($game_system, file)

Marshal.dump($game_switches, file)

Marshal.dump($game_variables, file)

Marshal.dump($game_self_switches, file)

Marshal.dump($game_screen, 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)

end

 

def self.make_filename(file_index)

return "Save#{file_index + 1}.rxdata"

end

end

 

 

class Window_SaveFile < Window_Base

def refresh

self.contents.clear

self.contents.font.color = normal_color

if @file_index == 0

name = "Autosave"

if $scene.is_a?(Scene_Save)

self.contents.font.color = disabled_color

end

else

name = "File #{@file_index}"

self.contents.font.color = normal_color

end

self.contents.draw_text(4, 0, 600, 32, name)

@name_width = contents.text_size(name).width

if @file_exist

for i in 0...@characters.size

bitmap = RPG::Cache.character(@characters[0], @characters[1])

cw = bitmap.rect.width / 4

ch = bitmap.rect.height / 4

src_rect = Rect.new(0, 0, cw, ch)

x = 300 - @characters.size * 32 + i * 64 - cw / 2

self.contents.blt(x, 68 - ch, bitmap, src_rect)

end

hour = @total_sec / 60 / 60

min = @total_sec / 60 % 60

sec = @total_sec % 60

time_string = sprintf("%02d:%02d:%02d", hour, min, sec)

self.contents.font.color = normal_color

self.contents.draw_text(4, 8, 600, 32, time_string, 2)

self.contents.font.color = normal_color

time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")

self.contents.draw_text(4, 40, 600, 32, time_string, 2)

end

end

end

 

class Scene_Save < Scene_File

 

alias lizzie_autosave_ss_ondec on_decision

 

def on_decision(filename)

if filename.include?("Save1.rxdata")

$game_system.se_play($data_system.buzzer_se)

return

end

lizzie_autosave_ss_ondec(filename)

end

end

 

 

Thanks for this! :)) close the topic now .. It's through !

Share this post


Link to post
Share on other sites

Thanks for this! :)) close the topic now .. It's through !

Cool! :ok:

Closing!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...