Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Bypass missing resource error, No such file or directory... but it's okay
krosk
post Feb 21 2011, 04:08 AM
Post #1


Level 2
Group Icon

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

module Audio
  class << self
    alias_method :temp_se_play, :se_play unless method_defined?(:temp_se_play)
    alias_method :temp_me_play, :me_play unless method_defined?(:temp_me_play)
    alias_method :temp_bgm_play, :bgm_play unless method_defined?(:temp_bgm_play)
    alias_method :temp_bgs_play, :bgs_play unless method_defined?(:temp_bgs_play)
  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


__________________________
Go to the top of the page
 
+Quote Post
   
CountVlad
post Apr 3 2011, 01:28 AM
Post #2


Level 2
Group Icon

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?
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Apr 4 2011, 06:04 AM
Post #3


Level 50
Group Icon

Group: +Gold Member
Posts: 1,528
Type: Scripter
RM Skill: Undisclosed




Yup, there is smile.gif

[Show/Hide] Night_Runner's Edit
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
    bitmap = alias_new(32, 32)
    bitmap.fill_rect(bitmap.rect, Color.new(255, 255, 0))
    return bitmap
  end
end

module Audio
  class << self
    alias_method :temp_se_play, :se_play unless method_defined?(:temp_se_play)
    alias_method :temp_me_play, :me_play unless method_defined?(:temp_me_play)
    alias_method :temp_bgm_play, :bgm_play unless method_defined?(:temp_bgm_play)
    alias_method :temp_bgs_play, :bgs_play unless method_defined?(:temp_bgs_play)
  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


I've just got it displaying the yellow box at the moment, I don't think that it's a good idea to attempt showing a different picture....


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
CountVlad
post Apr 5 2011, 06:45 AM
Post #4


Level 2
Group Icon

Group: Member
Posts: 15
Type: Developer
RM Skill: Skilled




That's brilliant! Thank you! smile.gif
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 25th May 2013 - 09:32 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker