Modding:JSON Patching: Difference between revisions

From Vintage Story Wiki
m
Add an overwrite issue, it's better to let them know than to be completely unaware
(Added file and name considerations section from unuroboros)
m (Add an overwrite issue, it's better to let them know than to be completely unaware)
Line 125: Line 125:
To avoid the possibility of mod conflicts, do not use the '''game''' folder. Instead, use a folder with the same name as your '''modid'''; that is, your mod's domain. So in this example, WolvesAreWimps.zip should instead have the folders '''assets\wolvesarewimps\patches''' and WolvesDropSticks.zip should instead have the folders '''assets\wolvesdropsticks\patches'''. File names are also arbitrary, you do not need to use '''survival-entities-land-wolf-male.json''' and can name the file anything you want, since its contents direct the game on what and how to patch, not the file's name.
To avoid the possibility of mod conflicts, do not use the '''game''' folder. Instead, use a folder with the same name as your '''modid'''; that is, your mod's domain. So in this example, WolvesAreWimps.zip should instead have the folders '''assets\wolvesarewimps\patches''' and WolvesDropSticks.zip should instead have the folders '''assets\wolvesdropsticks\patches'''. File names are also arbitrary, you do not need to use '''survival-entities-land-wolf-male.json''' and can name the file anything you want, since its contents direct the game on what and how to patch, not the file's name.
   
   
=== Overwriting issue ===
Patches that are creating e.g. behaviors or attributes (for example, if item does not have it), will be overwritten by patches from other mods that are doing same, but with another value.
For example, this patch will be overwritten with patch from example below, even if '''add''' operation is used:
<syntaxhighlight lang="json">
[
  {
    op: "add",
    path: "/behaviors",
    value: [{ "name": "SealPlacedCrock" }],
    file: "game:itemtypes/resource/fat.json"
  }
]
</syntaxhighlight>
<syntaxhighlight lang="json">
[
  {
    op: "add",
    path: "/behaviors",
    value: [{ "name": "Placeable" }],
    file: "game:itemtypes/resource/fat.json"
  }
]
</syntaxhighlight>


<!--T:26-->
<!--T:26-->
Confirmedusers, editor
982

edits