MZ Stuck making a skip file plugin

For anyone familiar with Krosk's find file plugin for VX Ace, that's essentially what I'm trying to recreate here. I have had minor success in my attempts except for a couple of snags.

I'm only focusing on Se, since it makes it faster to troubleshoot it when focusing on the one audio type.
Spoiler: Code in question
Code:
/*:
(pretend the about section is above this)

@param Missing Error Message
@type string
@default "%s could not be found. Please contact the dev at (your url here)."
@desc Error message if a sound file is missing.

@param Show in Console?
@type boolean
@default false
@desc Error message is shown in the console instead

*/

var ftp = ftp ||{}

var parameters = PluginManager.parameters("FTP_MissingFileSkipper");
var MissingError = parameters["Missing Error Message"];
var ConsoleMsg = parameters["Show in Console?"] == "false";

    
ftp.MissingFileSkipper = function () {
    AudioManager._OGPlaySe = AudioManager.playSe;

    AudioManager.playSe = function (se) {
        if (this._isError = true) {
            showMissingError(se.name);            
        } 
        else {
            this._OGPlaySe(se);
        }
    };

    showMissingError = function (filename) {
        const message = MissingError.replace("%s", filename);
        if (ConsoleMsg) {
            console.warn(message);
        }
        else {
            alert(message);
        }
    };    
    
};

ftp.MissingFileSkipper ();

;

When there's an error, aka a missing file, rpg maker tries to default to its error message. I wanted to try and recreate Krosk's Find File so that play testers can catch the more serious bugs, and I don't have to repackage it several times because I deleted an rtp file that I forgot I was still using.

So the current issues with it are as follows:
  1. Even when the se file (i.e. absorb1) is put back in the right place, the plugin still displays the error message.

  2. When at its default false, it sends the error message to console, but when set to true it sends it to the alert msgbox. This is the exact inverse of what I want, but as far as I can tell, it looks like it's set up correctly when compared to another boolean parameter in a different plugin.
I'm not quite sure what I'm missing here in order to make it work. I was trying to get it to work with try/catch initially, but it kept defaulting to the built-in error handling. Trying to override throwLoadError and checkErrors resulted in a couple of other bugs, so that idea was scrapped. The above code is the closest it's come to actually being functional.

Am I missing something, or have I gotten something wrong? Or both?

Once this is working, I can theoretically just apply it to the other audio types, then try to figure out applying it for images.
You can check this out from @Mac15001900, looks like it's doing what you want.

Even when the se file (i.e. absorb1) is put back in the right place, the plugin still displays the error message.

An error message of "failed to load" is not always a missing file. It can have several different causes:

1) the file is indeed missing

2) the file has a wrong Capitalization: A.png and a.png are two different files for a browser, only Windows has an override that loads the wrong file if it exists.

3) the filename contains a symbol that is not allowed under networking rules - only latin letters, arabic numbers and very few special signs are allowed. SPACE on the other hand is forbidden, which is why it is usually replaced by underscore _ on internet files.

4) the foldername of any folder in the entire filepath contains a forbidden symbol. Example:
c:\folder\test folder\project\img\actor.png
can cause a failed to load "img\actor.png"
That is the reason why for example space is replaced by %20 in a browser adress line if you open local files - the browser simply can't handle space, not even in internal error messages. And that %20 override doesn't always work.

So basically if the cause for the error is something else or if there are two causes for the error, then replacing the file will not stop the error message.
@Andar In this instance for testing purposes, I've just been moving absorb1 in and out of the se file without any change to its name. In theory, if it's just getting the same name file from the same location in the game files, putting the appropriate sound file back in place should make it work again, right?
not if the folderpath itself contains a forbidden letter.

Windows tries to force the browsers to access files through overrides in such cases, and those overrides do not always work.
Theoretically it is even possible that the local play can fail - in early versions of MV this was often the case, until the programmers made the playtest automatically use a virtual folder that would be guaranteed not to use the physical folderpath on the HDD.
Only after that change the playtest hadn't those failed to load errors for wrong foldernames anymore.
But a deployed playtest has to use the physical folderpath and can come against that problem.
@Andar In this particular instance of moving a file around, where there is no special character problem to speak of, it shouldn't be an issue.
The other plugin suggested isn't suitable to me, and still want to try to make my own work. From what I can tell it should work, but I'm still inexperienced to not know for sure what's going wrong.
So on further prodding, I have learned that the issue is:
AudioManager._OGPlaySe = AudioManager.playSe;

The reference isn't referencing, and I do not know what. The Boolean is still being weird, seems that even when I put false, it wants to default to behaving as though it were true.
I am not entirely sure if this is the problem causing your first issue, but in your posted code you have:
JavaScript:
if (this._isError = true)
This is most likely not what you meant to do as you are setting this._isError to true rather than comparing this._isError to true. You need to use 2 or 3 equal signs to compare things.

For your second issue, it is a simple logic error. Currently, you have:
JavaScript:
var ConsoleMsg = parameters["Show in Console?"] == "false";
Let's consider what would result from this code when the parameter is set to "false" or "true".

When the parameter is set to "false" you have told it to compare that against "false", so your variable will be set to true, because "false" is equal to "false". However, when the parameter is set to "true" it will compare that against "false" and the result will be false, because "true" is not equal to "false".
I am not entirely sure if this is the problem causing your first issue, but in your posted code you have:
JavaScript:
if (this._isError = true)
This is most likely not what you meant to do as you are setting this._isError to true rather than comparing this._isError to true. You need to use 2 or 3 equal signs to compare things.

For your second issue, it is a simple logic error. Currently, you have:
JavaScript:
var ConsoleMsg = parameters["Show in Console?"] == "false";
Let's consider what would result from this code when the parameter is set to "false" or "true".

When the parameter is set to "false" you have told it to compare that against "false", so your variable will be set to true, because "false" is equal to "false". However, when the parameter is set to "true" it will compare that against "false" and the result will be false, because "true" is not equal to "false".
Yeah, that was the problem, and I feel silly for not seeing it sooner when it was literally staring me right in the face with a boolean chart on the side trying to figure it out.

As for AudioManager._OGPlaySe = AudioManager.playSe;, I used a console.log to tell me what it is, and it says it's undefined. If it's referencing the original playSe to have it as a copy, shouldn't it still function? Have I written it wrong, and it's looking for something else?

Original thread: https://forums.rpgmakerweb.com/threads/stuck-making-a-skip-file-plugin.172954/