Prototype/Recipe: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(overhaul to include Prototype)
(Removed old prototype docs)
Tag: Replaced
 
(62 intermediate revisions by 9 users not shown)
Line 1: Line 1:
== Basics ==
<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]]).


== Properties ==
</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>
Inherits all properties from [[Prototype]].
 
=== ingredients ===
'''Type''': [[Types/table]]
 
A table containing ingredient names and counts. For example:
<pre>
ingredients = {{"iron-stick", 2}, {"iron-plate", 3}}
</pre>
or the same with full format:
<pre>
ingredients = {{type = "item", name = "iron-stick", amount = 2}, {type = "item", name = "iron-plate", amount = 3}}
</pre>
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:
<pre>
results=
    {
      {type="fluid", name="heavy-oil", amount=3},
      {type="fluid", name="light-oil", amount=3},
      {type="fluid", name="petroleum-gas", amount=4}
    },
</pre>
<pre>
results =
    {
      {type = "item", name = "iron-nuggets", amount = 9},
      {type = "item", name = "gold-nuggets", amount = 1}
    },
</pre>
 
=== category ===
'''Type''': [[Types/string]]
 
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]].
 
=== energy_required ===
'''Type''': [[Types/unsigned]]
 
Optional. The amount of time it takes to make this recipe. The default is 0.5.
 
For crafting recipes, this is the number of seconds it takes to craft at crafting speed 1.
 
=== enabled ===
'''Type''': [[Types/bool]]
 
Optional. This can be false to disable the recipe at the start of the game, or "true" to leave it enabled. The default is true.
 
If your recipe is unlocked by a technology, you should set this to "false".
 
=== 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 ==
 
=== vanilla "iron-plate" ===
 
<pre>
  {
    type = "recipe",
    name = "iron-plate",
    category = "smelting",
    energy_required = 3.5,
    ingredients = {{"iron-ore", 1}},
    result = "iron-plate"
  }
</pre>
 
=== vanilla "coal-liquefaction" ===
<pre>
data.raw.recipe["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
}
</pre>

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.