Prototype/Recipe: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(0.17.67)
(Removed old prototype docs)
Tag: Replaced
 
(35 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Prototype parent|PrototypeBase}}
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html]
A recipe. It can be a crafting recipe, a smelting recipe, or a custom type of recipe (see [[Prototype/RecipeCategory]]).


{{Prototype TOC|recipe}}
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
 
== General properties ==
Inherits all properties from [[PrototypeBase]].
 
{{Prototype property|category|[[Types/string|string]]|"crafting"|optional=true}}
Optional. The category of this recipe. The built-in categories can be found [[Data.raw#recipe-category|here]]. See also [[Prototype/RecipeCategory]].
 
{{Prototype property|subgroup|[[Types/string|string]]||optional=true}}
Optional. The subgroup of this recipe. If not specified, defaults to the subgroup of the product if there is only 1, or main_product if multiple products exist. If multiple products exit and no main_product is specified, the subgroup is required.
 
{{Prototype property|icons, icon,  icon_size (IconSpecification)|[[Types/IconSpecification|IconSpecification]]|optional=true}}
An icon is mandatory for recipe with more than 1 product and no main_product. Otherwise defaults to the icon of main_product/1 product.
 
If given, it overwrites the icon of the main_product/1 product.
 
{{Prototype property|crafting_machine_tint|[[Types/table|table]] of [[Types/Color|Color]]|optional=true}}
Optional.
 
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}, quaternary = {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 <code>false</code>. This will disable the recipe for the difficulty, same as setting it <code>enabled = false</code>. If it is enabled (by technologies etc), it will use the data from the other difficulty. Not setting a difficulty, e.g. <code>normal = nil</code>, is possible and gives that difficulty the exact same properties as the difficulty that is defined. See below for examples.
 
{{Prototype property|ingredients|[[Types/table|table]] of [[Types/IngredientPrototype|IngredientPrototype]]}}
A table containing ingredient names and counts. Can also contain information about fluid temperature and catalyst amounts.
<syntaxhighlight lang="lua">
ingredients = {{"iron-stick", 2}, {"iron-plate", 3}}
</syntaxhighlight>
The same with full format:
<syntaxhighlight lang="lua">
ingredients = {{type = "item", name = "iron-stick", amount = 2}, {type = "item", name = "iron-plate", amount = 3}}
</syntaxhighlight>
For fluids, the full format always has to be used:
<syntaxhighlight lang="lua">
ingredients = {{type="fluid", name="water", amount=50}, {type="fluid", name="crude-oil", amount=100}}
</syntaxhighlight>
Maximal ingredient amount is 65535. The catalyst amounts are automatically calculated from the recipe, or can be set manually.[https://factorio.com/blog/post/fff-256]
 
{{Prototype property|result|[[Types/string|string]]|optional=true}}
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".
 
{{Prototype property|result_count|[[Types/uint32|uint32]]|1|optional=true}}
Optional. The number of items created by this recipe.
 
{{Prototype property|results|[[Types/table|table]] of [[Types/ProductPrototype|ProductPrototype]]|optional=true}}
A table containing result names and counts. Can also contain information about fluid temperature and catalyst amounts. The catalyst amounts are automatically calculated from the recipe, or can be set manually.[https://factorio.com/blog/post/fff-256]
 
<syntaxhighlight lang="lua">
results=
    {
      {type="fluid", name="heavy-oil", amount=3},
      {type="fluid", name="light-oil", amount=3},
      {type="fluid", name="petroleum-gas", amount=4}
    },
</syntaxhighlight>
<syntaxhighlight lang="lua">
results =
    {
      {type = "item", name = "iron-nuggets", amount = 9},
      {type = "item", name = "gold-nuggets", amount = 1}
    },
</syntaxhighlight>
 
{{Prototype property|energy_required|[[Types/double|double]]|0.5|optional=true}}
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.
 
{{Prototype property|emissions_multiplier|[[Types/double|double]]|1.0|optional=true}}
 
{{Prototype property|requester_paste_multiplier|[[Types/uint32|uint32]]|30|optional=true}}
 
{{Prototype property|overload_multiplier|[[Types/uint32|uint32]]|0|optional=true}}
Used to determine how many extra items are put into an assembling machine before it's considered "full enough".
 
{{Prototype property|enabled|[[Types/bool|bool]]|true|optional=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".
 
{{Prototype property|hidden|[[Types/bool|bool]]|false|optional=true}}
Optional. Hides the recipe from crafting menus.
 
{{Prototype property|hide_from_stats|[[Types/bool|bool]]|false|optional=true}}
Optional. Hides the recipe from flow stats (item/fluid production statistics).
 
{{Prototype property|hide_from_player_crafting|[[Types/bool|bool]]|false|optional=true}}
Optional. Hides the recipe from the player's crafting screen. The recipe will still show up for selection in machines.
 
{{Prototype property|allow_decomposition|[[Types/bool|bool]]|true|optional=true}}
Optional. Whether this recipe is allowed to be broken down for the recipe tooltip "Total raw" calculations.
 
{{Prototype property|allow_as_intermediate|[[Types/bool|bool]]|true|optional=true}}
Optional. Whether the recipe can be used as an intermediate recipe in hand-crafting.
 
{{Prototype property|allow_intermediates|[[Types/bool|bool]]|true|optional=true}}
Optional. Whether the recipe is allowed to use intermediate recipes when hand-crafting.
 
{{Prototype property|always_show_made_in|[[Types/bool|bool]]|false|optional=true}}
Optional. Whether the "Made in: {Machine}" part of the tool-tip should always be present, not only when the recipe can not be hand-crafted.
 
{{Prototype property|show_amount_in_title|[[Types/bool|bool]]|true|optional=true}}
Optional. Whether the recipe name should have the product amount in front of it, e.g. "2 [[transport belt]]"
 
{{Prototype property|always_show_products|[[Types/bool|bool]]|false|optional=true}}
Optional. Whether the products are always shown in the recipe tool-tip.
 
{{Prototype property|main_product|[[Types/string|string]]|optional=true}}
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" ===
<syntaxhighlight lang="lua">
  {
    type = "recipe",
    name = "iron-plate",
    category = "smelting",
    energy_required = 3.5,
    ingredients = {{"iron-ore", 1}},
    result = "iron-plate"
  }</syntaxhighlight>
 
=== "coal-liquefaction" ===
 
<syntaxhighlight lang="lua">{
  type = "recipe",
  name = "coal-liquefaction",
  category = "oil-processing",
  subgroup = "fluid-recipes",
  order = "a[oil-processing]-c[coal-liquefaction]",
  enabled = false,
  energy_required = 5,
  icon = "__base__/graphics/icons/fluid/coal-liquefaction.png",
  icon_size = 32,
  ingredients =
  {
    {type="item", name="coal", amount=10},
    {type="fluid", name="heavy-oil", amount=25},
    {type="fluid", name="steam", amount=50}
  },
  results=
  {
    {type="fluid", name="heavy-oil", amount=35},
    {type="fluid", name="light-oil", amount=15},
    {type="fluid", name="petroleum-gas", amount=20}
  },
  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>
 
==== Modified so that it cannot be crafted in normal mode, unless unlocked via command/research ====
<syntaxhighlight lang="lua">  {
    type = "recipe",
    name = "iron-gear-wheel",
    normal = false,
    expensive =
    {
      ingredients = {{"iron-plate", 4}},
      result = "iron-gear-wheel"
    }
  },</syntaxhighlight>
 
==== Modified so that the expensive recipe is always used, even in normal mode ====
<syntaxhighlight lang="lua">  {
    type = "recipe",
    name = "iron-gear-wheel",
    normal = nil, --this line can be omitted
    expensive =
    {
      ingredients = {{"iron-plate", 4}},
      result = "iron-gear-wheel"
    }
  },</syntaxhighlight>

Latest revision as of 14:33, 25 October 2024

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/prototypes/RecipePrototype.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.