月下独孤 发表于 2011-6-11 19:24:32

容错脚本 第3版


#==============================================================================
# ■ 容错脚本第3版(070816修订)                                   BY 轮回者
#------------------------------------------------------------------------------
#  本脚本基于星大叔的容错脚本第2版,区别只是“下手”的地方不同而已。
#  说明请参看星大叔的容错脚本第2版。
#------------------------------------------------------------------------------
#  07.08.16
#     修正了按下F12重启后的错误
#     附,出错原因:重启后RMXP封装的类没有重置
#==============================================================================
begin
  result = Graphics::Transition.nil?
rescue
  result = true
end
if result
  
  $need_file_bitmap = []
  if FileTest.exist?("log_bitmap.txt")
    f = File.open("./log_bitmap.txt","r")
    $need_file_bitmap = f.read.split(/\n/)
    f.close
  end
  module Graphics
    Transition = method("transition")
    def self.transition(*arg)
      begin
        Transition.call(*arg)
      rescue Errno::ENOENT
        ary=[*arg]
        filename=ary
        unless $need_file_bitmap.include?(filename)
          $need_file_bitmap.push(filename)
          f = File.open("./log_bitmap.txt","a")
          f.write(filename + "\n")
          f.close
        end
        Transition.call(ary)
      end
    end
  end
  class Bitmap < Object
    alias ini_Fx initialize
     
    def initialize(*args)
      begin
        ini_Fx(*args)
        return
      rescue Errno::ENOENT
        filename=[*args]
        unless $need_file_bitmap.include?(filename)
          $need_file_bitmap.push(filename)
          f = File.open("./log_bitmap.txt","a")
          f.write(filename + "\n")
          f.close
        end
        ini_Fx(32,32)
      end
    end
  end
  $need_file_audio = []
  if FileTest.exist?("log_audio.txt")
    f = File.open("./log_audio.txt","r")
    $need_file_audio = f.read.split(/\n/)
    f.close
  end
  
  module Audio
    Me_play = method("me_play")
    def self.me_play(*arg)
      begin
        Me_play.call(*arg)
      rescue Errno::ENOENT
        filename=[*arg]
        unless $need_file_audio.include?(filename)
          $need_file_audio.push(filename)
          f = File.open("./log_audio.txt","a")
          f.write(filename + "\n")
          f.close
        end
        me_stop
      end
    end
    Bgm_play = method("bgm_play")
    def self.bgm_play(*arg)
      begin
        Bgm_play.call(*arg)
      rescue Errno::ENOENT
        filename=[*arg]
        unless $need_file_audio.include?(filename)
          $need_file_audio.push(filename)
          f = File.open("./log_audio.txt","a")
          f.write(filename + "\n")
          f.close
        end
        bgm_stop
      end
    end
    Se_play = method("se_play")
    def self.se_play(*arg)
      begin
        Se_play.call(*arg)
      rescue Errno::ENOENT
        filename=[*arg]
        unless $need_file_audio.include?(filename)
          $need_file_audio.push(filename)
          f = File.open("./log_audio.txt","a")
          f.write(filename + "\n")
          f.close
        end
        se_stop
      end
    end
    Bgs_play = method("bgs_play")
    def self.bgs_play(*arg)
      begin
        Bgs_play.call(*arg)
      rescue Errno::ENOENT
        filename=[*arg]
        unless $need_file_audio.include?(filename)
          $need_file_audio.push(filename)
          f = File.open("./log_audio.txt","a")
          f.write(filename + "\n")
          f.close
        end
        bgs_stop
      end
    end
  end
end

冷剑随风 发表于 2011-6-11 23:00:52

本帖最后由 冷剑随风 于 2011-6-11 23:02 编辑

此附容错脚本的范例工程,如果不懂这个脚本意思的可以下载。
下载请点我

御剑天河 发表于 2011-6-12 15:14:00

我不懂...下载

BlackFeather 发表于 2011-6-13 16:59:45

我到现在还不知道是容的啥错

恨思归 发表于 2012-1-20 18:14:21

容得啥错- -

天莫邪 发表于 2015-1-31 18:42:46

不懂,下了再说
页: [1]
查看完整版本: 容错脚本 第3版