class Interpreter
def tosave #存档事件脚本
file = File.open("Save/save.rxdata", "wb")
# 生成描绘存档文件用的角色图形
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
characters.push([actor.character_name, actor.character_hue])
end
# 写入描绘存档文件用的角色数据
Marshal.dump(characters, file)
# 写入测量游戏时间用画面计数
Marshal.dump(Graphics.frame_count, file)
# 保存魔法编号
# (将编辑器保存的值以随机值替换)
$game_system.magic_number = $data_system.magic_number
# 写入各种游戏对像
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)
file.close
end
def toload #读档事件脚本
file = File.open("Save/save.rxdata", "rb")
# 读取描绘存档文件用的角色数据
characters = Marshal.load(file)
# 读取测量游戏时间用画面计数
Graphics.frame_count = Marshal.load(file)
# 读取各种游戏对像
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = 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)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
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
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
openmaps if $game_switches[MAP_SWI_ID]
eval File.read('txt/lovestory.txt')
eval File.read('txt/story1-1.txt') if $game_variables[152] == 1
eval File.read('txt/story1-2.txt') if $game_variables[152] == 2
end
def delsave #删档事件脚本
file = File.delete("Save/save.rxdata")
end
end