MZ [Request] Replace error messages of Missing files for error log (or ignore completely instead).

I know that this is some controversial topic for many developers, however in production scenaries, when there's a missing file (for example, a sound, a music, or an image), what only should happen is that the file is not loaded because it was not found, and that's all.

However, when the error message appears, it can be very troublesome for both the developer and, more specifically, the player.

Because, imagine you deploy a game, everything goes good, but after an hour of playtime you enter a map where the BGM file was renamed to another one and you haven't updated it on the Map Properties. BoOM, *missing BGM_1* (retry).. (keep retrying)...

Now it's a game over for the project. Bad reviews are coming which will most likely not be removed, and now even if you update the project, you already have bad records in the reviews, all because a missing bgm file which could perfectly end just playing the previous BGM (or just hear silence until another BGM is played), and prevents your player from continue playing the game for... maybe an hour, or even worse, a full day or more.

Same happens for graphics, is better see that your character goes invisible, or swing an invisible weapon, than cut out the player's experience until you make a 300MB update for just 1KB file, having to make an "urgent update" just due an image rather than update the project a week or month later followed with a package of fixes/improvements.

Funny enough, there's some cases where a missing file just upgrades the functionality of some plugins and you get a desired effect instead of an unwanted effect.

This happens for example with @Pheonix KageDesu 's AnimaX. I wanted the option to only use LEFT-RIGHT frames on certain cases, so I used his plugin with another plugin snippet, and here's the result, however... oh oh, look what happens when I try to open menu... those error messages broke my plan!


...and now, in the case of AnimaX, if I add these missing files, I get the unwanted effect of the character looking at left direction when going up while I was facing right direction. So yeah, the missing images were actually upgrading AnimaX, weird enough that the errors of missing files were only shown up at the moment I press ESC for open the menu.. damm! I hate those error messages!

To avoid this chaos, is much better to let the developer decide what happens if there's a missing file:
  1. Nothing happens, no error log or in-game message: Let players send you an screenshot or video when they don't see the sword that supposedly should be shown.
  2. In-game message and/or error log: Let players see an pop-up error message somewhere in the screen once, then the game just skips the loading of said file and continues playing normally. Optionally, also the error is saved in a .log file that can be sent to the developers.
  3. Option to decide what happens in test mode and production mode. Maybe you find useful to show an in-game pop-up of a missing file when you-re play testing, but you don't want to happen anything at all on production, so players don't see an ugly "ERROR: SWORD.PNG NOT FOUND" message, and from 9 out of 10 players, they just didn't care enough and 1 of them noticed and reported it.

That's all. See the majority of commercial games from Sony, Xbox, etc, none of them cuts out your game just due a missing x.png file somewhere, players report it and the developers fixes it when they find convenient.

However I agree that for errors of code, is better to keep them because it may end into a cascade of unwanted glitches like freezes, dupes, etc. But, in the case of missing files, this should be upon developers choice.

This is something that I was looking for since the release of RPG Maker, however I haven't found anything after doing a google search. Maybe it already exists for MV and I haven't searched good enough.

Nonetheless, for myself, with just making that nothing happens would be alright, don't need error log neither pop-up error, I would let players notice and report them instead. But since this can be really useful for more developers, I improved the suggestion a bit more to also show an in-game pop-up plus save a .log file.

Hope to see this soon.
Thanks in advanced.
This has come up a few times before, if you search some threads.

The problem is that your game can't just keep going pretending that nothing happened.

Any given file that's supposed to exist may have dozens or more references to it and its various properties as the game continues to run. And then those properties are passed off to other functions within the code, or even used in calculations to determine how other parts of the game work.

How exactly are you supposed to do that when the file being referenced doesn't exist? And you're trying to return from battle to the map and resume the map's music, but looking for its timestamp doesn't exist? Or you're trying to place an animation on a battler's sprite but retrieving its coordinates doesn't exist?

It would take extensive recoding of the engine to make every single place that a property is coming from an external file possible to be ignored (in the cases where it even can be done without compromising the functionality of the game).

Or you can just make sure your game is properly playtested before releasing it to be reviewed.

In your specific case, I have no idea exactly what you're trying to achieve and what other plugin you're trying to combine it with because you're kind of ranting instead of linking the plugins and asking for help implementing what you want to achieve.

But it can certainly be done and it's certainly better to do that than to excise proper error reporting from RPG Maker.
What is happening on the video? I'm using AnimaX with only frames for Left and Right sides, and haven't added Up and Down. AnimaX doesn't have such feature to only use left-right, however the game just skips the missing files.

Yes, the engine is effectively skipping the missing files, and yes, when I switch to something that exists, just the game works as normal. However for some reason "it has memory" and warns about the missing files right when I open the menu and not while I'm on the map, very likely due the change of scene despite that the called scene isn't showing the missing file somewhere, instead it warns about the missing files that were happening on the previous scene (Scene_Map).

So here's the trouble, I'm using a plugin that thanks of the file skipping I'm getting the effect I want, however when I change to Scene_Menu (again, the menu isn't showing the missing files somewhere), the error messages appears and cuts out the game, now I have to pray for Kage, AnimaX developer have a gap on it's very busy agenda to add natively the feature of Left-Right only movement to AnimaX's frames.

What should happen then? What I'm looking to happen?

I just want that when a missing file is found, it's skipped until said missing file is called again, so for example in the case of a window, would be like skip an X.png file when opening it, but is fully operative, engine just only tries to load x.png once, until I close and open menu again, and keeps skipping the file loading until the same action loads another one.

Same scenary as happened with AnimaX, missing frame images are just skipped, so I get the desired effect of only show left-right frames.

And the same as if I renamed a sound file, engine by itself actually CAN skip the loading of the file and CONTINUE WORKING, however the problem is the error message. (caps for more highlighting).

What really does the engine is what you said, carries the loading for the next action, aka BGM_1 is missing, then will continue playing BGM_0 until the game plays BGM_2. The same would happen if the game wants to load for example Icon1, Icon2, Icon3 and the Icon2 is missing, you would see Icon1, Icon1, Icon3 (or just Icon1, (missing icon), Icon3). This happens already natively. You don't need to decide or make what happens because the engine already has a behavior for this scenario. Only need to remove the display message and the game pausing.

And regarding the ranting you mention, is a form of expression, not really a rant. Is like say "What you need to make rice with milk? Oh Damn! Rice and milk!". 🙂

EDIT: Removed the first line, because, you're right and not at same time, clarified this while I kept writing.
So I'm not going to thoroughly read or address most of that, because
1 - I already did, and
2 - No offense, but it is demonstrating a lack of understanding of how computer software works. There's nothing that works the way you suggest.

Choose any software you have installed on your computer, or any AAA-published game. Randomly delete some of its assets.

You're not going to get a log file that says, "Hey, I wish these things were here, but oh well!" You're going to get it not working 😛

And regarding the ranting you mention, is a form of expression, not really a rant.
I wasn't even meaning your tone or attitude entirely; it's the fact that it's really long and expounding on things far beyond what is necessary to convey your request.

The longer you go on (and you did this in your second post, also) and the more you say, the more it dilutes your message. Say what you need to say in accurate language and let it be 😉
It would take extensive recoding of the engine to make every single place that a property is coming from an external file possible to be ignored (in the cases where it even can be done without compromising the functionality of the game).
I think a simpler approach would probably be to load an empty image/sound instead, so they can act as a dummy item and avoid things breaking.

I'll see if I can find some time tomorrow for it, but I think this request should be reasonably simple to implement.
So I'm not going to thoroughly read or address most of that, because
1 - I already did, and
2 - No offense, but it is demonstrating a lack of understanding of how computer software works. There's nothing that works the way you suggest.

Choose any software you have installed on your computer, or any AAA-published game. Randomly delete some of its assets.

You're not going to get a log file that says, "Hey, I wish these things were here, but oh well!" You're going to get it not working 😛


I wasn't even meaning your tone or attitude entirely; it's the fact that it's really long and expounding on things far beyond what is necessary to convey your request.

The longer you go on (and you did this in your second post, also) and the more you say, the more it dilutes your message. Say what you need to say in accurate language and let it be 😉
I've been a gamer, windows user and more since I opened a computer case with five years old and I'm 33, the developers do choose what happens when a file is missing, either display an error message like when Windows can't load a missing DLL for run an specific software, or replace a missing image with an ugly MISSINGFILE.PNG photo when there's a missing texture on a map in a videogame, or just displays a square hole in the middle of the map and you see the sky under your feets and displays the missing file in an error_log (or even better, displays an error log right on the devs console in their own host) [Player ABC - Item XXX not found (Missing file)]. Every commercial project is programmed to behave differently depending on their own developers choice, but most common is what I said before, nothing happens, or another file is shown/played instead, and in some cases an error log is made or even sent to devs server (Privacy consent updates frequently and that's one of the reasons, "anonymous data" to identify errors and improve the product without you noticing it or doing nothing, their software automatically do the report in background silently).

The problem is when some developers of an specific engine want to give whatever personal opinion to not give the Game Developer what is requesting, which is just stop showing the error message or get more control of what happens when a file is missing, rather than provide a plugin which gives alternatives for test-mode, production, or both, because this can be done.

And this last phrase I'm telling it not because of your reply, but due even worser replies I found in my search which makes the requester look like an idiot when actually perfectly knows what is looking for and how it CAN work as alternative.

First of all, we would have to take a look at this part of rmmz_manager.js and improve it, making that in test mode the message is shown as a "pop-up" instead:
Code:
SceneManager.catchLoadError = function(e) {
    const url = e[1];
    const retry = e[2];
    Graphics.printError("Failed to load", url);
    if (retry) {
        Graphics.showRetryButton(() => {
            retry();
            SceneManager.resume();
        });
    } else {
        AudioManager.stopAll();
    }
};

Then, we would need to make that for example, if the file type is .ogg/mp3/m4a/mid/etc, then "empty.mp3" is played in its place.

Same for when a missing png file is found, make that a transparent pixel.png is loaded instead and then it's skipped.

Or as alternative, instead of keep trying loading the same file or replace it for a "placeholder" one, just let it be replaced for "null", just like when you're selecting a bgm in the map properties, or a character graphic in the database, you have the option to pick "None", right? So, make that when the game finds that some file is missing, it picks "None" instead.

Different thing would happen if we were talking about skipping error messages of plugin conflicts, but in this case we're talking about files, so there's an easy alternative.

EDIT: I don't remember if it was in RMXP, VX or VXAce (I own all makers except Unity and console ones), but I remember having a plugin to replace missing files for another one, it's been a lot of years so I don't remember with which one was.

EDIT2:

I think a simpler approach would probably be to load an empty image/sound instead, so they can act as a dummy item and avoid things breaking.

I'll see if I can find some time tomorrow for it, but I think this request should be reasonably simple to implement.

Seen your reply right now after refreshing, yeah, that gonna work, or you can check to replace as selecting None (null). I think this is a good approach to the right direction, at least, a workaround until it gets improved to give more control of what happens if some file is missing 🙂
if I can find some time tomorrow for it
So unfortunately I didn't manage to do that, and I'm now leaving for a week-long trip, so I won't be able to do this for a while. Sorry about that.

But if this issue is still unsolved a week from now I should have plenty of time to handle it.
So unfortunately I didn't manage to do that, and I'm now leaving for a week-long trip, so I won't be able to do this for a while. Sorry about that.

But if this issue is still unsolved a week from now I should have plenty of time to handle it.

Okay, take your time 🙂

Please share it with the community if you manage do it, I'm very sure it'll be really helpful for many developers. Thanks in advanced!
This proved a bit more complicated than anticipated, but I got it to work. At least for MV - there are some differences with MZ, but it should hopefully work there too.

Spoiler: MV version
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
        if (filename) {
            const fs = require('fs');
            var path = folder + encodeURIComponent(filename) + '.png';
            if (!fs.existsSync(decodeURIComponent(path))) return this.loadEmptyBitmap();
            var bitmap = this.loadNormalBitmap(path, hue || 0);
            bitmap.smooth = smooth; //Change the second "smooth" to "false" to disable bitmap blurring
            return bitmap;
        } else {
            return this.loadEmptyBitmap();
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        var ext = this.audioFileExt();
        var encodedName = name.split('/').map(encodeURIComponent).join('/');
        var url = this._path + folder + '/' + encodedName + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        if (this.shouldUseHtml5Audio() && folder === 'bgm') {
            if (this._blobUrl) Html5Audio.setup(this._blobUrl);
            else Html5Audio.setup(url);
            return Html5Audio;
        } else {
            return new WebAudio(url);
        }
    };

    Graphics.playVideo = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._videoLoader = ResourceHandler.createLoader(null, this._playVideo.bind(this, src), this._onVideoError.bind(this));
        this._playVideo(src);
    };
}

Spoiler: MZ version
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename) {
        if (filename) {
            const url = folder + Utils.encodeURI(filename) + ".png";
            const fs = require('fs');
            if (!fs.existsSync(decodeURIComponent(url))) return this._emptyBitmap;
            else return this.loadBitmapFromUrl(url);
        } else {
            return this._emptyBitmap;
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        const ext = this.audioFileExt();
        const url = this._path + folder + Utils.encodeURI(name) + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        const buffer = new WebAudio(url);
        buffer.name = name;
        buffer.frameCount = Graphics.frameCount;
        return buffer;
    };

    Video.play = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._element.src = src;
        this._element.onloadeddata = this._onLoad.bind(this);
        this._element.onerror = this._onError.bind(this);
        this._element.onended = this._onEnd.bind(this);
        this._element.load();
        this._loading = true;
    };
}

Both of these require empty sound files named "empty" in the audio/se folder. With bitmaps we can use the existing function for loading empty bitmaps, and with video we can just not load it at all, since an empty video object already exists, but for audio we do need to load something. I've attached two files with 0.2 seconds of silence that you can use (0-length audio files caused some problems, but those should be fine).

For MV, if you're using a script to disable bitmap blurring/smoothing, this will overwrite it - to undo that, change bitmap.smooth = smooth; to bitmap.smooth = false;.

It's also worth noting that this script will intentionally not do anything in a web build - the mechanic of retrying to get a file is rather important there, since failing to load it can be caused by the network connection temporarily dropping.
This proved a bit more complicated than anticipated, but I got it to work. At least for MV - there are some differences with MZ, but it should hopefully work there too.

Spoiler: MV version
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
        if (filename) {
            const fs = require('fs');
            var path = folder + encodeURIComponent(filename) + '.png';
            if (!fs.existsSync(decodeURIComponent(path))) return this.loadEmptyBitmap();
            var bitmap = this.loadNormalBitmap(path, hue || 0);
            bitmap.smooth = smooth; //Change the second "smooth" to "false" to disable bitmap blurring
            return bitmap;
        } else {
            return this.loadEmptyBitmap();
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        var ext = this.audioFileExt();
        var encodedName = name.split('/').map(encodeURIComponent).join('/');
        var url = this._path + folder + '/' + encodedName + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        if (this.shouldUseHtml5Audio() && folder === 'bgm') {
            if (this._blobUrl) Html5Audio.setup(this._blobUrl);
            else Html5Audio.setup(url);
            return Html5Audio;
        } else {
            return new WebAudio(url);
        }
    };

    Graphics.playVideo = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._videoLoader = ResourceHandler.createLoader(null, this._playVideo.bind(this, src), this._onVideoError.bind(this));
        this._playVideo(src);
    };
}

Spoiler: MZ version (untested)
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename) {
        if (filename) {
            const url = folder + Utils.encodeURI(filename) + ".png";
            const fs = require('fs');
            if (!fs.existsSync(decodeURIComponent(path))) return this._emptyBitmap;
            else return this.loadBitmapFromUrl(url);
        } else {
            return this._emptyBitmap;
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        const ext = this.audioFileExt();
        const url = this._path + folder + Utils.encodeURI(name) + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        const buffer = new WebAudio(url);
        buffer.name = name;
        buffer.frameCount = Graphics.frameCount;
        return buffer;
    };

    Video.play = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._element.src = src;
        this._element.onloadeddata = this._onLoad.bind(this);
        this._element.onerror = this._onError.bind(this);
        this._element.onended = this._onEnd.bind(this);
        this._element.load();
        this._loading = true;
    };
}

Both of these require empty sound files named "empty" in the audio/se folder. With bitmaps we can use the existing function for loading empty bitmaps, and with video we can just not load it at all, since an empty video object already exists, but for audio we do need to load something. I've attached two files with 0.2 seconds of silence that you can use (0-length audio files caused some problems, but those should be fine).

For MV, if you're using a script to disable bitmap blurring/smoothing, this will overwrite it - to undo that, change bitmap.smooth = smooth; to bitmap.smooth = false;.

It's also worth noting that this script will intentionally not do anything in a web build - the mechanic of retrying to get a file is rather important there, since failing to load it can be caused by the network connection temporarily dropping.

Thank you very much! Gonna test it this weekend.
I'll let you know if it works in MZ.
This proved a bit more complicated than anticipated, but I got it to work. At least for MV - there are some differences with MZ, but it should hopefully work there too.

Spoiler: MV version
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename, hue, smooth) {
        if (filename) {
            const fs = require('fs');
            var path = folder + encodeURIComponent(filename) + '.png';
            if (!fs.existsSync(decodeURIComponent(path))) return this.loadEmptyBitmap();
            var bitmap = this.loadNormalBitmap(path, hue || 0);
            bitmap.smooth = smooth; //Change the second "smooth" to "false" to disable bitmap blurring
            return bitmap;
        } else {
            return this.loadEmptyBitmap();
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        var ext = this.audioFileExt();
        var encodedName = name.split('/').map(encodeURIComponent).join('/');
        var url = this._path + folder + '/' + encodedName + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        if (this.shouldUseHtml5Audio() && folder === 'bgm') {
            if (this._blobUrl) Html5Audio.setup(this._blobUrl);
            else Html5Audio.setup(url);
            return Html5Audio;
        } else {
            return new WebAudio(url);
        }
    };

    Graphics.playVideo = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._videoLoader = ResourceHandler.createLoader(null, this._playVideo.bind(this, src), this._onVideoError.bind(this));
        this._playVideo(src);
    };
}

Spoiler: MZ version (untested)
JavaScript:
if (Utils.isNwjs()) {
    ImageManager.loadBitmap = function (folder, filename) {
        if (filename) {
            const url = folder + Utils.encodeURI(filename) + ".png";
            const fs = require('fs');
            if (!fs.existsSync(decodeURIComponent(path))) return this._emptyBitmap;
            else return this.loadBitmapFromUrl(url);
        } else {
            return this._emptyBitmap;
        }
    };

    AudioManager.createBuffer = function (folder, name) {
        const ext = this.audioFileExt();
        const url = this._path + folder + Utils.encodeURI(name) + ext;
        const fs = require('fs');
        if (!fs.existsSync(url)) url = this._path + "se/empty" + ext;
        const buffer = new WebAudio(url);
        buffer.name = name;
        buffer.frameCount = Graphics.frameCount;
        return buffer;
    };

    Video.play = function (src) {
        const fs = require('fs');
        if (!fs.existsSync(src)) return;
        this._element.src = src;
        this._element.onloadeddata = this._onLoad.bind(this);
        this._element.onerror = this._onError.bind(this);
        this._element.onended = this._onEnd.bind(this);
        this._element.load();
        this._loading = true;
    };
}

Both of these require empty sound files named "empty" in the audio/se folder. With bitmaps we can use the existing function for loading empty bitmaps, and with video we can just not load it at all, since an empty video object already exists, but for audio we do need to load something. I've attached two files with 0.2 seconds of silence that you can use (0-length audio files caused some problems, but those should be fine).

For MV, if you're using a script to disable bitmap blurring/smoothing, this will overwrite it - to undo that, change bitmap.smooth = smooth; to bitmap.smooth = false;.

It's also worth noting that this script will intentionally not do anything in a web build - the mechanic of retrying to get a file is rather important there, since failing to load it can be caused by the network connection temporarily dropping.
Sorry about the delay, just tested the script, I get this error on MZ just launching the project:
1710574797840.png


Line 6.
Sorry about the delay, just tested the script, I get this error on MZ just launching the project:
View attachment 298612

Line 6.
Right, it's url in MZ. I've edited the code in the post, so this error should be fixed. Though there might be a few more, since I don't have a way to test the MZ version 😛
Right, it's url in MZ. I've edited the code in the post, so this error should be fixed. Though there might be a few more, since I don't have a way to test the MZ version 😛
It works perfectly! No errors at all, also not "blinking" effects due missing sprites, game just skips the img file and continue running without any impact on the performance. Runs as expected.

Thank you very much @Mac15001900 🙂
It works perfectly! No errors at all, also not "blinking" effects due missing sprites, game just skips the img file and continue running without any impact on the performance. Runs as expected.

Thank you very much @Mac15001900 🙂
Nice, I'm glad that worked. I guess I can remove the "(untested)" note for it then 🙂

Original thread: https://forums.rpgmakerweb.com/threads/request-replace-error-messages-of-missing-files-for-error-log-or-ignore-completely-instead.166133/