[Ace] Common error debugging tips

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,816
Reaction score
5,505
First Language
Indonesian
Primarily Uses
RMVXA
There were numerous cases when people keep asking for support for a common error that occurred in their project. However, they are not completely wrong. While the error notices are the same, the reason is usually different. Thus they still deserve their own question answered by their own case. At the same time, usually, how to diagnose the error is still the same. So here is the thread for it.

----------------------------------------------
Damage formula deals zero damage
Causes:

By default, all the code error within the custom database formula is rescued by returning zero damage.

Why this happens:
I believe that the engine is being sold as "easy enough to use", thus preventing the error popup (which can lead to an assumption if the engine is buggy). This is, in my opinion, bad design for the developer. The developer needs to know what was the error instead of being confused by zero damage.

How to mitigate:
To make the error visible, you need to hijack the eval function from the default code library by inserting this snippet.
Code:
class RPG::UsableItem::Damage
  def eval(a, b, v)
    begin
      result = [Kernel.eval(@formula), 0].max * sign
    rescue StandardError => err
      raise "Formula: #{@formula}\n\n#{err.to_s}"
    end
    return result
  end
end
----------------------------------------------
Script 'Cache' line 106: RGSSError occurred. failed to create bitmap
Causes:

This error indicates that the game is failed to load an image (obviously, duh).

Why this happens:
There're many reasons for it. It could be because the image exceeded a certain threshold (i.e, too big), or the image is just corrupted. However, the engine did not mention which file that has the problem.

How to mitigate:
To investigate which file that has the problem, you could insert the snippet below. This, however, will NOT solve your problem. The failed image to load will simply be replaced by an empty bitmap, but while you're at it, it also pops up a message saying which file that has the problem
Code:
class << Cache
  def self.normal_bitmap(path)
    begin
      @cache[path] = Bitmap.new(path) unless include?(path)
    rescue
      msgbox "Failed to create bitmap: #{path}"
      @cache[path] = Bitmap.new(1,1)
    end
    @cache[path]
  end
end
The game refuses to save (additionally, it also deleted the save file)
Causes:
At some point, the save contains information that could not be saved. It is not corrupted, it just can not be saved.

Why this happens:
This mainly because of a poorly written external script. The script culprit put a specific element (usually a bitmap object, or sprite) to the save content object (in Game_Actor, or Game_System, etc), make it unable to dump into a save file. Again, the default engine didn't put a good indication of what was causing the issue. The engine just put a buzzer sound (and delete the save file) instead of error notice because somehow they don't like an error notice shows up in-game. So that people usually had no idea what was going on.

The reason why the save file is deleted is mainly that during the process of saving, it is corrupting the save file. Instead of the file being there and unable to load, it might as well as delete the file. Again, essentially hiding the error.

How to mitigate:
To check which game object that has the issue, you can try to put this snippet. Then try to save the game.
Code:
class Object
  alias :classname :class
end

class << DataManager
  def save_game(index)
    begin
      save_game_without_rescue(index)
    rescue
      delete_save_file(index)
      retry_saving
      false
    end
  end

  def retry_saving
    make_save_contents.each_value do |content|
      begin
        Marshal.dump(content)
      rescue
        msgbox "Failed to dump #{content.classname}"
      end
    end
  end
end
Unfortunately, this snippet alone will not save your project. It only pointed out on which game object that causes the issue. Once the object is identified, it's easier to break down which script is the culprit.

The next step is, if you know what you're doing, you can probably walk on your own. But if you don't know anything about scripting, you should ask people who have the knowledge on scripting.

Game_Interpreter Line 1411 Error
Refers to this thread: https://forums.rpgmakerweb.com/index.php?threads/a-better-game_interpreter-line-1411-error-backtracer.112849
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
4,816
Reaction score
5,505
First Language
Indonesian
Primarily Uses
RMVXA
Script 'Cache' line 88: NoMethodError. Undefined method 'empty?' for NilClass
Causes:

Usually compatibility, or just a badly written script.

Why this happens:
When the game loads a bitmap, it usually has a filename. By default, it should work just fine. But when the function to load the bitmap didn't get the filename, the game confused. Unfortunately, instead of blaming the actual culprit. The game blames the Cache module instead, which is not helpful.

How to Mitigate:
Method 1:
Hiding the error
You can try to hide the error and try to replace it with a transparent placeholder. So the game will show nothing. This may be useful if you want to see what happens if the image is failed to load but the game will still run. You may see some graphics are missing. From that, you can start to pinpoint which is the actual script culprit.

Add this as a new script below everything
Code:
class << Cache
  def self.load_bitmap(folder_name, filename, hue = 0)
    @cache ||= {}
    return empty_bitmap unless filename
    if filename.empty?
      empty_bitmap
    elsif hue == 0
      normal_bitmap(folder_name + filename)
    else
      hue_changed_bitmap(folder_name + filename, hue)
    end
  end
end
Method 2: Backtrace
This method is more accurate and probably more helpful if you know how to fix the script error. How to do it is simply replace the slot 'Main' (in the script editor) with this. You will see the trace and probably pin-point which script or process that is at fault.

Be sure to enable the console by choosing the menu Game --> Show Console
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

It's weird I actually have MORE work to do when stuck at home than before.
The No Travel Game Jam is here! Jump in to make a game in the month of April that takes place all in one town!


Decided to take a stab at video editing.... Even made a clickbait screen. I'm so proud of my sellout ways. :LZSexcite:

Forum statistics

Threads
95,470
Messages
929,397
Members
125,712
Latest member
Flane
Top