Modding:JSON Patching/en: Difference between revisions

From Vintage Story Wiki
Updating to match new version of source page
(Updating to match new version of source page)
 
(Updating to match new version of source page)
 
(One intermediate revision by the same user not shown)
Line 92: Line 92:
That's all you have to do. If there's already an enabled label in the file then we'd need to switch op from add to replace.
That's all you have to do. If there's already an enabled label in the file then we'd need to switch op from add to replace.


=== File Path and Name Considerations ===
By default, when you generate a mod using ModMaker 3000™, the folder structure will use '''game''' as the domain, and use the same file name as the vanilla JSON file. This can lead to mod conflicts.
Let's use the wolf examples from above. If you run ModMaker after making these changes to '''wolf-male.json''', the resulting ZIP will contain the file '''assets\game\patches\survival-entities-land-wolf-male.json'''. This seems to suggest two conventions that VS expects; that you should put JSON patches under the '''game''' folder, and that you should match the source file name using a folder-hyphen notation. Neither are true, however.
Say you split up the two different wolf changes into two different mods. The first is '''WolvesAreWimps''' and the second is '''WolvesDropSticks'''. ModMaker would generate identical folder structures and files for these two different mods; that is, both would contain the file '''assets\game\patches\survival-entities-land-wolf-male.json'''. These two mods will not work together because they have a filename conflict. (The one that is alphabetically last will take precedence: '''WolvesDropSticks'''.)
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>
'''Note''' : see the [[Modding:CompatibilityLib|Compatibility]] page for possible ways to handle conflicts and dependencies between mods.


At this point, you have all the tools for modifying assets using the patching system. This is an incredibly powerful tool that only limited by your imagination. Have fun patching!
At this point, you have all the tools for modifying assets using the patching system. This is an incredibly powerful tool that only limited by your imagination. Have fun patching!


{{Navbox/modding|Vintage Story}}
{{Navbox/modding|Vintage Story}}
43,204

edits