Modding:Variants: Difference between revisions

From Vintage Story Wiki
m
Added basic understanding.
m (Added mention of world properties.)
m (Added basic understanding.)
Line 1: Line 1:
<noinclude><languages/></noinclude>
<noinclude><languages/>
__TOC__


== Introduction ==
__TOC__</noinclude>
This page is in progress.


== Basic Understanding ==
== Basic Understanding ==
Vintage Story has a very large number of items, blocks, and entities, and this is helped by having variants of many objects.
Take, for example, the hammer item. There exists 9 hammers in the game and each one has identical functionality, with some minor details changed. Without variants, each hammer would have to be created individually which would result in a lot of time, and a lot of different files.
[[File:HammersToShowVariants.png]]
[[File:HammersToShowVariants.png]]
By using variants, a single hammer item is created, and variant groups are added to it. Most properties in our hammer item file remain the same, however some are changed dependent on the variant of hammer. Specifically, each hammer has identical functionality, however each hammer has a different texture, tooltier, durability, and attack power.
The hammer is referenced throughout this page, so here is the file in its entirety:
{| class="wikitable mw-collapsible mw-collapsed"
|''itemtypes/tool/hammer.json''
|-
|<syntaxhighlight lang="json">
{
code: "hammer",
class: "ItemHammer",
storageFlags: 257,
attributes: {
handbook: {
groupBy: ["hammer-*"]
},
toolrackTransform: {
rotation: { y: 1, z: -1 },
translation: { x: -0.2, y: 0.02 },
scale: 1.5,
},
groundStorageTransform: {
translation: { x: 0, y: -0.16, z: 0.33 },
rotation: { x: 26, y: 88, z: -87 },
scale: 1.01
}
},
behaviors: [{
name: "GroundStorable",
properties: {
layout: 'WallHalves',
wallOffY: 1,
sprintKey: true,
selectionBox: { x1: 0, y1: 0, z1: 0, x2: 1, y2: 0.1, z2: 1 },
collisionBox: { x1: 0, y1: 0, z1: 0, x2: 0, y2: 0, z2: 0 },
}
}],
variantgroups: [
{ code: "metal", states: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "gold", "silver",
"iron", "meteoriciron", "steel"
  ] },
],
tool: "hammer",
damagedby: ["blockbreaking", "attacking"],
heldTpHitAnimation: "smithingwide",
shape: { base: "item/tool/hammer" },
texturesByType: {
"*": {
"metal": { base: "block/metal/ingot/{metal}" },
"wood": { base: "item/tool/material/wood" }
}
},
tooltierbytype: {
"*-copper": 2,
"*-gold": 2,
"*-silver": 2,
"*-bismuthbronze": 3,
"*-tinbronze": 3,
"*-blackbronze": 3,
"*-iron": 4,
"*-meteoriciron": 4,
"*-steel": 5
},
durabilitybytype: {
"hammer-stone": 60,
"hammer-gold": 250,
"hammer-silver": 250,
"hammer-copper": 500,
"hammer-tinbronze": 750,
"hammer-bismuthbronze": 900,
"hammer-blackbronze": 1100,
"hammer-iron": 1800,
"hammer-meteoriciron": 2100,
"hammer-steel": 4500
},
attackpowerbytype: {
"hammer-stone": 1,
"hammer-copper": 1.25,
"hammer-gold": 1.5,
"hammer-silver": 1.5,
"hammer-bismuthbronze": 1.5,
"hammer-tinbronze": 1.75,
"hammer-blackbronze": 2,
"hammer-iron": 2.25,
"hammer-meteoriciron": 2.35,
"hammer-steel": 2.5
},
creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] },
fpHandTransform: {
translation: { x: 0.0468, y: -0.2, z: 0 },
rotation: { x: -33, y: 7, z: 90 },
scale: 2.75
},
guiTransform: {
translation: { x: 0, y: 0, z: 0 },
rotation: { x: -77, y: 46, z: 8 },
origin: { x: 0.59, y: 0.5, z: 0.49 },
scale: 2.6
},
groundTransform: {
translation: { x: 0, y: 0, z: 0 },
rotation: { x: 0, y: 0, z: 0 },
origin: { x: 0.5, y: 0.45, z: 0.5 },
scale: 4.5
},
tpHandTransform: {
translation: { x: -0.65, y: -0.48, z: -0.52 },
rotation: { x: 90, y: 1, z: 0 },
scale: 1
}
}
</syntaxhighlight>
|}


== Usage in JSON ==
== Usage in JSON ==
Line 84: Line 199:
base: "block/seashell/{type}"
base: "block/seashell/{type}"
}
}
</syntaxhighlight>
</syntaxhighlight>For example, a plain clam would look for a texture at textures/''block/creature/seashell/plain'', and would look for a shape at shapes/''block/seashell/clam''.


=== ByType Properties ===
=== ByType Properties ===
Line 151: Line 266:


== Conclusion ==
== Conclusion ==
 
Variants are exceptionally useful when creating content for Vintage Story, and it is highly recommended to understand how and why variants are used. To read about more content modding concepts, go to the [[Modding:Content Mod Concepts|Content Mod Concepts]] page.{{navbox/contentmodding}}
{{navbox/contentmodding}}
Confirmedusers
566

edits