Recipes
Based on game build 714014 | Last updated: 2026-03-10
Overview
The recipes.lua file defines and configures crafting recipes in DST using the Recipe2 and Ingredient APIs from recipe.lua. It enforces placement constraints (e.g., marsh tiles), dynamic yield calculations based on player skills (via skilltreeupdater), pet limits (via petleash), and follower requirements (via leader). It also supports recipe deconstruction customization via DeconstructRecipe, including blocking deconstruction and specifying returned components. The system integrates with custom filters, world geometry queries, and event system hooks (e.g., craftedextraelixir) to enable feature-rich crafting behaviors.
Usage example
local Recipe = require("recipe")
local recipes = require("recipes")
-- Register a marsh-only recipe with dynamic elixir yield
Recipe2("ghostly_elixir", {
ingredients = {
Ingredient("ghost_fragment", 1),
Ingredient("_HEALTH", 1),
},
canbuild = function(inst, builder)
return TheWorld.Map:GetTileAtPoint(inst.x, inst.z) == WORLD_TILES.MARSH
end,
onbuild = function(inst, builder)
local num = elixir_numtogive(recipe, builder)
if num > 1 then
builder:PushEvent("craftedextraelixir", { total = num })
end
return num
end,
})
-- Define a deconstruction recipe with no deconstruction allowed
DeconstructRecipe("security_pulse_cage_full", {}, { no_deconstruction = true })
Dependencies & tags
Components used:
leader— viabuilder.components.leader:CountFollowers(tag)for follower-based constraints.petleash— viabuilder.components.petleash:IsFullForPrefab(prefab)to enforce per-pet-type limits.skilltreeupdater— viadoer.components.skilltreeupdater:IsActivated(skill)for skill-based yield bonuses.
Tags:
"pocketwatch_inactive"— used to determine deconstruction eligibility (inverted logic)."plantkin"—builder_tagfor Wormwood recipes."clockmaker"—builder_tagfor pocketwatch recipes."balloonomancer"—builder_tagfor Wes recipes."ticoon"— used inCountFollowers("ticoon")for Ticoon builder recipes.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
no_deconstruction | boolean | false | If true, prevents the item from being deconstructed via hammering or deconstruction recipes. |
source_recipename | string | nil | Specifies the underlying craftable recipe name, used during deconstruction reconstruction. |
builder_tag | string | nil | Requires the builder to have the specified tag. |
no_builder_tag | string | nil | Prohibits the builder from having the specified tag. |
builder_skill | string | nil | Requires the builder to have the specified skill activated. |
action_str | string | nil | Localized string override for the crafting action. |
filter_text | string | nil | Recipe filter group key, validated via recipes_filter to ensure membership in CRAFTING_FILTERS. |
Main functions
IsMarshLand(pt, rot)
- Description: Checks if the tile at the given point is a marsh tile, used to restrict recipe placement to marsh terrain.
- Parameters:
pt: Point object with.x,.y,.zfields (typicallyinst.x,inst.z).rot: Rotation angle (unused; present for API consistency with other tests).
- Returns:
trueifTheWorld.Map:GetTileAtPoint(pt.x, pt.z) == WORLD_TILES.MARSH; otherwisefalseornil(if tile data is missing).
telebase_testfn(pt, rot)
- Description: Validates placement of telebase structures by checking three precomputed points around
ptfor visual ground (e.g., not water or void). - Parameters:
pt: Placement point with.x,.y,.z.rot: Rotation in degrees (converted internally to radians for point offset calculation).
- Returns:
trueifTheWorld.Map:IsVisualGroundAtPoint(...)returnstruefor all three points; otherwisefalse.
elixir_numtogive(recipe, doer)
- Description: Calculates the number of ghostly elixirs to award, applying luck-based bonuses based on activated skill and global tuning constants.
- Parameters:
recipe: Recipe object (unused in logic; present for signature compatibility).doer: Entity performing the craft; must havecomponents.skilltreeupdater.
- Returns: Integer:
1(base), increased by+1if"wendy_potion_yield"is activated and"GHOSTLYELIXIR_EXTRA1_CHANCE"luck roll passes, or+2if"wendy_potion_yield"is activated and"GHOSTLYELIXIR_EXTRA2_CHANCE"luck roll passes. Never returnsnilin practice—defaults to1if component/skill is unavailable. - Note: Fires
craftedextraelixirevent ondoeronly iftotal > 1.
calc_slingshotammo_numtogive(recipe, doer)
- Description: Returns adjusted slingshot ammo quantity when
"walter_ammo_efficiency"skill is active. - Parameters:
recipe: Recipe object; itsnumtogivefield is multiplied.doer: Entity performing the craft; must havecomponents.skilltreeupdater.
- Returns:
recipe.numtogive * 1.5(float) if skill is activated; otherwisenil.
get_slingshotammo_sg_state(recipe, doer)
- Description: Selects the appropriate stategraph action state for slingshot ammo crafting based on skill activation.
- Parameters:
recipe: Unused.doer: Entity performing the craft.
- Returns:
"domediumaction"if"walter_ammo_efficiency"is activated; otherwisenil.
pocketwatch_nodecon(inst)
- Description: Predicate function used to prevent deconstruction of active pocketwatch items. Returns
trueif deconstruction should be blocked. - Parameters:
inst: Entity instance (the crafted item).
- Returns:
trueifinst:HasTag("pocketwatch_inactive")isfalse(i.e., item is active); otherwisefalse.
DeconstructRecipe(recipe_name, returns, options)
- Description: Registers or overrides deconstruction logic for a recipe. Used to define what ingredients are returned when an item is deconstructed or hammered.
- Parameters:
recipe_name: String — name of the original craftable recipe (e.g.,"cotl_tabernacle_level2").returns: Table — list ofIngredientobjects returned on deconstruction.options: Optional table; supports:no_deconstruction = true— blocks deconstruction entirely.source_recipename = "..."— maps deconstructed item to its underlying craftable for reconstruction.
- Returns:
nil(side-effect: registers internal mapping inDECONSTRUCT_RECIPEStable).
Events & listeners
Pushes:
craftedextraelixir— fired on thedoerentity whenelixir_numtogiveproduces a yield > 1.
Data payload:{ total = number }, wheretotalis the final elixir count.
Listens to: None explicitly defined in recipes.lua.