Asset Blacklist and Whitelist - PorktoberRevolution/ReStocked GitHub Wiki
The Problem, and ReStock's solution
ReStock replaces many of Squad's models and textures with new ones (via ModuleManager patches). However, KSP will still load the old models and textures, adding to loading time and increasing memory usage.
When KSP loads models and textures, it first generates a list of everything to be loaded, and then loads it. ReStock's plugin modifies this list before KSP actually loads models and textures, modifying the entries so that KSP will ignore them. This is based on a blacklist of models and textures, so in addition to the ModuleManager patch telling the part to use the new model, there is an entry on the blacklist to prevent the old model and textures from loading.
My mod uses stock KSP models and/or textures, how do I get it to play nice with Restock?
We decided that it was probably not practical to maintain a list of which other mods use which stock models/textures on ReStock's side. But it's easy to include just one file in your mod that will tell ReStock not to block the assets you need from loading (see the next section).
Alternately, you might consider having your mod use the ReStock models and textures over the Squad ones if available. This can be done with simple ModuleManager editing, for instance:
MODEL
{
model:NEEDS[!ReStock] = Squad/Parts/...
model:NEEDS[ReStock] = ReStock/Assets/...
}
Blacklist/Whitelist syntax
Any number of blacklist/whitelist files can be present and will all be read. Blacklist files are identified as having the extension .restockblacklist
, and whitelist files have the extension .restockwhitelist
. Each line of a blacklist/whitelist file represents a GameData
relative path that ReStock's plugin will attempt to match files in KSP's file list against. If an asset is only blacklisted, it will not be loaded. If it is both blacklisted and whitelisted, it will be loaded. The syntax obeys the following rules:
- Config files (
.cfg
) will never be blacklisted/whitelisted - Comments (starting with a
//
) and empty lines are allowed - If the path ends with a
/
, it will match every file within that directory - If no extension is specified, any file with that name will be matched (it will ignore the extension)
- Wildcards (
*
) can be present in a path and will match anything but cannot cross directory boundaries
Practical Example
Let's say you use the stock mystery goo model somewhere in your mod. Evidently this will be a problem because ReStock blacklists it. You will probably see something like this in the log
[LOG 00:09:03.267] PartLoader: Compiling Part 'MyMod/Parts/ThingThatUsesGoo/ThingThatUsesGoo'
[ERR 00:09:03.269] PartCompiler: Cannot clone model 'Squad/Parts/Science/GooExperiment/GooExperiment' as model does not exist
[ERR 00:09:03.270] PartCompiler: Model was not compiled correctly
[ERR 00:09:03.270] PartCompiler: Cannot compile model
[ERR 00:09:03.271] PartCompiler: Cannot compile part
And let's say that using the ReStock goo model is not an option here. But you can fix this by whitelisting the model and textures in your mod. The relevant line in ReStock's blacklist is
Squad/Parts/Science/
So all models and textures in Squad/Parts/Science/
(and subdirectories) will not be loaded. You could add this line to your whitelist, but you're only using a few things from that directory so it doesn't make sense to force the rest of it to load too. You only need to whitelist the things you are using.
Your whitelist file will be something like MyMod/MyMod.restockwhitelist
(name and location don't matter exactly, only the extension). It could contain the following
Squad/Parts/Science/GooExperiment/
This will tell ReStock's plugin that everything in that directory should be whitelisted and therefore loaded. In this case those will be
Squad/Parts/Science/GooExperiment/GooExperiment.dds
Squad/Parts/Science/GooExperiment/GooExperiment.mu
Syntax Examples
Directories
Squad/Parts/Aero/aerodynamicNoseCone/
will match
Squad/Parts/Aero/aerodynamicNoseCone/aerodynamicNoseCone.mu
Squad/Parts/Aero/aerodynamicNoseCone/Rockomax_Adapters_diffuse.dds
Squad/Parts/Aero/aerodynamicNoseCone/Rockomax_Adapters_normal.dds
Wildcards
Squad/Parts/Aero/cones/ConesDiffuse*.dds
will match
Squad/Parts/Aero/cones/ConesDiffuse.dds
Squad/Parts/Aero/cones/ConesDiffuse_Orange.dds
Squad/Parts/Aero/cones/ConesDiffuse_White.dds
Extensions
Squad/Parts/Aero/miniIntake/SmallIntake
will match
Squad/Parts/Aero/miniIntake/SmallIntake.dds
Squad/Parts/Aero/miniIntake/SmallIntake.mu
Troubleshooting
KSP's log is probably the first place to look. If a part isn't loading because of a missing model, or a model isn't loading because of a missing texture, KSP will produce log messages telling you that. The log will also list every whitelist/blacklist that ReStock reads, a warning message if any line if one of those files does not match anything, and a list of every asset that ReStock is preventing from loading.
If you have further questions or need help, feel free to ask in the ReStock thread or reach out to blowfish directly on the forums.