Project1
标题:
【120929】凌的容错脚本v3[三版兼容+事件中脚本容错]
[打印本页]
作者:
凌童鞋
时间:
2012-9-27 23:29
标题:
【120929】凌的容错脚本v3[三版兼容+事件中脚本容错]
本帖最后由 凌童鞋 于 2012-9-30 14:19 编辑
通用版本
#==============================================================================
# ■ 凌的容错脚本 v3 [120929]
#------------------------------------------------------------------------------
# 解决游戏因发布时缺少文件等错误而使游戏无法正常进行的问题。
# 附赠功能:创建多层文件夹
#==============================================================================
# [120927]:基础版,支持Bitmap及Audio容错
# [120928]:修正IOError问题,感谢orzFly和雷达喵
# [120928]:支持Graphics.transition容错及save_data自动创建目录
# 修正部分BUG,感谢霜月冬音
#==============================================================================
File.open("errors.txt","w+"){|io|}
class Dir
class << self
alias :lynn_mkdir :mkdir unless $@
end
def self.mkdir(path, mode = 0777)
last_dir = ""
path.gsub(/\w*\//) {|m|
m.gsub(/\/|\\/){}
if last_dir != ""
last_dir = "#{last_dir}/#{m}"
else
last_dir = "#{m}"
end
if !FileTest.exist?(m) && !FileTest.directory?(m)
self.lynn_mkdir(last_dir)
end
}
end
end
module Kernel
def write_errors(argu)
open("errors.txt","a+"){|io| io.write(argu+"\n")if !io.read.to_s.include?(argu)}
end
def save_data(obj, filename)
Dir.mkdir(filename) unless FileTest.exist?(filename)
File.open(filename, "wb") { |io|
Marshal.dump(obj, io)
}
end
end
class Bitmap
alias :lynn_initialize :initialize unless $@
def initialize(* argu)
begin
lynn_initialize(* argu)
rescue Errno::ENOENT
lynn_initialize(1,1)
write_errors "Error:File not found on Bitmap.new\n#{argu[0]}"
end
end
end
module Audio
class << self
alias_method :lynn_bgm_play, :bgm_play unless $@
alias_method :lynn_bgs_play, :bgs_play unless $@
alias_method :lynn_me_play, :me_play unless $@
alias_method :lynn_se_play, :se_play unless $@
end
def self.bgm_play(* argu)
begin
self.lynn_bgm_play(* argu)
rescue Errno::ENOENT
write_errors "Error:File not found on Audio.bgm_play\n#{argu[0]}"
end
end
def self.bgs_play(* argu)
begin
self.lynn_bgs_play(* argu)
rescue Errno::ENOENT
write_errors "Error:File not found on Audio.bgs_play\n#{argu[0]}"
end
end
def self.me_play(* argu)
begin
self.lynn_me_play(* argu)
rescue Errno::ENOENT
write_errors "Error:File not found on Audio.me_play\n#{argu[0]}"
end
end
def self.se_play(* argu)
begin
self.lynn_se_play(* argu)
rescue Errno::ENOENT
write_errors "Error:File not found on Audio.se_play\n#{argu[0]}"
end
end
end
module Graphics
class << self
alias_method :lynn_transition, :transition unless $@
end
def self.transition(duration = 8, filename = "", vague = 40)
if filename != ""
if !FileTest.exist?(filename)
write_errors "Error:File not found on Graphics.transition\n#{filename}"
filename = ""
end
end
self.lynn_transition(duration,filename,vague)
end
end
复制代码
附加包
#==============================================================================
# ■ 凌的容错脚本 v3 附加包 [120929] [RMVA版本]
#------------------------------------------------------------------------------
# 解决游戏因发布时缺少文件等错误而使游戏无法正常进行的问题。
#==============================================================================
# [120929]:支援在事件中执行脚本的容错功能,同时输出所在地图与事件ID
#==============================================================================
# * 注意本脚本只能用于标准事件解释器结构的工程
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 脚本
#--------------------------------------------------------------------------
def command_355
script = @list[@index].parameters[0] + "\n"
while next_event_code == 655
@index += 1
script += @list[@index].parameters[0] + "\n"
end
begin
eval(script)
rescue
write_errors "Error on eval script\nMapID:#{@map_id}\nEventID:#{@event_id}"
write_errors "Script:\n#{script}ErrorMessage:\n#{$!.message}"
return
end
end
end
复制代码
#==============================================================================
# ■ 凌的容错脚本 v3 附加包 [120929] [RMVX版本]
#------------------------------------------------------------------------------
# 解决游戏因发布时缺少文件等错误而使游戏无法正常进行的问题。
#==============================================================================
# [120929]:支援在事件中执行脚本的容错功能,同时输出所在地图与事件ID
#==============================================================================
# * 注意本脚本只能用于标准事件解释器结构的工程
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 脚本
#--------------------------------------------------------------------------
def command_355
script = @list[@index].parameters[0] + "\n"
loop do
if @list[@index+1].code == 655 # 下一个事件指令在脚本2行以上的情况下
script += @list[@index+1].parameters[0] + "\n"
else
break
end
@index += 1
end
begin
eval(script)
rescue
write_errors "Error on eval script\nMapID:#{@map_id}\nEventID:#{@event_id}"
write_errors "Script:\n#{script}ErrorMessage:\n#{$!.message}"
return
end
return true
end
end
复制代码
#==============================================================================
# ■ 凌的容错脚本 v3 附加包 [120929] [RMXP版本]
#------------------------------------------------------------------------------
# 解决游戏因发布时缺少文件等错误而使游戏无法正常进行的问题。
#==============================================================================
# [120929]:支援在事件中执行脚本的容错功能,同时输出所在地图与事件ID
#==============================================================================
# * 注意本脚本只能用于标准事件解释器结构的工程
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# ● 脚本
#--------------------------------------------------------------------------
def command_355
# script 设置第一行
script = @list[@index].parameters[0] + "\n"
# 循环
loop do
# 下一个事件指令在脚本 2 行以上的情况下
if @list[@index+1].code == 655
# 添加到 script 2 行以后
script += @list[@index+1].parameters[0] + "\n"
# 事件指令不在脚本 2 行以上的情况下
else
# 中断循环
break
end
# 推进索引
@index += 1
end
# 评价
result = eval(script)
# 返回值为 false 的情况下
if result == false
# 结束
return false
end
# 继续
return true
end
end
复制代码
作者:
Luciffer
时间:
2012-9-27 23:32
嗯,好东西,塞个糖~
作者:
越前リョーマ
时间:
2012-9-30 11:19
还支持输出已经开挂了囧,话说VA容错终于呼之欲出了啊
作者:
Luciffer
时间:
2012-10-3 14:17
正好拿来在草莓塔(大雾)里测试一下。。。
作者:
和风一人
时间:
2012-11-24 11:04
好东西谢谢楼主。
作者:
tim315121
时间:
2013-3-4 17:59
挖出来问一下
VA要如何让他略过错误却不输出ERRORS.TXT出来?
作者:
凌童鞋
时间:
2013-3-6 06:11
标题:
RE: 【120929】凌的容错脚本v3
tim315121 发表于 2013-3-4 17:59
挖出来问一下
VA要如何让他略过错误却不输出ERRORS.TXT出来?
把12行和34行注释掉
作者:
命真苦
时间:
2013-5-19 09:00
顶一个!继续努力哦!
作者:
mileo
时间:
2014-5-11 13:40
感谢凌童鞋写的容错脚本
先前游戏报错,因为用了这个脚本而解决问题~~
因为还用了
http://cacaosoft.webcrow.jp/script/rgss3/
的 图像保存和スクリーンショット 功能
只是一按Print Screen就显示不能保存图片
请问这个该怎么解决呢? THX
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1