Group: Member
Posts: 16
Type: None
RM Skill: Undisclosed
Bypass missing resource error
Version 1 Author Krosk Release Date 02/21/2011
Introduction You just released a (crypted) demo of your latest RMXP game, you posted it in 50 forums to make sure everyone knows about your game, and you are extremely confident that your game is going to be the next major hit. However, the next day . . . . .
QUOTE
"No such file or directory - Graphics/Picture...."
This is a bug a player encounters only 10 minutes after the start of the game, and he can't go beyond this point (like everyone else playing your game) because it's during a mandatory introduction cinematic.
OTL... I know how you feel. It would have been okay if the player could continue to play regardless of the missing resource, right? This is what this script does.
Features This script will prevent a missing resource to make your game crash. The player will be notified that the resource is missing, but the game will still continue, allowing him to save the game or keep playing. This script reports a Graphic or an Audio missing resource. It doesn't prevent the missing of a data file. A missing picture will be replaced by an empty picture. A missing sound will just not be played.
Script
Bypass missing resource error
CODE
# -------------------------------------------------------- # Bypass missing resource error (BMRE) # by Krosk - thanks to Wawower and berka for optimization # -------------------------------------------------------- # This script will prevent a missing resource # to make your game crash. The player will be notified # that the resource is missing, but the game will still # continue, allowing him to save the game or keep playing. # # This script works with crypted and non-crypted project. # # This script reports a Graphic or an Audio missing resource. # It doesn't prevent the missing of a data file. # # A missing picture will be replaced by an empty picture. # A missing sound will just not be played. # # You can set the content of the string BMRE_NOSUCHTEXT # which is the message your player will see # when a resource is missing. # # If you don't want the player to be notified, # set # BMRE_NOTIFY = true # to # BMRE_NOTIFY = false # # Rewrite part of Bitmap class and Audio class. # --------------------------------------------------------
BMRE_NOTIFY = true BMRE_NOSUCHTEXT = "Please report this to the autor of the game.\n\nNb: You can keep playing the game."
class << Bitmap alias_method :alias_new, :new unless method_defined?(:alias_new) def new(*args) alias_new(*args) rescue if args.size == 1 print ("Resource #{args[0]} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end alias_new(32, 32) end end
def self.se_play(filename, volume = 100, pitch = 100) self.temp_se_play(filename, volume, pitch) rescue print ("Resource #{filename} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end
def self.me_play(filename, volume = 100, pitch = 100) self.temp_me_play(filename, volume, pitch) rescue print ("Resource #{filename} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end
def self.bgm_play(filename, volume = 100, pitch = 100) self.temp_bgm_play(filename, volume, pitch) rescue print ("Resource #{filename} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end
def self.bgs_play(filename, volume = 100, pitch = 100) self.temp_bgs_play(filename, volume, pitch) rescue print ("Resource #{filename} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end end
Customization
You can set the content of the string BMRE_NOSUCHTEXT which is the message your player will see when a resource is missing. If you don't want the player to be notified, set BMRE_NOTIFY = true to BMRE_NOTIFY = false.
Compatibility
This script works with crypted and non-crypted project. Only for RMXP.
Screenshot
None.
DEMO
No need.
Installation
Just paste this script somewhere before the script "Main". There might be compatibility issues with other scripts that rewrite Bitmap or Audio class.
FAQ
None.
Terms and Conditions
Written for personal use at first, so no need of credits for such a simple tool.
Credits
Thanks to Wawower and berka (2 French outstanding scripters) for syntax optimization
Group: Member
Posts: 15
Type: Developer
RM Skill: Skilled
It looks good! Is there a way of making it so that a yellow square (or other picture) is displayed instead of the missing graphic like in Bethesda's games?
# -------------------------------------------------------- # Bypass missing resource error (BMRE) # by Krosk - thanks to Wawower and berka for optimization # -------------------------------------------------------- # This script will prevent a missing resource # to make your game crash. The player will be notified # that the resource is missing, but the game will still # continue, allowing him to save the game or keep playing. # # This script works with crypted and non-crypted project. # # This script reports a Graphic or an Audio missing resource. # It doesn't prevent the missing of a data file. # # A missing picture will be replaced by an empty picture. # A missing sound will just not be played. # # You can set the content of the string BMRE_NOSUCHTEXT # which is the message your player will see # when a resource is missing. # # If you don't want the player to be notified, # set # BMRE_NOTIFY = true # to # BMRE_NOTIFY = false # # Rewrite part of Bitmap class and Audio class. # --------------------------------------------------------
BMRE_NOTIFY = true BMRE_NOSUCHTEXT = "Please report this to the autor of the game.\n\nNb: You can keep playing the game."
class << Bitmap alias_method :alias_new, :new unless method_defined?(:alias_new) def new(*args) alias_new(*args) rescue if args.size == 1 print ("Resource #{args[0]} is missing.\n") + BMRE_NOSUCHTEXT if BMRE_NOTIFY end bitmap = alias_new(32, 32) bitmap.fill_rect(bitmap.rect, Color.new(255, 255, 0)) return bitmap end end