加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 RyanBern 于 2015-5-31 12:01 编辑
下面是那个脚本,不知道是不是出错在这里。
出错之后,原来那个Save就变成0字节的文件了……
module Kernel alias origin_exit exit unless method_defined? :exit def exit(*args) case $scene when Scene_Map AutoSave.common_save unless $game_system.map_interpreter.running? when Scene_Battle AutoSave.common_save unless $game_system.battle_interpreter.running? else if $scene.type != NilClass and $scene.type != Scene_Title AutoSave.common_save end end origin_exit(*args) end end module AutoSave if @scene_proc.nil? @last_scene = nil.class @scene_proc = proc do |value| if value.nil? or value.is_a?(Scene_Title) if @last_scene != NilClass and @last_scene != Scene_Title AutoSave.common_save end end @last_scene = value.type end trace_var(:$scene,@scene_proc) end module_function def common_save filename = "Save#{$game_temp.last_file_index + 1}.rxdata" file = File.open(filename, "wb") write_save_data(file) file.close 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 Marshal.dump(characters, file) Marshal.dump(Graphics.frame_count, file) $game_system.save_count += 1 $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) end end
module Kernel
alias origin_exit exit unless method_defined? :exit
def exit(*args)
case $scene
when Scene_Map
AutoSave.common_save unless $game_system.map_interpreter.running?
when Scene_Battle
AutoSave.common_save unless $game_system.battle_interpreter.running?
else
if $scene.type != NilClass and $scene.type != Scene_Title
AutoSave.common_save
end
end
origin_exit(*args)
end
end
module AutoSave
if @scene_proc.nil?
@last_scene = nil.class
@scene_proc = proc do |value|
if value.nil? or value.is_a?(Scene_Title)
if @last_scene != NilClass and @last_scene != Scene_Title
AutoSave.common_save
end
end
@last_scene = value.type
end
trace_var(:$scene,@scene_proc)
end
module_function
def common_save
filename = "Save#{$game_temp.last_file_index + 1}.rxdata"
file = File.open(filename, "wb")
write_save_data(file)
file.close
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
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
$game_system.save_count += 1
$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)
end
end
|