AmethystZhou Posted January 7 Report Posted January 7 (edited) Let's say we have mod A (moda) and mod B (modb). Due to the game loading mods alphabetically, mod A will be loaded first, then mod B. If they patch different things, then both will co-exist and function indepently. However, what happens if they patch the same file? I ran into this question and got quite confused, so I did some testing. Here's what I found, hopefully this will help someone else Googling in the future! - If a file is only patched by one mod, then this will function no matter what. - If a file is patched by both mod A and mod B, but mod A patches values X and Y in the file, and mod B only patches Y: - X will always be patched no matter what. - In the default load order (based on mod IDs "moda" and "modb"), the Y value from mod B takes over since it loads last. - Adding mod B as a dependency in the modinfo.json of mod A forces A to load after B, and reverts the above, making the Y value from mod A take over. - Adding "dependsOn": [{ "modid": "modb"}] in the JSON patch itself within mod A has no effect. The Y value is still from mod B. So, how to force mod A to overwrite mod B's patches, without resorting to naming your mod ID "zzzzzzzmoda"? You can add .dll code to force a custom load order of your mod, as documented in the Wiki, or simply use the CompatibilityLib feature of the game. Using the case above as an example, instead of having \assets\moda\patches\patchY.json which may or may not get overwritten depending on whether mod B is also installed, you can add a separate folder \assets\moda\compatibility\modb\patches\patchY.json. This way, the patchY.json file will only be loaded if mod B is also installed, and will overwrite the same patch from mod B. The Wiki also explains some more advanced use case with mod-dependent JSON patch loading. Edited January 7 by AmethystZhou
Nat_VS Posted January 7 Report Posted January 7 Thanks for writing this! Could you please move the post to https://www.vintagestory.at/forums/forum/35-modding-guides/?
AmethystZhou Posted January 8 Author Report Posted January 8 16 hours ago, Nat_VS said: Thanks for writing this! Could you please move the post to https://www.vintagestory.at/forums/forum/35-modding-guides/? I don't think I can move the post, maybe a moderator can do that? Or I can re-post it to the other forum.
Recommended Posts