Advertisement
leequangson

"File Missing Error" Preventer

Sep 28th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.83 KB | None | 0 0
  1. #===============================================================
  2. # ● [XP/VX/Ace] ◦ 'FILE MISSING ERROR' PREVENTER ◦ □
  3. # * Game won't quit because file missing error anymore~ *
  4. #--------------------------------------------------------------
  5. # ◦ by Woratana [[email protected]]
  6. # ◦ Thaiware RPG Maker Community
  7. # ◦ Released on: 05/10/2008
  8. # ◦ Version: 1.0
  9. #--------------------------------------------------------------
  10. # * Put this script over everything in your game!
  11. # (Default scripts in Script Editor are not an exception!)
  12. #------------------------------------------------------------------
  13.  
  14. module Wora_FMEP
  15.   #========================================================
  16.   # * [START] 'FILE MISSING ERROR' PREVENTER SETUP PART *
  17.   #--------------------------------------------------------
  18.   Print_Missing_File = true
  19.   # Print Missing File when error occured
  20.  
  21.   Record_Missing_File = true
  22.   # Record missing file to missing file log?
  23.   Missing_Log_File_Name = 'missing_log.txt'
  24.   # Name of file to store missing file names list
  25.  
  26.   Use_Audio_Replacement = false
  27.   # Use replacement audio file for missing audio?
  28.   Audio_Replacement_File = 'Audio/SE/Buzzer1'
  29.   # Audio file that will play for missing audio
  30.  
  31.   Use_Bitmap_Replacement = false
  32.   # Use replacement image file for missing image?
  33.   Bitmap_Replacement_File = 'Graphics/Pictures/Filler'
  34.   # Image file that will use for missing image
  35.   #--------------------------------------------------------
  36.   # * [END] 'FILE MISSING ERROR' PREVENTER SETUP PART *
  37.   #========================================================
  38.  
  39.   def self.print(type, name)
  40.     if Print_Missing_File
  41.       p 'Missed File: ' + name.to_s
  42.     end
  43.     if Record_Missing_File
  44.       file = File.open(Missing_Log_File_Name, "a+")
  45.       type = type == 0 ? 'Bitmap' : 'Audio'
  46.       text = '*' + type.to_s + '* :' + name.to_s + "\n"
  47.       file.write(text) unless file.readlines.include?(text)
  48.       file.close
  49.     end
  50.   end
  51. end
  52.  
  53. class << Audio
  54.   AUDME = [:bgm_play, :bgs_play, :me_play, :se_play]
  55.   AUDME.each do |method|
  56.     new_method = 'wora_fmep_aud_' + method.to_s
  57.     alias_method(new_method, method) unless $@
  58. new_def = <<_ALIAS_
  59. def #{method}(*args)
  60.   begin
  61.     #{new_method}(*args)
  62.   rescue
  63.     Wora_FMEP.print(1, args[0])
  64.     #{new_method}(Wora_FMEP::Audio_Replacement_File, args[1], args[2]) if
  65.   Wora_FMEP::Use_Audio_Replacement
  66.   end
  67. end
  68. _ALIAS_
  69. eval(new_def)
  70.   end
  71. end
  72.  
  73. class Bitmap
  74.   unless $@
  75.     alias wora_fmep_bmp_ini initialize
  76.     def initialize(*args)
  77.       begin
  78.         wora_fmep_bmp_ini(*args)
  79.       rescue
  80.         Wora_FMEP.print(0, args[0])
  81.         if Wora_FMEP::Use_Bitmap_Replacement
  82.           wora_fmep_bmp_ini(Wora_FMEP::Bitmap_Replacement_File)
  83.         else
  84.           wora_fmep_bmp_ini(32, 32)
  85.         end
  86.       end
  87.     end
  88.   end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement