Jump to content

Compatibility Lib v1.2.1 (easy way to add assets for compatibility with other mods)


Recommended Posts

A simple library for Vintage Story that makes it easy to add compatibility with other mods for assets.

Easy way

Spoiler

You just need to add your asset to assets/<yourmodid>/compatibility/<othermodid>/<vanilla-path>. They will only be loaded if <othermodid> is loaded.

For example:
I have a More Variants mod (modid - morevariants), I want to add a patch to support Carry Capacity (modid - carrycapacity) and add recipes for Extra Chests (modid - extrachests). As a result, the assets will look like this:

  • assets
    • morevariants
      • blocktypes
      • patches
      • recipes
      • compatibility
        • carrycapacity
          • patches
            • carryable.json
        • betterchests
          • recipes
            • grid
              • copperchest.json
              • copperlabeledchest.json

P.S. If assets/<yourmodid>/<vanilla-path> and assets/<yourmodid>/compatibility/<othermodid>/<vanilla-path> exists then if <othermodid> is loaded, the first asset will be replaced.

Advanced (v1.2+)

Spoiler

You can use dependsOn[] in json-patch for create mod-dependent patch. For example:

  • dependsOn[{"modid": "morerecipes"}] - loaded if enabled morerecipes mod
  • dependsOn[{"modid": "morerecipes", "invert": true}] - loaded if disabled morerecipes mod
  • dependsOn[{"modid": "morerecipes"}, {"modid": "captureanimals"}] - loaded if enabled morerecipes AND captureanimals mods
  • dependsOn[{"modid": "morerecipes"}, {"modid": "captureanimals", "invert": true}] - loaded if enabled morerecipes AND disabled captureanimals

Warning! Unlike the easy way, if you use mod-dependent patches, it is advisable to add compatibilitylib in the mod dependencies, otherwise all patches will be loaded without the library installed.

How to add to modinfo.json:


{
  "modid": "bestmod",
  <...>
  "dependencies": {
    "game": "1.13.4", <-- minimal game version for your mod
    "compatibilitylib": "1.2.0" <-- minimal CL version
  }
}

 

Full patch example:





[
  {
    "_comment": "If you add enable: false to your recipe, you can simply enable it when the desired mod is loaded",
    "file": "recipes/grid/best-other-fish-recipe.json",
    "op": "replace",
    "path": "/enabled",
    "value": true,
    "dependsOn": [{ "modid": "primitivesurvival" }]
  },
  {
    "_comment": "Otherwise, just disable the recipe when the mod is not loaded",
    "file": "recipes/grid/best-fish-recipe.json",
    "op": "add",
    "path": "/enabled",
    "value": false,
    "dependsOn": [{ "modid": "primitivesurvival", "invert": true }]
  },
  {
    "_comment": "Or when two mods are loaded :P",
    "file": "recipes/grid/best-fish-recipe-with-acorns.json",
    "op": "replace",
    "path": "/enabled",
    "value": true,
    "dependsOn": [
        { "modid": "primitivesurvival" },
        { "modid": "acorns" }
     ]
  },
  { "_comment": "For simplicity, you can patch all recipes in a folder at once with *",
    "file": "recipes/grid/morerecipes-disable/*",
    "op": "add",
    "path": "/enabled",
    "value": false,
    "dependsOn": [{ "modid": "morerecipes" }]
  }
]

Download: ModDB or GitHub

Install as a regular mod, just add archive to your mods folder.

Edited by DArkHekRoMaNT
  • Like 3
  • Thanks 4
Link to post
Share on other sites
  • DArkHekRoMaNT changed the title to Compatibility Lib v1.1 (easy way to add compatibility with other mods)
  • 2 weeks later...
  • DArkHekRoMaNT changed the title to Compatibility Lib v1.1 (easy way to add assets for compatibility with other mods)
  • 2 weeks later...

so would this work with my Clay+Misc mod or do I need to finish cleaning it up and replacing everything in a more traditional mod form to work?

right now it's only released as it is made using the mod maker provided by VS and as result it doesn't transfer textures so I opened the mod zip it created and added the texture folder manually, other than that it is however the mod maker makes it.

I haven't gotten any feed back so I don't know if my mod even works for other people as of right now. it works for me but that's because I have the original JSON that I added in the vanilla Roaming > Vintagestory > assets > survival folder and everything is working on my end except the poring of the saw mold and I'm working on that. 

I'll be re-writing the whole thing in a proper mod folder using the game: reference line and everything but right now it's being hard to make work that way. it works best right in the folders themselves but I'm still learning and working on it. 

I wish it was as easy as modding 7 days to die and simply have a UIAtlases for my textures and a mod folder with <mymodname> <append xpath="/items"> put all the new items I want to add between here then close it with </append> </mymodname> this would be so much easier but this whole JSON thing is new to me and I'm still trying to figure it out.

Link to post
Share on other sites
2 hours ago, Sukotto82 said:

Roaming > Vintagestory > assets > survival

Don't do this, it will NOT work for other people.  Put this file in assets/game in your mod folder.

But in general, the library just looks at the assets in the compatibility category and checks for the modid in the list of loaded mods.  This should work for vanilla too.

 

Edited by DArkHekRoMaNT
  • Thanks 1
Link to post
Share on other sites
  • 1 month later...

Okay, I have a lot of mods now and would like a few more but need this, but have been avoiding this because I don't understand this. I have only ever been a designer and dabbled in flash animation a long while ago but am better at graphics than code. So I can't comfortable use something I don't understand. So, can I get a step by step for dummies on how to use this and when to use this mod and what you use and where the assets might be? Sorry...

Link to post
Share on other sites
  • DArkHekRoMaNT changed the title to Compatibility Lib v1.2 (easy way to add assets for compatibility with other mods)
  • DArkHekRoMaNT changed the title to Compatibility Lib v1.2.1 (easy way to add assets for compatibility with other mods)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.