Modding:JSON Patching: Difference between revisions

From Vintage Story Wiki
updated for 1.19.4 and cleaned up a bit
m (Updated game version.)
(updated for 1.19.4 and cleaned up a bit)
Line 1: Line 1:
<languages/><translate>
<languages/><translate>
<!--T:1-->
<!--T:1-->
{{GameVersion|1.19}}
{{GameVersion|1.19.4-rc.1}}


<!--T:2-->
<!--T:2-->
Line 15: Line 15:


<!--T:6-->
<!--T:6-->
The first thing you need to do is to setup a generic mod as outlined on the wiki. That information can be found on the [[Mod Packaging|mod packaging]] page. In that example the domain is the name of your mod. Patching is considered a content mod but if you have a .dll or .cs in your mod it is a code mod. Patches go in assets/domain/patches.
The first thing you need to do is to set up a generic mod as outlined on the wiki. That information can be found on the [[Mod Packaging|mod packaging]] page. In that example the domain is the name of your mod. Patching is considered a content mod but if you have a .dll or .cs in your mod it is a code mod. Patches go in assets/domain/patches.


<!--T:7-->
<!--T:7-->
Now that the mod files and folders are setup it is time to make the first patch. Start by making a .json and name it however you'd like. Open the file with your favorite text editor and fill it in with the following.
Now that the mod files and folders are set up, it is time to make the first patch. Start by making a .json and name it however you'd like. Open the file with your favorite text editor and fill it in with the following.
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
[
[
Line 32: Line 32:


<!--T:9-->
<!--T:9-->
Now lets give an example. For these examples I'll be modifying the wolf-male.json because it was the first one I modified, I'm very familiar with it, and it provides a good basis for examples. In this first example, we'll modify wolf damage.
Now let's give a few examples, using the wolf-male.json file.  Note that specific line numbers etc. below might not match your own wolf-male.json file if you're using a different version of the game. In this first example, we'll modify wolf damage.


<!--T:10-->
<!--T:10-->
Line 42: Line 42:


<!--T:11-->
<!--T:11-->
You can change the domain to modify other peoples mods as well.
You can change the domain to modify other people's mods, as well.


<!--T:12-->
<!--T:12-->
Line 52: Line 52:
op: "replace"
op: "replace"
</syntaxhighlight>
</syntaxhighlight>
Since wolves already deal damage we simply want to replace the damage value.
Since wolves already deal damage, we simply want to '''replace''' the damage value.


<!--T:14-->
<!--T:14-->
Line 65: Line 65:


<!--T:16-->
<!--T:16-->
Within these square brackets, you'll find sections between curly braces. '''Curly braces { }'''
Within these square brackets, we have sections.  These start and end in curly braces. '''Curly braces { }'''


<!--T:17-->
<!--T:17-->
Line 71: Line 71:


<!--T:18-->
<!--T:18-->
Now to break down the example. We see the value we want to modify on line 52. To get to that we trace it back to the first label which is '''server'''. From there the next label is behavoirs. Here we notice the square brackets, so we must count. In this case to 5. Next is the label '''aitasks''', then we hit more square brackets. The count for this is 0 because that's the number you start on. Finally we get to the label '''damage'''.
Now to break down the example. We see the value we want to modify (damage) on line 119. Trace it back to the first label, which is '''server'''. From there the next label is '''behaviors'''. Here we notice the square brackets, so we must count -- in this case to 9.
* <code>{ code: "repulseagents"</code>... is section 0
* <code>{ code: "controlledphysics"</code>... is section 1
* <code>{ code: "despawn"</code>... is section 2
* <code>{ code: "health"</code>... is section 3
* <code>{ code: "deaddecay"</code>... is section 4
* <code>{ code: "floatupwhenstuck"</code>... is section 5
* <code>{ code: "harvestable"</code>... is section 6
* <code>{ code: "breathe"</code>... is section 7
* <code>{ code: "emotionstates"</code>... is section 8
* <code>{ code: "taskai"</code>... is section 9
 
Next is the label '''aitasks''', then we hit more square brackets. The count for this is 0 because that's the number you start on. Finally we get to the label '''damage'''.


<!--T:19-->
<!--T:19-->
Line 86: Line 98:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
[  
[  
{ file: "game:entities/land/wolf-male", op: "replace", path: "/server/behaviors/4/aitasks/0/damage", value: 6},
{ file: "game:entities/land/wolf-male", op: "replace", path: "/server/behaviors/9/aitasks/0/damage", value: 6},
{ file: "game:entities/land/wolf-male", op: "add", path: "/drops/-", value: {  
{ file: "game:entities/land/wolf-male", op: "add", path: "/drops/-", value: {  
type: "item",  
type: "item",  
Line 164: Line 176:


<!--T:26-->
<!--T:26-->
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 is only limited by your imagination. Have fun patching!


<!--T:27-->
<!--T:27-->
{{Navbox/modding|Vintage Story}}
{{Navbox/modding|Vintage Story}}
</translate>
</translate>
Confirmedusers, editor
1,051

edits