class Interpreter def load_file(filename) # 文件不存在的情况下 unless FileTest.exist?(filename) # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 再生成临时对像 $game_temp = Game_Temp.new # 停止 BGM Audio.bgm_stop # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 写入存档数据 file = File.open(filename, "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 $game_temp.last_file_index = @file_index end end
class Interpreter
def load_file(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 再生成临时对像
$game_temp = Game_Temp.new
# 停止 BGM
Audio.bgm_stop
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 写入存档数据
file = File.open(filename, "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
$game_temp.last_file_index = @file_index
end
end
复制以上代码到你的游戏里面
这样的话,在事件中选择“脚本”,然后输入
load_file(你的文件名,记得加双引号和后缀.rxdata)
就可以了~ |