-
Notifications
You must be signed in to change notification settings - Fork 3
included patchmod
A common problem when making a mod is to make it compatible with other mods. A common approach is to make a patch file to add new data to make use of some other mods. This is then released as a standalone mod. This is far from ideal because not only could one mod require multiple patchmods, the user has to manage the patchmods, which includes a high risk of doing it incorrectly.
The answer is to include the patchmod in the mod itself. This means only one mod to release and maintain and the user will not have to worry about mod combos. If the user likes a mod, he/she can enable it and it will adapt itself to whatever other mods are loaded without any human interaction.
The way to make a patchmod inside your patch is actually surprisingly simple. You make a Sequence of operations and the first one is IsModLoaded. Since the sequence will stop applying the operations after the first failed one, whatever follows IsModLoaded will only be applied if the mod is loaded.
Example:
<Operation Class="ModCheck.Sequence">
<patchName>Patching for A Dog Said...</patchName>
<operations>
<li Class="ModCheck.IsModLoaded">
<modName>A Dog Said...</modName>
</li>
<li Class="PatchOperationAdd">PatchOperationAdd can be written just like it's normally written. However IsModLoaded will prevent it from being reached should A Dog Said... not be loaded. This means your animal will work with ADS without the user doing anything. However should the user not use ADS for whatever reason, your mod will still work just fine.
You can add multiple patches to match multiple mods and if you need complex decision making, you can use logic operators like AND, OR and IfElse. This should remove the need for most, if not all patchmods.
See also: conditional Harmony patching and A-Dog-Said...-patching-guide