Skip to content

smelt.state

Tier: Host - Available in every runtime, including headless mode.

Classification: Supported - Primary alpha facade for user config and plugins.

Per-plugin state. smelt.state.get(name) returns an ephemeral table that survives /reload only; smelt.state.persistent(name) returns a JSON-backed wrapper that survives restarts too.

smelt.state.get

fun(name?: string): table

Return an ephemeral state table. With an explicit name, returns the table for that name. With no arg, returns the current plugin's scoped table keyed by the current scope name. Raises if called with no arg outside a module body (no scope active).

smelt.state.persistent

fun(name: string, opts: { debounce_ms: integer? }?): table

Return the JSON-backed state wrapper for name. Top-level assignments are saved after opts.debounce_ms (100 ms by default). Call state.save() after mutating nested values; state.all exposes the underlying table. Pending top-level writes are also flushed during runtime teardown and reload.