Confirmedusers, editor
1,011
edits
(Normalizing all snippets to use shorthand property names, to avoid confusion; fixing JSON error in example) |
Craluminum (talk | contribs) (move operation) |
||
Line 271: | Line 271: | ||
"addeach" only works when the patch value is an array and the target is an array. Otherwise it will thrown an exception. | "addeach" only works when the patch value is an array and the target is an array. Otherwise it will thrown an exception. | ||
=== Move operation === | |||
"move" is used to move entry to temporary path for using it again later. As example, let's say a mod added new entries to some dictionary that has "*" (wildcard) key. In this case, moving wildcard is essential, because wildcard matches all variants. This is the initial value before both patches: | |||
<syntaxhighlight lang="yaml"> | |||
# Section of showball.json | |||
"damageByType": { | |||
"*-snow": 0.001, | |||
"*-beenade": 0.001, | |||
"*": 1 | |||
}</syntaxhighlight> | |||
For example, this is value after "addmerge" patches: | |||
<syntaxhighlight lang="yaml"> | |||
"damageByType": { | |||
"*-snow": 0.001, | |||
"*-beenade": 0.001, | |||
"*": 1, | |||
"*-meteorite-iron": 10, | |||
}</syntaxhighlight> | |||
Example patch using "move". Here we move wildcard to temporary path, then move it back again. In this case, "move" patches should be right after "addmerge" and "add" patches: | |||
<syntaxhighlight lang="yaml"> | |||
{ | |||
"op": "move", | |||
"frompath": "/damageByType/*", | |||
"path": "/temp", | |||
"file": "game:itemtypes/snowball.json" | |||
}, | |||
{ | |||
"op": "move", | |||
"frompath": "/temp", | |||
"path": "/damageByType/*", | |||
"file": "game:itemtypes/snowball.json" | |||
}</syntaxhighlight> | |||
This is the value after "move" patches: | |||
<syntaxhighlight lang="json"> | |||
"damageByType": { | |||
"*-snow": 0.001, | |||
"*-beenade": 0.001, | |||
"*-meteorite-iron": 10, | |||
"*": 1 | |||
}</syntaxhighlight> | |||
<!--T:26--> | <!--T:26--> |