Modding:JSON Patching: Difference between revisions

From Vintage Story Wiki
Marked this version for translation
m (Add an overwrite issue, it's better to let them know than to be completely unaware)
(Marked this version for translation)
Line 116: Line 116:




=== File Path and Name Considerations ===  
=== File Path and Name Considerations === <!--T:28-->
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.
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.


<!--T:29-->
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.
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.


<!--T:30-->
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'''.)
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.
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 ===  
=== Overwriting issue === <!--T:31-->
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.
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.


<!--T:32-->
For example, this patch will be overwritten with patch from example below, even if '''add''' operation is used:
For example, this patch will be overwritten with patch from example below, even if '''add''' operation is used:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
Confirmedusers
13,514

edits