Modding:Creating Recipes: Difference between revisions

From Vintage Story Wiki
(Created page with "__FORCETOC__ Before you should start here. I highly recommend to read Creating Items first in order to understand this tutorial properly. == Basics == === Ingredient Pat...")
 
No edit summary
Line 3: Line 3:


== Basics ==
== Basics ==
Let's create an recipe for our wand (which we added in [[Creating Items|creating items]] tutorial).


=== Ingredient Pattern ===
=== Ingredient Pattern ===
In order to tell the game what to put where we can use the pattern. In our example we want to add this recipe to the game
[[File:Recipe Wand Pickaxe.png]]
which would look like this:
<syntaxhighlight lang="json">
ingredientPattern: "P S S",
width: 1,
height: 3,
</syntaxhighlight>
<code>P</code> and <code>S</code> are identifier which will be defined later. Every row is separated with a tab, while an empty cell is mark with an underscore <code>_</code>. The <code>width</code> of this recipe is <code>1</code> and it is <code>3</code> rows high.


=== Ingredients ===
=== Ingredients ===


Is there a quantity selection for ingredients?
All we need to do now, is to define the identifiers we have used before. In our example <code>P</code> stands for a copper pickaxe and <code>S</code> for an ordinary stick.
 
<syntaxhighlight lang="json">
ingredients: {
"P": { type: "item", code: "pickaxe-copper"},
"S": { type: "item", code: "stick"}
},
</syntaxhighlight>
 
<code>Type</code> is either <code>block</code> or <code>item</code> depending whether it's an item or a block.
 
In order to find out the <code>code</code> of each item (or block), you can type <code>.edi</code> into console, which will add the code property to the tooltip:
 
[[File:Recipe Stick Tooltip.png]]
 
 
Furthermore, we could add a required quantity to our ingredients, so instead of one stick per slot we could make it require more:
 
<syntaxhighlight lang="json">
ingredients: {
"P": { type: "item", code: "pickaxe-copper"},
"S": { type: "item", code: "stick", quantity: 2}
},
</syntaxhighlight>
 
Another thing we could do is instead of consuming the pickaxe, we could use it as a tool:
 
<syntaxhighlight lang="json">
ingredients: {
"P": { type: "item", code: "pickaxe-copper", isTool: true},
"S": { type: "item", code: "stick"}
},
</syntaxhighlight>
 
This would cause the pickaxe to lose one durability during crafting, instead of consuming the whole pickaxe at once.


=== Output ===
=== Output ===
We still need to define the output, which is rather similar to defining the ingredients:
<syntaxhighlight lang="json">
output: { type: "item", code: "wand-pickaxe"}
</syntaxhighlight>
Theoretically we could add the <code>quantity</code> property here as well.
=== Distributing ===
This is how our final recipe looks like:
<syntaxhighlight lang="json">
{
ingredientPattern: "P S S",
width: 1,
height: 3,
ingredients: {
"P": { type: "item", code: "pickaxe-copper"},
"S": { type: "item", code: "stick"}
},
output: { type: "item", code: "wand-pickaxe"}
}
</syntaxhighlight>
You can download all 3 recipes [http://wiki.vintagestory.at/images/8/87/MyWandRecipeMod.zip here].


== Advanced ==
== Advanced ==
Line 16: Line 91:
=== Type based recipes ===
=== Type based recipes ===


Planks for example
There are more complicated things you can do with recipes. This the recipe for wooden planks which are crafted out of logs:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
{
{
Line 28: Line 103:
}
}
</syntaxhighlight>
</syntaxhighlight>
Instead of having a recipe for every wood type, you can assign a name to an ingredient (in this case it is <code>name: "wood"</code>) and everything identified by <code>*</code> will later on replaced be for the output. Meaning <code>{wood}</code> will be replaced by the type of the giving log.
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>.

Revision as of 15:24, 17 February 2017

Before you should start here. I highly recommend to read Creating Items first in order to understand this tutorial properly.

Basics

Let's create an recipe for our wand (which we added in creating items tutorial).

Ingredient Pattern

In order to tell the game what to put where we can use the pattern. In our example we want to add this recipe to the game

Recipe Wand Pickaxe.png

which would look like this:

	ingredientPattern: "P	S	S",
	width: 1,
	height: 3,

P and S are identifier which will be defined later. Every row is separated with a tab, while an empty cell is mark with an underscore _. The width of this recipe is 1 and it is 3 rows high.

Ingredients

All we need to do now, is to define the identifiers we have used before. In our example P stands for a copper pickaxe and S for an ordinary stick.

	ingredients: {
		"P": { type: "item", code: "pickaxe-copper"},
		"S": { type: "item", code: "stick"}
	},

Type is either block or item depending whether it's an item or a block.

In order to find out the code of each item (or block), you can type .edi into console, which will add the code property to the tooltip:

Recipe Stick Tooltip.png


Furthermore, we could add a required quantity to our ingredients, so instead of one stick per slot we could make it require more:

	ingredients: {
		"P": { type: "item", code: "pickaxe-copper"},
		"S": { type: "item", code: "stick", quantity: 2}
	},

Another thing we could do is instead of consuming the pickaxe, we could use it as a tool:

	ingredients: {
		"P": { type: "item", code: "pickaxe-copper", isTool: true},
		"S": { type: "item", code: "stick"}
	},

This would cause the pickaxe to lose one durability during crafting, instead of consuming the whole pickaxe at once.

Output

We still need to define the output, which is rather similar to defining the ingredients:

	output: { type: "item", code: "wand-pickaxe"}

Theoretically we could add the quantity property here as well.

Distributing

This is how our final recipe looks like:

{
	ingredientPattern: "P	S	S",
	width: 1,
	height: 3,
	ingredients: {
		"P": { type: "item", code: "pickaxe-copper"},
		"S": { type: "item", code: "stick"}
	},
	output: { type: "item", code: "wand-pickaxe"}
}

You can download all 3 recipes here.

Advanced

Type based recipes

There are more complicated things you can do with recipes. This the recipe for wooden planks which are crafted out of logs:

{
	ingredientPattern: "L",
	ingredients: {
		"L": { type: "block", code: "log-*-ud", name: "wood" }
	},
	width: 1,
	height: 1,
	output: { type: "block", code: "planks-{wood}", quantity: 4  }
}

Instead of having a recipe for every wood type, you can assign a name to an ingredient (in this case it is name: "wood") and everything identified by * will later on replaced be for the output. Meaning {wood} will be replaced by the type of the giving log.

For example if we would have a birch log block, its code would be log-birch-ud, so * would stand for birch, therefore the output will be converted from code: "planks-{wood}" to code: "planks-birch".