Giter VIP home page Giter VIP logo

compatibilitylib's Introduction

CompatibilityLib

Embedded in vanilla since 1.15.0, do not use the library as mod in later versions, the game will crash.

Wiki page (actually info): https://wiki.vintagestory.at/index.php?title=Modding:CompatibilityLib
Topic on forum: https://www.vintagestory.at/forums/topic/2863-combatibility-lib
Moddb page: https://mods.vintagestory.at/show/mod/110

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

Easy way

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+)

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 enabled: 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" }]
  }
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.