Script 'Cache' line 106: RGSS Error (Failed Bitmap)

MissSheep

Warper
Member
Joined
Jul 21, 2019
Messages
3
Reaction score
0
First Language
Greek
Primarily Uses
Other
Hello, so i'll go straight to the point. My game (pocket mirror) is having the following error: Script 'Cache' line 106:RGSS Error (failed to create bitmap):kaocry:

So i'm guessing that i'm getting this error because my game doesn't keep my save files.. it's like i save the game then close it but the save file has dissapeared so when i go to a specific area i get the error i mentioned before. So my question is: Does anybody know what i have to do? I tried re-downloading the game but still didn't work. Please help me.. i'm not good with these stuff so i don't know..:kaoswt:
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Did you place you game in "C:\Program Files\Whatever" or "C:\Program Files (x86)\Whatever"? If you did, you have to run the program with administrator privileges or the OS does not allow you to write in one of those folders.

I am not sure if that error is caused by this, but this might be the reason preventing your game from saving properly.

That said, the error you get means that the engine cannot load an image. It might be because the file is corrupted, because it has a wrong extension, because it was an image taken in-game and not successfully saved, there are various reasons for it. I am afraid you have to investigate more.

EDIT:
Check if you have two files with the same name, but different extension, with one of them being from the RTP. That might be causing the error.
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
because it has a wrong extension
The extension doesn't matter. The fact that you load an image in the script, specify the string without the file extension at all and still work, yeah it doesn't matter. It is likely the file is corrupted, or simply can not load, or too big to load.

EDIT:
Check if you have two files with the same name, but different extension. That might be causing the error as well.
This also doesn't matter. RGSS engine prioritizes a certain extension to load when it has the same name. And simply ignore another one.
 

MissSheep

Warper
Member
Joined
Jul 21, 2019
Messages
3
Reaction score
0
First Language
Greek
Primarily Uses
Other
Did you place you game in "C:\Program Files\Whatever" or "C:\Program Files (x86)\Whatever"? If you did, you have to run the program with administrator privileges or the OS does not allow you to write in one of those folders.

I am not sure if that error is caused by this, but this might be the reason preventing your game from saving properly.

That said, the error you get means that the engine cannot load an image. It might be because the file is corrupted, because it has a wrong extension, because it was an image taken in-game and not successfully saved, there are various reasons for it. I am afraid you have to investigate more.

EDIT:
Check if you have two files with the same name, but different extension. That might be causing the error as well.
Oh, well i don't know how to place my program there.. and i'm guessing that it definetly isn't there.

The extension doesn't matter. The fact that you load an image in the script, specify the string without the file extension at all and still work, yeah it doesn't matter. It is likely the file is corrupted, or simply can not load, or too big to load.


This also doesn't matter. RGSS engine prioritizes a certain extension to load when it has the same name. And simply ignore another one.
Is there a way to find that file and repair it? And the area i'm trying to enter doesn't have an image it's just a room so i'm sure it isn't the image
 
Last edited by a moderator:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@TheoAllen what you said is only partially true. It is true that the engine prioritizes a certain file extension and it is also true that it does not see files with a wring extension, but it is also equally true that there are exceptions.

Even if RGSS does not handle a certain file extension, having two files with the same name, but different extension, might mislead the engine if one of them is from the RTP. It is a known issue that has already been reported. On top of it, if you have files with different extensions, this occurs not only in the game, but even in the engine itself. You can test this by simply creating a file called Actor4.txt and see how those images don't appear even when you are in the database, no need to open the game itself. It is a clear conflict between the RTP .png file and the local .txt file simply because they have the same name.

The reason behind that is that the engine gives higher priority to files within the local folder rather than files in the RTP folder. That priority applies before the extension priority itself. No ifs and buts here, if you do not believe it, you can test it on your own; if you have a file with the wrong extension that has the same name of a file in the RTP folder you still get that error.

The result is this one:
 

Attachments

Last edited:

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA

@MissSheep, please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.


I will go ahead and merge your three posts together for you this time.

In the future, if you need to quote multiple people, you can use the Multi-Quote function by hitting the "+ Quote" tag on individual posts, and then clicking the "Insert Quotes" button that appears near the text box where you're typing your post.

If you accidentally post and you are having trouble getting the quotes into the Edited post, I recommend doing what you would need to to make the multi-quote post (as above), except instead of posting it, just copy the whole thing (tags and all), and then click "Edit" on your original post and replace what's there by pasting the text you copied.

You didn't do anything bad; just be more careful because it's disruptive to have multiple consecutive posts by the same person in short succession.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
that error is caused by a bitmap being created with the wrong size, or missing path.
being that you mention save files, my guess, is that's a faulty character sprite.

go into the code, and add this chunk
Code:
module Cache
def self.normal_bitmap(path)
    begin
      @cache[path] = Bitmap.new(path) unless include?(path)
    rescue
      @cache[path] = Bitmap.new(2,2)
    end
    return @cache[path]
  end
end
right at the end of the Cache module, below the last "end".
if there's an error, it should default to loading an empty file.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
@Heirukichi That's fair, however, sorry to disappoint you, but I'd like to add but and ifs. You mentioned RTP, but I was assuming that there is no RTP involved. Besides, you didn't even mention RTP in your previous post. And you said "two files with the same name but the different extension" might be confusing when you didn't add RTP in the context. Although, I appreciate the information.

And it appears to only happen if it clashed with RTP, in a normal circumstance where the filename is different than the RTP one. I tried with this.
Screenshot_1186.jpg
And from the editor itself, it's alright (disclaimer: I didn't test it in an actual game, but I assume it will work anyway)
Screenshot_1187.jpg
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
if there's an error, it should default to loading an empty file.
Hiding errors by using something similar to "rescue" (in this case loading an empty file is a way to hide the error) is hardly a good practice. It is much better to take time to understand what is causing the error rather than "eliminating" it with a quick and not definitive fix. If the engine is not loading an image and you load an empty image instead, sooner or later you will see nothing when you should see an image instead.

And it appears to only happen if it clashed with RTP, in a normal circumstance where the filename is different than the RTP one.
Yes, you are right, I didn't mention the RTP in the first post and I can see how it can be misleading. I will change it promptly in order not to mislead potential users with the same problem in the future. Anyway, as I said, besides that exception, everything else works as you said and the engine prioritizes files with the right extension. Not only does it show them correctly in the engine, it also works in-game (and I am 100% sure of that because I tested it).

EDIT
@TheoAllen I modified the first post, thank you for pointing that out.

EDIT 2
sorry to disappoint you, but I'd like to add but and ifs
I am not disappointed at all. It is not like you negated the existence of the exception I mentioned (it does exist, and negating its existence would just be plain wrong, that is what I meant with "no ifs and buts").

I only mentioned that exception because you said that the extension does not matter, which is not true in that situation and it is the main reason why I said that it might cause errors. As I said in my previous post, besides that exception, what you said is true.

Also, why would pointing out the missing RTP part in my first post disappoint me? It was the truth, adding it only makes things easier to understand and leaves less room for personal interpretation of my post, while not having it can be misleading. I deem what you said quite useful.

Only a petty person who would take it on a personal level could be disappointed because of that, and I do not consider myself one. After all, posting on this forum is a way to help other people, taking it on a personal level only means that one is trying to show off and does not want other people to prove him or her wrong. That would mean being here for the wrong reason.
 
Last edited:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I am not disappointed at all.
That particular phrase was a joke, don't mind it much :p
Now since all had been cleared. I'm out until the OP reported another problem.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
If the engine is not loading an image and you load an empty image instead, sooner or later you will see nothing when you should see an image instead.
you can replicate the hole, by gauging the size of the drill bit.
you can't *get* to the hole, if the way *to* it collapses every time you walk it.

leave the problem, prevent the program from crashing due to an unhandled exception, get to the exception, measure it, and *make* the handler.
the next time you run it, it'll consider the exception, and handle it.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
get to the exception, measure it, and *make* the handler.
the next time you run it, it'll consider the exception, and handle it.
The problem is, your example is *hard* to measure. Except by guessing "Which graphics am I missing?".
If you looked at the link I posted earlier, I make it *easier* to measure.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
@gstv87 I completely agree with Theo here. On top of it, what is the point of hiding an error by changing the script when you can simply edit the script in a way that it marks the error? Both are very short edits, but the latter is much smarter, and that is the reason why it is considered a bad practice to hide errors. It is much better to have your program crash with a meaningful error message rather than having it continue its execution but hiding the mistake. In this case, Theo's script still has a rescue method, but it displays a message with the expected path that is generating the error.

Another very important reason, that is usually underrated, is that the same error might appear later in a different situation. Once you edit the script to hide it, any other error with the same nature is going to be hidden as well. The first time the error appears you know where it happened because the game crashed, the second time you might completely miss it and think that the graphics not being shown (as in this example) might be caused by something else. Nobody ensures you that you will remember that you changed the script to hide that kind of error, especially if the same situation happens after three or four months.

This is something that people usually underestimate, but in computer science it is a very common thing. Not being able to remember what you wrote and having to check the documentation is a common thing. That is the main reason behind the existence of software documentation, even when the code is only used by employees of a single company and not made available to the public. Why is that so? Because even those very same employees who wrote it originally might forget how it works internally after a long time has passed.
 

MissSheep

Warper
Member
Joined
Jul 21, 2019
Messages
3
Reaction score
0
First Language
Greek
Primarily Uses
Other
that error is caused by a bitmap being created with the wrong size, or missing path.
being that you mention save files, my guess, is that's a faulty character sprite.

go into the code, and add this chunk
Code:
module Cache
def self.normal_bitmap(path)
    begin
      @cache[path] = Bitmap.new(path) unless include?(path)
    rescue
      @cache[path] = Bitmap.new(2,2)
    end
    return @cache[path]
  end
end
right at the end of the Cache module, below the last "end".
if there's an error, it should default to loading an empty file.
So if i do this will it tell me what error it is next time? And plus in the game will i be able to play at that area that had the crush?

@gstv87 I completely agree with Theo here. On top of it, what is the point of hiding an error by changing the script when you can simply edit the script in a way that it marks the error? Both are very short edits, but the latter is much smarter, and that is the reason why it is considered a bad practice to hide errors. It is much better to have your program crash with a meaningful error message rather than having it continue its execution but hiding the mistake. In this case, Theo's script still has a rescue method, but it displays a message with the expected path that is generating the error.

Another very important reason, that is usually underrated, is that the same error might appear later in a different situation. Once you edit the script to hide it, any other error with the same nature is going to be hidden as well. The first time the error appears you know where it happened because the game crashed, the second time you might completely miss it and think that the graphics not being shown (as in this example) might be caused by something else. Nobody ensures you that you will remember that you changed the script to hide that kind of error, especially if the same situation happens after three or four months.

This is something that people usually underestimate, but in computer science it is a very common thing. Not being able to remember what you wrote and having to check the documentation is a common thing. That is the main reason behind the existence of software documentation, even when the code is only used by employees of a single company and not made available to the public. Why is that so? Because even those very same employees who wrote it originally might forget how it works internally after a long time has passed.
So what do i need to do in the end?
 
Last edited by a moderator:

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
So if i do this will it tell me what error it is next time?
That is exactly what we are arguing about. If you do it that way, you are NOT getting any notification about which error it is. If you follow the link in Theo's post and use that script instead, the engine is going to tell you which image is missing.
And plus in the game will i be able to play at that area that had the crush?
Yes, you will. Even if you will not be able to know where the error lies. However, if you use the script that Theo provided, you can still continue playing (even if a message box is going to appear when the game is unable to load the image) while, at the same time, knowing which image is causing the error.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[dpost]MissSheep[/dpost]
If you want to add something, just use the Edit button on your post and put in the extra info/comment. I'll merge your post for you this time. This is the second time in this thread that you have been asked not to double post. Please take note.

If you want to quote more than one person, please use the Multiquote button, otherwise the forum software automatically creates a new post per quote. If you just want to indicate exactly who you are replying to, or let them know that you are replying to them, it is easier to use @ plus their username, like this @MissSheep. As you type the name, a drop down list appears and after a few letters it is easy to select the one you want.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,847
Messages
1,016,972
Members
137,561
Latest member
JaCrispy85
Top