Modding:Item Json Properties: Difference between revisions

From Vintage Story Wiki
Line 26: Line 26:
     <td>required</td>
     <td>required</td>
     <td>A unique identifier for the item.</td>
     <td>A unique identifier for the item.</td>
     <td>An example JSON(s) in Vintage Story.</td>
     <td>Reference JSONs that use this property.</td>
   </tr>
   </tr>
   <tr>
   <tr>
Line 33: Line 33:
A '''domain prefix''' will be added dynamically depending on the location of the file. Every mod and VintageStory itself have a unique prefix.
A '''domain prefix''' will be added dynamically depending on the location of the file. Every mod and VintageStory itself have a unique prefix.


For example the code '''<code>stone</code>''' turns into '''<code>game:stone</code>'''.  
For example the code '''<code>stone</code>''' turns into '''<code>game:stone</code>'''. To refer to items outside your mod (IE with item patches) you would use the following format:  '''<code>yourmod:youritem</code>'''


The code identifier has to be unique inside its domain. In theory there could be equal identifiers with different domain prefixes.
The code identifier has to be unique inside its domain. In theory there could be equal identifiers with different domain prefixes.
Line 94: Line 94:
----
----


Furthermore there are two ways of combining groups together. So far we covered the default combination mode, which is <code>multiplicative</code> (the total count of variants is the product of all states).
Furthermore there are other ways of combining groups together. So far we covered the default combination mode, which is <code>multiplicative</code> (the total count of variants is the product of all states). There are two other methods, Additive and SelectiveMultiply.
 
Let's take a look at the <code>additive</code> combination mode used in the flowerpot block:


Let's take a look at a different example (flowerpot), which uses the <code>additive</code> combination mode:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
variantgroups: [
variantgroups: [
Line 120: Line 121:


In this case, the result would be <code>same-raw</code>, <code>same-baked</code>, <code>different-raw</code>, <code>different-baked</code>, <code>red</code> and <code>green</code>
In this case, the result would be <code>same-raw</code>, <code>same-baked</code>, <code>different-raw</code>, <code>different-baked</code>, <code>red</code> and <code>green</code>
The third combination mode <code>"SelectiveMultiply"</code> which allows you to specify which variant groups you want to combine multiplicatively with. There are many examples of this in the clothing item JSONS, as shown below with the lowerbody asset:
<syntaxhighlight lang="json">
    code: "clothes",
    variantgroups: [
{ code: "category",  states: ["lowerbody"] },
{ code: "lowerbody", combine: "SelectiveMultiply", onVariant: "category", states: [
"aristocrat-leggings", "dirty-linen-trousers", "fine-trousers", "jailor-pants", "lackey-breeches", "merchant-pants",
                "messenger-trousers", "minstrel-pants", "noble-pants", "prince-breeches", "raindeer-trousers", "raw-hide-trousers",
                "shepherd-pants", "squire-pants", "steppe-shepherds-trousers", "tattered-peasent-gown", "torn-riding-pants",         
                "warm-woolen-pants", "woolen-leggings", "workmans-gown"
          ] },
],
</syntaxhighlight>
the function <code>onVariant</code> specifies which variant group to selectively combine with, ignoring all other variants without it.
using this will result in an item called <code>clothes-lowerbody-aristocrat-leggings</code>, <code>clothes-lowerbody-dirty-linen-trousers</code>, etc.
     </td>
     </td>
   </tr>
   </tr>
Line 193: Line 214:
</td>
</td>
   </tr>
   </tr>
  <tr>
  <td scope="row"><div class="tt" data-tt-id="p_enabled" data-tt-parent="root">allowedVariants</div></td>
  <td>array</td>
  <td>-</td>
  <td>Used to trim unnecessary items generated by combined variants. </td>
  <td>crystalizedore-graded, ore-graded, ore-ungraded</td>
</tr>
   <tr>
   <tr>
     <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Specific</b></td>
     <td colspan="4" style='font-size: 14pt; border-bottom: 2pt solid black; padding-left: 100px;'><b>Specific</b></td>
219

edits