Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

settings

World-settings reader and writer for `/zero/source/.world_settings`. The single canonical surface for any script that needs to read or mutate engine settings (renderer culling, physics gravity, LSP strictness, startup scene, etc.). Auto-injected as the global `settings` by the pr…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

settings

World-settings reader and writer for /zero/source/.world_settings. The single canonical surface for any script that needs to read or mutate engine settings (renderer culling, physics gravity, LSP strictness, startup scene, etc.). Auto-injected as the global settings by the prelude — user code never needs to require this module.

Settings live in a TOML file inside the world's manifest. Reads always re-parse the file so callers see the live state (no stale cache); writes go through vfs.write, so play mode locks settings the same as any other source file. Call wld.edit() first to unlock for mid-play writes.

Exports

  • settings.get(key: string) -> any — raw value at a dotted key, or nil.
  • settings.getString(key: string, default?: string) -> string — type-narrowed string accessor.
  • settings.getNumber(key: string, default?: number) -> number — type-narrowed number accessor.
  • settings.getBool(key: string, default?: boolean) -> boolean — type-narrowed boolean accessor.
  • settings.set(key: string, value: any) — set + write.
  • settings.setMany(updates: { [string]: any }) — batched set + single write.
  • settings.all() -> { [string]: any } — snapshot of the full settings document.

Usage

-- Read
local mode = settings.getString("render.culling_mode", "gpu")
local gravity = settings.getNumber("physics.gravity", -9.81)
if settings.getBool("render.shadows", true) then ... end

-- Write
settings.set("render.culling_mode", "cpu")
settings.setMany({
    ["render.culling_mode"] = "cpu",
    ["physics.gravity"] = -3.7,
})

-- Inspect everything
for section, keys in pairs(settings.all()) do
    print("[" .. section .. "]")
    for k, v in pairs(keys) do print("  " .. k .. " =", v) end
end

Notes

  • The typed accessors (getString / getNumber / getBool) fall back to the documented default ("" / 0 / false) on type mismatch — they never coerce.
  • Modifying the snapshot returned by settings.all() does NOT propagate. Persist changes with set or setMany.
  • Each get* re-reads the file. Settings access is infrequent enough that the parse cost is negligible; the trade-off is no stale-cache class of bug from foreign writes.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict global settings

read( ) → void

Read + parse the file each call. The file is small (~50 lines) and settings access is infrequent enough that the parse cost is negligible — this avoids a stale-cache class of bug where someone else's `vfs.write` of the file leaves our cache out of date.

walk(root: { [string]: any }, dotted: string) → any

Walk a dotted key into a nested table. Returns the leaf value or nil.

argtypedescription
root{ [string]: any }
dottedstring

assign(root: { [string]: any }, dotted: string, value: any) → void

Walk a dotted key, creating intermediate tables, and assign at the leaf.

argtypedescription
root{ [string]: any }
dottedstring
valueany

get(key: string) → any

Look up a value by dotted key. Returns whatever the file holds at that path — string / number / boolean / array / table — or nil if missing.

argtypedescription
keystringDotted-path key, e.g. `"render.culling_mode"`.

examples

local mode = settings.get("render.culling_mode")

getString(key: string, default: string?) → string

String-typed accessor. Returns the value when present and string-typed; falls back to `default` (or "" if omitted) on missing key or type mismatch.

argtypedescription
keystringDotted-path key.
defaultstring?Optional fallback string.

examples

local mode = settings.getString("render.culling_mode", "gpu")

getNumber(key: string, default: number?) → number

Number-typed accessor. Returns the value when present and number-typed; falls back to `default` (or 0) on missing key or type mismatch.

argtypedescription
keystringDotted-path key.
defaultnumber?Optional fallback number.

examples

local g = settings.getNumber("physics.gravity", -9.81)

getBool(key: string, default: boolean?) → boolean

Boolean-typed accessor. Returns the value when present and boolean-typed; falls back to `default` (or false) on missing key or type mismatch.

argtypedescription
keystringDotted-path key.
defaultboolean?Optional fallback boolean.

examples

if settings.getBool("render.shadows", true) then ... end

set(key: string, value: any) → void

Set a value by dotted key, then serialize and write the file. In play mode the write fails like any other source-file write — call `wld.edit()` first to unlock.

argtypedescription
keystringDotted-path key.
valueanyReplacement value (string / number / boolean / table).

examples

settings.set("render.culling_mode", "cpu")

setMany(updates: { [string]: any }) → void

Apply many key/value updates in one batched write — fewer serialize+write round-trips than calling `set` per-key. Same lock semantics as `set`. ["render.culling_mode"] = "cpu", ["physics.gravity"] = -3.7, })

argtypedescription
updates{ [string]: any }A table of dotted-key → value pairs.

examples

settings.setMany({

all( ) →

Snapshot of the entire settings document (parsed). Modifying the returned table does NOT propagate — call `set` or `setMany` to persist. Useful for editors/inspectors that render every section. print(section, keys) end

examples

for section, keys in pairs(settings.all()) do

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

7items
·
other · born here
▤file
▲ 0↑ born
▣
module · born here
❒asset
# toml Pure-Luau TOML parser and emitter. Use whenever a script needs to read or write a TOML file — settings, importer rules, tool configs, or any other authored config the user touches by hand. Auto-injected as the global `toml` by the prelude — no `require` in user code. `vfs.read` returns bytes. JSON has built-in parsing via `json`, but TOML — the format used for `.world_settings`, `pyproject`-style configs, and any human-friendly key=value file — needs a parser. `toml` provides one with no native dependency, so it works the same on native and WASM. ## Exports - `toml.parse(src: string) -> { [string]: any }` — TOML bytes to nested Luau table. Throws with the line number on syntax errors. - `toml.encode(root: { [string]: any }) -> string` — Luau table to canonical TOML bytes (alphabetical section/key order; deterministic output). ## Usage ```luau -- Parse local body = vfs.read("/zero/source/myconfig.toml") local config = toml.parse(body) print(config.render.culling_mode) -- Mutate + write back config.render.culling_mode = "cpu" vfs.write("/zero/source/myconfig.toml", toml.encode(config)) ``` ## Supported TOML - Sections, including dotted (`[a.b.c]`) - Key/value pairs with dotted keys (`a.b.c = 1`) - Strings: `"..."` (escaped) and `'...'` (literal); triple-quoted variants for multi-line bodies - Integers (with `_` digit separators) and floats (incl. `inf`, `-inf`, `nan`, exponents) - Booleans (`true` / `false`) - Inline arrays (`[1, 2, 3]`) - Inline tables (`{ a = 1, b = 2 }`) - `#` comments ## Not implemented These are rare in settings/config files; add when a real call site needs them rather than carrying dead code. - Array-of-tables (`[[name]]`) - Hex / octal / binary integer literals (`0xff`, `0o77`, `0b1010`) - Date / time literals ## Notes - `--!global toml` directive promotes the module's typed functions onto the runtime universe's globals bucket, so `toml.parse` / `toml.encode` are available without any per-source `require`. - The encoder is fully deterministic: sections and keys are sorted alphabetically, integer-shaped numbers are emitted without a decimal point (`2` not `2.0`), and nested tables become dotted section headers (`[a.b]`). - Parser errors carry the line number for fast diagnosis.
▲ 0↑ born
·
other · born here
▤file
▲ 0↑ born
backing path · modules/settings.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ 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".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.