Register File Plugin

Most people around here have already heard of the problem:
If you check "exclude unused files" on deployment, several plugins will cause errors about missing files.

This is a problem of the plugins because they do not use the official functions to register their files as needed to the editor, either because the plugin writer hasn't read about that in the help file or because the file can't easily be registered.

Up to now I usually told people with that problem to just use the file in the events of an unconnected map as a workaround, but that only works with files that can be used by events.
It doesn't work with files who are in different folders or can't be used with events.


But I just had another idea:
The plugin registering a file doesn't have to be the same plugin as the one actually using that file.


So I'm requesting for the community a rather simple plugin that has a lot of string parameters to be used for filepaths, and that simply registers all files whose paths and filenames are placed in those parameters.

Ideally a game developer would simply copy the file string from an error message about a missing file and place it in this plugins parameters to register that file, so that on next deployment with that option it will not be excluded.
That will need a bit of work from the developer to find all those missing references, but probably less work than searching for the references and placing them in events on maps.


The plugin should also include the following two bughunting features:

1) chack all filestrings from the parameter if any contains a %
If yes, place error message that file xy contains letters forbidden under networking rules and needs to be renamed and all references ingame changed for deployment to work.

2) check if two or more of the strings are identical
If two strings are identical, inform the user that that file is already registered and if it is still reported as missing after being registered the cause is something other than the missing registration.


Suggestion:
either include a long list of optional parameters to be able to contain even a lot of missing registrations, or write the parameters with dynamic plugin name to allow the plugin itself to be duplicated with different names as often as needed to handle whatever number of files need registering.
There is no "official function" to do this, it isn't javascript code that enables the editor to know what files are required by that plugin. Plugin creators are meant to use a comment within their plugin help file to have this functionality work. That comment being @requiredAssets, a plugin that would do what you are asking would be required to write itself to disk after appending comments to itself. This isn't exactly ideal. Also more often than not, I think this issue arises from the fact that plugin creators don't necessarily have hard coded file names, instead opting to just have the user specify which file it is. This would mean, if the user were to change which file they used, it wouldn't exactly solve the problem and they'd have to readd the new file and remove the old one.

Edit: I guess you could also have a bunch of parameters with just @require 1, but regardless it only works for some param types it seems anyway (I just looked).
That is a nice request to ask. I already seem a lot of problems around here about that.
I think that can be solved if the plugin makers just put in the parameters that need a file:
@require 1
Code:
@require 1
If this directive is present, the file specified by this parameter will be included in the deployment if "Exclude unused files" is chosen.
But still, is a valid request because there is no way to guarantee that the plugin makers will do this in all of his plugins and also the ones that are retired.
If no one gives a try, I will do. Because now I'm very busy =/
For static filenames this is OK but a lot of the time you'll be dealing with dynamic filenames. Wonder how they might be addressed externally
I literally posted this exact plugin in another thread a couple of days ago... if I find it I'll repost it here.

It doesn't include your extra two features, mind you. In fact, it doesn't include any code at all. Still, it's probably a good starting point?

EDIT: Found it faster than I expected. Here you go! You can do whatever you like with it (consider it public domain, CC0, whatever). If you or someone else does add the two extra features you mentioned, it would probably be best to just remove my name from the author, since anyone could have written the same thing in like five minutes.

JavaScript:
/*:
@plugindesc Create references to files for the Exclude Unused setting.
@author Solar Flare Games

@param Images
@type file[]
@require 1
@dir img/
@default []

@param Audio
@type file[]
@require 1
@dir audio/
@default []

@param Animations
@type animation
@require 1
@default []

@help
This plugin has no functionality, but allows you to list assets that should be
included by the Exclude Unused Files feature.
*/

Suggestion:
either include a long list of optional parameters to be able to contain even a lot of missing registrations, or write the parameters with dynamic plugin name to allow the plugin itself to be duplicated with different names as often as needed to handle whatever number of files need registering.
As you can see, neither of these workarounds are needed. A single parameter can hold all references to images that you might need. That is, unless you're using an older version of RPGMaker MV - support for complex plugin parameters was added in 1.5.x, I believe.
This is a problem of the plugins because they do not use the official functions to register their files as needed to the editor, either because the plugin writer hasn't read about that in the help file or because the file can't easily be registered.
I have to point out that the function you're referring to here works only for file type as a parameter selected by the user himself. Any file used internally by the plugin isn't covered by that feature.
I stand corrected. I didn't know about "@requiredAssets". That still leaves the problem of dynamic filenames as mentioned above though.

Using a dedicated plugin with "@require 1" is pretty much the same as using a CE to list all your files.
They include the same type of files and in both cases the user has to manually check every plugin content for the files beeing used or spend extensive test/debug time to find out what files are missing.
Thinking about the issue, perhaps it would be better to build a custom file stripper function as an MV tool?

I messed around with MV Tools couple days ago and we can build our own quite easily.

1595732345831.png


The custom resource checker would basically go through the project and identify files that might be unused, and then prompt the user to take a look at the list to see what was identified.

Basically if we're "not sure" if it's in use or not, it's better to just keep it in the folder.
I have to point out that the function you're referring to here works only for file type as a parameter selected by the user himself. Any file used internally by the plugin isn't covered by that feature.

For files used internally by the plugin, the plugin developer just need to use the method Kaliya mentioned above. That will allow Exclude Unused Files to detect them.

Thinking about the issue, perhaps it would be better to build a custom file stripper function as an MV tool?

I messed around with MV Tools couple days ago and we can build our own quite easily.
I was wondering about this awhile ago and would be quite interested in seeing more information on adding additional tools. Or are tools just a list of arbitrary programs? It would be better if there's some kind of connection between the tool and the editor...
I clean out the folder of "audio", "img" (which has all images), than simply add the files
you are going to use.

this way, you always use all images and sounds used in the project.
but if there is still removing when used, than leave "remove unused files" and do it manually.

Manually is 100% the savest way anyway.
I disagree. The safest way is to use only plugins that properly support Exclude Unused Files. The computer can do a much better job than you at figuring out which files are used and which ones are not, as long as every plugin properly registers which files it uses.
I was wondering about this awhile ago and would be quite interested in seeing more information on adding additional tools. Or are tools just a list of arbitrary programs? It would be better if there's some kind of connection between the tool and the editor...

I wrote a tutorial for building your own MV Tools.
They can be GUI or console applications.

Original thread: https://forums.rpgmakerweb.com/threads/register-file-plugin.124500/