Modding:Creating Recipes: Difference between revisions

From Vintage Story Wiki
no edit summary
m (change separator (tab to comma))
No edit summary
Line 141: Line 141:
For example if we would have a birch log block, its code would be <code>log-birch-ud</code>, so <code>*</code> would stand for <code>birch</code>, therefore the output will be converted from <code>code: "planks-{wood}"</code> to <code>code: "planks-birch"</code>.
For example if we would have a birch log block, its code would be <code>log-birch-ud</code>, so <code>*</code> would stand for <code>birch</code>, therefore the output will be converted from <code>code: "planks-{wood}"</code> to <code>code: "planks-birch"</code>.


=== Converting an ingredient to another item upon crafting === <!--T:34-->
Sometimes you want to keep one or more of the ingredients, but convert them to a different item after crafting. For example, when crafting a honey-sulfur poultice, the player needs a bowl filled with honey, but the bowl is not consumed to craft it. Instead the bowl of honey is turned into an empty bowl. This is accomplished by adding the <code>returnedStack</code> property to the ingredient. This property's value needs to contain a <code>type</code> and <code>code</code> just like the standard ingredient properties. This tells the recipe which item to give the player back.


<!--T:34-->
Continuing with the honey-sulfur poultice example, a bowl of honey as an ingredient looks like <code>"B": { type: "block", code: "bowl-honey" }</code>, but the player would lose the bowl if the recipe were written this way. We need to add <code>returnedStack</code> to the ingredient's properties and indicate which item to replace it with. In this case, the player should receive an empty bowl in place of the bowl of honey <code>returnedStack: { type: "block", code: "bowl-burned" }</code>. This property is placed alongside the <code>type</code> and <code>code</code> properties of an ingredient. Putting it all together:
<syntaxhighlight lang="json">
{
ingredientPattern: "SBS _L_",
ingredients: {
"L": { type: "block", code: "linen-*" },
"S": { type: "item", code: "powderedsulfur" },
"B": {
type: "block",
code: "bowl-honey",
returnedStack: { type: "block", code: "bowl-burned" }
}
},
width: 3,
height: 2,
output: { type: "item", code: "poultice-linen-honey-sulfur", quantity: 4  }
}
</syntaxhighlight>
 
 
<!--T:35-->
{{Navbox/modding|Vintage Story}}
{{Navbox/modding|Vintage Story}}


</translate>
</translate>
Confirmedusers, editor
6

edits