Moods
The API for giving a level, a zone or a scene a mood on THIS machine: `Moods.apply(name, opts)` ("goldenHour", "storm", "sunset.cartoon"; `fade`, `palette`, `overrides`), `Moods.get` / `define` / `list` / `palettes` / `info`, the priority stack of requests (`request(source, name,…
moodKit.Moods
The API for giving a level, a zone or a scene a mood on THIS machine: Moods.apply(name, opts) ("goldenHour", "storm", "sunset.cartoon"; fade, palette, overrides), Moods.get / define / list / palettes / info, the priority stack of requests (request(source, name, opts) / release(source), highest priority wins, apply asks at 100), clear, current, on(fn), and the level source (setLevelSource(fn), levelNow()). The Mood and LevelMoods components call Moods.tick(dt) to run the blend; with none in the scene it runs on its own task. Nothing is synced.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict moodKit's API: give a level, a zone or the whole scene a mood (time of day, weather, sky, colour grade, haze, toon ramp, ink and paper) on THIS machine only, blended smoothly from the mood before. Moods.apply("goldenHour") -- one call, blends over 3 s Moods.apply("sunset.cartoon", { fade = 6 }) -- a mood in another palette Moods.apply("dusk", { palette = "noir", overrides = { weather = "snow" } }) Moods.define("myLevel", { base = "dawn", hour = 8 }) -- your own, built on a library mood Several things can ask for a mood at once (a scene default, a level, a zone you walk into, a cutscene): each asks under its own `source` with a `priority`, and the highest wins. `Moods.apply` asks as "api" at priority 100. Components drive the blend each frame; with none in the scene, the blend runs on a task of its own.
deepMerge(into: Map, from: Map) → Map
| arg | type | description |
|---|---|---|
| into | Map | |
| from | Map |
canonical(name: string) → string
The library name an alias or any-case name stands for ("storm" -> "thunderstorm", "Golden Hour" -> "goldenHour"), or the name itself.
| arg | type | description |
|---|---|---|
| name | string |
split(name: string) → void
| arg | type | description |
|---|---|---|
| name | string |
has(name: string) → boolean
True when `name` (a mood, alias, defined mood, or "mood.palette") resolves.
| arg | type | description |
|---|---|---|
| name | string |
raw(name: string, depth: number) → Map
| arg | type | description |
|---|---|---|
| name | string | |
| depth | number |
get(name: string, opts: Map?) → Map
A resolved mood as plain data, ready for the adapters: `name` may be "dusk", an alias ("storm"), a defined mood, or "dusk.noir". `opts.palette` draws it in a palette, `opts.overrides` changes any field after the palette (deep merge). Errors on an unknown name, listing the real ones.
| arg | type | description |
|---|---|---|
| name | string | |
| opts | Map? |
define(name: string, def: Map) → string
Add (or replace) a named mood. `def.base` names a mood it starts from ("dawn", "sunset.cartoon" is not allowed: use `palette = "cartoon"` in the def); every other field overrides it. Returns the name.
| arg | type | description |
|---|---|---|
| name | string | |
| def | Map |
list( ) → void
Every mood name: the library's in order, then the ones `define` added.
library( ) → void
The library's moods only, in order (dawn ... blizzard).
palettes( ) → void
Every palette name: storybook, realistic, cartoon, moody, pastel, noir.
aliases( ) → void
The aliases table (alias -> library mood).
info(name: string) → Map
A mood's label and description for a picker: { name, label, description, tags }.
| arg | type | description |
|---|---|---|
| name | string |
winner( ) → Map
request(source: string, name: string?, opts: Map?) → void
Ask for a mood under `source` (any string: "scene", "level", "zone:cave", "cutscene"). The highest `opts.priority` (default 0) wins, the latest on a tie. `opts.fade` (seconds, default 3) is the blend into it; `opts.palette`, `opts.overrides`, `opts.entries` as for `get`/`apply`. Asking again with the same mood and options changes nothing. `name` nil releases the source.
| arg | type | description |
|---|---|---|
| source | string | |
| name | string? | |
| opts | Map? |
release(source: string) → void
Stop asking for a mood under `source`; the next highest request blends back in (or, with none left, the kits go back to their shared state).
| arg | type | description |
|---|---|---|
| source | string |
apply(name: string, opts: Map?) → Map
Lay a mood on THIS machine now (as source "api", priority 100), blending from what is showing over `opts.fade` seconds (default 3; 0 = at once). `name` like `get`: "goldenHour", "storm", "sunset.cartoon". Returns the resolved mood.
| arg | type | description |
|---|---|---|
| name | string | |
| opts | Map? |
clear( ) → void
Take every request and this machine's mood off; the kits go back to the shared clock, weather and the stack's own settings.
current( ) → Map
What this machine shows: { name, palette, source, blending (0..1 or nil), mood } or nil.
requests( ) → Map
Every source asking for a mood now: { source = { name, priority } }.
on(fn: (Map?) → void
Call `fn(current)` whenever the winning mood changes on this machine. Returns an unsubscribe function.
| arg | type | description |
|---|---|---|
| fn | (Map? |
emit( ) → void
lay(m: Map, r: Map) → void
| arg | type | description |
|---|---|---|
| m | Map | |
| r | Map |
tick(dt: number, who: string?) → boolean
Advance the blend by `dt` seconds and write it to the kits. The Mood / LevelMoods components call it once a frame; `who` lets only one of them drive. Returns true while a blend runs.
| arg | type | description |
|---|---|---|
| dt | number | |
| who | string? |
kick( ) → void
Make sure something drives the blend: a component that called `tick` in the last half second, else a task of moodKit's own.
lastApplyMs( ) → number
How long the last write of a mood to the kits took on this machine, in milliseconds.
addLevelSource(name: string, fn: (() → void
Add a way to find the level this machine's player is on: `fn()` returns a level id or nil. Several sources may stand at once; the highest `priority` that answers wins (moodKitBridges' platformer3dKit source asks at 50, campaignKit's at 40). Pass nil as `fn` to take one away.
| arg | type | description |
|---|---|---|
| name | string | |
| fn | (( |
setLevelSource(fn: (() → void
The game's own level source, ahead of every other (priority 100): `fn()` returns a level id or nil. Pass nil to take it away.
| arg | type | description |
|---|---|---|
| fn | (( |
levelNow( ) → string
The level this machine's player is on: the highest-priority level source that answers, else nil.
poke( ) → void
Say the level may have changed (a level started, ended or restarted), so LevelMoods looks now instead of at its next poll.
pokes( ) → number
How many times `poke` was called: LevelMoods compares it to know when to look again.
adapters( ) → any
The adapters module: `Moods.adapters().register(name, adapter)` plugs a kit in; `.available()`, `.setEnabled(name, on)`.
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.