04-10-2023, 02:23 AM
SaveUpdate Scriptlet
ACE Version
by Kyonides Arkanthes
Introduction
There was a user that once wanted to add a very specific feature to the game header, namely the current map's name. Well, this scriptlet should let you modify all of your existing saved games by automatically adding that name to the hash for you.
Warnings
- It has no GUI at all, guys!
- This is a temporary scriptlet. Do not include it your official releases!
- Be wise and backup the game files beforehand.
Code:
# * SaveUpdate Scriptlet ACE * #
# Scripter : Kyonides Arkanthes
# 2023-04-09
# This scriptlet facilitates the update of your old saved games by adding
# secondary features like Current Map's Name and the like to the header.
# It has no graphical interface at all. Not like it ever needed one, though.
# * Scriptlet Published and Distributed AS IS. * #
# I might refuse any user's request for upgrade or maintenance releases. #
module SaveUpdate
FILENAME_TEMPLATE = 'Save*.rvdata2'
INCLUDE_MAPNAME = true
extend self
@header = {}
def extend_header
if INCLUDE_MAPNAME
@header[:map_name] = $game_map.display_name
end
end
def load_game_file(filename)
File.open(filename, "rb") do |file|
@header = Marshal.load(file)
contents = Marshal.load(file)
DataManager.extract_save_contents(contents)
end
end
def save_game_file(filename)
extend_header
File.open(filename, "wb") do |file|
Marshal.dump(@header, file)
Marshal.dump(DataManager.make_save_contents, file)
end
@header.clear
end
def update_game_file(filename)
load_game_file(filename)
save_game_file(filename)
end
def clear_global_vars
$game_system = nil
$game_timer = nil
$game_message = nil
$game_switches = nil
$game_variables = nil
$game_self_switches = nil
$game_actors = nil
$game_party = nil
$game_troop = nil
$game_map = nil
$game_player = nil
end
def run
filenames = Dir.glob(FILENAME_TEMPLATE).sort
if filenames.empty?
msgbox "SaveUpdate Script Notice:\nNo game file was ever found!"
return
end
DataManager.load_normal_database
filenames.each{|fn| update_game_file(fn) }
clear_global_vars
end
run
end
Terms & Conditions
Free for use in any kind of game.
Do not repost it anywhere!
Do not make any personal requests!
Distributed AS IS.