recipes
recipeKit's public surface for recipes: `define`, `remove`, `get`, `list`, `setOrder` and `loadPack` manage what can be made; `setScale` and `costOf` scale costs; `missing`, `missingText` and `canMake` read the local player's inventoryKit bag and the station check (`setStationChe…
recipes
recipeKit's public surface for recipes: define, remove, get, list, setOrder and loadPack manage what can be made; setScale and costOf scale costs; missing, missingText and canMake read the local player's inventoryKit bag and the station check (setStationCheck); craft checks, pays (pay) and puts the result in the bag, or hands a place recipe to the game's onPlace handler; on listens to crafted, refused and defined. Toasts go through navUiKit when it is installed. Called by game scripts, by the menu module and by the kit's tests.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
opt(ok: boolean, mod: any) → any
| arg | type | description |
|---|---|---|
| ok | boolean | |
| mod | any |
_Inv( ) → any
_Nav( ) → any
_Juice( ) → any
toast(text: string, opts: any?) → void
Show a toast through navUiKit when it is installed (does nothing otherwise).
| arg | type | description |
|---|---|---|
| text | string | |
| opts | any? |
juice(name: string) → void
| arg | type | description |
|---|---|---|
| name | string |
on(event: string, fn: any) → void
Listen to `crafted(id)`, `refused(id, why)` or `defined(id)`. Returns a function that stops listening.
| arg | type | description |
|---|---|---|
| event | string | |
| fn | any |
_emit(event: string, ...: any) → void
| arg | type | description |
|---|---|---|
| event | string | |
| ... | any |
normResult(res: any) → void
| arg | type | description |
|---|---|---|
| res | any |
define(id: string, def: any) → any
Define (or replace) a recipe: { label, needs = { item = n }, result = { item, n }?, place = string?, station = string?, category = string? }. Returns the stored recipe.
| arg | type | description |
|---|---|---|
| id | string | |
| def | any |
remove(id: string) → boolean
Remove a recipe. Returns whether it existed.
| arg | type | description |
|---|---|---|
| id | string |
get(id: string) → any
The recipe with this id, or nil.
| arg | type | description |
|---|---|---|
| id | string |
list(category: string?) → void
Every recipe (or every recipe of one category) in definition order.
| arg | type | description |
|---|---|---|
| category | string? |
setOrder(ids: { string }) → void
Reorder: the ids given come first in that order, the rest follow as they were.
| arg | type | description |
|---|---|---|
| ids | { string } |
categories( ) → void
Every category in use, in the order first seen.
loadPack(name: string) → void
Load one of the ready packs in the packs module (survivalBasics, cooking, building). Returns the ids it defined.
| arg | type | description |
|---|---|---|
| name | string |
reset( ) → void
Remove every recipe and listener and put scale, station check and place handler back to how the kit starts.
_snapshot( ) → any
A copy of the whole recipe book and settings, for tests: hand it back to M._restore.
_restore(snap: any) → void
| arg | type | description |
|---|---|---|
| snap | any |
setScale(k: number) → void
Multiply every cost by `k` (rounded up; 0 makes everything free).
| arg | type | description |
|---|---|---|
| k | number |
scale( ) → number
The cost multiplier.
costOf(id: string) → void
What a recipe costs after scaling: { item = n }.
| arg | type | description |
|---|---|---|
| id | string |
missing(id: string) → void
What the local player is still missing for a recipe: { item = n } (empty when they have it all).
| arg | type | description |
|---|---|---|
| id | string |
sortedParts(t: { [string]: number }) → void
| arg | type | description |
|---|---|---|
| t | { [string]: number } |
missingText(miss: { [string]: number }) → string
"Needs 2 stone, 1 fiber" for a missing table ("" when nothing is missing).
| arg | type | description |
|---|---|---|
| miss | { [string]: number } |
costText(id: string) → string
"2 stone, 1 fiber" (or "free") for a recipe's scaled cost.
| arg | type | description |
|---|---|---|
| id | string |
setStationCheck(fn: any?) → void
Decide whether the local player is at a station: fn(station) -> boolean. Default: every station passes. nil restores the default.
| arg | type | description |
|---|---|---|
| fn | any? |
atStation(station: string?) → boolean
Whether the local player is at a station (always true for no station).
| arg | type | description |
|---|---|---|
| station | string? |
onPlace(fn: any?) → void
The game's handler for `place` recipes: fn(id, recipe) -> (ok, why?). Called after the checks; it takes payment with Recipes.pay(id) when it really places.
| arg | type | description |
|---|---|---|
| fn | any? |
canMake(id: string) → void
Whether the local player can make a recipe now: (true) or (false, why).
| arg | type | description |
|---|---|---|
| id | string |
pay(id: string) → boolean
Take a recipe's scaled cost from the local player's bag. Returns whether all of it was taken (checks first, so a refusal takes nothing).
| arg | type | description |
|---|---|---|
| id | string |
refuse(id: string, why: string, r: any?) → void
| arg | type | description |
|---|---|---|
| id | string | |
| why | string | |
| r | any? |
craft(id: string) → void
Craft a recipe as the local player: check, pay and put the result in the bag (or hand a `place` recipe to the onPlace handler), toast and emit. Returns (ok, why?).
| arg | type | description |
|---|---|---|
| id | string |
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.