Recipe
class ExampleCrafting-recipe prototype used by machines and crafting UIs
- read-only Assigning to the field raises an error.
- load-only Usable only while mods load. The game seals these members once loading finishes, so a call or a write from a running world raises an error.
Fields
| Name | Type | Description | |
|---|---|---|---|
| ticks | load-only | integer | Craft time in engine ticks |
| default_locked | read-only | boolean | True when a research gates this recipe. Derived from the research graph, not authored: writing to it is overwritten when the research tree initializes. |
| locked | boolean | Currently locked if true | |
| productivity | load-only | integer | Percentage bonus (e.g. 20 = +20 %) |
| input | read-only | RecipeInventory | Read-only container of required items |
| output | read-only | RecipeInventory | Read-only container of produced items |
| tier | load-only | integer | Recipe tier used for speed scaling: every tier above its dictionary's start_tier doubles craft time; below it the recipe is clamped to start_tier. |
| start_tier | load-only | integer | The dictionary's start_tier, copied to every recipe in it when the mods finish loading. |
| dictionary | read-only | RecipeDictionary | The dictionary holding this recipe |
Example
Smelt copper in half the time, for two ore. Every field the mod touches is load-only, so the edit runs in post_init, the last stage before the game seals its prototypes — and the one prototype it changes is shared by every smelter in the world.
local SmeltFaster = {}
function SmeltFaster.post_init()
-- Recipe names repeat across dictionaries, so a recipe is addressed through the one
-- holding it. Vanilla smelts chalcopyrite ore into a copper plate in 60 ticks.
local smelter = RecipeDictionary.get('SmelterRecipeDictionary')
local ore = smelter:recipe('ChalcopyriteOre')
ore.ticks = 30
-- input is read-only as a field: the slots are rewritten through the container itself.
ore.input:clear()
ore.input:add(StaticItem.get('ChalcopyriteOre'), 2, RecipeItemData.new())
end
db:mod(SmeltFaster) Standard members (5)
Every class of this kind carries these.
| Recipe.cast(object) | Trying to cast Object into Recipe |
| Recipe.get_class() | Return Recipe class object |
| Recipe.find(name) | Looks Recipe up in db, nil when there is none |
| Recipe.get(name) | Takes Recipe from db, reports a miss to the log |
| Recipe.reg(name) load-only | Register a new Recipe static object |
Inherited from Prototype (2)
- name read-only Object name
- Prototype:is_valid() Returns false once the underlying engine object has been destroyed
Inherited from Object (1)
- Object:get_class() Class of this object
Used by
- RecipeDictionary.add param
- RecipeDictionary.recipes return
- RecipeDictionary.recipe return
- RecipeDictionary.remove param
- RecipeInventory.recipe field
- StaticResearchRecipe.recipe_unlocks field
- StaticResearchRecipe.unlocks param