Prototype/Recipe: Difference between revisions
(overhaul to include Prototype) |
(0.16) |
||
Line 2: | Line 2: | ||
A recipe. It can be a crafting recipe, a smelting recipe, or a custom type of recipe (see [[Prototype/RecipeCategory]]). | A recipe. It can be a crafting recipe, a smelting recipe, or a custom type of recipe (see [[Prototype/RecipeCategory]]). | ||
== | == General properties == | ||
Inherits all properties from [[Prototype]]. | Inherits all properties from [[Prototype]]. | ||
=== category === | |||
'''Type''': [[Types/string]] | |||
'''Default''': "crafting" | |||
Optional. The category of this recipe. The default is "crafting". The built-in categories can be found [[Data.raw#recipe-category|here]]. See also [[Prototype/RecipeCategory]]. | |||
=== subgroup === | |||
'''Type''': [[Types/string]] | |||
Optional. The subgroup of this recipe. If not specified, defaults to the subgroup of the product if tehre is only 1, or main_product if multiple products exist. If multiple products exit and no main_product is specified, the subgroup is requiered. | |||
=== icon === | |||
'''Type''': [[Types/FileName]] | |||
Either icon or icons is mandatory for recipe with more than 1 product and no main_product. Otherwise defaults to the iocn of main_product/1 product. | |||
If given, it overwrites the icon of the main_product/1 product. | |||
=== icon_size === | |||
'''Type''': [[Types/uint]] | |||
Mandatory if "icon" is defined (regardless of whether icon is mandatory). The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon. | |||
=== icons === | |||
Either icon or icons is mandatory for recipe with more than 1 product and no main_product. Otherwise defaults to the iocn of main_product/1 product. | |||
If given, it overwrites the icon of the main_product/1 product. | |||
=== crafting_machine_tint === | |||
'''Type''': [[Types/table]] of [[Types/Color]] | |||
'''Default''': nil | |||
Format: | |||
<syntaxhighlight lang="lua">crafting_machine_tint = { primary = {r=0,g=0,b=0,a=0}, secondary = {r=0,g=0,b=0,a=0}, tertiary = {r=0,g=0,b=0,a=0}}</syntaxhighlight> | |||
Each key/value pair is optional and defaults to the above value. | |||
== Recipe data == | |||
If the recipe does not have a difficulty, this is located directly in the prototype. Otherwise, if the "normal" or "expensive" property exists, the recipe has difficulty. Then, the recipe data has to be specified for each difficulty instead of directly in the prototype. If at least one difficulty has recipe data defined, the other difficulty can be set to false. This will give it the exact same properties as the difficulty that is defined. See below for examples. | |||
=== ingredients === | === ingredients === | ||
Line 48: | Line 90: | ||
</pre> | </pre> | ||
=== | === energy_required === | ||
'''Type''': [[Types/ | '''Type''': [[Types/double]] | ||
'''Default''': 0.5 | |||
Optional. The amount of time it takes to make this recipe. | |||
This is the number of seconds it takes to craft at crafting speed 1. | |||
=== emissions_multiplier === | |||
'''Type''': [[Types/double]] | |||
'''Default''': 1.0 | |||
=== requester_paste_multiplier === | |||
'''Type''': [[Types/uint]] | |||
'''Default''': 30 | |||
''' | |||
=== overload_multiplier === | |||
'''Type''': [[Types/uint]] | |||
'''Default''': 0 | |||
=== enabled === | === enabled === | ||
'''Type''': [[Types/bool]] | '''Type''': [[Types/bool]] | ||
Optional. This can be false to disable the recipe at the start of the game, or "true" to leave it enabled | '''Default''': true | ||
Optional. This can be false to disable the recipe at the start of the game, or "true" to leave it enabled. | |||
If your recipe is unlocked by a technology, you should set this to "false". | If your recipe is unlocked by a technology, you should set this to "false". | ||
=== hidden === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Optional. Hides the recipe from crafting menus. | |||
=== hide_from_stats === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Optional. Hides the recipe from flow stats (production statistics). | |||
=== allow_decomposition === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': true | |||
Optional. Whether the recipe can be broken down for "total-raw" calculations. | |||
=== allow_as_intermediate === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': true | |||
Optional. Whether the recipe can be used as an intermediate recipe in hand-crafting. | |||
=== allow_intermediates === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': true | |||
Optional. Whether the recipe is allowed to use intermediate recipes when hand-crafting. | |||
=== always_show_made_in === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Optional. Whether the "Made in: {Machine}" part of the tooltip should always be present, not only when the recipe can not be hand-crafted. | |||
=== show_amount_in_title === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': true | |||
Optional. Whether the recipe name should have the product amount in front of it, e.g. "2 [[transport belt]]" | |||
=== always_show_products === | |||
'''Type''': [[Types/bool]] | |||
'''Default''': false | |||
Optional. Whether the products are always shown in the recipe tooltip. | |||
=== main_product === | === main_product === | ||
Line 78: | Line 190: | ||
== Examples == | == Examples == | ||
=== | === "iron-plate" === | ||
<syntaxhighlight lang="lua"> | |||
< | |||
{ | { | ||
type = "recipe", | type = "recipe", | ||
Line 88: | Line 199: | ||
ingredients = {{"iron-ore", 1}}, | ingredients = {{"iron-ore", 1}}, | ||
result = "iron-plate" | result = "iron-plate" | ||
} | }</syntaxhighlight> | ||
</ | |||
=== "coal-liquefaction" === | |||
= | <syntaxhighlight lang="lua">{ | ||
type = "recipe", | type = "recipe", | ||
name = "coal-liquefaction", | name = "coal-liquefaction", | ||
Line 140: | Line 250: | ||
}, | }, | ||
allow_decomposition = false | allow_decomposition = false | ||
} | }</syntaxhighlight> | ||
</ | |||
=== "iron-gear-wheel" — recipe with difficulty === | |||
<syntaxhighlight lang="lua"> { | |||
type = "recipe", | |||
name = "iron-gear-wheel", | |||
normal = | |||
{ | |||
ingredients = {{"iron-plate", 2}}, | |||
result = "iron-gear-wheel" | |||
}, | |||
expensive = | |||
{ | |||
ingredients = {{"iron-plate", 4}}, | |||
result = "iron-gear-wheel" | |||
} | |||
},</syntaxhighlight> | |||
==== Modfied so that the expensive recipe is always used, even in normal mode ==== | |||
<syntaxhighlight lang="lua"> { | |||
type = "recipe", | |||
name = "iron-gear-wheel", | |||
normal = false, | |||
expensive = | |||
{ | |||
ingredients = {{"iron-plate", 4}}, | |||
result = "iron-gear-wheel" | |||
} | |||
},</syntaxhighlight> |
Revision as of 16:12, 1 May 2018
Basics
A recipe. It can be a crafting recipe, a smelting recipe, or a custom type of recipe (see Prototype/RecipeCategory).
General properties
Inherits all properties from Prototype.
category
Type: Types/string
Default: "crafting"
Optional. The category of this recipe. The default is "crafting". The built-in categories can be found here. See also Prototype/RecipeCategory.
subgroup
Type: Types/string
Optional. The subgroup of this recipe. If not specified, defaults to the subgroup of the product if tehre is only 1, or main_product if multiple products exist. If multiple products exit and no main_product is specified, the subgroup is requiered.
icon
Type: Types/FileName
Either icon or icons is mandatory for recipe with more than 1 product and no main_product. Otherwise defaults to the iocn of main_product/1 product.
If given, it overwrites the icon of the main_product/1 product.
icon_size
Type: Types/uint
Mandatory if "icon" is defined (regardless of whether icon is mandatory). The size of the square icon, in pixels, e.g. 32 for a 32px by 32px icon.
icons
Either icon or icons is mandatory for recipe with more than 1 product and no main_product. Otherwise defaults to the iocn of main_product/1 product.
If given, it overwrites the icon of the main_product/1 product.
crafting_machine_tint
Type: Types/table of Types/Color
Default: nil
Format:
crafting_machine_tint = { primary = {r=0,g=0,b=0,a=0}, secondary = {r=0,g=0,b=0,a=0}, tertiary = {r=0,g=0,b=0,a=0}}
Each key/value pair is optional and defaults to the above value.
Recipe data
If the recipe does not have a difficulty, this is located directly in the prototype. Otherwise, if the "normal" or "expensive" property exists, the recipe has difficulty. Then, the recipe data has to be specified for each difficulty instead of directly in the prototype. If at least one difficulty has recipe data defined, the other difficulty can be set to false. This will give it the exact same properties as the difficulty that is defined. See below for examples.
ingredients
Type: Types/table
A table containing ingredient names and counts. For example:
ingredients = {{"iron-stick", 2}, {"iron-plate", 3}}
or the same with full format:
ingredients = {{type = "item", name = "iron-stick", amount = 2}, {type = "item", name = "iron-plate", amount = 3}}
Maximal ingredient amount is 65535.
result
Type: Types/string
Can be replaced with the results parameter. The item created by this recipe. Must be the name of an item, such as "iron-gear-wheel".
result_count
Type: Types/unsigned
Optional. The number of items created by this recipe. The default is 1.
results
Type: Types/table
A table containing result names and counts. For example:
results= { {type="fluid", name="heavy-oil", amount=3}, {type="fluid", name="light-oil", amount=3}, {type="fluid", name="petroleum-gas", amount=4} },
results = { {type = "item", name = "iron-nuggets", amount = 9}, {type = "item", name = "gold-nuggets", amount = 1} },
energy_required
Type: Types/double
Default: 0.5
Optional. The amount of time it takes to make this recipe.
This is the number of seconds it takes to craft at crafting speed 1.
emissions_multiplier
Type: Types/double
Default: 1.0
requester_paste_multiplier
Type: Types/uint
Default: 30
overload_multiplier
Type: Types/uint
Default: 0
enabled
Type: Types/bool
Default: true
Optional. This can be false to disable the recipe at the start of the game, or "true" to leave it enabled.
If your recipe is unlocked by a technology, you should set this to "false".
Type: Types/bool
Default: false
Optional. Hides the recipe from crafting menus.
hide_from_stats
Type: Types/bool
Default: false
Optional. Hides the recipe from flow stats (production statistics).
allow_decomposition
Type: Types/bool
Default: true
Optional. Whether the recipe can be broken down for "total-raw" calculations.
allow_as_intermediate
Type: Types/bool
Default: true
Optional. Whether the recipe can be used as an intermediate recipe in hand-crafting.
allow_intermediates
Type: Types/bool
Default: true
Optional. Whether the recipe is allowed to use intermediate recipes when hand-crafting.
always_show_made_in
Type: Types/bool
Default: false
Optional. Whether the "Made in: {Machine}" part of the tooltip should always be present, not only when the recipe can not be hand-crafted.
show_amount_in_title
Type: Types/bool
Default: true
Optional. Whether the recipe name should have the product amount in front of it, e.g. "2 transport belt"
always_show_products
Type: Types/bool
Default: false
Optional. Whether the products are always shown in the recipe tooltip.
main_product
Type: Types/string
Optional.
For recipes with more than one product: This defines of which result the icon, subgroup and name is used. If it is not set and the recipe has more than 1 result the recipe will use the recipe-name and recipe-description locale and its own subgroup and icon.
For recipes with 1 result: The recipe uses the icon, subgroup and name of the result by default. If set this property is set to an empty string, the recipe will use the properties of the recipe instead of the result.
Examples
"iron-plate"
{
type = "recipe",
name = "iron-plate",
category = "smelting",
energy_required = 3.5,
ingredients = {{"iron-ore", 1}},
result = "iron-plate"
}
"coal-liquefaction"
{
type = "recipe",
name = "coal-liquefaction",
category = "oil-processing",
subgroup = "fluid-recipes",
order = "a[oil-processing]-c[coal-liquefaction]",
enabled = false,
energy_required = 5,
icons = {{icon = "__base__/graphics/icons/fluid/coal-liquefaction.png"}},
ingredients = {
{
amount = 10,
name = "coal",
type = "item"
},
{
amount = 25,
name = "heavy-oil",
type = "fluid"
},
{
amount = 50,
name = "steam",
type = "fluid"
}
},
results = {
{
amount = 35,
name = "heavy-oil",
type = "fluid"
},
{
amount = 15,
name = "light-oil",
type = "fluid"
},
{
amount = 20,
name = "petroleum-gas",
type = "fluid"
}
},
allow_decomposition = false
}
"iron-gear-wheel" — recipe with difficulty
{
type = "recipe",
name = "iron-gear-wheel",
normal =
{
ingredients = {{"iron-plate", 2}},
result = "iron-gear-wheel"
},
expensive =
{
ingredients = {{"iron-plate", 4}},
result = "iron-gear-wheel"
}
},
Modfied so that the expensive recipe is always used, even in normal mode
{
type = "recipe",
name = "iron-gear-wheel",
normal = false,
expensive =
{
ingredients = {{"iron-plate", 4}},
result = "iron-gear-wheel"
}
},