查看: 1826|回复: 2

[已经过期] RMXP 自动存档,读档时按ESC出错

[复制链接]
梦石
0
星屑
153
在线时间
120 小时
注册时间
2011-9-4
回帖
70
发表于 2015-5-30 22:08:29 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 RyanBern 于 2015-5-31 12:01 编辑

下面是那个脚本,不知道是不是出错在这里。

DWHQB8ZMQ8HL}B14SYKY2GO.png {YS739NCOP~}WBTWT(G[U]8.png

出错之后,原来那个Save就变成0字节的文件了……

  1. module Kernel
  2. alias origin_exit exit unless method_defined? :exit
  3. def exit(*args)
  4.    case $scene
  5.    when Scene_Map
  6.      AutoSave.common_save unless $game_system.map_interpreter.running?
  7.    when Scene_Battle
  8.      AutoSave.common_save unless $game_system.battle_interpreter.running?
  9.    else
  10.      if $scene.type != NilClass and $scene.type != Scene_Title
  11.        AutoSave.common_save
  12.      end
  13.    end
  14.    origin_exit(*args)
  15. end
  16. end
  17. module AutoSave
  18. if @scene_proc.nil?
  19.    @last_scene = nil.class
  20.    @scene_proc = proc do |value|
  21.      if value.nil? or value.is_a?(Scene_Title)
  22.        if @last_scene != NilClass and @last_scene != Scene_Title
  23.          AutoSave.common_save
  24.        end
  25.      end
  26.      @last_scene = value.type
  27.    end
  28.    trace_var(:$scene,@scene_proc)  
  29. end
  30.   
  31. module_function
  32.   
  33. def common_save
  34.    filename = "Save#{$game_temp.last_file_index + 1}.rxdata"
  35.    file = File.open(filename, "wb")
  36.    write_save_data(file)
  37.    file.close
  38. end
  39.   
  40. def write_save_data(file)
  41.    characters = []
  42.    for i in 0...$game_party.actors.size
  43.      actor = $game_party.actors[i]
  44.      characters.push([actor.character_name, actor.character_hue])
  45.    end
  46.    Marshal.dump(characters, file)
  47.    Marshal.dump(Graphics.frame_count, file)
  48.    $game_system.save_count += 1
  49.    $game_system.magic_number = $data_system.magic_number
  50.    Marshal.dump($game_system, file)
  51.    Marshal.dump($game_switches, file)
  52.    Marshal.dump($game_variables, file)
  53.    Marshal.dump($game_self_switches, file)
  54.    Marshal.dump($game_screen, file)
  55.    Marshal.dump($game_actors, file)
  56.    Marshal.dump($game_party, file)
  57.    Marshal.dump($game_troop, file)
  58.    Marshal.dump($game_map, file)
  59.    Marshal.dump($game_player, file)
  60. end
  61. end
复制代码
梦石
0
星屑
153
在线时间
120 小时
注册时间
2011-9-4
回帖
70
 楼主| 发表于 2015-5-31 20:11:06 | 显示全部楼层
yourenma^^^^^^^
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2015-5-31 20:43:55 | 显示全部楼层
把第10行改成酱试下
  1. if $scene.type != NilClass and $scene.type != Scene_Title and  $game_party
复制代码
xp vx va mv  va mz 各类型脚本/插件定制
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部