menu
recipeKit's craft menu for the local player. `setup` picks one of six `THEMES` (rustic, scifi, cartoon, pixel, minimal, cozy), one of the `LAYOUTS` (list, grid), the title and optional categories; `open`, `close`, `toggle` and `isOpen` show it; `move`, `pick` and `refresh` drive…
menu
recipeKit's craft menu for the local player. setup picks one of six THEMES (rustic, scifi, cartoon, pixel, minimal, cozy), one of the LAYOUTS (list, grid), the title and optional categories; open, close, toggle and isOpen show it; move, pick and refresh drive it. Every row is a button showing the recipe's cost, greyed when it cannot be made, with station recipes marked: a mouse click or tap crafts that row and hovering highlights it, and the mouse pointer is freed while the menu is open. step polls the keyboard and gamepad every frame: arrows or W and S (d-pad) move, left and right too in the grid, Enter or E (south, A) crafts, Escape (east, B) closes, and a held key repeats after 0.35 s. keyboard(on) turns the key handling on or off. Pure helpers nextIndex, dirDelta and repeatStep hold the movement and repeat rules. Used by the CraftMenu and RecipeGallery components and by games with their own controls.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
layoutOf(id: string) → any
| arg | type | description |
|---|---|---|
| id | string |
setup(cfg: any?) → void
Pick the theme, layout, title and (optionally) the categories the menu shows. Unknown theme or layout names are refused.
| arg | type | description |
|---|---|---|
| cfg | any? |
config( ) → any
The current menu settings: { theme, layout, title, categories }.
keyboard(on: boolean?) → boolean
Turn the menu's keyboard handling on or off (on by default). Pass nothing to read it. Returns the current setting.
| arg | type | description |
|---|---|---|
| on | boolean? |
items( ) → void
The recipes the menu shows, in order.
indexOf(id: string) → number
The row (1-based) a recipe id sits on in the menu, or nil.
| arg | type | description |
|---|---|---|
| id | string |
rowIds( ) → void
The recipe ids of the rows the menu shows, in order.
selected( ) → number
The highlighted row (1-based).
nextIndex(sel: number, n: number, delta: number) → number
Pure: the row `delta` steps from `sel` among `n` rows, wrapping round at either end. 1 when there are no rows.
| arg | type | description |
|---|---|---|
| sel | number | |
| n | number | |
| delta | number |
dirDelta(dir: string, columns: number) → number
Pure: the move a direction makes with `columns` per line: up and down step a whole line, left and right one row (only in a grid). 0 for no move.
| arg | type | description |
|---|---|---|
| dir | string | |
| columns | number |
repeatStep(rec: any, down: boolean, now: number, delay: number?, rate: number?) → boolean
Pure: key repeat. `rec` is a table kept per key; returns true on the press and then every `rate` seconds once the key has been held `delay` seconds.
| arg | type | description |
|---|---|---|
| rec | any | |
| down | boolean | |
| now | number | |
| delay | number? | |
| rate | number? |
clampSel( ) → void
visibleLines(th: any?) → number
How many lines of recipes fit on the screen in theme `th` (the panel takes at most MAX_HEIGHT of the screen's height, with room for the title, the more above / below markers and Close). At least 3.
| arg | type | description |
|---|---|---|
| th | any? |
measureRow( ) → void
once a row is drawn, its real height (with the gap) replaces the estimate, so the window fits the theme's font
rowButton(r: any, index: number, th: any, width: number) → any
| arg | type | description |
|---|---|---|
| r | any | |
| index | number | |
| th | any | |
| width | number |
tree( ) → any
The widget tree of the menu as it would draw now.
marker(id: string, text: string) → any
| arg | type | description |
|---|---|---|
| id | string | |
| text | string |
row(i: number, w: number) → any
| arg | type | description |
|---|---|---|
| i | number | |
| w | number |
rowId(i: number) → string return M
| arg | type | description |
|---|---|---|
| i | number |
isOpen( ) → boolean
Whether the menu is open.
_clearGuard( ) → void
Test hook: forget the last craft so the next click or key is not taken for the same press.
guarded( ) → boolean
craftRow(index: number) → void
| arg | type | description |
|---|---|---|
| index | number |
_onCallback(id: string, _data: any?) → boolean
Handle a widget callback id from the menu's screen: a row's id crafts that row, the close id closes. Returns whether the id was the menu's. A second craft within PICK_GUARD seconds of the last (a key and a click on the same press) is ignored.
| arg | type | description |
|---|---|---|
| id | string | |
| _data | any? |
open( ) → boolean
Open the menu (registers and shows its screen and frees the mouse pointer while it is up).
close( ) → void
Close the menu; the game's pointer lock comes back.
toggle( ) → void
Open the menu when closed, close it when open.
refresh( ) → void
Redraw the menu if it is open (after the bag, the recipes or the settings change).
focusRow( ) → void
Move the highlight by `delta` rows, wrapping round at either end. Returns the new row.
followFocus( ) → void
move(delta: number) → number
| arg | type | description |
|---|---|---|
| delta | number |
pick( ) → void
Craft the highlighted recipe. Returns Recipes.craft's (ok, why?). Ignored (false, "too soon") within PICK_GUARD seconds of the last craft.
edge(name: string, down: boolean) → boolean
| arg | type | description |
|---|---|---|
| name | string | |
| down | boolean |
padNow( ) → number
wall-clock seconds: os.clock() is processor time, which a busy engine runs through several times faster
ensurePadMap( ) → void
_padState( ) → any
Debug view of the pad-button map: whether it is active, which buttons are held and when each was last pressed (os.clock()).
padDown(button: string) → boolean
| arg | type | description |
|---|---|---|
| button | string |
keysDown(action: string) → boolean
| arg | type | description |
|---|---|---|
| action | string |
held(name: string, down: boolean, now: number) → boolean
| arg | type | description |
|---|---|---|
| name | string | |
| down | boolean | |
| now | number |
hover( ) → void
touchTaps( ) → void
A finger's tap on a row or Close. A touch does not always reach a `button` widget as a click (it can only hover it), so the menu reads short taps itself and works the widget under the finger, unless the engine delivered the tap as a click already (then `_onCallback` ran since the finger went down).
step( ) → void
Poll input while the menu is open: arrows or W and S (pad d-pad) move, left and right too in the grid, Enter or E (pad south) crafts, Escape (pad east) closes. Held keys repeat after REPEAT_DELAY seconds. Hovering a row highlights it. Also redraws twice a second so costs follow the bag. Call every frame.
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.