Autor : Darkleo
Version : 1.0
Feature :
This script has 4 features :
* It allows you to make a save using events
* It allows you to use a save using events
* It add an automatic save (invisible)
* It allows you to copy or erase saves
I think you don't need screenshoot ^^
Script :
I'm French, and I know I'm not very good at English, so please correct me ^^
Enjoy ! (or not)
Version : 1.0
Feature :
This script has 4 features :
* It allows you to make a save using events
* It allows you to use a save using events
* It add an automatic save (invisible)
* It allows you to copy or erase saves
I think you don't need screenshoot ^^
Script :
Code:
#====================================================================
# â– Module Sauvegarde
#====================================================================
# Auteur : Darkleo
# Script : Save utility
#====================================================================
# ==> In command "Insert script" <==
# Save : sauver(X)
# Load : charger(X)
# Automatic save (invisible) : autosave ou autoload
# Copy a save : copier(a,b)
# --> copy slot a into slot b
# Erase a save : supprimer(X)
# ==> In a condition "If script :" <==
# Verify if the save exist : testfile(X)
#
# "X" correspond to the slot save expected
# Use 0 for autosave
#
# Examples :
# charger(2) --> load slot 2
# autosave --> make an automatic save
# copier(0,4) --> copy the automatic save into the slot 4
#====================================================================
module Sauvegarde
module_function
#--------------------------------------------------------------------------
def testfile(file)
filename = (file == 0 ? "Autosave.rxdata" : "Save#{a}.rxdata")
FileTest.exist?(filename)
end
#--------------------------------------------------------------------------
def sauver(file)
file = File.open("Save#{file}.rxdata", "wb")
write_save_data(file) ; file.close
end
#--------------------------------------------------------------------------
def charger(file)
return if not FileTest.exist?("Save#{file}.rxdata")
file = File.open("Save#{file}.rxdata", "rb")
read_save_data(file) ; file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
def autosave
file = File.open("Autosave.rxdata", "wb")
write_save_data(file) ; file.close
end
#--------------------------------------------------------------------------
def autoload
return if not FileTest.exist?("Autosave.rxdata")
file = File.open("Autosave.rxdata", "rb")
read_save_data(file) ; file.close
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
def copier(a,b)
return if a == b
filename = (a == 0 ? "Autosave.rxdata" : "Save#{a}.rxdata")
return if testfile(filename)
source = File.open(filename, "rb")
filename2 = (b == 0 ? "Autosave.rxdata" : "Save#{b}.rxdata")
destination = File.open(filename2, "wb")
destination.write(source.read)
source.close ; destination.close
end
#--------------------------------------------------------------------------
def supprimer(file)
filename = (file == 0 ? "Autosave.rxdata" : "Save#{file}.rxdata")
File.delete(filename) if testfile(filename)
end
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
$game_system.save_count += 1
$game_system.magic_number = $data_system.magic_number
[characters, Graphics.frame_count, $game_system,
$game_switches, $game_variables, $game_self_switches,
$game_screen, $game_actors, $game_party, $game_troop,
$game_map, $game_player].each {|v| Marshal.dump(v, file)}
end
#--------------------------------------------------------------------------
def read_save_data(file)
list = %Q(characters, Graphics.frame_count, $game_system,
$game_switches, $game_variables, $game_self_switches,
$game_screen, $game_actors, $game_party, $game_troop,
$game_map, $game_player) ; list.gsub!(/ /, "")
list.gsub!(/\n/, "") ; list = list.split(',')
list.each {|n| eval "#{n} = Marshal.load(file)"}
if $game_system.magic_number != $data_system.magic_number
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
$game_party.refresh
end
#--------------------------------------------------------------------------
end
#====================================================================
#====================================================================
class Interpreter
include Sauvegarde
end
#====================================================================
I'm French, and I know I'm not very good at English, so please correct me ^^
Enjoy ! (or not)