modules
The modules namespace: 3711 functions.
modules/AgentSkillAssetTypeRef/README
require("@builtin::assetTypes.agentSkill.behavior") -- AgentSkillAssetTypeRef
Per-instance methods exposed on every AssetRef<agentSkill>. Loaded lazily by assetType.shared.ref.
Usage: local AgentSkillAssetTypeRef = require("@builtin::assetTypes.agentSkill.behavior")
modules/AgentSkillAssetTypeRef/getInstructions
getInstructions(self): string?
Read the skill's instructions.md body — the prose an agent
receives when it invokes the skill.
Parameters
selfany(optional)
local body = skillRef:getInstructions()
modules/AgentSkillAssetTypeRef/getManifest
getManifest(self): { [string]: any }
Read and parse the skill's skill.yaml manifest — its description,
declared dependencies, and subskill ordering.
Parameters
selfany(optional)
local m = skillRef:getManifest()
modules/AgentSkillAssetTypeRef/getReadme
getReadme(self): string?
Read the skill's README.md body.
Parameters
selfany(optional)
print(skillRef:getReadme())
modules/AgentSkillAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail — the skill's whole structured
surface: { description, kind, when, checks, stages, verdicts, instructions, dependencies, subskills, manifestError }. checks carries each acceptance
criterion as { check, observe } — what must hold, and where it is seen.
stages carries the ordered passes as { name, detail, checks }, each
holding the criteria that only mean anything once that pass has run.
verdicts carries the outcomes a reader reports as { verdict, means } —
the word, and what reporting it asserts.
dependencies carries each declared identity with what it resolved to and
whether it resolves here; a toolbox additionally carries the tools it
holds, a module the exports it carries, and a tool its own signature, all
read live rather than restated.
subskills carries each nested skill's parent/sub invoke address.
This is the dump skills.invoke renders — a skill with no readable
instructions.md still describes, reporting the gap rather than erroring.
Parameters
selfany(optional)
local subskills = asset.inspect(skillRef).detail.subskills
modules/AgentSkillAssetTypeRef/onChange
onChange(self, change)
Lifecycle hook: re-publish this skill when anything inside its folder is written, so a skill just authored is listed and an edited description is the one agents see. Reads the manifest and writes nothing back.
Parameters
selfany(optional) — The changed skill's AssetRef.changeany(optional) — The write record the dispatcher passes through.
modules/AgentSkillAssetTypeRef/onDelete
onDelete(self)
Lifecycle hook: take this skill's row out of the roster when the skill leaves the runtime — deleted, or moved to a new identity, which registers it again there. The roster lists each skill that exists once.
Parameters
selfany(optional) — The departing skill's AssetRef.
modules/AgentSkillAssetTypeRef/onRegister
onRegister(self)
Lifecycle hook: publish this skill to the roster agents read when the skill first registers. The scope it is listed under is derived from the asset's own identity.
Parameters
selfany(optional) — The registering skill's AssetRef.
modules/AnimationAssetTypeBehavior/README
require("@builtin::assetTypes.animation.behavior") -- AnimationAssetTypeBehavior
Behaviour for the animation asset type — a clip's disk shape. The payload is data.zanim (the engine-native binary AnimAsset, parallel to .mesh's data.zmsh). onCreate writes that payload, and — when the clip's source rig guid is supplied — records it as source_rig.json (a .rig asset reference) so the clip knows the skeleton it was authored on and retargets onto any humanoid. Converters call asset.create("animation", name, { bytes, rig }) to mint a clip.
Usage: local AnimationAssetTypeBehavior = require("@builtin::assetTypes.animation.behavior")
modules/AnimationAssetTypeBehavior/onChange
onChange(ref: any, change: { [string]: any })
React to a write inside a .animation/ instance: when the clip's source
rig link (source_rig.json) changes, record the rig's humanoid
classification into .metadata for search — the clip inherits it from the
rig it targets. Originator-only; .metadata syncs as ordinary content.
Parameters
refany(optional) — The AssetReffor the changed clip. change{ [string]: any }—{ path, asset, type, kind, origin }.
modules/AnimationAssetTypeBehavior/reindexSearchMeta
reindexSearchMeta(self): ()
Re-derive this clip's search .metadata (its humanoid classification,
resolved from the source rig). onChange calls it when source_rig.json
changes; the search-metadata backfill calls it per clip to populate clips
minted before the deriver existed.
Parameters
selfany(optional)
animationRef:reindexSearchMeta()
modules/AssetChangeDispatch/README
require("@builtin::assetTypes.assetType.shared.changeDispatch") -- AssetChangeDispatch
Routes a VFS source write to the enclosing typed-asset's onChange(ref, change) hook. Installs _G.__zero_dispatch_asset_change, which the engine calls (via ffi_callbacks::fire_asset_change_dispatch) once per source write.
This is the type-level analogue of the component-centric
onAssetReload(field) fan-out. Components react to assets they
reference; an asset type reacts to writes INSIDE its own
instances. When any file under a <name>.<type>/ folder changes on
the VFS, the engine hands the written path here; this module finds
the enclosing typed-asset folder, loads its
<type>.assetType/behavior.luau, and — if that module exports an
onChange function — invokes onChange(ref, change).
The engine half is deliberately thin (a generic "this path was
written" signal); all the resolution + behaviour lives here in Luau,
mirroring the __build_asset_ref_proxy split.
Usage: local AssetChangeDispatch = require("@builtin::assetTypes.assetType.shared.changeDispatch")
modules/AssetChangeDispatch/dispatch
dispatch(path: string, kind: string?, origin: string?)
Dispatch the asset-type change hook for a VFS path. Called by the engine for two orthogonal axes:
kind: a per-file EDIT ("edited",pathis the written file) vs an asset COMPLETION ("seeded",pathis the typed-asset folder, now fully present from a world seed). The type inspectskindto decide whether to filter by which file changed or act on the whole asset."dependency"says a module the asset's code atpathrequired has re-run, or that a referencepathnames has bound to a target that did not exist before, and goes to the type'sonDependencyChange(ref, change)alone.origin:"local"for a write made on this client,"remote"for a peer-synced write — forwarded so hooks can gate on it (importers run on the originator only). Resolves the typed asset, loads itsbehavior.luau, and invokesonChange(ref, change)(change = { path, asset, type, kind, origin }, plussettingsandsettingsChangedfor a write to the settings values file). The written file's content version moves first; the enclosing asset folder's moves last, after the type has reacted. An edit schedules no preview. When the path has no enclosing typed asset, forwards to the loose-file seam (dispatch_loose) so the importer system can claim orphan writes. A hook may wait on what it reads:vfs.readof bytes only the blob store holds fetches them. The writes routed to one asset react in the order they were routed, each once the hook before it has finished.
Parameters
pathstring— The VFS path: the written file (edited) or the asset folder (seeded).kindstring?(optional) — "edited" (default) or "seeded".originstring?(optional) — "local" (default) or "remote".
__zero_dispatch_asset_change("/zero/source/Goblin.dynamicAsset/prompt.json", "edited", "local")
modules/AssetChangeDispatch/dispatchDelete
dispatchDelete(path: string, guid: string?)
Dispatch the asset-type DELETE hook for a removed typed-asset FOLDER —
the teardown counterpart of dispatch. path is the folder that was
removed; this resolves its <name>.<type> identity, loads the type's
behavior.luau, and invokes onDelete(ref) if defined (a .component
unregisters its type). No-op when the path isn't a registered typed asset
or the type defines no onDelete. The engine calls this via
ffi_callbacks::fire_asset_delete_dispatch once per typed-asset folder
removal. A removal routed while the asset's onChange is waiting tears
the asset down once that hook, and every write queued behind it, has
finished.
Parameters
pathstring— The removed asset folder's VFS path.guidstring?(optional) — The removed asset's guid, as its manifest row carried it, when the removal knew it.
__zero_dispatch_asset_delete("/zero/source/Spinner.component", guid)
modules/AssetRef/README
require("@builtin::assetTypes.assetType.shared.ref") -- AssetRef
AssetRef proxy builder. Attaches the default method metatable to every { __ref, type, name, guid, identity, path } envelope produced by asset.resolve / asset.ref, and dispatches type-specific methods from <typename>.assetType/behavior.luau so a .material ref carries material-only methods (and so on).
The Rust side (crates/zero_scripting/src/ffi/bindings/asset.rs)
used to ship a C metatable with a fixed __index that knew about
getSource / getBytes / getText / exists / inspect / meta.
That shape couldn't grow without an FFI change, which meant the
per-asset-type behaviour required to make refs useful (read a
material's properties, instantiate a bundle, run a tool) had no
hook.
This module owns that responsibility now. It exposes one entry
point — M.build(envelope) — that the Rust factory invokes via
the _G.__build_asset_ref_proxy global the prelude installs. The
build call attaches a shared metatable whose __index first
serves the default method table, then falls through to the type's
own ref table (loaded lazily from @builtin::assetTypes.<type>.behavior).
The default method surface is fixed and engine-required —
per-type ref tables CANNOT shadow getSource / getBytes /
getText / exists / deps / canInstantiate / canPreview /
preview (which calls the type's own ref.preview when it has one),
or the lazy meta, runtime, events, typeRef, modules and
residency properties. inspect is NOT a fixed default — it falls
through to the type's own ref.inspect(self) (returning the
type-specific detail for asset.inspect's dispatch), and is nil
when the type defines none.
Usage: local AssetRef = require("@builtin::assetTypes.assetType.shared.ref")
modules/AssetRef/build
build(envelope: any): any
Attach the AssetRef method metatable to an envelope table. Invoked
by the Rust factory (push_asset_ref_handle →
_G.__build_asset_ref_proxy) immediately after the six envelope
fields (__ref, type, name, guid, identity, path) have
been set, so the metatable's __index only ever fires for method /
property lookups, never for the literal envelope fields.
Parameters
envelopeany(optional) — The freshly-built envelope table.
local r = require("@builtin::assetTypes.assetType.shared.ref").build({ type = "material", path = "/zero/source/Gold.material", ... })
modules/AssetRef/canInstantiate
canInstantiate(self): boolean
Whether this asset can be instantiated into a scene — true iff its
asset type defines an instantiate method. Generic capability query
(no type allowlist); consumers gate on it before offering a scene path
(an Asset.source field, a viewport drop, a tool argument).
Parameters
selfany(optional)
if asset.resolve("Golem","dynamicAsset"):canInstantiate() then ... end
modules/AssetRef/canPreview
canPreview(self): boolean
Whether this asset can render a preview — true when its type declares
a preview: recipe in its type.yaml, defines its own preview, or
defines instantiate (a scene-instantiable asset previews as itself).
Parameters
selfany(optional)
if ref:canPreview() then local p = ref:preview() end
modules/AssetRef/deps
deps(self): { deps: { any }, unresolved_deps: { any }, problems: { any } }
Return this asset's outbound reference table, aggregated across
every file inside it (for composite asset folders) — same data
asset.deps(ref) returns. deps holds the references that
resolved ({ asset_guid, origin, literal, via, line?, checksum?, ... }), unresolved_deps the literals nothing answered
({ literal, via, reason, line? }), and problems the findings
attached to the asset. An asset that references nothing returns all
three empty.
Parameters
selfany(optional)
modules/AssetRef/flushPendingPersists
flushPendingPersists()
Write out every asset whose edit-mode persistence is still coalesced, spending no allowance and waiting on no refill. The runtime-state wipe on a mode flip calls this first, so a change made in the last window before the flip reaches the asset instead of being cleared with the overlay it lives in. Call it before reading an asset's file for a value a runtime write may have just changed.
require("@builtin::assetTypes.assetType.shared.ref").flushPendingPersists()
modules/AssetRef/forgetRuntime
forgetRuntime(guid: string): boolean
Forget everything a type derived from ONE asset's content — the values
it cached in ref.runtime off the bytes that asset used to hold. Called
when an asset's content is REPLACED under a guid live consumers already
hold: a type memoizes its parse, its GPU handle, its settings against the
content it read, and each of those describes the previous bytes the moment
the new ones land. Emptying the table in place rather than replacing it is
what makes the clear reach every holder — the runtime table is shared by
every resolver of the copy the world holds under the guid, and a type may
be holding it directly. A recorded version's copy, held in that version's
folder, keeps a runtime table of its own and is left as it is.
Parameters
guidstring— The asset's stable guid; the copy the world holds under it is the one forgotten.
require("@builtin::assetTypes.assetType.shared.ref").forgetRuntime(ref.guid)
modules/AssetRef/loadTypeBehavior
loadTypeBehavior(asset_type: string): ({ [string]: any }?, string?)
Load an asset type's behavior.luau module table, reporting a
behavior that raised while loading. The first return is the module (nil
when the type ships no behavior.luau); the second is set when the type
HAS a behavior.luau that raised, and carries the require key plus the
error it raised.
A caller that runs the type's hooks — asset.create runs onCreate —
reads the second return to tell "this type declares no behavior" from
"this type's behavior is broken", which are opposite situations for the
asset it is about to write.
Parameters
asset_typestring— The type name (e.g."dynamicAsset","material").
local mod, err = require("@builtin::assetTypes.assetType.shared.ref").loadTypeBehavior("dialogue")
modules/AssetRef/loadTypeBehaviorOf
loadTypeBehaviorOf(type_ref: any): ({ [string]: any }?, string?)
Load the behavior.luau module table of the asset type type_ref
names, from the folder the type asset lies in, the way
loadTypeBehavior loads it once the name has resolved. For a caller that
already holds the type asset, such as a row of asset.list("assetType").
Parameters
type_refany(optional) — The type asset: a ref or a listing row holding itsidentityandpath.
for _, t in ipairs(asset.list("assetType")) do local mod = require("@builtin::assetTypes.assetType.shared.ref").loadTypeBehaviorOf(t) end
modules/AssetRef/loadTypeModule
loadTypeModule(asset_type: string): { [string]: any }?
Load the full behavior.luau module table for an asset type
(every key the type declares), or nil when the type ships no
behavior.luau. Registry-driven resolution — same path the per-type
ref dispatch uses. Exposed so the asset-change dispatcher
(@builtin::assetTypes.assetType.shared.changeDispatch) can reach a type's onChange
hook without duplicating the resolution logic.
Parameters
asset_typestring— The type name (e.g."dynamicAsset","material").
local m = require("@builtin::assetTypes.assetType.shared.ref").loadTypeModule("dynamicAsset")
modules/AssetRef/persistInEditMode
persistInEditMode(self: any)
Generic edit-mode persistence hook an assetType calls when a change of
its own is meant to reach the file. In EDIT mode, flush a ref's transient
runtime overlay (ref.runtime) to its backing asset file by invoking the
type's own saveDefinition(self), so the change syncs to peers and is
saved. Works for any assetType that defines a saveDefinition; whether a
given type's runtime writes route through here is that type's own
contract. The write-through is
rate-limited per asset: an asset carries an allowance of 8 writes that
refills at one per 250ms. Changes made in one frame are coalesced onto a
single re-emit, and a caller that changes a value and moves on has it on
disk a frame or two later. A caller that keeps changing the same asset
runs the allowance down to its refill rate, so over any span the asset
costs at most that allowance plus one write per 250ms, whatever cadence
the changes arrive at.
In PLAY mode this is a deliberate no-op: runtime overlays stay transient
(frame-fast) and are persisted back to the source asset on demand. An
assetType opts in simply by exposing ref.saveDefinition; no per-type
branching lives here.
Parameters
selfany(optional) — Any AssetRef.
require("@builtin::assetTypes.assetType.shared.ref").persistInEditMode(matRef)
modules/AssetRef/preview
preview(self, opts: { [string]: any }?): { [string]: any }
Render this asset's preview in the preview studio, by the recipe its
type declares under preview: in its type.yaml — or through the type's
own preview when it defines one (kind: custom). A scene-instantiable
type that declares nothing previews by instantiating the asset.
Parameters
selfany(optional)opts{ [string]: any }?(optional) —{ size? = { width, height }, angle? = { yaw, pitch }, live? }.
local p = asset.resolve("gold", "material"):preview({ size = { width = 256, height = 256 } })
modules/AssetRef/requireKeyOf
requireKeyOf(ref: any): string?
The key an asset's own code is required by from a type's behavior: its path, which the module loader answers with the module the asset's identity names, for a world asset and a library one alike. A ref that holds no path is required by the path its guid resolves to, and only a ref with neither by its identity.
Parameters
refany(optional) — The asset ref.
local ok, mod = pcall(require, AssetRef.requireKeyOf(moduleRef))
modules/AssetRef/requireTypeModule
requireTypeModule(identity: string?, path: string?, stem: string?, accept: ((any) -> boolean)?): (any?, string?)
Require a module inside an asset folder — a type's <stem>.luau
("behavior", a settings schema file's own stem, or any other module a
type.yaml names), or, with no stem, the asset's own entry module (its
init.luau, as an importer or a component ships) — from wherever the
asset lives (the builtin library, a world-authored folder, a vendored
library), through the ONE resolution that works for all of them: see
the comment above for the routes it tries in order.
Parameters
identitystring?(optional) — The asset's own resolved identity (ref.identity), or nil.pathstring?(optional) — The asset's own resolved folder path (ref.path), or nil.stemstring?(optional) — The module's file stem (its filename with.luaustripped), or nil for the asset's entry module.accept((any) -> boolean)?(optional) — Optional acceptance check a loaded module must satisfy to count as a hit — distinguishing "declares none" from "failed to load" for a module whose shape this caller knows. Omit to accept any table.
local schema, err = require("@builtin::assetTypes.assetType.shared.ref").requireTypeModule(identity, path, "settings")
modules/AssetRef/typeModuleKeys
typeModuleKeys(identity: string?, path: string?, stem: string?): { string }
The require keys requireTypeModule tries, in order, for a module
inside an asset folder: the asset's identity with the stem appended, then
the folder path under @local/. A key reads true from library.has once
the module source is registered under it.
Parameters
identitystring?(optional) — The asset's own resolved identity (ref.identity), or nil.pathstring?(optional) — The asset's own resolved folder path (ref.path), or nil.stemstring?(optional) — The module's file stem, or nil for the asset's entry module.
for _, key in ipairs(AssetRef.typeModuleKeys(ref.identity, ref.path, "schema")) do print(library.has(key)) end
modules/AssetRefShapes/README
require("@builtin::assetTypes.assetType.shared.refShapes") -- AssetRefShapes
Publishes what every AssetRef<category> answers to, so a member read on an asset-typed value is checked against the category's own surface.
An asset category's per-instance surface is authored: a
<name>.assetType/behavior.luau declares M.ref = { ... }, and each
category declares its own. So the members an AssetRef<inputMap>
carries are knowable only to inputMap itself — no fixed set of
types covers the ones a world defines, and the checker has no way to
guess them.
This module reads each registered category's M.ref table from its
source (never executing it) and renders it as a Luau table type, then
hands the whole set to the engine. From there a ref:method(...) on
an asset-typed value resolves against the category's real surface: a
name it does not carry is reported with the list of the ones it does.
The sweep is complete and replaces what was published before, so a
category whose type is removed stops being published. It runs at
world load, and again whenever a behavior.luau is written — the
assetType type's own onChange hook re-publishes, which is what
makes an edited surface take effect without a restart.
Usage: local AssetRefShapes = require("@builtin::assetTypes.assetType.shared.refShapes")
modules/AssetRefShapes/ensure
ensure()
Publish the surfaces if they are not known to be current, and do nothing when they are. This is what a checker calls before it reads them: it makes the published set complete at the moment of use rather than at some earlier moment that may not have arrived yet. A set a sweep left stale while it waited on bytes is swept again once the engine is past the frame that sweep ran in, so a run of checks in one frame pays for one sweep.
AssetRefShapes.ensure()
modules/AssetRefShapes/install
install()
Arm the world-load sweep. Idempotent.
AssetRefShapes.install()
modules/AssetRefShapes/instanceReturnsOf
instanceReturnsOf(typeRef: any, out: { { category: string, identity: string, method: string, definition: string, source: string } })
The instance-derived returns one category contributes: for each of
its instances, the type each refShapes entry states for THAT asset.
A category whose behavior declares no refShapes contributes none.
This is how a method whose result is shaped by the asset gets typed at
all. inputMapRef:activate() answers one handle per binding the map
declares — a set that is authored, differs per map, and changes when a
control is added — so no fixed signature can state it and only the
type itself can compute it.
Each entry is function(self) -> (typeExpression, source?): the type
that call answers for THIS asset, and the module whose type vocabulary
the expression is written in — the handles an inputMap:activate()
answers are Handle, a name its own module declares. Omit the source
when the expression names only types visible from anywhere.
Parameters
typeRefany(optional) — TheAssetRef<assetType>for the category.out{ { category: string, identity: string, method: string, definition: string, source: string } }— Array the{ category, identity, method, definition, source }records append to.
AssetRefShapes.instanceReturnsOf(asset.resolve("inputMap", "assetType"), {})
modules/AssetRefShapes/invalidate
invalidate(path: string?)
Mark the published set stale, so the next ensure publishes it
again, in the same frame as well. With a path, a write landed at that path: the answers of the
instances holding it are computed again and every other one is read
from what was kept. Without one, every answer is computed again —
what a changed type definition or a world load asks for.
Parameters
pathstring?(optional) — The written path, or nil to recompute everything.
AssetRefShapes.invalidate("/zero/source/controls.inputMap/bindings.yaml")
modules/AssetRefShapes/publish
publish(): number
Sweep every registered asset type and publish its ref: surface,
plus every instance-derived return its types compute. Complete each
time: a category the sweep does not reach stops being published, so a
removed type's surface never lingers. The sweep never yields: a source
whose bytes are not resident yet is fetched, left unstated, and stated
by an ensure in a later frame, which sweeps again while one is
outstanding.
AssetRefShapes.publish()
modules/AssetRefShapes/published
published(): { categories: { [string]: string }, returns: { [string]: { [string]: string } } }
What the checker currently believes, as
{ categories = { [category] = definition }, returns = { [identity] = { [method] = definition } } }. Publishes first, so it answers about
the set a check would use rather than a stale one.
This is the answer to "is my type not published, or published and correct?" — from a call site the two look the same, because both are simply no diagnostic. Read it when a member access you expected to be reported was not.
AssetRefShapes.published().returns["@builtin::inputMaps.default"]
modules/AssetRefShapes/shapeOf
shapeOf(typeRef: any): string?
The Luau table type describing one category's ref: surface — the
methods its behavior.luau declares, plus everything every AssetRef
carries regardless of category. Returns nil when the type ships no
behavior or declares no M.ref methods: a category that states nothing
of its own is left opaque rather than described by the common members
alone, so an access on it stays unchecked instead of being judged
against a surface its author never wrote.
Parameters
typeRefany(optional) — TheAssetRef<assetType>for the category.
local t = AssetRefShapes.shapeOf(asset.resolve("inputMap", "assetType"))
modules/AssetTypeAssetTypeRef/README
require("@builtin::assetTypes.assetType.behavior") -- AssetTypeAssetTypeRef
Per-instance methods exposed on every AssetRef<assetType>. Loaded lazily by assetType.shared.ref.
An AssetRef<assetType> points at a <typename>.assetType/
definition folder. SHARED CODE that a type exposes to every instance
is declared in that type's own behavior.luau as a modules map of
tracked requires, e.g.:
-- inside <typename>.assetType/behavior.luau
M.modules = { shared = require(".shared") }
and reached from any instance through the pinned instance->type link:
-- inside any foo.<thatType>/init.luau
local api = asset.containing(FILE).modules.shared
Resolution follows the instance's pinned typeRef guid (its .refs
via = "asset_type" dep), so identically-named modules in different
types never collide and an imported instance reaches the exact type
version it was authored against. This is the mechanism that makes a
type fully self-contained: the behaviour every instance relies on
lives in the type, not duplicated as a require("modules.x") in
100 instance files. See @builtin::assetTypes.assetType.shared.ref.module for the dispatch.
Usage: local AssetTypeAssetTypeRef = require("@builtin::assetTypes.assetType.behavior")
modules/AssetTypeAssetTypeRef/getAbout
getAbout(self): { [string]: string }?
Read the three texts the type states about itself in its about.yaml:
intent (what the type is for in someone's game), function (how it
works) and usage (what a person or agent does with one). Only keys that
hold written text are returned.
Parameters
selfany(optional)
local about = assetTypeRef:getAbout(); if about then print(about.intent) end
modules/AssetTypeAssetTypeRef/getReadme
getReadme(self): string?
Read the asset type's own README.md body (type-level docs —
what THE TYPE is, surfaced by asset.inspect).
Parameters
selfany(optional)
print(assetTypeRef:getReadme())
modules/AssetTypeAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail for a type definition: { about },
the intent / function / usage texts of its about.yaml, when the
type has written them.
Parameters
selfany(optional)
local about = asset.inspect("font", "assetType").detail.about
modules/AssetTypeAssetTypeRef/onChange
onChange(ref, change)
Re-publish every asset category's ref: surface after a write
inside a type definition.
Parameters
refany(optional) — TheAssetRef<assetType>for the edited type.changeany(optional) —{ path, asset, type, kind, origin }for the write.
-- the engine calls this; a behavior.luau edit is picked up live
modules/AssetTypeAssetTypeRef/onCreate
onCreate(name: string): { [string]: string }
Generic-creation hook for asset.create("assetType", name). Scaffolds a
new asset type by cloning this type definition's own template/ skeleton
with the [name] placeholder rewritten to your type's name, so the new
<name>.assetType/ is ready to edit (type.yaml, behavior.luau, and its
own template/ instance body). Pure: returns the substituted file map.
Parameters
namestring— The new type's name. Becomes its.<name>instance suffix.
asset.create("assetType", "Waypoint")
modules/AssetTypeAssetTypeRef/validate
validate(ref): { any }
asset.validate's semantic check of a type definition, read from the
folder's own type.yaml. Every type names the file its Inspector sections
come from with inspector: { type }; a type that names none is
assetType.inspector_required, an error for a @builtin type the
engine's library authors and a warning for a world's own or for one the
library carries by reference (vfs.installedFrom), which the world that
published it answers for (a push refuses only errors, so a world holding
one still publishes, and its assets show the generic sections). A block
that is not a map naming .luau files is assetType.inspector_block, a
named file missing from the folder assetType.inspector_file_missing, and
one that does not load or returns the wrong shape
assetType.inspector_invalid, an error.
Parameters
refany(optional) — TheAssetRef<assetType>being validated.
local v = asset.validate("@builtin::assetTypes.material")
modules/AssetTypeDeclaration/README
require("@builtin::assetTypes.assetType.shared.declaration") -- AssetTypeDeclaration
A type's type.yaml, decoded: the declaration every question about the type as a whole reads from — which files it holds, whether it broadcasts its subassets, how its instances are pictured. Read once per type and held; the change dispatcher calls forget for every write inside an .assetType folder and for every removed type, so an edited type.yaml is read again.
Usage: local AssetTypeDeclaration = require("@builtin::assetTypes.assetType.shared.declaration")
modules/AssetTypeDeclaration/forget
forget()
Drop every held declaration, so each is read again the next time it is asked for.
declaration.forget()
modules/AssetTypeDeclaration/of
of(typeName: string): { [string]: any }?
The decoded type.yaml of typeName, or nil when no type answers to
the name, it has no type.yaml, or the file does not decode — the last
with a warning naming the type. The table is shared: read it, do not
write to it.
Parameters
typeNamestring— The asset type's name ("bundle").
local broadcasts = declaration.of("package").broadcasts_subassets == true
modules/AssetTypePreviewRecipe/README
require("@builtin::assetTypes.assetType.shared.previewRecipe") -- AssetTypePreviewRecipe
How a type makes its instances' pictures, as its type.yaml declares it under preview:. The declaration names one of the four recipes the preview runtime implements, and whatever that recipe needs: | kind | The picture is | Needs | |---|---|---| | instantiate | the asset stood in the studio through its own instantiate | — | | image | a file the instance already holds, fitted to the frame | source.files | | surface | the asset painted on a builtin mesh | mesh | | custom | whatever the type's behavior.luau preview returns | — | It says how an instance's preview.png is PRODUCED. What is embedded for search is a separate declaration, indexing.content, and neither implies the other.
Usage: local AssetTypePreviewRecipe = require("@builtin::assetTypes.assetType.shared.previewRecipe")
modules/AssetTypePreviewRecipe/forget
forget()
Drop every held recipe, so each is read again from its type.yaml
the next time it is asked for. The change dispatcher calls this for every
write inside an .assetType folder and for every type removed.
previewRecipe.forget()
modules/AssetTypePreviewRecipe/of
of(typeName: string): PreviewRecipe?
The preview recipe typeName declares, or nil when it declares none —
in which case its instances persist no picture. Read from the type's
type.yaml once, and again after any of the type's files change.
Parameters
typeNamestring— The asset type's name ("material").
local r = previewRecipe.of("texture") -- { kind = "image", files = { ... } }
modules/AssetTypeRuntime/README
require("@builtin::assetTypes.assetType.shared") -- AssetTypeRuntime
The assetType runtime — the machinery that reads a type's behavior.luau and turns its declarations into live behaviour.
A <typename>.assetType/behavior.luau is a table of DECLARATIONS:
ref methods, modules shared code, events schema, namePattern,
refShapes, and the onCreate / onRegister / onChange / onDelete
/ validate hooks. Nothing in that table runs itself. This module is
what runs it, and it lives inside assetType.assetType/ because reading
a type's declarations IS the assetType type's own behaviour — the same
way material.assetType owns what a .material does.
The sub-modules, one per stage of a type's life:
| Field | Reads from behavior.luau | What it does |
|---|---|---|
ref | ref, modules | Builds every AssetRef and dispatches per-type methods onto it. |
create | onCreate, onReplace, namePattern, creationInputs | Backs asset.create — scaffolds a new instance of a type. |
onRegister | onRegister | Fires an instance's once-only registration hook. |
changeDispatch | onChange, onDelete, refShapes | Routes a VFS write or delete to the enclosing asset's type. |
refShapes | refShapes, ref | Publishes each category's ref: surface to the checker. |
events | events | The per-asset event runtime ref.events reads. |
instantiable | ref.instantiate | The instantiation contract a type opts into — stands the root, applies the base placement opts, and shapes the return. |
declaration | type.yaml | The type's decoded declaration, read once and held. |
previewRecipe | type.yaml preview: | How an instance's preview.png is produced. |
settings | type.yaml's settings: block | Resolves an asset's schema, values file and defaults. |
typeYaml | type.yaml | The type's folder and its parsed type.yaml, read once per content version. |
inspector | type.yaml's inspector: block | The inspector declaration a type names for its assets. |
| Fields resolve LAZILY. The prelude requires the sub-modules in | ||
dependency order (ref, then changeDispatch, onRegister.install(), | ||
refShapes.install()); a table that required all of them on load would | ||
| take that ordering away from it. |
Usage: local AssetTypeRuntime = require("@builtin::assetTypes.assetType.shared")
modules/AssetTypeSharedInspector/README
require("@builtin::assetTypes.assetType.shared.inspector") -- AssetTypeSharedInspector
Which inspectors a type declares, and the declaration each file returns. A type names them in type.yaml under inspector:, with either key or both: type: "inspector.luau" is the Inspector for every asset of the type (a file in the type folder); instance: "inspector.luau" is a file each asset may ship in its own folder, whose sections apply to what that asset declares — a component's instances on entities — and never to the asset's own view.
Usage: local AssetTypeSharedInspector = require("@builtin::assetTypes.assetType.shared.inspector")
modules/AssetTypeSharedInspector/blockFor
blockFor(typeName: string): any?
The inspector: value a type declares, or nil. Well-formed, it is a
map naming type and/or instance; blockProblem says what is wrong
with any other value.
Parameters
typeNamestring— The asset type's name.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local block = InspectorDecl.blockFor("material")
modules/AssetTypeSharedInspector/blockProblem
blockProblem(block: any): string?
Why an inspector: value is malformed, or nil. A block is a map naming
type, instance or both, each a .luau file in the folder it applies to.
Parameters
blockany(optional) — The decodedinspector:value.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local problem = InspectorDecl.blockProblem({ type = "inspector.luau" })
modules/AssetTypeSharedInspector/declarationFor
declarationFor(ref: any): (any?, string?, string?)
The declaration for ref in the asset view: its type's type: inspector.
Parameters
refany(optional) — The asset ref.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local decl, problem, file = InspectorDecl.declarationFor(matRef)
modules/AssetTypeSharedInspector/declarationStamp
declarationStamp(typeName: string): string
Text that moves when what typeName's inspector declaration is made
from changes: its type folder and inspector file, and each module the
file requires, a module it required before that module was known
included. Read after typeDeclaration, which reloads the declaration on
such a change; empty for a type whose declaration was never read.
Parameters
typeNamestring— The asset type's name.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local s = InspectorDecl.declarationStamp("material")
modules/AssetTypeSharedInspector/declaresTypeInspector
declaresTypeInspector(typeName: string): boolean
Whether typeName's assets show a declared Inspector in their own
view: an inspector: block naming type, or one malformed enough that its
problem is what that view shows.
Parameters
typeNamestring— The asset type's name.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
if InspectorDecl.declaresTypeInspector("material") then print("declared") end
modules/AssetTypeSharedInspector/instanceDeclarationFor
instanceDeclarationFor(declarerRef: any): (any?, string?, string?)
The declaration declarerRef ships for the things it declares — a
component's inspector.luau, applied to that component on an entity.
(nil, nil, file) when the type names an instance: file this asset does
not ship; (nil, nil, nil) when the type names none.
Parameters
declarerRefany(optional) — The declaring asset (a component).
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local decl, problem, file = InspectorDecl.instanceDeclarationFor(compRef)
modules/AssetTypeSharedInspector/loadIn
loadIn(typeRef: any, file: string): (any?, string?, string)
Load the inspector file file of the type definition typeRef — the
type folder that ref names, whatever other type shares its name — and
check its shape.
Parameters
typeRefany(optional) — TheAssetRef<assetType>whose folder holds the file.filestring— The inspector file itstype.yamlnames.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local _, problem = InspectorDecl.loadIn(typeRef, "inspector.luau")
modules/AssetTypeSharedInspector/requiredSeverity
requiredSeverity(typeRef: any): string
How severe a missing inspector: block is on the type definition
typeRef: "error" for a @builtin type the engine's library authors,
"warning" for a world's own type and for one the library carries by
reference (vfs.installedFrom), which the world that published it
answers for. A push refuses only errors.
Parameters
typeRefany(optional) — TheAssetRef<assetType>, or any table carrying itsidentityandpath.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local severity = InspectorDecl.requiredSeverity(typeRef)
modules/AssetTypeSharedInspector/shapeProblem
shapeProblem(decl: any): string?
Check a declaration's shape: sections an array of sections, replace
a map of id to section, order an array of ids; any other member a function.
Parameters
declany(optional) — What the inspector file returned.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local problem = InspectorDecl.shapeProblem(decl)
modules/AssetTypeSharedInspector/typeDeclaration
typeDeclaration(typeName: string): (any?, string?, string?)
The declaration a type's own inspector file returns — the sections every
asset of typeName shows. (nil, nil, nil) when the type names no type:
inspector; (nil, problem, file?) when the block is malformed or the file
is missing, fails to load or returns the wrong shape. The answer, a failure
included, is held until a file of the type folder or a module the
inspector file requires changes.
Parameters
typeNamestring— The asset type's name.
local InspectorDecl = require("@builtin::assetTypes.assetType.shared.inspector")
local decl, problem = InspectorDecl.typeDeclaration("material")
modules/AssetTypeSharedSettings/README
require("@builtin::assetTypes.assetType.shared.settings") -- AssetTypeSharedSettings
Typed per-asset settings: which schema governs an asset, what its values are, and where both are declared. A type's type.yaml names its schema file and its values file; nothing here is found by convention.
Usage: local AssetTypeSharedSettings = require("@builtin::assetTypes.assetType.shared.settings")
modules/AssetTypeSharedSettings/acceptedFieldNames
acceptedFieldNames(typeName: string): { string }
Every field name a write to typeName may carry: the fields its
schema declares plus the older names its normalizeSettings maps
(behavior.luau's normalizedSettingNames), sorted.
Parameters
typeNamestring— The asset type's name.
local names = Settings.acceptedFieldNames("texture")
modules/AssetTypeSharedSettings/applyCorrections
applyCorrections(
Apply typeName's cross-field corrections to a complete values
table — the one path every settings write takes: resolveForCreate for
a new asset, M.writeValues for every later write (asset.setSettings,
a type's first-encode seed, the legacy heal). The type's
settingsCorrections hook (M.settingsCorrectionsHookOf) is asked once,
over a copy of values, for the fields a constraint the schema cannot
express forces to another value.
explicit names the fields the writer asked for by name — the
settings table passed to asset.create, the patch passed to
asset.setSettings. Corrections merge into the values the way every
settings layer does (M.mergeValues): a correction to one field of a
group leaves the group's other fields. A correction over a field the
writer did NOT name applies silently: nobody asked for that value, so
overriding it states a fact. A correction that changes a leaf field the
writer DID name refuses the whole write, naming the field's path
(group.field inside a group), the value asked for, the value it is
corrected to, and why it cannot hold (the hook's second return, keyed by
the path or the top-level field, or a generic reason) — an explicit
request is never silently rewritten into something else.
local fixed = Settings.applyCorrections("texture", values, patch, { label = "asset.setSettings" })
modules/AssetTypeSharedSettings/applyDerivedDefaults
applyDerivedDefaults(
Apply typeName's derived defaults to a complete values table: the
type's settingsDerivedDefaults hook (M.derivedHookOf) is asked once,
over a copy of values, and every field it answers that explicit does
not name takes the answered value. A create passes every schema field as
changed; a write passes the fields whose value it moved.
local values = Settings.applyDerivedDefaults("texture", values, { textureType = true }, { textureType = true })
modules/AssetTypeSharedSettings/blockFor
blockFor(typeName: string): any?
The settings: block a type declares, or nil when it declares none.
Parameters
typeNamestring— The asset type's name, e.g. "texture".
local block = Settings.blockFor("texture")
modules/AssetTypeSharedSettings/cloneValues
cloneValues(values: { [string]: any }): { [string]: any }
A deep copy of a settings values table — every table-valued field,
and every table nested inside one (a Field.settingsOf group, a list of
structs), copied at whatever depth it goes. Settings values are
YAML-shaped data (tables, strings, numbers, booleans, never a cycle), so
a plain recursive table copy is the whole guarantee this makes: nothing
a hook or onCreate does to what it's handed, at ANY depth, can reach
the table asset.create goes on to stamp into the values file.
Parameters
values{ [string]: any }— The values table to copy.
local copy = Settings.cloneValues(resolved)
modules/AssetTypeSharedSettings/creationInputsOf
creationInputsOf(typeName: string): { [string]: string | boolean }
The creation inputs typeName declares, and the shape each one
belongs to — its behavior.luau's exported creationInputs map, when
it ships one, or an empty map. A key is a top-level asset.create opt
the type's onCreate reads as what the asset is MADE FROM; its value is
the name of the opt that selects the shape the input belongs to, or
true for an input that belongs to every shape. soundClip declares
{ sampleRate = "pcm", channels = "pcm", ext = "bytes", writeSource = "bytes" }:
sampleRate and channels describe raw PCM as it arrives and mean
something only alongside pcm; ext names the container encoded source
bytes are in, and writeSource keeps a copy of them, and both mean
something only alongside bytes.
asset.create reads it before anything else touches the caller's opts.
A declared input given alongside the opt that selects its shape is a
creation input and reaches onCreate unchanged. A declared input given
on any other shape has no meaning there and never reaches onCreate;
one that names no declared setting refuses the create, naming the input
and the opt it belongs with.
Parameters
typeNamestring— The asset type's name.
Settings.creationInputsOf("soundClip").sampleRate --> "pcm"
modules/AssetTypeSharedSettings/defaultsOf
defaultsOf(schema: any): { [string]: any }
Every declared default of schema, one value per field. A field
declared without a default is absent rather than nil-valued.
Parameters
schemaany(optional) — The Field schema table.
local values = Settings.defaultsOf(schema)
modules/AssetTypeSharedSettings/derivedHookOf
derivedHookOf(typeName: string): (({ [string]: any }, { [string]: true }, { [string]: true }) -> { [string]: any }?)?
typeName's own derived-defaults hook — its behavior.luau's
exported settingsDerivedDefaults(values, explicit, changed), when it
ships one — or nil. It answers the values of fields whose default follows
another field (a texture's colour space follows its texture type), given
the complete values, the fields the writer named (explicit) and the
fields this write changed (changed). The framework applies a returned
field only when the writer did not name it (M.applyDerivedDefaults).
Parameters
typeNamestring— The asset type's name.
Returns { [string]: any }?)? — The hook function, or nil when the type declares none.
local hook = Settings.derivedHookOf("texture")
modules/AssetTypeSharedSettings/diffFor
diffFor(ref: any, writtenPath: string): ({ [string]: any }?, { [string]: any }?)
The settings a write to writtenPath produced, and which fields it
changed, when that path IS the asset's declared values file. A write to
anything else answers (nil, nil). A values file that fails its schema
answers (nil, nil) too, after reporting the violations — the asset keeps
the settings it last had rather than taking an invalid set. changed is
computed against an in-process baseline (last_values, forgotten on
delete via forgetChangeBaseline) — a fresh process, or an asset diffed
for the first time this session, reports every field as old = nil.
Parameters
refany(optional) — The asset ref.writtenPathstring— The path that was written.
local values, changed = Settings.diffFor(ref, change.path)
modules/AssetTypeSharedSettings/fieldNames
fieldNames(typeName: string): { string }
Every field name typeName's settings schema declares, sorted.
Parameters
typeNamestring— The asset type's name.
local names = Settings.fieldNames("texture")
modules/AssetTypeSharedSettings/forgetChangeBaseline
forgetChangeBaseline(assetPath: string)
Forget the diff baseline diffFor holds for assetPath — the
settings it last saw for that asset's own folder path. Called when the
asset is deleted, so a later create that reuses the same path (a
delete-then-recreate) diffs its first write against nothing rather than
against what the deleted asset last held, and the baseline map does not
grow for assets no longer alive.
Parameters
assetPathstring— The asset's own folder path, asdiffForkeys its baseline.
Settings.forgetChangeBaseline("/zero/source/Rock.texture")
modules/AssetTypeSharedSettings/healLegacyIfNeeded
healLegacyIfNeeded(ref: any, origin: string?)
Migrate ref's settings out of legacy storage, when a LOCAL edit
just landed on an asset that still carries them there: settings in the
legacy .metadata block move into its values file, and a values file
holding an older spelling (one the type's normalizeSettings rewrites)
is rewritten in the declared spelling — every existing asset self-heals
this way as it is touched, rather than only on an explicit settings
write. Called once per dispatched edit, generically, for every
registered type (a type that declares no settings block, an asset whose
values file its type ships no normalizeSettings for or holds only the
declared spelling, or one with no values file whose .metadata carries
no settings key, returns without writing — this is a no-op the
overwhelming majority of the time, by construction, and convergent: a
second call after healing finds the values file in the declared
spelling and does nothing).
Never runs for a REMOTE-origin dispatch — the peer whose own edit this
was heals it there, and the migration reaches every other session as
an ordinary synced write once it does. Never runs for installed /
foreign-origin content (isForeignOrigin, the same check
M.writeValues already applies to the .metadata removal) — a
library's own content is not this world's to rewrite.
The healed values are what M.valuesOf already reports for this
asset — the stored settings read through the type's normalizeSettings
(M.normalizeFor), filtered to declared fields, schema-checked — with
the fields the type's settingsHealed hook changes for settings stored
before its schema decided them (a texture whose settings predate
compression heals to the compression it should have). The diff
baseline is seeded with the values read before the heal, so that write's
own follow-up dispatch reports only what the hook changed: nothing, when
healing only relocates storage — the edit that triggered the heal
already got its own reaction from the dispatch that called this — and
the changed fields otherwise, which the type reacts to as to any
settings change.
Parameters
refany(optional) — The asset ref the just-applied edit landed on.originstring?(optional) — The dispatch's origin ("local"/nil, or "remote") — seeAssetChangeDispatch.dispatch.
Settings.healLegacyIfNeeded(ref, change.origin)
modules/AssetTypeSharedSettings/isForeignOrigin
isForeignOrigin(ref: any): boolean
True when ref's origin is outside this world — installed from a
library, or carried by the engine's library by reference, rather than
authored here or shipped with the engine. Read through the same envelope
asset.inspect reports, origin.kind: "installed" for either, and
"authored" for a world-authored or builtin asset. An origin asset.inspect cannot answer (it raises, or
reports a shape these reads don't recognise) resolves foreign: what this
guards is that a foreign asset's legacy settings are never dropped or
rewritten, so an undetermined origin takes the side that leaves the
asset's content as it is.
Parameters
refany(optional) — The asset ref.
if not Settings.isForeignOrigin(ref) then Settings.healLegacyIfNeeded(ref, "local") end
modules/AssetTypeSharedSettings/mergeValues
mergeValues(schema: any, base: { [string]: any }?, overlay: { [string]: any }?): { [string]: any }
Lay overlay over base under schema, the one way settings layers
combine: a field overlay names replaces the field in base, except a
struct field (a Field.struct, or a Field.settingsOf group) that both
hold as tables, which merges field by field at whatever depth it nests —
so a layer naming one field of a group leaves the group's other fields
where the layers below put them. Neither input is modified; the result
is a deep copy.
Parameters
schemaany(optional) — The Field schema the values follow (the fields of a struct at depth), or nil to replace every named field.base{ [string]: any }?(optional) — The values below.overlay{ [string]: any }?(optional) — The values laid over them.
Settings.mergeValues(schema, { group = { a = 1, b = 2 } }, { group = { b = 3 } }) --> { group = { a = 1, b = 3 } }
modules/AssetTypeSharedSettings/normalizeFor
normalizeFor(typeName: string?, values: { [string]: any }, stored: { [string]: any }?): { [string]: any }
values in the spelling typeName's schema declares: the type's
normalizeSettings applied, or values itself when it ships none. Every
settings source passes through here — a values file, a legacy
.metadata block, a create's preset / importer / caller layers, a
asset.setSettings patch — so an older spelling reads, creates and
writes as the field it names today. The hook is handed copies; neither
table passed here is modified.
Parameters
typeNamestring?(optional) — The asset type's name (nil answersvaluesunchanged).values{ [string]: any }— A settings table in any spelling the type accepts.stored{ [string]: any }?(optional) — The asset's current values, whenvaluesis a patch over them.
local values = Settings.normalizeFor("texture", { format = "bc7" })
modules/AssetTypeSharedSettings/normalizeHookOf
normalizeHookOf(typeName: string): (({ [string]: any }, { [string]: any }?) -> { [string]: any })?
typeName's own normalisation hook — its behavior.luau's exported
normalizeSettings(values, stored?), when it ships one — or nil. The
hook maps every older spelling a stored file or a write may carry (a
renamed field, an older enum member) to the field and member the schema
declares now, and returns a new table. stored, when given, is the
asset's current values, which an older spelling in a patch may need to
keep the meaning it had against them.
Parameters
typeNamestring— The asset type's name.
Returns { [string]: any })? — The hook function, or nil when the type declares none.
local hook = Settings.normalizeHookOf("texture")
modules/AssetTypeSharedSettings/orderedNames
orderedNames(schema: any): { string }
The field names of schema in the order they are declared: by each
descriptor's declaredOrder, a name breaking a tie and a descriptor
without one sorting after those that carry one.
Parameters
schemaany(optional) — The Field schema table.
for _, name in ipairs(Settings.orderedNames(schema)) do print(name) end
modules/AssetTypeSharedSettings/presetLayerFor
presetLayerFor(typeName: string, destPath: string): ({ [string]: any }?, any?)
The Preset Manager's layer for a new asset of typeName at
destPath: the valid values of the world's first [[presets]] row
naming the type's assetType whose filter matches the new asset's path
(under /source for a durable asset, under /runtime/assets for a
runtime one), and the match. Nil for any other destination, a type with
no type-level schema, or no matching row.
Parameters
typeNamestring— The asset type being created.destPathstring— Where the new asset lands.
local layer = Settings.presetLayerFor("texture", "/zero/source/sprites/hero.texture")
modules/AssetTypeSharedSettings/recordedWrite
recordedWrite(path: string, text: string)
Write text to path, recording the write into the open undo
operation when one is open so undoing it restores the file's previous
contents. Raises when the write fails.
Parameters
pathstring— VFS path.textstring— The whole new contents.
local Yaml = require("@builtin::modules.yaml")
Settings.recordedWrite(ref.path .. "/values.yaml", Yaml.encode(doc))
modules/AssetTypeSharedSettings/requiredModulesCurrent
requiredModulesCurrent(record: any, ref: any): boolean
Whether a value read alongside record still stands: every module it
listed holds the version it was listed at, and — when some required
module was not yet known — none of those has become known since. That
last question is asked again at most every quarter second, so a read held
while a module was unknown is not read again on every call.
Parameters
recordany(optional) — WhatrequiredModulesRecordanswered.refany(optional) — The asset the record was taken for.
if held and Settings.requiredModulesCurrent(held.modules, ref) then return held.value end
modules/AssetTypeSharedSettings/requiredModulesRecord
requiredModulesRecord(ref: any): { deps: { { path: string, version: number } }, depsPending: boolean, depsCheckedAt: number }
What a read derived from ref's code depends on beyond ref's own
files: the entry file of each module its sources require (as its
reference table has bound them), with the content versions they have now,
and whether some module it requires is not yet known. Hold it beside the
value read, and ask requiredModulesCurrent before serving the value
again.
Parameters
refany(optional) — The asset.
held.modules = Settings.requiredModulesRecord(ref)
modules/AssetTypeSharedSettings/requiredModulesStamp
requiredModulesStamp(record: any, ref: any): string
Text that moves when a module a record listed changes, or when a
module it required before that module was known becomes known (asked at
most every quarter second, as requiredModulesCurrent asks it): the
content versions of its listed modules now, and whether the read beside
it has gone stale. Fold it into a build signature to rebuild what was read
from code that requires them.
Parameters
recordany(optional) — WhatrequiredModulesRecordanswered.refany(optional) — The asset the record was taken for.
parts[#parts + 1] = Settings.requiredModulesStamp(held.modules, ref)
modules/AssetTypeSharedSettings/resolveForCreate
resolveForCreate(
Resolve the settings a created asset is stamped with. For a new
asset the layers, lowest priority first, are: the schema's declared
defaults, the type's own settingsDefaults hook, the Preset Manager's
first matching row, the creating importer's settings for this type, and
the settings table the caller passed. When destPath already holds an
asset of typeName that records settings of its own, it is being
re-authored — overwrite = true, or an importer re-creating what it made
inside its container — and those settings take the place of every layer
below the caller's, so what it was stamped with and edited to stays. An
asset that records none (a hand-written container being seeded) takes
the layers a new asset takes. Each layer overrides the
ones before it, field by field, and a struct field merges field by field
inside (M.mergeValues). Each layer is read through the type's
normalizeSettings (M.normalizeFor), so a layer naming a field in an
older spelling sets the field it names today. Once every layer has
merged, the type's derived defaults (M.applyDerivedDefaults) set each
field whose default follows another and that no layer above the schema
named; for a re-authored asset its own settings name nothing, and a
derived field follows only a field the caller's settings changed. Then
M.applyCorrections applies the type's
cross-field corrections with the caller's settings table as the
explicit fields: a correction over a field that came from any layer
below the caller applies silently, and one that contradicts a field the
caller's own settings table set refuses the creation, naming the field,
the value asked for, and why it cannot hold.
The (possibly corrected) result is checked against the schema, so a bad value nothing corrects refuses the creation rather than landing in a new asset.
local values = Settings.resolveForCreate("texture", name, dest, opts, opts.settings, nil)
modules/AssetTypeSharedSettings/resolvePatch
resolvePatch(ref: any, patch: { [string]: any }): ({ [string]: any }, { [string]: any })
The complete values a partial settings patch writes — the values
asset.setSettings hands M.writeValues. The patch is read through the
type's normalizeSettings against the asset's current values, so an
older field name lands as the field it names today with the meaning it
had for this asset, and is merged over those values, a struct group
field by field (M.mergeValues); the type's
derived defaults (M.applyDerivedDefaults) then move each field that
follows a field this patch changed, unless the patch names it too.
M.writeValues applies the corrections with the normalised patch as the
explicit fields.
Parameters
refany(optional) — The asset ref.patch{ [string]: any }— Any subset of the schema's fields, in the current or an older spelling.
local values, named = Settings.resolvePatch(texRef, { compression = "uastc" })
modules/AssetTypeSharedSettings/schemaFor
schemaFor(ref: any): any?
The schema governing ref's own settings values — the type-level
schema when its type declares one, else the schema the asset declares
for itself. ref naming an assetType asset itself (rather than an
instance of one) reports that TYPE's own declared schema — the same
schema every instance of it reports.
Parameters
refany(optional) — The asset ref.
local schema = Settings.schemaFor(texRef)
modules/AssetTypeSharedSettings/schemaForType
schemaForType(typeName: string): any?
The schema governing the settings of assets of typeName, when the
type declares one at type level (schema: { type = ... }).
Parameters
typeNamestring— The asset type's name.
local schema = Settings.schemaForType("texture")
modules/AssetTypeSharedSettings/schemaOfDeclarer
schemaOfDeclarer(identity: string): any?
The schema a declarer declares, named by its identity. This is what
Field.settingsOf(identity) resolves to: an assetType's instance-settings
schema, or an importer's / component's own declared schema.
Parameters
identitystring— The declarer's asset identity.
local schema = Settings.schemaOfDeclarer("@builtin::assetTypes.texture")
modules/AssetTypeSharedSettings/schemaOfInstance
schemaOfInstance(ref: any): any?
The schema an individual asset declares for itself, when its type
says the schema is per instance (schema: { instance = ... }). Whether
an instance may lack the file is what the type's files: block says of
it: a schema file listed under files.optional may be absent, and an
instance without one declares no settings; one listed under
files.required, or not listed at all, must load, and a missing one is
the instance's declaration broken, and is logged.
Parameters
refany(optional) — The asset ref.
local schema = Settings.schemaOfInstance(importerRef)
modules/AssetTypeSharedSettings/schemaProblemOf
schemaProblemOf(ref: any): string?
Why ref's settings schema resolved to nothing: the declaring file
could not be read, compiled, run, or did not declare its table; or the
type refused what it declared — the sentence its behavior.luau's
exported settingsSchemaProblem(schema, ref) returned. Nil when the
schema resolved or ref's type declares none.
Parameters
refany(optional) — The asset ref.
local why = Settings.schemaProblemOf(compRef)
modules/AssetTypeSharedSettings/seedChangeBaseline
seedChangeBaseline(assetPath: string, values: { [string]: any })
Record values as the settings diffFor last saw for assetPath,
so the dispatch of a values file written with exactly these values
reports nothing changed. Every writer that has ALREADY done what those
values ask for calls it with what it writes: asset.create after
stamping a new asset (its onCreate encoded against them), a type's
first-encode seed of a hand-written container, and the legacy heal
(which moves values without changing one). A later write that changes a
field still diffs against these and reports that field.
Parameters
assetPathstring— The asset's own folder path, asdiffForkeys its baseline.values{ [string]: any }— The complete values table the values file holds.
Settings.seedChangeBaseline(rawget(texRef, "path"), values)
modules/AssetTypeSharedSettings/settingsCorrectionsHookOf
settingsCorrectionsHookOf(typeName: string): (({ [string]: any }, string, { [string]: any }?) -> ({ [string]: any }?, { [string]: string }?))?
typeName's own settings-corrections hook — its behavior.luau's
exported settingsCorrections(values, name, opts), when it ships one —
or nil. Where settingsDefaults supplies an opinion a layer below the
caller can still override, this hook enforces a cross-field constraint
the schema itself has no way to express (a field whose valid range
depends on another field's resolved value). M.applyCorrections calls
it on every settings write — once a create's layers have merged, and on
every later write of the values file. Called with the complete values;
it READS them and RETURNS a table of the corrections to apply (or nil
for none), rather than mutating what it was given. A SECOND return,
{ [field]: reason }, names why a corrected field cannot hold the value
it is being corrected away from — used only when the writer named that
field explicitly, to explain the refusal; omitted or missing a field
falls back to a generic reason.
Parameters
typeNamestring— The asset type's name.
Returns ({ [string]: any }?, { [string]: string }?))? — The hook function, or nil when the type declares none.
local hook = Settings.settingsCorrectionsHookOf("texture")
modules/AssetTypeSharedSettings/settingsDefaultsHookOf
settingsDefaultsHookOf(typeName: string): ((string, { [string]: any }?, { [string]: any }) -> { [string]: any }?)?
typeName's own create-time settings-defaults hook — its
behavior.luau's exported settingsDefaults(name, opts, asked), when it
ships one — or nil. A type contributes a layer here for whatever it can
only compute at creation (a name-derived convention, a fact read off a
pre-encoded payload the caller handed it, a default that follows a field
another layer sets); resolveForCreate calls it once per create, above
the schema's own defaults and below every other layer, with asked
holding what the layers above it (the Preset Manager, an importer, the
caller) name, field by field, the higher layer's value where two name
one. The hook returns a fresh table of its own opinions; it is never
handed anything to mutate, and a field it returns that a layer above it
names takes that layer's value.
Parameters
typeNamestring— The asset type's name.
Returns { [string]: any }?)? — The hook function, or nil when the type declares none.
local hook = Settings.settingsDefaultsHookOf("texture")
modules/AssetTypeSharedSettings/settingsHealedHookOf
settingsHealedHookOf(typeName: string): (({ [string]: any }, { [string]: any }) -> { [string]: any }?)?
typeName's own settings-heal hook — its behavior.luau's exported
settingsHealed(values, stored), when it ships one — or nil. Healing
moves an asset's settings out of older storage on a local edit; this
hook answers the fields whose value that move changes, for content whose
stored settings predate what the type's schema now decides. values is
what a read of the stored settings reports, stored the settings exactly
as stored (before an older spelling is read as today's). It returns the
fields to change, or nil for none.
Parameters
typeNamestring— The asset type's name.
Returns { [string]: any }?)? — The hook function, or nil when the type declares none.
local hook = Settings.settingsHealedHookOf("texture")
modules/AssetTypeSharedSettings/valuesEqual
valuesEqual(a: any, b: any): boolean
Structural equality for a settings value at any depth: two tables are
equal when they hold the same keys and every value is itself equal
(recursively), and two scalars (string, number, boolean, nil) are equal
by ==. Table VALUES in a settings table are always freshly built —
defaultsOf clones a default, read_values_file decodes a fresh table
from YAML — so comparing them by reference would report a table-valued
field as changed on every read even when its contents are identical.
The one comparison every settings-value equality check in this module
shares — diffFor's own diff and resolveForCreate's
caller-conflict check both call this rather than each carrying its own.
Takes acyclic settings values — YAML-shaped data, the same invariant
clone_value relies on — so the recursive walk always terminates.
Parameters
aany(optional) — A settings value (a scalar or a table, at any nesting depth).bany(optional) — A settings value to compare it against.
Settings.valuesEqual({ a = 1, b = { 2, 3 } }, { a = 1, b = { 2, 3 } }) --> true
modules/AssetTypeSharedSettings/valuesOf
valuesOf(ref: any): { [string]: any }?
This asset's settings values: every declared default, overlaid with
what its values file holds — or, for content that predates the values
file, with its legacy .metadata settings. A field neither sets reads as
its declared default, so content written before a field existed still
answers for it. A stored field the schema no longer declares is filtered
out, so a schema revision that drops a field leaves old content reading
as clean rather than carrying a value nothing recognises. A stored value
that fails its own field's constraint is dropped the same way — the
field falls back to its declared default and a warning names the path,
the field and the violation — so a read never answers with a value the
schema (and therefore the type's own encode) refused. The values are
resolved in memory from what is already on disk. An asset whose type
declares no values file holds no settings values of its own — a
component's live on each entity it is on — and reads as nil, while its
schema still answers through schemaFor.
Parameters
refany(optional) — The asset ref.
local s = Settings.valuesOf(texRef)
modules/AssetTypeSharedSettings/valuesPathOf
valuesPathOf(ref: any): string?
The path of ref's settings values file, per its type's declared
settings.values, or nil when its type declares no values file. A ref
that carries its guid or identity without its path reaches the same file
through what that name resolves to.
Parameters
refany(optional) — The asset ref.
local p = Settings.valuesPathOf(texRef)
modules/AssetTypeSharedSettings/whyNoSettings
whyNoSettings(ref: any): string
Why ref carries no settings, as a sentence naming where they would
be declared: the type declares no settings block; or the type declares a
schema per instance and this instance ships none, naming the file it
would be; or the type's declared schema did not load.
Parameters
refany(optional) — The asset ref, one for whichM.schemaForanswered nil.
error("asset.setSettings: " .. Settings.whyNoSettings(ref))
modules/AssetTypeSharedSettings/writeActedValues
writeActedValues(ref: any, values: { [string]: any })
Write ref's whole values file (M.writeValues) with values, the
settings the caller has already acted on, and seed the change baseline
with what was written (M.seedChangeBaseline) before that write's
dispatch runs, so the dispatch reports nothing changed and no reaction
runs a second time.
Parameters
refany(optional) — The asset ref.values{ [string]: any }— The complete values table.
Settings.writeActedValues(texRef, values)
modules/AssetTypeSharedSettings/writeValues
writeValues(ref: any, values: { [string]: any }, explicit: { [string]: any }?): { [string]: any }
Write this asset's whole settings values file. The values (and
explicit) are read through the type's normalizeSettings first, so an
older spelling is stored as the field it names today. They then take
the type's cross-field corrections (M.applyCorrections, with explicit
as the fields the writer named — a correction contradicting one of them
refuses the write), then are checked against the schema. Every violation
is reported in one error naming the field, what it takes, and where the
schema is declared. When the asset
also carries legacy .metadata settings and its origin is authored —
this world's own content, or the engine's builtin library — the legacy
key is dropped as part of this same write, so the values file above is
what a read prefers from here on. A library-installed asset keeps its
.metadata settings key alongside the values file this call writes.
Inside an undo operation, the write is recorded so undoing the operation
restores the previous file contents; authored legacy content is first
healed into its values file, so undo returns it to the healed file,
which reads the same values as the legacy one. When that heal does not
complete, the legacy settings stay in .metadata and the step records
the values file alone, so undo falls back to the legacy values.
Parameters
refany(optional) — The asset ref.values{ [string]: any }— The complete values table.explicit{ [string]: any }?(optional) — The fields the writer asked for by name (a patch), or nil.
Settings.writeValues(texRef, { filter = "nearest", colorSpace = "srgb" })
modules/AssetTypeSharedTypeYaml/README
require("@builtin::assetTypes.assetType.shared.typeYaml") -- AssetTypeSharedTypeYaml
A type's type.yaml, parsed: the folder a type lives in and the document its type.yaml holds, read once per content version of that file. Every block a type declares — settings:, inspector: — is read from here, and so are the texts of its about.yaml (about, aboutAt).
Usage: local AssetTypeSharedTypeYaml = require("@builtin::assetTypes.assetType.shared.typeYaml")
modules/AssetTypeSharedTypeYaml/about
about(typeName: string): { [string]: string }?
The written about.yaml texts of the type typeName; see aboutAt.
Parameters
typeNamestring— The asset type's name.
local about = TypeYaml.about("font")
modules/AssetTypeSharedTypeYaml/aboutAt
aboutAt(folder: string): { [string]: string }?
The texts the type folder at folder states in its about.yaml:
intent (what the type is for in someone's game), function (how it
works) and usage (what a person or agent does with one). Only the keys
that hold written text are returned; a key that is missing, empty or still
starts with the [[describe]] marker is left out.
Parameters
folderstring— The type's folder, e.g./zero/source/libs/@builtin/assetTypes/font.assetType.
local about = TypeYaml.aboutAt("/zero/source/libs/@builtin/assetTypes/font.assetType")
modules/AssetTypeSharedTypeYaml/aboutMarkdown
aboutMarkdown(about: { [string]: string }?): string
The about.yaml texts as a Markdown section titled "About this type",
each text under its label. Empty text when no key holds written text.
Parameters
about{ [string]: string }?(optional) — Whatabout/aboutAtreturned, or nil.
print(TypeYaml.aboutMarkdown(TypeYaml.about("font")))
modules/AssetTypeSharedTypeYaml/aboutRows
aboutRows(about: { [string]: string }?): { { key: string, label: string, text: string } }
The labelled about.yaml texts as { { key, label, text } } in reading
order: Intent, Function, Usage. Empty when no key holds written text.
Parameters
about{ [string]: string }?(optional) — Whatabout/aboutAtreturned, or nil.
for _, row in ipairs(TypeYaml.aboutRows(TypeYaml.about("font"))) do print(row.label, row.text) end
modules/AssetTypeSharedTypeYaml/describeBlock
describeBlock(typeName: string): { guidance: string?, examples: { string } }
What services describe hands the model when it writes a description
for an asset of this type: the type's own guidance on what to cover, and
the identities of the examples whose descriptions show the shape.
Parameters
typeNamestring— The asset type's name.
local block = TypeYaml.describeBlock("module"); print(block.guidance)
modules/AssetTypeSharedTypeYaml/described
described(typeName: string): { DescribedFile }
The files a type's assets must describe: every file its type.yaml
declares with a described content check, with the keys and headings the
check names and the limit on each key. Empty when the type asks its assets
for no description.
Parameters
typeNamestring— The asset type's name.
for _, f in ipairs(TypeYaml.described("module")) do print(f.file, f.required) end
modules/AssetTypeSharedTypeYaml/folder
folder(typeName: string): (string?, string?)
The folder the assetType typeName lives in, and its identity.
Parameters
typeNamestring— The asset type's name, e.g. "texture".
local folder, identity = TypeYaml.folder("material")
modules/AssetTypeSharedTypeYaml/of
of(typeName: string): { [string]: any }?
The document typeName's type.yaml holds, decoded. Read again when
the file's content changes.
Parameters
typeNamestring— The asset type's name.
local doc = TypeYaml.of("material"); print(doc.suffix)
modules/AssetValidator/README
require("@builtin::systems.worldValidation.assetValidator") -- AssetValidator
Structure validator for asset folders. Delegates each asset to asset.validate — the engine primitive that checks the folder against its type's type.yaml (required files, one_of_groups, unexpected entries, content constraints), waives the describe-this-asset requirements for private subassets (assets nested inside a non-broadcasting container like a .bundle), and runs the type's own semantic validate hook — and maps the result into the report's Problem records.
asset.validate is the same primitive the world.push gate runs,
so a world that validates clean here also passes the structural
half of the publish gate. Each problem is attributed to the asset
path (missing files anchor at the asset root; existing files —
unexpected entries, content violations — anchor at the file).
An asset whose type has no registered type.yaml gets a
schema.unknown_type warning; an asset the registry cannot
resolve (e.g. written this frame, registration still draining)
gets a schema.unresolved_asset warning.
Usage: local AssetValidator = require("@builtin::systems.worldValidation.assetValidator")
modules/AssetValidator/dependencyProblemsFrom
dependencyProblemsFrom(path: string, deps: any, guidCache: { [string]: boolean })
Map an asset's reference table into publish-blocking Problem records.
Split from the lookup so the mapping can be exercised on a reference table
directly. A guid already present in guidCache is not looked up again.
Parameters
pathstring— Asset path the problems are attributed to.depsany(optional) — Reference table in the shapeasset.depsreturns.guidCache{ [string]: boolean }— Memo of guid → whether the live asset index carries it.
local problems = AssetValidator.dependencyProblemsFrom(path, asset.deps(path), {})
modules/AssetValidator/validate
validate(entry, guidCache: { [string]: boolean }?)
Validate one asset folder via asset.validate and map the
result into Problem records.
Parameters
entryany(optional) — Asset entry fromvfsScanner—{ path, name, type }.guidCache{ [string]: boolean }?(optional)
local problems = AssetValidator.validate({ path = "/source/Foo.component", name = "Foo.component", type = "component" })
modules/AssetValidator/validateBatch
validateBatch(assets)
Validate a batch of asset entries and flatten the per-asset
problem lists into one array. Convenience wrapper over M.validate.
Parameters
assetsany(optional) — Array of asset entries from the scanner.
local all = AssetValidator.validateBatch(bucket.assets)
modules/AvatarAssetTypeBehavior/README
require("@builtin::assetTypes.avatar.behavior") -- AvatarAssetTypeBehavior
Behaviour for the avatar asset type — a playable character composed from three INDEPENDENT parts so each swaps on its own axis: - body — a .bundle: skinned mesh + bone entities (the look). - controller — the movement system (default: CharacterController + MovementState + Humanoid, the standard kinematic humanoid mover). - animation — the system that animates the body (default: the shared Locomotion blend space, which reads the controller's velocity and plays retargeted clips; or ClipPlayer; or your own component). Movement and animation are NOT tied together: attaching the controller never pulls in Locomotion, and choosing your own animation keeps the standard controller — so authoring your own locomotion is a one-field swap. The clip set retargets onto any humanoid rig, so the default locomotion drives any humanoid body with no per-body setup. :instantiate() composes the parts; :setCharacter(root, body) swaps the body. Point a scene's PlayerPrototype.body at a body carrying this avatar to make it the body every connecting player spawns with.
Usage: local AvatarAssetTypeBehavior = require("@builtin::assetTypes.avatar.behavior")
modules/AvatarAssetTypeBehavior/instantiate
instantiate(self, target: EntityRef?, opts: any): (EntityRef, { [string]: string })
Instantiate this avatar: spawn an avatar root, spawn the body bundle
under it, then attach the movement controller and the animation system —
independently. With the defaults the root gets the standard humanoid
controller and the shared Locomotion that drives the body with retargeted
clips. Pass a target entity REF to make that entity the avatar root (the
player-avatar path passes the freshly-spawned avatar entity here).
Parameters
selfany(optional)targetEntityRef?(optional) — Optional avatar root as an EntityRef. Omit to spawn one.optsany(optional) — Optional{ position, rotation, scale, name, temporary, idMap, diff, sourceTag }— the base placement opts land on the root;idMappins the composed body root, label, and every body-bundle child to stable ids across re-instantiations;diffreplays the user's sparse edits to the composed body.sourceTagmarks the call as owned — theAssetcomponent sets it when it drives the composition itself.
local av = avatarRef:instantiate()
modules/AvatarAssetTypeBehavior/onCreate
onCreate(name: string, opts: CreateOpts?): { [string]: string }
Generic-creation hook for asset.create("avatar", name, opts). Composes
the avatar from a body plus an independent movement controller and
animation system, written as avatar.json. The body is a .bundle
(skinned mesh + bones), a plain .mesh (a simple visual), or omitted (a
body-less avatar — a controller / first-person camera with no mesh).
Defaults: the standard humanoid controller and, for a humanoid body, the
shared Locomotion (clips from the locomotion preset, default "synty").
Override animation to author your own locomotion without touching movement;
pass controller = false for a body the engine doesn't move; pass clip for
a single-clip ClipPlayer. Humanoid-ness drives the default animation only
and is auto-derived from a rigged body; pass humanoid to set it explicitly
(e.g. a body-less first-person avatar that still carries Humanoid).
Parameters
namestringoptsCreateOpts?(optional)
asset.create("avatar", "my_hero", { body = heroBundle }) -- standard controller + locomotion
asset.create("avatar", "fp_player", { humanoid = true }) -- body-less first-person player
modules/AvatarAssetTypeBehavior/setCharacter
setCharacter(self, root: any, body: any): EntityRef
Swap the body on a live avatar. Despawns the current body and spawns
body (a .bundle ref) in its place. The controller + animation systems
live on the avatar root and re-resolve the new body's rig, so the look swaps
while movement and animation are kept. A single-clip ClipPlayer rides the
skinned body, so it is re-attached to the new body. Every item seated with
Humanoid:attach is kept and re-seated on the new body's socket for the
same point, with the same transform, as soon as the new body's skeleton
stands (within the call when the body wakes inside it); an item whose point
the new body does not have stays on the avatar root. The new body takes the old body's id and
is composed with the options the avatar was instantiated with, and the
avatar's Asset id map is updated to name it.
Parameters
selfany(optional)rootany(optional) — The live avatar root (an EntityRef from:instantiate()).bodyany(optional) — The new body — a.bundleref (guid / identity / AssetRef).
avatarRef:setCharacter(avatarRoot, asset.resolve("knight", "bundle"))
modules/AvatarTypeAssetTypeBehavior/README
require("@builtin::assetTypes.avatarType.behavior") -- AvatarTypeAssetTypeBehavior
Behaviour for the avatarType asset type. An avatar type describes a kind of body (a humanoid, a quadruped, a vehicle): the roles and chains a rig of that kind maps onto, and how to find them in a skeleton. An avatar points at its type by guid, and a rig stores its author's overrides per type. The type's init.luau is the module; ref:module() loads it.
Usage: local AvatarTypeAssetTypeBehavior = require("@builtin::assetTypes.avatarType.behavior")
modules/AvatarTypeAssetTypeBehavior/onChange
onChange(self, _change)
Drop the cached module and advance the generation when the type's content
changes, so the next :module() loads the edited init.luau and every rig
qualified under the old one is qualified again.
Parameters
selfany(optional) — The avatarType AssetRef that changed._changeany(optional) — What happened to it; the cache is dropped whatever it was.
modules/BlankAppLayout/README
require("@builtin::_templates.blank_app.blank_app_layout") -- BlankAppLayout
Minimum-viable app — one screen built from the raw CSS-parity widget tree. Clone-and-edit starting point; replace build with your own tree.
Usage: local BlankAppLayout = require("@builtin::_templates.blank_app.blank_app_layout")
modules/BundleAssetTypeRef/README
require("@builtin::assetTypes.bundle.behavior") -- BundleAssetTypeRef
Per-instance methods exposed on every AssetRef<bundle>. Loaded lazily by assetType.shared.ref.
Usage: local BundleAssetTypeRef = require("@builtin::assetTypes.bundle.behavior")
modules/BundleAssetTypeRef/getTemplate
getTemplate(self): any
Parse the bundle's entity_template into a Lua value. The engine
format is a flat array of entity records ({ name, original_id, parent_id, components, ... }), so the result is an array-table; the
return type is any because the payload is decoded JSON. Returns nil
when parsing fails or the bundle has no template.
Parsed results are cached per-guid — repeat :instantiate on the same
bundle reuses the parsed table instead of re-decoding the JSON. Cleared
when the template is written — by :setTemplate or straight to the
bundle's entity_template — so authoring-time edits land on the next
instantiate.
Parameters
selfany(optional)
local t = bundleRef:getTemplate()
modules/BundleAssetTypeRef/getTemplateRaw
getTemplateRaw(self): string?
Read the raw entity_template file (JSON) as a string. Use
:getTemplate() for a parsed table.
Parameters
selfany(optional)
local raw = bundleRef:getTemplateRaw()
modules/BundleAssetTypeRef/inspectDetail
inspectDetail(self): any
asset.inspect type-specific detail: { nodeCount, attachedComponents, rootName }, parsed from the bundle's own
entity_template JSON — never instantiates the hierarchy. A bundle
with no readable template returns an empty detail rather than
erroring.
Parameters
selfany(optional)
local attached = asset.inspect(bundleRef).detail.attachedComponents
modules/BundleAssetTypeRef/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Instantiate this bundle. The DEFAULT — bundle:instantiate() with no
target entity — spawns ONE root entity carrying an Asset component that
references this bundle: the component spawns the bundle's hierarchy as
TEMPORARY runtime children (never written to the saved scene) and owns
save / reload / diff, so the scene stays clean (one entity per instance,
not the whole exploded permanent tree). This is the one-call path to put a
bundle in the world.
Passing a target entityId (instantiate ONTO that entity, which becomes
the bundle root) OR opts.raw = true (build a permanent fresh hierarchy)
selects the RAW explode: it spawns every child in the entity_template,
remaps cross-entity references, applies any saved sparse diff, and writes
the bundleProvenance live-link attribute, returning the root entity id
and the originalId → runtimeId map. The Asset component, Player
avatars, and template tooling use this raw path.
Spawn mode is selected by opts.deferred. Default (deferred = false)
uses the legacy batch() flush — every component is visible on the
SAME tick so spawn-then-query patterns (tests, scene-load critical
path, spawn-then-read flow) keep working. Pass opts.deferred = true
for hundreds-to-thousands-of-entities bundles (large levels, density
spawners, gibbed-prop debris bundles): the spawn+component work wraps
in queue() and the engine drainer spreads it across multiple frames
at the QUEUE_DRAIN_BUDGET_PER_FRAME cap. The root entity id is
minted same-tick either way (entity.spawn always returns immediately),
but in deferred mode children + components arrive in the ECS over the
next few frames — don't read them back synchronously.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional target entity — an entity REF (proxy) to explode ONTO (that entity becomes the bundle root; this selects the RAW path). Omit for the default (fresh root +Assetcomponent).opts{ [string]: any }?(optional) — Optional{ position, rotation, scale, name, temporary, raw, idMap, diff, sourceTag, deferred }. The base placement opts land on the returned root;raw = trueforces the raw explode into a fresh permanent hierarchy (noAssetcomponent);idMapreuses saved child ids (stable ids across reload);diffreapplies sparse child overrides keyed by templateoriginal_id;sourceTaglabels the provenance record (defaults to"bundle");deferred=trueswitches the spawn pump from same-tickbatch()to cross-framequeue()— required for thousand-entity bundles to avoid one huge frame stall;temporary=truespawns every child born temporary (theAssetcomponent's re-created scaffolding — kept out of the saved scene so a reload doesn't respawn them alongside a re-instantiate).idMap/diff/deferred/temporaryapply to the raw path only.
local root = bundleRef:instantiate() -- scene-clean instance (Asset component); root is an EntityRef
local root, map = bundleRef:instantiate(entity.spawn("mount")) -- raw, ONTO an entity ref
local root, map = bundleRef:instantiate(nil, { raw = true }) -- raw permanent fresh hierarchy
modules/BundleAssetTypeRef/listChildren
listChildren(self, rootsOnly: boolean?): { string }
List the names of every entity captured in THIS bundle instance's
entity_template. Pass rootsOnly = true to restrict to entities with
no parent_id. Best-effort: empty list when the template can't parse.
Parameters
selfany(optional)rootsOnlyboolean?(optional) — When true, only entities with noparent_idare returned.
for _, name in ipairs(bundleRef:listChildren()) do print(name) end
modules/BundleAssetTypeRef/listContents
listContents(self): { { name: string, isDirectory: boolean } }
List the entries directly under the bundle root folder (meshes, textures, materials, sub-bundles) for tooling (inspectors, dependency graphs).
Parameters
selfany(optional)
for _, e in ipairs(bundleRef:listContents()) do print(e.name) end
modules/BundleAssetTypeRef/meshBindings
meshBindings(self): { any }
List each renderable node's mesh→material binding from THIS bundle's
entity_template — the static data a spawned Model / SkinnedModel
resolves — WITHOUT instantiating anything. Answers "which material does
this mesh bind" as a direct read, with no spawn / settle / tree-walk /
despawn cycle. Each entry is { node, nodeId, component, mesh, material },
where mesh and material are ref descriptors { guid, identity, name, path } (nil when the component omits that field). One entry per
renderable component, in template order. Best-effort: empty list when the
template can't parse.
Parameters
selfany(optional)
for _, b in ipairs(bundleRef:meshBindings()) do print(b.node, b.material and b.material.name) end
modules/BundleAssetTypeRef/onChange
onChange(ref: any, change: { [string]: any })
React to a write inside a .bundle/ instance: an entity_template
change means the assembled model changed — regenerate the bundle's
preview.png, its persisted visual description (syncs, publishes,
feeds search and browser thumbnails), and record the component set +
humanoid classification into .metadata for search facets. Originator-only;
both artifacts sync to peers as ordinary content.
Parameters
refany(optional) — The AssetReffor the changed container. change{ [string]: any }—{ path, asset, type, kind, origin }.
modules/BundleAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts?): { [string]: string }
Generic-creation hook for asset.create("bundle", name, opts).
With opts.entity, composes that LIVE entity's hierarchy into the new
bundle's entity_template in the same call — one step, capturing live
component state (serialized component snapshots) + transforms of the root and
every non-temporary descendant. With no opts, the bundle starts from
the template skeleton's entity_template.
Parameters
namestringoptsCreateOpts?(optional)
asset.create("bundle", "tree_prefab", { entity = rootRef })
modules/BundleAssetTypeRef/reindexSearchMeta
reindexSearchMeta(self): ()
Re-derive this bundle's search .metadata (component set + humanoid
classification) from its current entity_template, without touching the
preview. onChange calls it on every template edit; the search-metadata
backfill calls it per bundle to populate assets minted before the deriver
existed. Reads the template fresh — the parsed cache is only invalidated by
setTemplate.
Parameters
selfany(optional)
bundleRef:reindexSearchMeta()
modules/BundleAssetTypeRef/setTemplate
setTemplate(self, template: { any }): boolean
Overwrite the bundle's entity_template with a Lua table,
JSON-encoded. The VFS write triggers the engine's asset hot-reload
pipeline, so every component subscribed to this bundle's guid (via a
declared asset field) reconciles automatically. Returns true on
success.
Parameters
selfany(optional)template{ any }— The full entity-template table (array of records) to write.
bundleRef:setTemplate(bundleRef:getTemplate())
modules/BundleAssetTypeRef/update
update(self, entityId: string): boolean
Re-compose THIS bundle from entityId's current hierarchy and
write the new template back to the bundle's on-disk path. Walks the
whole hierarchy under entityId (recursive), capturing live component
state + transforms of every non-temporary descendant. The VFS write
fires the engine's asset hot-reload pipeline, so every component
subscribed to this bundle's guid reconciles automatically.
Parameters
selfany(optional)entityIdstring— The entity whose live hierarchy is captured into the bundle.
bundleRef:update(playerId) -- "save" the live edits back into the bundle
modules/BundleUpdate/README
require("@builtin::modules.bundle_update") -- BundleUpdate (also available as global 'bundle')
Adds bundle.update to the existing bundle namespace. Pure Luau — thin ergonomic wrapper around bundle.compose. The prelude grafts this onto the engine's bundle table at boot.
bundle.update(entityId, bundleRef?) re-composes the bundle from the
entity's current hierarchy state, writing the new template into the
bundle's existing on-disk path. The reconcile is fully engine-driven:
the VFS write fires the generic asset hot-reload pipeline, which
dispatches onAssetReload(field) on every component instance whose
declared asset field references the bundle's guid. Components decide
what reload means for them (Asset.component → despawn + re-instantiate
template; user components → whatever they implement in
onAssetReload).
With one arg, the bundle ref is inferred from
entity(entityId).component.get("Asset").source. With two args the
explicit ref wins. There is no opt-in subscription surface —
declaring an asset field IS the subscription.
Usage: local BundleUpdate = require("@builtin::modules.bundle_update") Also available as global: bundle
modules/BundleUpdate/installInto
installInto(bundle: BundleNamespace)
Install update onto the supplied bundle-shaped namespace.
The prelude calls this once at boot with the engine's bundle
global; users reach the result as bundle.update.
Parameters
bundleBundleNamespace— The target namespace table. No-op when given a non-table value.
require("@builtin::modules.bundle_update").installInto(bundle)
modules/BundleUpdate/update
update(entityId: string, bundleRef: BundleRef?): any
Re-compose a bundle from an entity's current hierarchy and write
it back to the bundle's on-disk path. The VFS write triggers the
engine's generic asset hot-reload pipeline, which fires
onAssetReload(field) on every component subscribed to this
bundle's guid via a declared asset field — those components
reconcile per their own policy.
Parameters
entityIdstring— The entity whose hierarchy is captured into the bundle.bundleRefBundleRef?(optional) — Optional. When omitted, the ref is inferred from the entity'sAsset.sourcefield. When given, the explicit ref wins.
bundle.update(entityId) -- infer from Asset
bundle.update(entityId, { guid = "..." }) -- explicit ref
modules/CanvasAppLayout/README
require("@builtin::_templates.canvas_app.canvas_app_layout") -- CanvasAppLayout
Node-graph canvas built from the raw CSS-parity widget tree — absolutely positioned node cards over an SVG bezier connector; click a node to select it.
Usage: local CanvasAppLayout = require("@builtin::_templates.canvas_app.canvas_app_layout")
modules/CarriedReferences/README
require("@builtin::modules.api.engine.carried.references") -- CarriedReferences
Usage: local CarriedReferences = require("@builtin::modules.api.engine.carried.references")
modules/CarriedReferences/close
close(value: any, site: string, prefix: string): any
value (decoded component data) with every asset-reference envelope
in it, at any depth, naming what the closure at site means by it: the
guid the reference resolves to there (the session guid of the carried copy,
or the engine library asset), or, while the mount answers nothing for it,
the reference spelled in the mount (@carried.<key>::<reference>). A field
holding that spelling waits on the mount and applies once the mount holds
the asset. A component reference (componentType beside __ref) stays as
written.
Parameters
valueany(optional) — The data to read.sitestring— The siteM.siteanswers for the asset holdingvalue.prefixstring— The prefixM.siteanswers for that asset.
local data = references.close(comp.data, site, prefix)
modules/CarriedReferences/records
records(template: { any }, path: string?, identity: string?): { any }
The records of an entity template as the asset holding them composes
them. For an asset of a carried mount, a copy whose records' component
data names every asset reference within the closure (close); for an
asset of the open world, template itself.
Parameters
template{ any }— The template's records ({ { components = { { type, data } } } }).pathstring?(optional) — The VFS path of the asset holding the template.identitystring?(optional) — Optional identity of the same asset.
local records = references.records(bundleRef:getTemplate(), bundleRef.path, bundleRef.identity)
modules/CarriedReferences/site
site(path: string?, identity: string?): (string?, string?)
Where an asset of a carried mount stands: the site a reference it holds is read at, and the prefix its mount spells content with.
Parameters
pathstring?(optional) — The asset's VFS path.identitystring?(optional) — Optional identity of the same asset, read whenpathnames no mount (@carried.<key>::<name>).
local site, prefix = references.site(ref.path, ref.identity)
modules/ComponentAssetTypeRef/README
require("@builtin::assetTypes.component.behavior") -- ComponentAssetTypeRef
Per-instance methods exposed on every AssetRef<component>. Loaded lazily by assetType.shared.ref.
Usage: local ComponentAssetTypeRef = require("@builtin::assetTypes.component.behavior")
modules/ComponentAssetTypeRef/attachTo
attachTo(self, entityId: string, fields: { [string]: any }?): any
Attach this component to an entity, equivalent to
entity(entityId).component.add(compRef, fields). The ref names the
component by its identity, so a component whose leaf name another
package's component shares attaches as itself.
Parameters
selfany(optional)entityIdstring— Target entity ID.fields{ [string]: any }?(optional) — Optionalpublicfield overrides.
compRef:attachTo(playerId, { speed = 5 })
modules/ComponentAssetTypeRef/getAssetFields
getAssetFields(self): any
The component type's asset-field declarations — a map of field name
to asset category (e.g. { material = "material" }), or nil when the
component declares no Field.assetRef fields.
Parameters
selfany(optional)
for field, cat in pairs(compRef:getAssetFields() or {}) do end
modules/ComponentAssetTypeRef/getInfo
getInfo(self): any
Metadata for the component type: { name, builtin, executionOrder, hooks }, where hooks is a { <hookName> = true } map scanned from
the source.
Parameters
selfany(optional)
local info = compRef:getInfo() print(info.executionOrder)
modules/ComponentAssetTypeRef/getInitScript
getInitScript(self): string?
Read the component's entry script (init.luau / init.lua)
as raw text.
Parameters
selfany(optional)
local src = compRef:getInitScript()
modules/ComponentAssetTypeRef/getReadme
getReadme(self): string?
Read the component's README.md body.
Parameters
selfany(optional)
print(compRef:getReadme())
modules/ComponentAssetTypeRef/getSource
getSource(self): string?
The component type's registered source text — the live definition
in the runtime registry. getInitScript reads the on-disk entry file;
this reads what the engine actually registered (and resolves builtin
components by identity).
Parameters
selfany(optional)
local src = compRef:getSource()
modules/ComponentAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { fields, privateFields, methods, events, hooks, assetFields, executionOrder }, parsed from the component's own
entry script (getInitScript) via luau_introspect. Cached on the
asset's content checksum, so re-inspecting unchanged source is free.
A component with no readable entry script returns an empty detail
rather than erroring.
Parameters
selfany(optional)
local events = asset.inspect(compRef).detail.events
modules/ComponentAssetTypeRef/isRegistered
isRegistered(self): boolean
Whether the component type is registered with the ECS, so that
component.add(name) takes it. The source is stored the moment the
asset is written; the type registers when that registration drains, on
a later frame, and this reads the registration rather than the source.
Parameters
selfany(optional)
while not compRef:isRegistered() do task.wait() end
modules/ComponentAssetTypeRef/listInstances
listInstances(self): { string }
List every entity in the live scene that currently has a component of this type. Useful for inspector tooling.
Parameters
selfany(optional)
for _, id in ipairs(compRef:listInstances()) do print(id) end
modules/ComponentAssetTypeRef/listPublicFields
listPublicFields(self): { string }
Best-effort list of the component's public field names by
parsing the entry script. Recognises public.<name> = ...
assignments at module scope; doesn't expand metatable
declarations. Comments and string literals are not read. Use as a
discovery hint, not a strict schema.
Parameters
selfany(optional)
for _, f in ipairs(compRef:listPublicFields()) do print(f) end
modules/ComponentAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: (re)register + hot-reload this component
type whenever its .component is seeded (a world seed) or its entry script
(init.luau / init.lua) is edited. This is what registers and live-reloads
USER components — library components register through the VFS write hook
(author-immutable content does not dispatch onChange). Mirrors the
.material / .shader assetTypes owning their own registration. Convergent
- idempotent: registration never writes back into the asset folder, and the underlying registry upsert is a no-op when the source is unchanged.
Parameters
refany(optional)changeany(optional)
modules/ComponentAssetTypeRef/onDelete
onDelete(ref)
Asset-type delete callback: unregister this component type when its
.component folder is removed. The teardown counterpart of onChange's
registration — the type owns both halves of its runtime lifecycle, the way
the .material / .shader types do. __components.unregister drops every
type the folder registered, under each name it answers to (a nested
component's full identity and its bare leaf), from the runtime registry,
the FFI type-info / schema mirrors, and the /registered/components/
projection; instances already attached to live entities keep running
(their closures are already bound).
Parameters
refany(optional)
modules/ComponentAssetTypeRef/onRegister
onRegister(self)
Initial-registration callback: register this component's type from its
entry script the moment the instance first registers. Fired by the
world-ready onRegister sweep BEFORE the world entrypoint (and its scene
load) runs, so component.add-by-name resolves for entities the same
load materialized. Idempotent: the registry upsert is a no-op when the
source is unchanged, and a later onChange re-registration converges on
the same definition.
Parameters
selfany(optional)
modules/ComponentAssetTypeRef/settingsSchemaProblem
settingsSchemaProblem(schema: { [string]: any }, ref: any): string?
The component type's verdict on a component's settings schema: a
field named for one of the names the engine reserves on every component
(__components.reservedFields) is refused, because the engine refuses to
add a component whose public table declares one to an entity. Called by
the settings module on every schema it reads for a component.
Parameters
schema{ [string]: any }— The Field schema the component'spublictable declares.refany(optional) — The component's asset ref.
modules/ComputeShaderAssetTypeRef/README
require("@builtin::assetTypes.computeShader.behavior") -- ComputeShaderAssetTypeRef
Per-instance methods exposed on every AssetRef<computeShader>. Loaded lazily by assetType.shared.ref.
Usage: local ComputeShaderAssetTypeRef = require("@builtin::assetTypes.computeShader.behavior")
modules/ComputeShaderAssetTypeRef/buffer
buffer(self, name: string): any?
The buffer this shader last made under name. Two systems driving one
shader over the same data reach for this rather than each creating their
own; a system that wants its own calls createBuffer again.
Parameters
selfany(optional)namestring— The name the buffer was created under.
local params = shaderRef:buffer("params") or shaderRef:createBuffer("params", { type = "vec4", len = 3 })
modules/ComputeShaderAssetTypeRef/compile
compile(self)
Compile this shader now, rather than on its first dispatch. Idempotent. NORMALLY UNNECESSARY — a dispatch compiles on first use. Reach for this only to avoid the one-frame first-dispatch warm-up in a latency-critical spot.
Parameters
selfany(optional)
shaderRef:compile()
modules/ComputeShaderAssetTypeRef/compileByName
compileByName(ref: string): boolean
Compile a compute shader by reference from its .computeShader VFS source
— the lazy compile-on-first-use entry. A system that must guarantee the
shader is registered before its first dispatch calls this (via
compute.compileByName) to bring it online through the same generic
compileCompute path an edit runs. Resolution goes through the universal
asset system — a reference that doesn't resolve is a bad reference in the
content that owns it, not something to special-case here.
Parameters
refstring— A compute-shader asset reference (identity / guid) resolvable byasset.resolve.
require("@builtin::assetTypes.assetType.shared.ref").loadTypeModule("computeShader").compileByName("@builtin::shaders.compute_double")
modules/ComputeShaderAssetTypeRef/copyBufferToTexture
copyBufferToTexture(self, source: any, name: string, width: number, height: number, format: string?): TextureHandle
Copy one of this shader's buffers into a cached GPU texture, staying on the GPU — the path for an image a compute pass produced.
Parameters
selfany(optional)sourceany(optional) — The buffer holding tightly-packed rows in the format's texel layout.namestring— Texture name, unique within this shader.widthnumber— Texture width in texels.heightnumber— Texture height in texels.formatstring?(optional) — Texel format:"rgba16f"(default),"rgba32f","rgba8".
local tex = shaderRef:copyBufferToTexture(packed, "foam", 256, 256, "rgba16f")
modules/ComputeShaderAssetTypeRef/createBuffer
createBuffer(self, name: string, opts: { [string]: any }): any
Create a GPU buffer this compute shader owns. It is a substrate buffer —
the same one every other part of the engine deals in — filed under this
shader's guid, name, and a serial, so two callers asking this shader for a
params each get their own. Pass the handle to any shader's dispatch,
including another shader's, to bind it there. The shader remembers what it
made: shaderRef:buffer(name) returns the last buffer created under that
name, which is how two callers share one instead.
Parameters
selfany(optional)namestring— What this buffer is for, e.g."params"or"verts".opts{ [string]: any }—{ type, len, usage? }—typeis the element ("f32","vec3","vec4","quat","mat4"),lenis how many of them, andusageadds what the buffer is used for beyond the storage it always has:"readback"to read it on the CPU,"vertex"to draw it as geometry,"index"to draw it as an index run,"indirect"for a draw to read its arguments out of. A buffer can carry several.
There is no integer element: a buffer is a block of 32-bit words, so a
binding the shader declares as u32 or atomic<u32> in bindings.yaml is
created as "f32" here and written with buf:writeU32. The element type
sets the STRIDE; what the words mean is the shader's to say.
local verts = shaderRef:createBuffer("verts", { type = "vec3", len = 1024, usage = { "readback" } })
verts:write(packed) -- an array of numbers, or a `buffer` already holding the words
local values = verts:read():result()
local counts = shaderRef:createBuffer("counts", { type = "f32", len = 64 }) -- bindings.yaml: element: u32
counts:writeU32({ 0, 0, 0, 0 })
local geo = shaderRef:createBuffer("geo", { type = "vec3", len = 4096, usage = { "vertex", "readback" } })
local args = shaderRef:createBuffer("args", { type = "f32", len = 5, usage = { "indirect" } }) -- DrawIndexedIndirectArgs
modules/ComputeShaderAssetTypeRef/createSampler
createSampler(self, name: string, opts: { [string]: any }?): TextureHandle
Create a sampler owned by this compute shader, for its texture bindings.
Parameters
selfany(optional)namestring— Sampler name, unique within this shader.opts{ [string]: any }?(optional) — Sampler options — filtering and addressing.
local smp = shaderRef:createSampler("linear", { filter = true, clamp = true })
modules/ComputeShaderAssetTypeRef/createStorageTexture2D
createStorageTexture2D(self, name: string, opts: { [string]: any }): TextureHandle
Create a write-only 2D storage texture owned by this compute shader — the target a raymarch or image pass writes.
Parameters
selfany(optional)namestring— Texture name, unique within this shader.opts{ [string]: any }—{ width, height, format? }.
local out = shaderRef:createStorageTexture2D("out", { width = 1920, height = 1080, format = "rgba16f" })
modules/ComputeShaderAssetTypeRef/createTexture3D
createTexture3D(self, name: string, opts: { [string]: any }): TextureHandle
Create a 3D texture owned by this compute shader — a density volume, an
occupancy grid, a signed-distance field. Keyed by the shader's guid plus
name, so it cannot collide with another asset's.
Parameters
selfany(optional)namestring— Texture name, unique within this shader.opts{ [string]: any }—{ width, height, depth, format?, storage? }.
local density = shaderRef:createTexture3D("density", { width = 64, height = 64, depth = 64, format = "r16f", storage = true })
modules/ComputeShaderAssetTypeRef/createTextureHistory
createTextureHistory(self, name: string, opts: { [string]: any }): TextureHandle
Create a temporal history pair owned by this compute shader — the previous frame's result to read while writing this frame's.
Parameters
selfany(optional)namestring— History name, unique within this shader.opts{ [string]: any }—{ width, height, format? }.
local history = shaderRef:createTextureHistory("taa", { width = 1920, height = 1080, format = "rgba16f" })
modules/ComputeShaderAssetTypeRef/destroy
destroy(self): boolean
Destroy this texture or sampler and free its GPU memory.
Parameters
selfany(optional)
modules/ComputeShaderAssetTypeRef/dispatch
dispatch(self, opts: { [string]: any }): boolean
Dispatch this compute shader with named buffers bound to its declared
storage bindings, in order. Compiles on first use. A zero in any workgroup
dimension is refused and recorded as a dispatch failure, so a count derived
from how much data there is passes through math.max(1, ...) first.
Parameters
selfany(optional)opts{ [string]: any }—{ buffers, workgroups }—buffersnames one compute buffer per declared storage binding;workgroupsis{ x, y, z },{ x }, orx.
shaderRef:dispatch({ buffers = { "positions" }, workgroups = { 64 } })
modules/ComputeShaderAssetTypeRef/dispatchEx
dispatchEx(self, opts: { [string]: any }): boolean
Dispatch this compute shader with explicit texture / storage-texture /
sampler resources, one per declared binding in order. A params: block's
uniform is engine-owned and takes no entry here. A zero in any workgroup
dimension is refused and recorded as a dispatch failure, so a count derived
from how much data there is passes through math.max(1, ...) first.
A resource's kind says what it is, in the words bindings.yaml uses:
buffer (name is a buffer handle), texture3d / storage3d (a 3D
texture handle), storage2d (a 2D storage texture handle), texture2d
(a copyBufferToTexture handle or a texture asset's guid), sampler (a
sampler handle), history_prev / history_curr (one side of a history
pair) and scene_depth (the frame's scene depth, no name). A slot takes
the kind it is declared with; a texture2d slot also reads a storage2d,
a history side or scene_depth, and a storage2d slot also writes
history_curr. The engine spellings texture_3d, texture_2d and
storage_2d name the same resources. Any other kind is refused, naming
the accepted ones.
Parameters
selfany(optional)opts{ [string]: any }—{ resources, workgroups }: each resource is{ kind, name }.
shaderRef:dispatchEx({ resources = { { kind = "storage2d", name = target } }, workgroups = { 8, 8 } })
shaderRef:dispatchEx({ resources = { { kind = "storage3d", name = density }, { kind = "buffer", name = params } }, workgroups = { 8, 8, 8 } })
modules/ComputeShaderAssetTypeRef/dispatchOnVertices
dispatchOnVertices(self, opts: { [string]: any }): boolean
Dispatch this compute shader with a model's vertex buffer bound at the
first storage binding, and opts.buffers filling the rest. Use to mutate
vertex positions directly. A zero in any workgroup dimension is refused and
recorded as a dispatch failure, so a count derived from how many vertices
there are passes through math.max(1, ...) first.
Parameters
selfany(optional)opts{ [string]: any }—{ model, buffers?, workgroups }—modelis the mesh guid whose vertices the shader writes.
shaderRef:dispatchOnVertices({ model = meshHandle.guid, workgroups = { 64 } })
modules/ComputeShaderAssetTypeRef/getBindings
getBindings(self): { [string]: any }
List this compute shader's declared bindings + params (parsed from
bindings.yaml). Returns { bindings = { {name, kind, access?, element?, format?}, ... }, params = { {name, type, default}, ... } }. This is the
editor-discovery surface, and the SAME parse the compile uses. Raises,
naming the file, when bindings.yaml is text the YAML decoder refuses
(with the line) or bindings: / params: holds anything but a list of
mappings (with the key).
Parameters
selfany(optional)
for _, b in ipairs(computeRef:getBindings().bindings) do print(b.name, b.kind) end
modules/ComputeShaderAssetTypeRef/getSource
getSource(self): string?
Read the compute WGSL body (shader.wgsl) as raw text.
Parameters
selfany(optional)
local src = computeRef:getSource()
modules/ComputeShaderAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: (re)compile the compute shader whenever its
WGSL body or bindings.yaml is written. This is the ONLY thing that compiles
a .computeShader — so it fires on the initial create (the template write)
AND on every later edit, with no world reload. Convergent: see
compileCompute.
Parameters
refany(optional)changeany(optional)
modules/ComputeShaderAssetTypeRef/onDelete
onDelete(ref)
Asset-type delete callback: release the program a removed
.computeShader folder registered. The teardown counterpart of
onChange's compile, so the type owns both halves of its runtime
lifecycle the way .material does: the program, the params uniform it
carried and the dispatch history under its key go with the asset, and a
shader authored afresh at the same path registers a new program rather
than inheriting the one the removed asset left.
Parameters
refany(optional)
modules/ComputeShaderAssetTypeRef/program
program(self): any
This shader's kernel ABI as a program: program:variant(spec) lowers and
compiles one specialization, and variant:run(env) allocates the outputs
bindings.yaml declares (count, capacity, append with a live counter),
binds and dispatches. See modules.compute_abi.
Parameters
selfany(optional)
local variant = shaderRef:program():variant({ specialize = { T = "vec3<f32>" } })
local run = variant:run({ n = 64, inputs = { src = srcBuffer } })
modules/ComputeShaderAssetTypeRef/read
read(self): Readback
Start a GPU→CPU read-back of this 3D texture's voxels. The read takes
frames to arrive — ask the returned Readback whether it is :ready(),
then drain it.
Parameters
selfany(optional)
local pending = density:read()
if pending:ready() then local voxels = pending:result() end
modules/ComputeShaderAssetTypeRef/setParam
setParam(self, prop: string, value: number): boolean
Set one scalar parameter declared in this shader's bindings.yaml
params: block. The next dispatch sees the new value; a value set before
the shader's first compile is the value it starts with.
Parameters
selfany(optional)propstring— Parameter name as declared inbindings.yaml.valuenumber— New scalar value.
shaderRef:setParam("scale", 4.0)
modules/ComputeShaderAssetTypeRef/setSource
setSource(self, src: string): boolean
Overwrite the compute WGSL body on disk. Hot-reload recompiles the shader on the next frame. Returns true on success.
Parameters
selfany(optional)srcstring— New WGSL source (only@compute fn main+ helpers).
computeRef:setSource(myWgsl)
modules/ComputeShaderAssetTypeRef/status
status(self): { { [string]: any } }
What the engine did with this shader's dispatches, one record per
target. A dispatch is recorded into a command encoder frames after the
call that asked for it returned, so this is where its outcome lands:
ok is the most recent outcome, dispatches counts what reached the
encoder, failures how many of those could not be recorded, and
lastError says why the last failure failed (kept after a recovery).
target is the mesh guid for a dispatchOnVertices, empty for a
dispatch that writes only its bound buffers. This answers "is this pass
running?" — an empty result means nothing has dispatched this shader.
Parameters
selfany(optional)
for _, d in ipairs(shaderRef:status()) do print(d.target, d.ok, d.lastError) end
modules/ComputeShaderAssetTypeRef/write
write(self, data: buffer | string | { number }): boolean
Upload voxels into this 3D texture: a buffer or a binary string
carrying the texture's byte layout verbatim, or one number per channel in
the texture's format.
Parameters
selfany(optional)databuffer | string | { number }— Voxel bytes, or voxel values in texel order.
modules/ComputeShaderAssetTypeRef/writeFloats
writeFloats(self, floats: { number }, formatOrOpts: (string | { [string]: any })?): boolean
Upload float voxels into this 3D texture, converting to the texture's format.
Parameters
selfany(optional)floats{ number }— Voxel values in texel order.formatOrOpts(string | { [string]: any })?(optional) — Source format name, or an options table.
modules/ContentVersion/README
require("@builtin::modules.content_version") -- ContentVersion
Per-path content-version counters — a cheap, synchronous "has this file changed?" token that lets an assetType behavior memoize a parse in its ref's runtime and serve repeated reads as a pure table lookup instead of re-reading + re-parsing the file every call.
A source write bumps the written path's counter. A memoized reader keyed
by the value get(path) returned when it parsed can then check, on every
later call, whether the counter still matches — an integer compare, no
vfs.read, no parse. It rebuilds only when the counter moved.
Two write surfaces feed it, so the token reflects a change no matter where
it came from:
vfs.write/vfs.movebump SYNCHRONOUSLY, in the same call, so a script that writes a file and reads it back in the SAME tick sees the new content immediately (the asset-changeonChangedispatch fires a frame LATER, too late for a same-tick read).- the generic asset-change dispatcher bumps on every source write it
routes, including peer-synced and engine-originated writes that never
pass through the Luau
vfs.*surface — with the engine's normalized path, which is the canonical form a reader keys on. A typed asset's FOLDER path carries a counter too: the dispatcher bumps it after it has routed a write inside the asset and the asset's type has reacted to it, so a reader of "anything in this asset" keys on one number. Counters are per PATH (not one global epoch): the per-frame dirty-entity writer churns scene-dirty paths every frame during play, and a global epoch would let that churn invalidate every unrelated cache. Per-path isolation means only a change to THE file a reader depends on rebuilds it. The counters are held once for the process (__contentVersion): a write made in a worker VM, the engine thread's dispatch of it, and a write made on the engine thread advance the same number, and every VM reads it. A counter lives as long as its path, or as long as a reader has read it. Removing a path (vfs.remove, a move off it, a folder removal reaching it, a peer's removal, the shell'srm) moves the counter of a path some reader has read, so that reader rebuilds: inside the removing call forvfs.removeandvfs.move, and on the frame the engine delivers the removal for a peer's or the shell's. The counter of a path no reader read goes with the path, and a write back starts it from 0. The store therefore holds one small integer per path that exists or that a reader read, which keeps it the size of the content rather than of every path a session ever wrote.
Usage: local ContentVersion = require("@builtin::modules.content_version")
modules/ContentVersion/bump
bump(path: string)
Bump path's version counter, invalidating every reader memoized
against its previous value. Called by the vfs.* write surface and the
asset-change dispatcher; content code rarely calls it directly.
Parameters
pathstring— VFS path whose content changed.
require("@builtin::modules.content_version").bump(p)
modules/ContentVersion/get
get(path: string): number
The current version counter for path (0 if no VM ever wrote it).
A memoized reader stores the value it saw when it parsed, and treats a
later call as a cache hit exactly while get(path) still returns it.
Parameters
pathstring— Normalized VFS path.
local v = require("@builtin::modules.content_version").get(p)
modules/DataAssetTypeRef/README
require("@builtin::assetTypes.data.behavior") -- DataAssetTypeRef
Per-instance methods on every AssetRef<data> — a configured value instance of a dataType contract. Instances carry values only; structure and behavior live on the contract.
Usage: local DataAssetTypeRef = require("@builtin::assetTypes.data.behavior")
modules/DataAssetTypeRef/contract
contract(self)
The dataType contract this instance is bound to.
Parameters
selfany(optional)
local weaponType = smg:contract()
modules/DataAssetTypeRef/data
data(self, wanted: string?)
Resolve this instance into a read-only typed value object: this
instance's values.yaml with the contract's schema defaults applied,
ref fields materialized (assetRef -> AssetRef, dataRef -> nested
value object), and the bound contract chain's behavior methods
reachable on it — the bound contract's own methods win over an
ancestor's when both define the same name, and any explicit instance
value wins over both. Errors loudly when the instance violates its
contract, when wanted is given and the bound contract's chain
doesn't include it, and when dataRef fields form a circular chain.
Parameters
selfany(optional)wantedstring?(optional) — Optional contract the caller requires — an assertion, not a filter: the returned object still carries the FULL bound schema and method chain.
local w = smg:data("tdWeapon"); print(w.damage, w:effectiveRating())
modules/DataAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { contract, valueKeys },
parsed from this instance's own values.yaml — the bound contract
identity plus the sorted top-level keys of its values map. Never
resolves the contract or materializes ref fields (that's :data()).
Parameters
selfany(optional)
local valueKeys = asset.inspect(dataRef).detail.valueKeys
modules/DataAssetTypeRef/onCreate
onCreate(name: string, opts: { contract: string })
Create a data instance bound to a contract. Seeds values.yaml with the contract's declared defaults so a fresh instance is immediately valid wherever every required field has a default.
Parameters
namestringopts{ contract: string }
modules/DataAssetTypeRef/satisfies
satisfies(self, wanted: string): (boolean, string?)
Whether this instance's contract chain includes wanted — true
for the bound contract itself and for any contract it extends.
Parameters
selfany(optional)wantedstring— Contract identity (bare leaf or full identity).
if smg:satisfies("weapon") then ... end
modules/DataAssetTypeRef/satisfiesDetail
satisfiesDetail(self, wanted: string): { ok: boolean, code: string, reason: string? }
Chain-membership check that also reports WHY, as a stable code a caller can branch on without matching reason text.
Parameters
selfany(optional)wantedstring— Contract identity (bare leaf or full identity).
local d = smg:satisfiesDetail("weapon")
if not d.ok and d.code ~= "contract-mismatch" then warn(d.reason) end
modules/DataAssetTypeRef/setValues
setValues(self, patch: { [string]: any })
Change this instance's values: patch replaces the named top-level
fields. The result is checked against the bound contract, and it is
refused — one error naming each violation, nothing written — when it
introduces a violation, or leaves one standing at or under a value the
change set. A list item is known by what it holds rather than where it
sits, so removing or reordering items sets none of the rest. A violation
the file already held anywhere else stays listed without stopping the
change, so an instance that does not yet satisfy its contract is filled
in one field at a time and a value beside an undeclared key stays
editable. A written result goes to values.yaml (re-encoded, so comments
in the file are not kept), recorded into the open undo operation when
there is one.
Parameters
selfany(optional)patch{ [string]: any }— Top-level field -> new value, in the forms values.yaml holds.
ref:setValues({ clipmap = { baseTile = 100, levels = 5 } })
modules/DataAssetTypeRef/validateInstance
validateInstance(self): (boolean, { DS.Violation })
Validate this instance's values against its contract's merged schema (missing required fields, constraint breaches, unknown fields, ref-field existence + contract compatibility).
Parameters
selfany(optional)
local ok, v = smg:validate()
modules/DataSchema/README
require("@builtin::modules.data_schema") -- DataSchema
Schema engine for the typed-data system. A contract's schema.yaml declares fields + constraints; this module parses the decoded declaration, merges extends chains, applies defaults, validates value tables, and maps a contract onto Field descriptors so a data instance's values edit through typed controls: values convert between the file's forms and the controls', and an edit lands on the stored values leaf by leaf. No VFS reads — callers decode the YAML themselves and inject asset/contract resolvers; converting a reference resolves it.
Usage: local DataSchema = require("@builtin::modules.data_schema")
modules/DataSchema/applyDefaults
applyDefaults(merged: { [string]: FieldSpec }, values: { [string]: any }): { [string]: any }
Produce a NEW value table with every schema default filled in
where values has no explicit entry — recursively: struct values
gain their subfield defaults and array elements gain their item
defaults, at every depth. Neither input is mutated.
Parameters
merged{ [string]: FieldSpec }— Merged field map frommergeChain.values{ [string]: any }— The instance's raw value table.
local filled = DataSchema.applyDefaults(merged, rawValues)
modules/DataSchema/editedValues
editedValues(merged: { [string]: FieldSpec }, stored: { [string]: any }, edited: { [string]: any }, base: string?): { [string]: any }
The top-level values a control edit writes: for each field edited
names, the value stored holds with only the leaves the edit changed
replaced, each in the form the file held it in. Every value the edit
leaves alone keeps its stored value and form — a colour held as numbers
(above 1 included), a map-form vector, and keys the contract does not
declare.
Parameters
merged{ [string]: FieldSpec }— The merged field map.stored{ [string]: any }— The values as the data file holds them.edited{ [string]: any }— Control-form values for the fields the edit names.basestring?(optional) — The data file's VFS path, which a~reference expands against.
local patch = DataSchema.editedValues(schema, stored, controlPatch, ref.path)
modules/DataSchema/fromFieldValues
fromFieldValues(merged: { [string]: FieldSpec }, values: { [string]: any }): { [string]: any }
Values from the Field controls in the forms the data file holds: the
inverse of toFieldValues.
Parameters
merged{ [string]: FieldSpec }— The merged field map.values{ [string]: any }— The control-form values (any subset of fields).
local stored = DataSchema.fromFieldValues(schema, patch)
modules/DataSchema/mergeChain
mergeChain(chain: { Schema? }): ({ [string]: FieldSpec }?, { string })
Merge an extends chain of parsed schemas into one field map. The chain is ordered ROOT PARENT FIRST, derived contract LAST. A child redeclaring a parent field is a problem — shared shape comes from the parent, per-child shape from new fields.
Parameters
chain{ Schema? }— Array of Schema, root parent first. A nil hole (e.g. a failedparseSchemaresult passed straight in) is a problem entry.
local merged, problems = DataSchema.mergeChain({ itemSchema, weaponSchema })
modules/DataSchema/parseSchema
parseSchema(raw: any): (Schema?, { string })
Parse a decoded schema.yaml table into a Schema. Returns
(schema, problems) — schema is nil when any problem was found. fields
may be written as a map (name -> spec) or as a sequence of specs each
carrying its own name:; both key the resulting fields by name.
Parameters
rawany(optional) — The decoded document ({ extends?, fields }).
local Yaml = require("@builtin::modules.yaml")
local schema, problems = DataSchema.parseSchema(Yaml.decode(bytes))
modules/DataSchema/toFieldValues
toFieldValues(merged: { [string]: FieldSpec }, values: { [string]: any }, base: string?): { [string]: any }
A data instance's values in the forms the Field controls read:
colours as { r, g, b, a }, vectors as { x, y, z }, references as
{ __ref = guid }, number enum members as strings.
Parameters
merged{ [string]: FieldSpec }— The merged field map.values{ [string]: any }— The values as the data file holds them.basestring?(optional) — The data file's VFS path, which a~reference expands against.
local shown = DataSchema.toFieldValues(schema, values, ref.path)
modules/DataSchema/toFields
toFields(merged: { [string]: FieldSpec }): { [string]: any }
One Field descriptor per contract field, so a data instance's values
edit through the same typed controls as asset settings: a number with
both bounds is a range, a string or number with enum an enum (a number
enum's members shown as strings), and every other type its Field kind.
Parameters
merged{ [string]: FieldSpec }— The merged field map (dataTypeRef:schema()).
local fields = DataSchema.toFields(contract:schema())
modules/DataSchema/validateValues
validateValues(
Validate a raw value table against a merged field map. Checks missing required fields (a field with a default is never missing), per-field constraints, unknown top-level fields, and ref fields via the injected resolvers.
local violations = DataSchema.validateValues(merged, rawValues, resolvers)
modules/DataTypeAssetTypeRef/README
require("@builtin::assetTypes.dataType.behavior") -- DataTypeAssetTypeRef
Per-instance methods exposed on every AssetRef<dataType> — the contract surface of the typed-data system: schema (extends chain merged), validation, defaults, chain navigation, instance listing.
Usage: local DataTypeAssetTypeRef = require("@builtin::assetTypes.dataType.behavior")
modules/DataTypeAssetTypeRef/chain
chain(self)
The full extends chain as refs, root parent first, this contract last.
Parameters
selfany(optional)
for _, link in ipairs(t:chain()) do print(link.identity) end
modules/DataTypeAssetTypeRef/defaults
defaults(self)
The default value table the merged schema declares.
Parameters
selfany(optional)
local d = weaponType:defaults()
modules/DataTypeAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { fields, extends }, the
contract's OWN declared field schema (not the merged extends chain) —
fields is { {name, type, required}, ... } sorted by name, parsed
from this contract's own schema.yaml. extends is the parent
contract identity, or nil for a root contract.
Parameters
selfany(optional)
local fields = asset.inspect(dataTypeRef).detail.fields
modules/DataTypeAssetTypeRef/instances
instances(self)
Every data instance bound to this contract (or to a contract that extends it). Scans the whole data-asset registry — a discovery surface for authoring and tooling, not a per-frame call. A broken instance (unreadable values.yaml, dangling contract binding) warns and is skipped, so one bad instance never aborts enumeration of the rest.
Parameters
selfany(optional)
for _, ref in ipairs(weaponType:instances()) do print(ref.identity) end
modules/DataTypeAssetTypeRef/parent
parent(self)
The parent contract ref (extends), or nil for a root contract.
Parameters
selfany(optional)
local base = rangedType:parent()
modules/DataTypeAssetTypeRef/schema
schema(self)
The contract's merged field schema — its own fields plus every
field inherited through the extends chain.
Parameters
selfany(optional)
local schema = weaponType:schema()
modules/DataTypeAssetTypeRef/validateValues
validateValues(self, values: { [string]: any })
Validate a value table against this contract's merged schema.
Parameters
selfany(optional)values{ [string]: any }
local ok, v = weaponType:validate({ damage = 12 })
modules/Debris/README
require("@builtin::modules.debris") -- Debris
Timed entity despawn — Roblox Debris:AddItem(instance, lifetime) analog. Wraps the internal __debris.* FFI with a typed Luau surface. Installed as the global debris via the prelude.
Collapses the common task.delay + entity.despawn pattern into one call.
Use for transient entities — bullet tracers, hit FX, dropped pickups,
tween-completion cleanups, ragdoll cleanup.
Semantics (match Roblox):
debris.add(id, lifetime)queues a despawn afterlifetimeseconds. Defaultlifetimeis 10 seconds.- Calling
addtwice on the same entity REPLACES the prior deadline. - If the entity is despawned through any other path the pending record is dropped silently — no error.
- Pending entries survive
world.save/world.load(saved lifetime is seconds-remaining, so timers resume from where they paused).
Usage: local Debris = require("@builtin::modules.debris")
modules/Debris/add
add(id: any, lifetime: number?): DebrisHandle
Schedule the entity for despawn after lifetime seconds (default 10). Calling again on the same entity replaces the prior deadline. Negative or zero lifetime despawns immediately. Returns a handle for cancel(), or 0 if the entity id couldn't be resolved.
Parameters
idany(optional) — Entity id, name, or proxy table.lifetimenumber?(optional) — Seconds before despawn — defaults to 10 when nil.
local bullet = entity.spawn("Bullet"); debris.add(bullet.id, 2.0)
local h = debris.add(target.id, 5); debris.cancel(h)
modules/Debris/cancel
cancel(handleOrId: any): boolean
Cancel a pending despawn. Accepts either a handle from debris.add or an entity id / proxy. Returns true if a pending record was actually removed.
Parameters
handleOrIdany(optional) — Cancel handle, or entity id / name / proxy.
debris.cancel(handle); debris.cancel(target.id)
modules/Debris/clear
clear(): boolean
Drop every pending entry. Used by the test suite to isolate cases — not part of the user-facing surface.
modules/Debris/count
count(): number
Number of currently pending debris entries — handy for diagnostics overlays.
print(debris.count(), "pending despawns")
modules/Debris/list
list(): { DebrisEntry }
Snapshot every pending entry as a flat array of {id, remainingSecs, handle} records. Order is not stable — don't rely on it.
for _, e in debris.list() do print(e.id, e.remainingSecs) end
modules/Debris/pending
pending(id: any): number?
Return the number of seconds remaining before the entity is despawned, or nil if it isn't scheduled.
Parameters
idany(optional) — Entity id, name, or proxy.
local s = debris.pending(bullet.id); if s then print("dies in", s) end
modules/DepthProbe/README
require("@builtin::tests.fixtures.depth_probe") -- DepthProbe
The reader half of the depth probe — the two depth grids depth_probe_feature.renderFeature writes each frame, one at afterDepthPrepass and one at afterOpaque. A suite requires this module and enables the feature; the feature records the targets it writes here, so both halves address the same targets.
Usage: local DepthProbe = require("@builtin::tests.fixtures.depth_probe")
modules/DepthProbe/read
read(): ({ number }?, { number }?)
Read both grids: the nearest depth of each tile at afterDepthPrepass
and at afterOpaque, row by row.
local seam, final = probe.read()
modules/DisplayCurve/README
require("@builtin::tests.fixtures.display_curve") -- DisplayCurve
The chain's display transform in Luau, for the suites that predict what a light value arrives at the frame as: the Khronos PBR Neutral tone curve __display__ applies at its default (curve = 3), the sRGB encode over it, and the two composed. The port is of zero_display_neutral in post_process_renderer.rs — the same formula read on a light triple rather than on a fragment, since the curve mixes channels by their shared peak and a single channel cannot be converted on its own.
Usage: local DisplayCurve = require("@builtin::tests.fixtures.display_curve")
modules/DisplayCurve/neutralCurve
neutralCurve(rgb: { number }): { number }
The Khronos PBR Neutral tone curve on a light triple, as __display__
applies it at curve = 3.
Parameters
rgb{ number }— Linear light, one entry per channel.
local curved = DisplayCurve.neutralCurve({ 1.0, 0.5, 0.25 })
modules/DisplayCurve/shownRGB
shownRGB(rgb: { number }): { number }
The code values the delivered frame shows for a light triple: the
Neutral curve, then the sRGB encode, on each channel. The curve mixes
channels by their shared peak, so one channel's code value depends on the
other two — which is why this takes the whole triple. The engine applies
the display exposure before the curve, so this answers for exposure = 1;
a case running at another exposure scales the triple by it first.
Parameters
rgb{ number }— Linear light, one entry per channel. A negative channel reads 0.
local shown = DisplayCurve.shownRGB({ 0.8, 0.8, 0.8 })
modules/DisplayCurve/srgbDecode
srgbDecode(code: number): number
The inverse of srgbEncode: a 0-255 code value back to the channel's
share of peak light before the transfer function encoded it. Exact for a
frame held at curve = 0, where __display__ only clamps to [0, 1] and
encodes — a case reading such a frame at an exposure other than 1
divides that back out afterward to recover the light the scene carried.
Parameters
codenumber— The code value, on a 0-255 scale.
local peak = DisplayCurve.srgbDecode(128)
modules/DisplayCurve/srgbEncode
srgbEncode(v: number): number
One channel of a display's peak light as the 0-255 code value that shows it, IEC 61966-2-1.
Parameters
vnumber— The channel's share of peak light; clamped to [0, 1].
local code = DisplayCurve.srgbEncode(0.5)
modules/DockedAppLayout/README
require("@builtin::_templates.docked_app.docked_app_layout") -- DockedAppLayout
Docked-shell UI template — a top toolbar, a scrolling body, and a bottom status bar built as a raw CSS-parity widget tree. Clone-and-edit starting point for editor-style tool apps.
Usage: local DockedAppLayout = require("@builtin::_templates.docked_app.docked_app_layout")
modules/DotBot/README
require("@builtin::plugins.dotbot.surface") -- DotBot
DotBot's Luau surface: the agents a person has connected, the conversations they hold, and the turns they run.
Usage: local DotBot = require("@builtin::plugins.dotbot.surface")
modules/DotBotRun/README
require("@builtin::modules.api.editor.dotbotRun") -- DotBotRun
A DotBot run driven from outside the panel: a boot that names a prompt (--agent dotbot --agent-prompt <text>, or start_instance { prompt }) hands it to DotBot as the first message of a fresh conversation, or a boot that names --agent-resume sends its message into the conversation this world's run already holds. The run is recorded the way an agent CLI records its own: the conversation in this machine's agent-session store under (world, dock slot), and every prompt and turn event in its transcript (agentSessions.record), which agent_run_report reads.
Usage: local DotBotRun = require("@builtin::modules.api.editor.dotbotRun")
modules/DotBotRun/start
start(opts: { [string]: any }): { [string]: any }
Start a DotBot run over this engine's DotBot plugin, in the background: the prompt as the first message of a fresh conversation, or a resume message into the conversation this machine recorded for the world and slot. The outcome and every turn are recorded in the run's transcript and reported as the agent's state in the engine status. One run per engine; a second call starts nothing and answers whether the first was started.
Parameters
opts{ [string]: any }—{ agent, worldGuid, slot?, prompt?, resume?, model?, effort?, account?, seeded?, asPanel? }:agentisdotbot(DotBot on its Claude account) ordotbot-<provider>;accountnames the connected account of that provider the run is put on (its agent such asdotbot-claude~2, its account key, its panel name or its email; an account the host provides also by the host's id for it);seededwaits for the Claude accounts the host hands this engine to reach DotBot before the account is chosen;asPanel, in place ofagentandaccount, runs on the agent a person's own message in the DotBot panel starts a conversation on.
modules/DotBotRun/startArmed
startArmed(): boolean
Start the DotBot run this engine's boot armed, from the boot's own
settings (--agent, --agent-prompt or --agent-resume, --agent-model,
--agent-effort, --agent-account, the bound world). Does nothing on a
boot that armed no DotBot run, or once this engine has started one.
modules/DotBotRun/watchHanded
watchHanded(): boolean
Serve the prompts the page hosting this engine hands the editor's
agent (origozero.ai's /create idea, posted as agent_prompt on the
worker channel): each is sent as the first message of the world's DotBot
conversation, once the DotBot plugin has loaded, and the page is told
whether it was sent or why not. Started once per engine; a later call
starts nothing.
modules/DotBotTranscript/README
require("@builtin::plugins.dotbot.transcript") -- DotBotTranscript
The DotBot panel's transcript: a conversation's rows as the widget tree one tab draws, rebuilt row by row. A row whose content has not changed since the last draw is the same subtree it was, its callbacks carried over, so a delta streaming into the last answer rebuilds that answer and nothing above it. The newest rows are drawn and the rest wait behind a "Show earlier messages" row, so what a redraw costs is set by how much is on screen rather than by how long the conversation is.
Usage: local DotBotTranscript = require("@builtin::plugins.dotbot.transcript")
modules/DotBotTranscript/folded
folded(key: string, runs: { any }, conversation: string?): boolean
Whether key's section is folded to its heading for runs, the
agents of conversation: as the person set it for that conversation
since its agents last started or all ended, else open while an agent
works and folded once every agent has ended.
Parameters
keystringruns{ any }conversationstring?(optional)
modules/DotBotTranscript/new
new(deps: { [string]: any })
Build a transcript.
Parameters
deps{ [string]: any }—{ source, icons, expanded, onToggle, pageSize? }:sourcereads a tool answer (traceOf,toolsRunIn);iconsholds thedown,right,alertandbotpaths;expandedis the open/closed table, keyed by row key, that the panel keeps;onToggle()runs after a row is opened or closed;pageSizeoverridesM.PAGE.
modules/DotBotTranscript/newAgents
newAgents(deps: { [string]: any })
Build the agent cards one tab draws above its composer.
Parameters
deps{ [string]: any }— The same{ source, icons, expanded, onToggle }a transcript takes (icons.termmarks a tool call,icons.stopthe Stop button), plusonOpen(run, key)(a card's chevron or name) andonStop(run, key)(its Stop), each handed the run and the key of the section it was pressed in;pageSizeoverridesM.AGENT_PAGE.
modules/DotBotTranscript/render
render(tabId: string, messages: { any }, opts: { [string]: any }?): any
messages as the scroll area tabId draws.
Parameters
tabIdstringmessages{ any }opts{ [string]: any }?(optional) —{ conversation?, now? }: the conversation the rows belong to (a new one starts again at one page), and the clock a thinking row's seconds are read against (os.clock()when absent).
modules/DotBotTranscript/setFolded
setFolded(key: string, runs: { any }, conversation: string?, folded: boolean)
Fold (true) or open key's section for conversation's agents
runs, as a press on its heading does: it holds until the
conversation's agents next start or all end.
Parameters
keystringruns{ any }conversationstring?(optional)foldedboolean
modules/DotBotTranscript/showEarlier
showEarlier(tabId: string)
Draw one page more of the earlier rows on tabId's next render.
Parameters
tabIdstring
modules/DotBotTranscript/stats
stats(tabId: string): any
What tabId's last render did: { rows, drawn, built, kept, hidden }.
rows is every row the conversation has, drawn the rows on screen,
built the rows whose nodes were made by that render, kept the rows
that carried the nodes they already had, and hidden the rows behind
"Show earlier messages".
Parameters
tabIdstring
modules/DotBotWorkflows/README
require("@builtin::plugins.dotbot.workflows") -- DotBotWorkflows
The DotBot panel's Workflows view: every workflow run in the engine as a card (its name, state, who started it, how long it has run, its phase and how many of its requests are answered), and one run opened: its phases with each request (its state, the agent that holds it and for how long, the claims that ran out, its error, and its answer once opened), its log, and Cancel while it runs. A card or a request row whose content has not changed since the last draw is the same subtree it was, its callbacks carried over, so a change to one request builds that row and nothing else.
Usage: local DotBotWorkflows = require("@builtin::plugins.dotbot.workflows")
modules/DotBotWorkflows/detail
detail(key: string, run: any, opts: { [string]: any }?): { any }
One run opened: its header (name, state, who started it, how long
it has run, its progress, why it ended, and Cancel while it runs),
each phase with its requests, and its log. opts.nowSec is the wall
clock times are read against.
Parameters
keystringrunany(optional)opts{ [string]: any }?(optional)
modules/DotBotWorkflows/list
list(key: string, opts: { [string]: any }?): any
Every workflow run in the engine, newest first, one card each;
a press on a card opens the run. opts.nowSec is the wall clock
times are read against.
Parameters
keystringopts{ [string]: any }?(optional)
modules/DotBotWorkflows/new
new(deps: { [string]: any })
Build a Workflows view.
Parameters
deps{ [string]: any }—{ source, icons, onToggle?, onOpenAgent?, onConversation? }:sourceis the panel's source (workflows,workflow,workflowPhases,workflowRevision,workflowAgent,workflowConversation,cancelWorkflow,conversations,subagents,splitAddress);iconsholds theright,down,stopandtermpaths;onToggle()runs after something in the view opened, closed or was asked of a run;onOpenAgent(agentRun, key)opens an agent a turn started; andonConversation(address, key)opens a conversation, each from viewkey.
modules/DotBotWorkflows/open
open(key: string): string?
The run opened in view key, by id, or nil while the list shows.
Parameters
keystring
modules/DotBotWorkflows/setOpen
setOpen(key: string, runId: string?)
Open run runId in view key, or go back to the list with nil.
Parameters
keystringrunIdstring?(optional)
modules/DotBotWorkflows/stats
stats(key: string): any
What the last draw of key did: { runs | requests, built, kept }.
Parameters
keystring
modules/DynamicAssetTypeRef/README
require("@builtin::assetTypes.dynamicAsset.behavior") -- DynamicAssetTypeRef
Behaviour for the dynamicAsset asset type — a prompt-driven, self-regenerating 3D asset. Reference example for the asset-type onChange change-callback. Loaded lazily by @builtin::assetTypes.assetType.shared.ref.
Usage: local DynamicAssetTypeRef = require("@builtin::assetTypes.dynamicAsset.behavior")
modules/DynamicAssetTypeRef/onChange
onChange(ref, change)
Regenerate this dynamic asset when its own prompt.json is written with
a prompt other than the one already generated. A write anywhere else in the
instance is ignored, and a prompt arriving while a generation is in flight is
held for the poll loop to pick up when that one settles.
Parameters
refany(optional) — The changed.dynamicAsset's reference.changeany(optional) — The change record the asset dispatcher raised for the write.
modules/EcsAudioListenerSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsAudioListener") -- EcsAudioListenerSpec
Usage: local EcsAudioListenerSpec = require("@builtin::modules.api.engine.ecs.components.EcsAudioListener")
modules/EcsAudioSourceSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsAudioSource") -- EcsAudioSourceSpec
Usage: local EcsAudioSourceSpec = require("@builtin::modules.api.engine.ecs.components.EcsAudioSource")
modules/EcsCameraSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsCamera") -- EcsCameraSpec
Usage: local EcsCameraSpec = require("@builtin::modules.api.engine.ecs.components.EcsCamera")
modules/EcsColliderSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsCollider") -- EcsColliderSpec
Usage: local EcsColliderSpec = require("@builtin::modules.api.engine.ecs.components.EcsCollider")
modules/EcsCollisionGroupsSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsCollisionGroups") -- EcsCollisionGroupsSpec
Usage: local EcsCollisionGroupsSpec = require("@builtin::modules.api.engine.ecs.components.EcsCollisionGroups")
modules/EcsComponentSpecs/README
require("@builtin::modules.api.engine.ecs.components") -- EcsComponentSpecs
Usage: local EcsComponentSpecs = require("@builtin::modules.api.engine.ecs.components")
modules/EcsFluidForcesSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsFluidForces") -- EcsFluidForcesSpec
Usage: local EcsFluidForcesSpec = require("@builtin::modules.api.engine.ecs.components.EcsFluidForces")
modules/EcsForceSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsForce") -- EcsForceSpec
Usage: local EcsForceSpec = require("@builtin::modules.api.engine.ecs.components.EcsForce")
modules/EcsGravityFieldSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsGravityField") -- EcsGravityFieldSpec
Usage: local EcsGravityFieldSpec = require("@builtin::modules.api.engine.ecs.components.EcsGravityField")
modules/EcsHandle/README
require("@builtin::modules.api.engine.ecs.handle") -- EcsHandle
Usage: local EcsHandle = require("@builtin::modules.api.engine.ecs.handle")
modules/EcsHandles/README
require("@builtin::modules.api.engine.ecs.handles") -- EcsHandles
Usage: local EcsHandles = require("@builtin::modules.api.engine.ecs.handles")
modules/EcsHandles/handleFields
handleFields(typeName: string): { { rust: string, category: string } }?
The fields of a native component that hold a GPU handle.
Parameters
typeNamestring— The component's public name underecs.
local fields = handles.handleFields("Mesh")
modules/EcsHandles/insertAll
insertAll(specs: { { id: string, type: string, data: any } }, site: string?): { { type: string, ids: { string }, message: string } }
Insert saved native components, one insertMany per distinct entry.
Parameters
specs{ { id: string, type: string, data: any } }— A list of{ id, type, data }: the entity, the public component name and the saved row. Entities stating the sametypeanddatashare one insert.sitestring?(optional) — Optional path or identity of the asset the rows were read from. A site inside a carried mount resolves each guid within that mount's closure.
local failed = handles.insertAll({ { id = id, type = "Mesh", data = { mesh = guid } } })
modules/EcsHandles/value
value(entry: any, site: string?): any
The component value a saved ecs entry states: its handle fields resolved from asset guids to the handles the component holds.
Parameters
entryany(optional) —{ type, data },typethe public name underecsanddatathe saved row.sitestring?(optional) — Optional path or identity of the asset the entry was read from. A site inside a carried mount resolves each guid within that mount's closure (asset.tryResolve(guid, category, site)).
ecs.insert(id, handles.value({ type = "Mesh", data = { mesh = guid } }))
modules/EcsLiftSurfaceSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsLiftSurface") -- EcsLiftSurfaceSpec
Usage: local EcsLiftSurfaceSpec = require("@builtin::modules.api.engine.ecs.components.EcsLiftSurface")
modules/EcsLightSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsLight") -- EcsLightSpec
Usage: local EcsLightSpec = require("@builtin::modules.api.engine.ecs.components.EcsLight")
modules/EcsMaterialSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsMaterial") -- EcsMaterialSpec
Usage: local EcsMaterialSpec = require("@builtin::modules.api.engine.ecs.components.EcsMaterial")
modules/EcsMeshSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsMesh") -- EcsMeshSpec
Usage: local EcsMeshSpec = require("@builtin::modules.api.engine.ecs.components.EcsMesh")
modules/EcsMorphWeightsSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsMorphWeights") -- EcsMorphWeightsSpec
Usage: local EcsMorphWeightsSpec = require("@builtin::modules.api.engine.ecs.components.EcsMorphWeights")
modules/EcsPhysicsJointSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsPhysicsJoint") -- EcsPhysicsJointSpec
Usage: local EcsPhysicsJointSpec = require("@builtin::modules.api.engine.ecs.components.EcsPhysicsJoint")
modules/EcsPhysicsSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsPhysics") -- EcsPhysicsSpec
Usage: local EcsPhysicsSpec = require("@builtin::modules.api.engine.ecs.components.EcsPhysics")
modules/EcsPlan/README
require("@builtin::modules.api.engine.ecs.plan") -- EcsPlan
Usage: local EcsPlan = require("@builtin::modules.api.engine.ecs.plan")
modules/EcsPlaneHoldSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsPlaneHold") -- EcsPlaneHoldSpec
Usage: local EcsPlaneHoldSpec = require("@builtin::modules.api.engine.ecs.components.EcsPlaneHold")
modules/EcsPlayerOwnedSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsPlayerOwned") -- EcsPlayerOwnedSpec
Usage: local EcsPlayerOwnedSpec = require("@builtin::modules.api.engine.ecs.components.EcsPlayerOwned")
modules/EcsRetargetProfileSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsRetargetProfile") -- EcsRetargetProfileSpec
Usage: local EcsRetargetProfileSpec = require("@builtin::modules.api.engine.ecs.components.EcsRetargetProfile")
modules/EcsShaderDataSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsShaderData") -- EcsShaderDataSpec
Usage: local EcsShaderDataSpec = require("@builtin::modules.api.engine.ecs.components.EcsShaderData")
modules/EcsShaftNetworkSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsShaftNetwork") -- EcsShaftNetworkSpec
Usage: local EcsShaftNetworkSpec = require("@builtin::modules.api.engine.ecs.components.EcsShaftNetwork")
modules/EcsSkeletonSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsSkeleton") -- EcsSkeletonSpec
Usage: local EcsSkeletonSpec = require("@builtin::modules.api.engine.ecs.components.EcsSkeleton")
modules/EcsSkySpec/README
require("@builtin::modules.api.engine.ecs.components.EcsSky") -- EcsSkySpec
Usage: local EcsSkySpec = require("@builtin::modules.api.engine.ecs.components.EcsSky")
modules/EcsSoftBodySpec/README
require("@builtin::modules.api.engine.ecs.components.EcsSoftBody") -- EcsSoftBodySpec
Usage: local EcsSoftBodySpec = require("@builtin::modules.api.engine.ecs.components.EcsSoftBody")
modules/EcsTessellationSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsTessellation") -- EcsTessellationSpec
Usage: local EcsTessellationSpec = require("@builtin::modules.api.engine.ecs.components.EcsTessellation")
modules/EcsTransformConstraintsSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsTransformConstraints") -- EcsTransformConstraintsSpec
Usage: local EcsTransformConstraintsSpec = require("@builtin::modules.api.engine.ecs.components.EcsTransformConstraints")
modules/EcsTransformSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsTransform") -- EcsTransformSpec
Usage: local EcsTransformSpec = require("@builtin::modules.api.engine.ecs.components.EcsTransform")
modules/EcsVisibilityRangeSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsVisibilityRange") -- EcsVisibilityRangeSpec
Usage: local EcsVisibilityRangeSpec = require("@builtin::modules.api.engine.ecs.components.EcsVisibilityRange")
modules/EcsWatch/README
require("@builtin::modules.api.engine.ecs.watch") -- EcsWatch
Usage: local EcsWatch = require("@builtin::modules.api.engine.ecs.watch")
modules/EcsWatch/entities
entities(ids: { string }, ...: any): Watch
A watch over the named entities, whatever they hold, and over the
entities holding any of the given component terms. changed() also
reports a named entity that moved.
Parameters
ids{ string }— The ids of the entities watched for movement.argsany(optional)
modules/EcsWatch/new
new(...: any): Watch
A watch over the entities holding any of the given component terms.
Parameters
argsany(optional)
modules/EcsWheelColliderSpec/README
require("@builtin::modules.api.engine.ecs.components.EcsWheelCollider") -- EcsWheelColliderSpec
Usage: local EcsWheelColliderSpec = require("@builtin::modules.api.engine.ecs.components.EcsWheelCollider")
modules/EditorLayoutAssetTypeRef/README
require("@builtin::editor.edui.editorLayout.behavior") -- EditorLayoutAssetTypeRef
Per-instance methods + the onRegister / onChange lifecycle hooks for every AssetRef<editorLayout>. Loaded lazily by asset_ref.module.
Usage: local EditorLayoutAssetTypeRef = require("@builtin::editor.edui.editorLayout.behavior")
modules/EditorLayoutAssetTypeRef/loadRecordMethod
loadRecordMethod(self): any?
Read this instance's layout record: its name, title, description, slot, mode, panels with regions, fractions, origin, and the captured arrangement when it holds one.
Parameters
selfany(optional)
local rec = layoutRef:loadRecord()
modules/EditorPanelAssetTypeRef/README
require("@builtin::editor.edui.editorPanel.behavior") -- EditorPanelAssetTypeRef
Per-instance methods + the onRegister lifecycle hooks for every AssetRef<editorPanel>. Loaded lazily by asset_ref.module.
Usage: local EditorPanelAssetTypeRef = require("@builtin::editor.edui.editorPanel.behavior")
modules/EditorPanelAssetTypeRef/getInitScript
getInitScript(self): string?
Read the instance's init.luau source as raw text (inspectors).
Parameters
selfany(optional)
modules/EditorPanelAssetTypeRef/loadSpecMethod
loadSpecMethod(self): any
Read this instance's panel spec (the table its init.luau returns).
Parameters
selfany(optional)
local spec = panelRef:loadSpec()
modules/EditorPanelAssetTypeRef/onChange
onChange(self, change)
Parameters
selfany(optional)changeany(optional)
modules/EditorPanelAssetTypeRef/onDelete
onDelete(self)
Parameters
selfany(optional)
modules/EditorPanelAssetTypeRef/onRegister
onRegister(self)
Parameters
selfany(optional)
modules/EditorPanelAssetTypeRef/panelIds
panelIds(self): { string }
The panel ids this file registers, one per spec it returns, in order:
a spec's own id, else the instance name, suffixed by position for the
later specs of a multi-tab file. Answered from the instance's last
registration, which every write to it repeats, so reading it runs
nothing; an instance never registered (a runtime profile) loads its
spec to answer. Raises the load error when init.luau does not return a
spec.
Parameters
selfany(optional)
for _, id in ipairs(panelRef:panelIds()) do print(id) end
modules/EffectAssetTypeBehavior/README
require("@builtin::systems.effects.effect.behavior") -- EffectAssetTypeBehavior
Per-instance methods and lifecycle hooks of the effect asset type. An effect's effect.yaml names what it plays: each entry under plays is one graph or a stack of graphs played together, called by its name. play plays an entry where the caller asks, with its inputs, and answers a handle that drives it; entries lists what can be played and the inputs each takes.
Usage: local EffectAssetTypeBehavior = require("@builtin::systems.effects.effect.behavior")
modules/EffectAssetTypeBehavior/entries
entries(self): (any, string?)
What this effect plays: each entry's name, the graphs it plays together and the inputs it takes, and the entry played when none is named.
Parameters
selfany(optional)
for name, e in effectRef:entries().entries do print(name, #e.graphs) end
modules/EffectAssetTypeBehavior/entry
entry(self, name: string?, cooperative: boolean?): (any, string?)
One of this effect's entries: the graphs it plays together, each with the inputs it declares.
Parameters
selfany(optional)namestring?(optional) — The entry's name, aseffect.yamllists it underplays; nil for the default.cooperativeboolean?(optional) — True from a task: describing the effect hands the frame back between its graphs.
local burst = effectRef:entry("burst")
modules/EffectAssetTypeBehavior/instantiate
instantiate(self, target: any?, opts: { [string]: any }?): (any, { [string]: string })
Place this effect in the scene: an entity with an Effect component
that plays one of its entries there, the way a drop into the viewport or an
Asset field places it.
Parameters
selfany(optional)targetany?(optional) — Optional owning entity ref; the effect's entity spawns under it.opts{ [string]: any }?(optional) — The base placement opts (position,rotation,scale,name,temporary), plusentry(the entry it plays; the effect's default when omitted) andinputs(values for the entry's inputs by name).
local root = effectRef:instantiate(nil, { position = { 0, 1, 0 }, entry = "flare" })
modules/EffectAssetTypeBehavior/isDescribed
isDescribed(self): boolean
Whether the effect's entries are described already, so that entry answers without reading its graphs.
Parameters
selfany(optional)
if effectRef:isDescribed() then bind() end
modules/EffectAssetTypeBehavior/newGraph
newGraph(self, name: string, opts: { part: boolean? }?): any
Make a new graph inside this effect: under graphs/ for one it plays,
under parts/ for one its graphs use as a node.
Parameters
selfany(optional)namestring— The graph's name.opts{ part: boolean? }?(optional) —{ part? }: true makes it underparts/.
local core = beacons:newGraph("flareCore")
local crack = beacons:newGraph("crack", { part = true })
modules/EffectAssetTypeBehavior/onCreate
onCreate(name: string, opts: CreateOpts?): { [string]: string }
Scaffold a new effect playing one entry: effect.yaml with that entry
as its default, the graph it plays under graphs/ by the same name, and a
README to describe each. The entry is opts.entry, or the effect's own
name when none is given.
Parameters
namestring— The effect's name.optsCreateOpts?(optional) —{ entry? }: the name of the entry it starts with and of its graph.
asset.create("effect", "beacons", { entry = "flare" })
modules/EffectAssetTypeBehavior/onRegister
onRegister(self)
Initial-registration callback: describe the effect in a task of its own, a slice of each frame at a time, so
the Effect that plays it finds its entries described when it binds them.
Parameters
selfany(optional)
modules/EffectAssetTypeBehavior/play
play(self, entryName: string?, opts: PlayOpts?): any
Play one of this effect's entries. Every graph the entry holds plays
together from the same moment, each given the inputs it declares, under
the entity root names, so the effect moves with it (a sword, a torch, a
character's hand); with no root it stands in the world. A finished play
is kept and played again by the next call for the same entry.
Parameters
selfany(optional)entryNamestring?(optional)optsPlayOpts?(optional) —{ root?, offset?, rotation?, inputs?, ending?, speed?, keep? }.root: the entity it plays on (proxy or id).offset: where it stands, fromrootor, with no root, in the world.rotation: its rotation there (pitch/yaw/roll degrees, or a quaternion).inputs: values for the entry's inputs by name; each goes to every graph of the entry that declares it.ending:"graph"(what the timeline declares),"loop"or"hold".speed: 1 its own rate.keep: stay once finished instead of going.
local beacons = asset.resolve("beacons", "effect")
local shown = beacons:play("flare", { root = mast, offset = { 0, 0.9, 0 }, inputs = { size = 0.4 } })
shown:onFinished(function() print("done") end)
modules/EffectAssetTypeBehavior/playing:playback
playing:playback(): any
Where the play stands and what it has cost: the Effect's playback(), its combined cost and one entry per graph. Once the play has finished and gone back to the kept plays, the answer is what it stood at when it went.
modules/EffectAssetTypeBehavior/playing:set
playing:set(input: string, value: any)
Set one of the entry's inputs while it plays, on every graph that declares it.
Parameters
inputstringvalueany(optional)
modules/EffectAssetTypeBehavior/preview
preview(self, opts: { [string]: any }?): { [string]: any }
Render this effect to a still: its default entry played on the preview
stage (effects.stage) from its first frame, over the dark backdrop and
framed on the effect's body, and the picture taken at the effect's still
moment: the latest of the moments its graphs name with g:still (halfway
through its range, or two seconds into a timeline with no end, for a graph
that names none). A timeline with an end is moved to that moment; one with
no end is played to it.
Parameters
selfany(optional)opts{ [string]: any }?(optional) —{ size? = { width, height }, angle? = { yaw, pitch }, backdrop?, fit? }, aspreview.fromEntitiestakes them.
local shot = effectRef:preview({ size = { width = 256, height = 256 } })
modules/EffectAssetTypeBehavior/removeEntry
removeEntry(self, name: string)
Remove an entry and the comment lines directly above it. The default moves to the first entry left; the last entry cannot be removed.
Parameters
selfany(optional)namestring— The entry's name.
beacons:removeEntry("flare")
modules/EffectAssetTypeBehavior/renameEntry
renameEntry(self, old: string, new: string)
Rename an entry; the default follows it.
Parameters
selfany(optional)oldstring— The entry's name now.newstring— Its new name: letters, digits and _, starting with a letter.
beacons:renameEntry("glow", "flare")
modules/EffectAssetTypeBehavior/setDefault
setDefault(self, name: string)
Make an entry the one played when none is named.
Parameters
selfany(optional)namestring— The entry's name.
beacons:setDefault("flare")
modules/EffectAssetTypeBehavior/setEntry
setEntry(self, name: string, graphs: { any })
Set what one entry plays: replaces the entry's graphs, or adds the entry after the others when the effect has none by that name. Other lines of effect.yaml, comments included, are kept.
Parameters
selfany(optional)namestring— The entry's name: letters, digits and _, starting with a letter.graphs{ any }— The graphs it plays together: procGraph refs, or names as effect.yaml states them (~.graphs.flash).
beacons:setEntry("flare", { asset.resolve("~.graphs.flareCore", "procGraph"), "~.graphs.flareTrail" })
modules/EffectAssetTypeBehavior/validate
validate(ref): { { code: string, message: string, severity: string? } }
The effect's own rules: effect.yaml plays graphs that resolve, its
default is one of its entries, every graph under graphs/ is played by
some entry, and each folder holds only the assets it is for.
Parameters
refany(optional)
modules/EffectAssetTypeBehavior/warm
warm(self, entryName: string?, count: number?, inputs: { [string]: any }?)
Keep plays of this effect's entries ready, built ahead of time, so a
play takes one and shows its first frame at once. Plays are made one after
another on the frames after the call, and one counts as ready once every
graph of it is planned, cooked and has its first frame presented
(entries() reports ready). A play made for inputs is ready for a play
given the same inputs; one given others cooks for them as it starts. A
finished play goes back on its first frame, prepared again for the inputs
it last played with, while its entry has fewer than this count. An entry
nothing sized keeps the effect's pool setting ready, made the first time
that entry plays; call this at a level's load, or before a burst, with the
number of plays of an entry that run at once.
Parameters
selfany(optional)entryNamestring?(optional)countnumber?(optional) — How many to keep ready; nil keeps the effect'spoolsetting. 0 keeps none.inputs{ [string]: any }?(optional) — The values of the entry's inputs the plays are made for, asplaytakes them; nil makes them with the defaults.
beacons:warm()
beacons:warm("flare", 6)
beacons:warm("flare", 2, { size = 0.4 })
modules/EffectShared/README
require("@builtin::systems.effects.effect.shared") -- EffectShared
What the effect type and its Effect component share: which of an entry's graphs takes each input, and the plays the type handed out and keeps to play again. An entry is what effectRef:entry(name) answers.
Usage: local EffectShared = require("@builtin::systems.effects.effect.shared")
modules/EffectShared/add
add(path: string, entry: string, e: any, stillPreparing: boolean?)
Put a play made ahead of time among the kept plays of its entry: it
waits disabled and out of the scene's hierarchy. A play still preparing
counts as ready once prepared is called for it.
Parameters
pathstring— The effect's VFS path.entrystring— The entry's name.eany(optional) — The play's entity, carrying a bound Effect component.stillPreparingboolean?(optional) — Whether its graphs are still doing the work its first play needs.
modules/EffectShared/current
current(record: any): boolean
Whether record is still the play its entity is playing.
Parameters
recordany(optional)
modules/EffectShared/defaultSize
defaultSize(path: string): number
The pool size every entry of the effect at path keeps until warm() sizes it.
Parameters
pathstring
modules/EffectShared/dropKept
dropKept(path: string)
Let go of every kept play of the effect at path: what it plays changed.
Parameters
pathstring— The effect's VFS path.
modules/EffectShared/finished
finished(entityId: string)
Called by an Effect component when every graph of its entry has finished. A play the effect type handed out tells its listeners, and goes back to the kept plays unless it stays.
Parameters
entityIdstring— The Effect component's entity.
modules/EffectShared/handOut
handOut(e: any, path: string, entry: string, stays: boolean): any
Hand a play out: who to tell when it finishes, and whether it stays where it is once finished instead of going back to the kept plays.
Parameters
eany(optional) — The play's entity.pathstring— The effect's VFS path.entrystring— The entry's name.staysboolean— Whether the play stays once finished.
modules/EffectShared/inputs
inputs(entry: any): { [string]: any }
The inputs an entry takes: every input any of its graphs declares.
Parameters
entryany(optional) — An entry, aseffectRef:entry(name)answers it.
modules/EffectShared/isPreparing
isPreparing(entityId: string): boolean
Whether the kept play entityId is still doing the work its first play needs.
Parameters
entityIdstring— The play's entity.
modules/EffectShared/keep
keep(record: any)
Take a handed-out play back: pause it, take it out of the scene and keep it ready for the next play of its entry, or let it go when the entry already has as many plays, ready and playing, as its pool size.
Parameters
recordany(optional) — The play's record.
modules/EffectShared/onKept
onKept(fn: (any) -> ())
Name what is done with each play that goes back among the kept plays:
it counts as preparing until prepared is called for it.
Parameters
fn(any) -> ()— Called with the play's entity.
modules/EffectShared/prepared
prepared(entityId: string)
A kept play's graphs are done with the work its first play needs.
Parameters
entityIdstring— The play's entity.
modules/EffectShared/ready
ready(path: string, entry: string): number
How many kept plays of entry are ready now: built, and their graphs
done with the work their first play needs.
Parameters
pathstringentrystring
modules/EffectShared/route
route(entry: any, inputs: { [string]: any }?): ({ { [string]: any } }?, string?)
Each graph's share of inputs: the values of the inputs it declares.
Parameters
entryany(optional) — An entry, aseffectRef:entry(name)answers it.inputs{ [string]: any }?(optional) — Values by input name.
modules/EffectShared/setDefaultSize
setDefaultSize(path: string, count: number)
Set the pool size every entry of the effect at path keeps until warm() sizes it.
Parameters
pathstringcountnumber
modules/EffectShared/setSize
setSize(path: string, entry: string, count: number)
Set how many plays of entry of the effect at path are kept ready;
ready plays past the count are let go.
Parameters
pathstring— The effect's VFS path.entrystring— The entry's name.countnumber— Whole number >= 0.
modules/EffectShared/size
size(path: string, entry: string): number
How many plays of entry are kept ready.
Parameters
pathstringentrystring
modules/EffectShared/sortedKeys
sortedKeys(t: { [string]: any }): { string }
The keys of t, sorted.
Parameters
t{ [string]: any }
modules/EffectShared/stopped
stopped(entityId: string): boolean
Called by an Effect component told to stop. A play the effect type handed out goes back to the kept plays.
Parameters
entityIdstring— The Effect component's entity.
modules/EffectShared/take
take(path: string, entry: string): any?
A kept play of entry of the effect at path, or nil when none is kept.
Parameters
pathstring— The effect's VFS path.entrystring— The entry's name.
modules/EffectShared/total
total(path: string, entry: string): number
How many plays of entry there are: kept ones, ready or preparing, and
ones playing now.
The pool size counts both, so plays are built while fewer exist and a
finished one always goes back while the pool is not over its size.
Parameters
pathstringentrystring
modules/Engine/README
require("@builtin::modules.api.engine.engine") -- Engine (also available as global 'engine')
Process-level engine state surface. Read-only boot profile and read-write engine mode. Both exposed as computed properties via metatable __index / __newindex — never call them as methods. Usage: if engine.profile == "editor" then ... end engine.mode = "play" engine.setMode("play", { strict = false }) Implemented as a thin Luau wrapper over internal FFI: engine.profile → __engineSettings.get("profile") engine.mode → __mode.get() / __mode.set(value) engine.setMode → __mode.set(value, strict) engine.paused → __pause.get() / __pause.set(value) engine.timeScale → __timescale.get() / __timescale.set(value) engine.timeScaleOwner → who the rate answers to (hold, or last writer) engine.gameplayReady → __gameplay.ready() engine.mode = X is load-bearing — the setter owns the mode-flip side effects so any path that changes mode behaves identically: edit → play: drain pending edit-mode marks into the dirty overlay (so wld.edit() can reassemble the user's authored state) BEFORE flipping __mode. Never writes canonical scene.json. play → edit: flip __mode first, then reload the active non-additive layer so the dirty overlay reapplies + play-mode runtime mutations are discarded. Toolbox wrappers (wld.play() / wld.edit()) are thin pass-throughs — they MUST NOT carry side-effect logic. If a future caller writes engine.mode = "play" directly (or via a different toolbox tool), the same side effects fire. Putting drain/reload on the toolbox alone would let a direct assignment leave the scene in a half-applied state. See man engine for the full surface and side effects.
Usage: local Engine = require("@builtin::modules.api.engine.engine") Also available as global: engine
modules/Engine/_fireWorldLoaded
_fireWorldLoaded(detail: string?)
INTERNAL. Mark the world fully loaded and fan out to every
onWorldLoaded subscriber. Called by the builtin world-entrypoint
loader once onWorldLoad has returned. Idempotent per load — re-fires
on a genuine reload (mirrors a scene's onReady), so the flag is set
true and subscribers run on each call.
Parameters
detailstring?(optional) — Optional JSON text the boot timeline'sworld_loadedmark carries as its detail: the loader's account of the frames the load ran across.
modules/Engine/_resetWorldLoaded
_resetWorldLoaded()
INTERNAL. Clear the world-loaded latch on unbind/unload so a subsequent bind re-fires onWorldLoaded for the new world.
modules/Engine/editWaiters
editWaiters(): { EditWaiter }
Everyone waiting for this engine to leave play so their edit-mode work
can run, oldest first. Each entry is { key, id, name, reason, heldSeconds }: id is the waiting caller, the same value
vfs.currentAuthor().id reads, and heldSeconds is how long it has been
waiting. A session holding play reads this to see whose work it is
holding. Empty in edit mode and whenever nobody has said they are waiting.
for _, who in ipairs(engine.editWaiters()) do
log.warn(("%s has waited %.0fs for edit mode"):format(who.name or who.key, who.heldSeconds))
end
modules/Engine/engineRecord
engineRecord(record: { [any]: any })
Declare record an engine record: a table a subsystem keeps as its
own account of what the engine holds — the renderer's registry of live
features, its capture views — and puts back through its own reset.
engine.snapshotModuleState neither copies nor walks it, and
engine.restoreModuleState leaves it as that reset left it, so a module
restore never seats a record back around what the reset did: a feature a
suite destroyed stays destroyed, and one it made again under its identity
stays the one the renderer ticks.
Parameters
record{ [any]: any }— The table.
engine.engineRecord(activeFeatures)
modules/Engine/holdTimeScale
holdTimeScale(scale: number, options: TimeScaleHoldOptions?): () -> ()
Run the simulation at scale for as long as the hold stands, and
return the release. engine.timeScale is one number for the whole
process, so a rate one agent sets is the rate every other agent's
entities and measurements run at; a hold records who set it and refuses a
plain engine.timeScale write from anywhere else while it stands, so the
rate cannot move under a measurement without the measurement hearing
about it.
Holds nest: the innermost names the rate, and the rate that stood before
the outermost is back once the last release is called. Each release takes
its own hold off the stack whatever order the releases come in.
exclusive takes the rate for the owner key the call states: while that
hold stands, a hold is admitted only when it states the same key, and
every other one is refused with an error naming the key and the rate. That
is what lets one caller pin the rate its run is measured at while another
agent drives the same engine.
Parameters
scalenumber— The rate to run at: 1 is real time, 0.5 half speed, 0 frozen, 2 double. Finite and>= 0.optionsTimeScaleHoldOptions?(optional) —owneris the key this hold is taken under, a non-empty string, and an exclusive hold states one. A hold that states no key takes the key of the agent the call is attributed to, or a mintedhold#nwhen the call carries no agent identity, so every hold answers to a keyengine.releaseTimeScaleaccepts andengine.timeScaleOwnerreports asid.exclusivetakes the rate for the stated key until the hold is released.
Returns () — A function that releases this hold. Calling it twice releases once.
local release = engine.holdTimeScale(0.08) ; task.wait(0.12) ; release()
local release = engine.holdTimeScale(1, { exclusive = true, owner = "duel-measurement" })
modules/Engine/markBaseline
markBaseline(): number
Read this module's own memory — the time-scale holds standing, who
wrote the rate last, the rate that stood before any hold, the
onTimeScaleChange subscribers and the highest watcher id each registry
has handed out — and answer with a generation engine.resetToBaseline
puts exactly that back from. Take it once, before the work whose changes
are to be undone.
local mark = engine.markBaseline() -- then run, then engine.resetToBaseline(mark)
modules/Engine/markScriptingBaseline
markScriptingBaseline(): number
Record the scripting registries — world-event subscriptions, the
four lifecycle-watcher lists, and the require cache — as they stand
right now, as a mark engine.resetScriptingState() restores to. Marks
stack: a reset names the generation it restores to, and the marks taken
after that one go with it. Returns the new mark's generation, counting
from 1.
Mark once the engine is serving rather than while it boots: the
registries keep growing as the prelude subscribes, the world
entrypoint runs and the startup scene loads, so a mark taken partway
through sits below the rest of that work and the first reset would
remove it.
engine.markScriptingBaseline()
world.on("player_join", function() end)
engine.resetScriptingState() -- the subscription above is gone
modules/Engine/offDeviceRebuilt
offDeviceRebuilt(id: number): boolean
Remove an engine.onDeviceRebuilt subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it named
none — already removed, or never registered.
Parameters
idnumber— Watcher id returned byengine.onDeviceRebuilt.
local id = engine.onDeviceRebuilt(function() end)
engine.offDeviceRebuilt(id)
modules/Engine/offMemoryPressure
offMemoryPressure(id: number): boolean
Remove an engine.onMemoryPressure subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it named
none: already removed, or never registered.
Parameters
idnumber— Watcher id returned byengine.onMemoryPressure.
local id = engine.onMemoryPressure(function() end)
engine.offMemoryPressure(id)
modules/Engine/offModeChange
offModeChange(id: number): boolean
Remove an engine.onModeChange subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it
named none — already removed, or never registered.
Parameters
idnumber— Watcher id returned byengine.onModeChange.
local id = engine.onModeChange(function() end)
engine.offModeChange(id)
modules/Engine/offPauseChange
offPauseChange(id: number): boolean
Remove an engine.onPauseChange subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it
named none.
Parameters
idnumber— Watcher id returned byengine.onPauseChange.
modules/Engine/offTimeScaleChange
offTimeScaleChange(id: number): boolean
Remove an engine.onTimeScaleChange subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it named
none.
Parameters
idnumber— Watcher id returned byengine.onTimeScaleChange.
local id = engine.onTimeScaleChange(function() end)
engine.offTimeScaleChange(id)
modules/Engine/offWorldLoaded
offWorldLoaded(id: number): boolean
Remove an onWorldLoaded subscriber by its watcher id.
Parameters
idnumber
modules/Engine/offWorldReady
offWorldReady(id: number): boolean
Remove an engine.onWorldReady subscriber by its watcher id.
Returns true when a live watcher carried that id, false when it
named none.
Parameters
idnumber— Watcher id returned byengine.onWorldReady.
modules/Engine/offWorldUnloading
offWorldUnloading(id: number): boolean
Remove an engine.onWorldUnloading subscriber by its watcher
id. Returns true when a live watcher carried that id, false when it
named none.
Parameters
idnumber— Watcher id returned byengine.onWorldUnloading.
modules/Engine/onDeviceRebuilt
onDeviceRebuilt(callback: (number) -> ()): number
Register a callback that fires after the engine has answered a lost render device by building another one. The callback receives the new device generation — a number that counts the devices this session has run on, and moves exactly once per rebuild. Returns a watcher id.
A device is lost when the driver resets, when the GPU is taken away, or when a browser reclaims a WebGPU context. Everything the engine can re-derive by itself it does: meshes, materials, shaders, render passes and the UI are all back on the new device before this fires. What it cannot re-derive is what YOUR content made and only the GPU held — a texture uploaded from pixels a script computed, a compute buffer it filled, a render target it created. Make those again here.
Content that owns no GPU resource of its own needs no subscriber: asset handles re-materialise on their next use.
Parameters
callback(number) -> ()— Function invoked as(generation: number).
engine.onDeviceRebuilt(function(generation)
-- the noise field lived only on the GPU, so it is computed again
print("upload the noise field again for device generation", generation)
end)
modules/Engine/onMemoryPressure
onMemoryPressure(callback: (string, string) -> ()): number
Register a callback that fires when the system says it is short of
memory, after the engine has released what that level of pressure
releases. The callback receives the level ("normal", "moderate",
"low" or "critical") and who reported it: onTrimMemory(<level>) for
Android's report, script for renderer.signalMemoryPressure. Returns a
watcher id.
The engine frees what it can rebuild by itself: mip levels the frame does
not sample, render-target storage nothing is drawing into, and from
"critical" half the texture budget. What it cannot free is what YOUR
content keeps: a cache of generated meshes, a table of decoded audio,
pixels kept for a later upload. Drop those here and build them again when
they are next needed. A level stands for a minute after the last report,
and renderer.memoryPressure() reads the level in force and what the
engine released.
Parameters
callback(string, string) -> ()— Function invoked as(level: string, source: string).
engine.onMemoryPressure(function(level, source)
if level ~= "normal" then
decodedClips = {} -- decoded again on next play
end
end)
modules/Engine/onModeChange
onModeChange(callback: (string, string) -> ()): number
Parameters
callback(string, string) -> ()
modules/Engine/onPauseChange
onPauseChange(callback: (boolean, boolean) -> ()): number
Register a callback that fires synchronously whenever the gameplay
pause flag flips via an explicit engine.paused write. Callback
receives (newPaused, oldPaused) as booleans. Returns a watcher id.
Pause is independent of engine.mode: pausing play mode returns the
editor authoring surface (free camera + EditorOnly entities) over the
frozen play world, and resuming hides it again. Mode-driven pause
resets (the edit=paused / play=running defaults applied on a mode flip)
are delivered through onModeChange, not this hook.
Parameters
callback(boolean, boolean) -> ()— Function invoked as(newPaused: boolean, oldPaused: boolean).
local id = engine.onPauseChange(function(paused)
print(paused and "frozen" or "running")
end)
modules/Engine/onTimeScaleChange
onTimeScaleChange(
Register a callback that fires on every move of the simulation rate,
whoever moved it: an engine.timeScale write, a hold taken at a rate
other than the one in force, a release that hands a different rate back.
The callback receives (newScale, oldScale, owner), where owner is the
record engine.timeScaleOwner answers with. It counts transitions, so a
write or a hold landing on the rate already in force moves nothing and
announces nothing; engine.timeScaleOwner is what answers who holds a
rate that has stayed where it is. Several agents drive one engine at once,
so this is how a run whose numbers depend on the rate learns that somebody
else moved it instead of reading the number and finding out afterwards.
Returns a watcher id.
local id = engine.onTimeScaleChange(function(new, old, who)
log.warn(("rate %g -> %g by %s"):format(old, new, who and who.id or "nobody"))
end)
modules/Engine/onWorldLoaded
onWorldLoaded(callback: () -> ()): number
Register a callback fired (no args) when the world is fully
LOADED — its .world_entrypoint.luau ran AND its onWorldLoad
returned (the startup scene loaded, defaults seeded, editor UI
mounted). This is strictly AFTER onWorldReady (content synced):
ready = "bytes are in the VFS"; loaded = "the entrypoint has run".
LATCHED — a callback registered after the world is already loaded
fires immediately, so a late consumer never misses it and never has
to poll. Read the same state synchronously via engine.worldLoaded.
Parameters
callback() -> ()— Function invoked with no arguments.
modules/Engine/onWorldReady
onWorldReady(callback: () -> ()): number
Register a callback fired (no args) when the bound world's
content has been synced into the VFS and the world is ready to
load. This is the race-free, user-space hook that drives the whole
world-VM lifecycle: the builtin world-entrypoint loader subscribes
to it and, when it fires, loadstring(vfs.read(...))s
/source/.world_entrypoint.luau and runs its onWorldLoad —
exactly the way a scene entrypoint loads. The trusted VM fires this
(via world.markReady()) ONLY once the bytes are in the VFS, so a
subscriber never sees a half-synced world. Returns a watcher id.
Parameters
callback() -> ()— Function invoked with no arguments.
modules/Engine/onWorldUnloading
onWorldUnloading(callback: () -> ()): number
Symmetric teardown of engine.onWorldReady: register a callback
fired (no args) when the bound world is unbinding/swapping out. The
builtin loader runs the world entrypoint's onWorldUnload here, so
the world entrypoint has the same load/unload parity a scene
entrypoint has. Returns a watcher id.
Parameters
callback() -> ()— Function invoked with no arguments.
modules/Engine/releaseBaseline
releaseBaseline(generation: number): boolean
Drop the mark generation names, and every mark taken after it, once
the caller that took it is done resetting to it. It touches the
marks alone.
Parameters
generationnumber— The mark to drop, asengine.markBaselinereturned it.
engine.releaseBaseline(mark) -- the run is over
modules/Engine/releaseScriptingBaseline
releaseScriptingBaseline(generation: number): boolean
Drop the scripting mark generation names, and every mark taken
after it, once the caller that took it is done resetting to it. The
registries stay as they stand. A mark holds the require cache's keys as
they stood, so a caller that marks once per run drops each mark when its
run is over.
Parameters
generationnumber— The mark to drop, asengine.markScriptingBaselinereturned it.
engine.releaseScriptingBaseline(mark) -- the run is over
modules/Engine/releaseTimeScale
releaseTimeScale(owner: string): number
Parameters
ownerstring
modules/Engine/resetScriptingState
resetScriptingState(generation: number?): { [string]: number }
Drop every world-event subscription, lifecycle watcher and
cached module registered since the mark generation names — the
newest engine.markScriptingBaseline() when omitted — leaving
everything registered before it in place, including the builtin
world-entrypoint loader, which subscribes at VM boot and so always
sits below any mark. The marks taken after that one go with the
reset. A module with a frame on the stack keeps its cache entry and
its registrations. Raises when no such mark is in force. Returns
per-registry counts of what was removed: worldEvents,
modeWatchers, worldReadyWatchers, worldUnloadingWatchers,
pauseWatchers, deviceRebuiltWatchers, memoryPressureWatchers,
modules, and total.
Parameters
generationnumber?(optional) — The generation to restore to, asmarkScriptingBaselinereturned it; the newest mark when omitted.
modules/Engine/resetToBaseline
resetToBaseline(generation: number?): number
Put this module's own memory back as engine.markBaseline read it:
every time-scale hold taken since comes off, every onTimeScaleChange
subscriber added since is removed, the last writer and the base rate read
as they did, the rate in force follows, and the record of who registered
each watcher forgets the ids handed out since. The marks taken after
generation go with the reset.
Parameters
generationnumber?(optional) — The mark to restore to; the newest when omitted.
engine.resetToBaseline(mark)
modules/Engine/restoreModuleState
restoreModuleState(snapshot: { [string]: any }, options: { remint: { [string]: string }?, gone: ((any) -> boolean)?, successor: ((any) -> any?)?, only: { [string]: boolean }? }?): { [string]: any }
Put every module's state back to what engine.snapshotModuleState
read. A table is refilled in place, so a closure holding it sees the
restored contents, and the upvalue is pointed back at it, so a module that
assigned its local a new table is reading the restored one again.
The same snapshot restores to the same state however many times it is used, so one reading taken before a run puts every later point in that run back to it.
A value whose reading names an object the engine no longer holds — a
buffer whose storage was destroyed since, answering alive false — is
left as it stands: what it remembered cannot be given back to it, and
what it holds now is what it went on to make. The module holding it is
left whole, because what it remembers beside that object — the count it
sized the object for, the flag that says it made one — is the state of
the object it now holds instead; it is counted under stale. A data
table naming a gone object in one of its fields is a registry, and is
refilled around that field.
Called from a coroutine that can yield, the restore gives the frame back every few milliseconds.
the engine re-minted since replaced by the id it now uses.
Parameters
snapshot{ [string]: any }options{ remint: { [string]: string }?, gone: ((any) -> boolean)?—remintmaps an id the reading holds to the id the engine now uses for the same thing — a render feature's guid after the feature was made again under its identity.goneanswers whether a value the reading holds names something the engine no longer holds — a record carrying a render feature's guid when no feature carries it now; a handle answeringalivefalse is known without it.successoranswers, for an object that has gone, the live object standing in for it — the handle under a buffer's name after the buffer was made again under it — and the reading is put back holding that one, its own fields left as they are. A handle that already answeredalivefalse when the reading was taken is the module's own record of something gone before it, and is put back as it is.sameanswers whether a value a module holds now already stands in for the gone object a successor was found for — the module's own live handle to the buffer made again under the name — and such a value is kept, the successor released.onlynames the modules to put back, by module name, and every other module's reading is left untouched — a second pass over the modules an earlier one left as they stood, once what stands in for the objects they named exists.successor((any) -> any?)?(optional)only{ [string]: boolean }? }?(optional)
engine.restoreModuleState(snap)
engine.restoreModuleState(snap, { remint = { [oldGuid] = newGuid } })
modules/Engine/scriptingRegistryCounts
scriptingRegistryCounts(): { [string]: number }
How many subscriptions each scripting registry holds right now,
plus the size of the require cache and the generation of the mark in
force. Keys: worldEvents, modeWatchers, worldReadyWatchers,
worldUnloadingWatchers, pauseWatchers, deviceRebuiltWatchers,
memoryPressureWatchers, modules, and baselineGeneration (nil when
no mark has been taken).
modules/Engine/setMode
setMode(mode: string, options: { strict: boolean?, endSession: boolean? }?): { mode: string, bypassed: { any }, leftPlaySession: boolean }
Change the engine mode with per-call control over the play gate, and
read back what the change went past. engine.mode = value is the same
flip with the defaults.
options.strict = false lets THIS call enter play while your own content
carries error-severity diagnostics. It settles with the call: the world's
lsp.strict_mode is untouched, so no other session and no later session
of the world sees a different gate. The returned bypassed array holds
the diagnostics the call went past — each { path, line, col, code, message, severity } — and the engine log carries the same list. An
error in content another session wrote never gates the flip, so it never
appears here; a push still refuses to publish while any of them stands.
Parameters
modestring—"edit"or"play".options{ strict: boolean?, endSession: boolean? }?(optional) —{ strict: boolean?, endSession: boolean? }.strict = falsewaives the play gate for this call;trueor omitted honours the world'slsp.strict_mode.endSession = truewith"edit"ends the running play session for every caller in it, whether or not you take part, and answers for everything the session holds (engine.discardPlayChanges()arms its discard); without it, an"edit"from one of several callers in play takes only that caller out, and one from a caller outside the session is refused.
local report = engine.setMode("play", { strict = false })
for _, d in ipairs(report.bypassed) do
print(("entered play past %s:%d — %s"):format(d.path, d.line, d.message))
end
modules/Engine/snapshotModuleState
snapshotModuleState(): { [string]: any }
Read the state every cached module holds — the upvalues of the closures
it hands back — and answer with it, so engine.restoreModuleState can put
exactly that back later.
Take it once, before the work whose changes are to be undone. Data is copied, so a table a module goes on mutating does not change what was read; an object — a table carrying a metatable or methods of its own — is kept by reference and its fields copied, so restoring returns the object every other holder is still attached to rather than a lookalike that answers none of its methods.
A module with a frame on the stack while the reading is taken — the caller, and whatever called it — is mid-operation, and what it holds is left out: neither copied here nor written back by the restore, however another module reaches it. Called from a coroutine that can yield, the walk gives the frame back every few milliseconds, so the engine keeps stepping through a reading that takes seconds.
local snap = engine.snapshotModuleState()
modules/Engine/timeScaleHolds
timeScaleHolds(): { string }
modules/Engine/waitForEdit
waitForEdit(reason: string?): () -> ()
Say that this caller's edit-mode work is waiting on the play session, and get back the call that takes the wait off.
One process runs one simulation, so a play session holds the engine in
play for every caller outside it, and an agent whose edit-mode work
cannot proceed has no way to say so. While this wait stands it rides the
run-state block of every response any session gets from this engine, so
the callers in the play session learn somebody is waiting for it. Read
engine.playSession for who they are, and engine.modeOwner for who
entered play and how long ago.
A wait is keyed by the caller the call was attributed to, so a named caller that registers twice moves its own entry forward rather than queueing behind itself: one caller waits once. A call carrying no agent identity is named by nothing to key on, so each such ask stands as its own waiter and the release it handed back takes that one off. Reaching edit mode takes every wait off, so a caller whose release is lost with the task that held it leaves nothing standing.
Parameters
reasonstring?(optional) — What this caller is waiting to do, shown beside its name.
Returns () — A function that takes this caller's wait off.
local done = engine.waitForEdit("promote my scene edits")
-- ... once the engine reaches edit and the work is taken ...
done()
modules/Engine/watcherSources
watcherSources(): { [string]: { [number]: string } }
Who registered each watcher still standing, by registry: modeWatchers,
pauseWatchers, deviceRebuiltWatchers, memoryPressureWatchers,
worldReadyWatchers and worldUnloadingWatchers, each a map from watcher id to the source and
line that registered it. A watcher registered before this module loaded
is absent. What a reading of the registry counts names when it finds a
watcher more than it began with.
for id, at in pairs(engine.watcherSources().modeWatchers) do print(id, at) end
modules/EntityRecords/README
require("@builtin::modules.entity_records") -- EntityRecords
Walks a live entity hierarchy into the flat record array the engine's entity templates use. Shared by bundle (its entity_template) and by scene builds (their baked output), so both speak one record shape.
Usage: local EntityRecords = require("@builtin::modules.entity_records")
modules/EntityRecords/addData
addData(data: any, instanceName: string?): any
The data table component.add puts a record's instance back with:
data itself for the anonymous instance, and a copy carrying name for a
named one, which is the key component.add reads the instance name from.
Parameters
dataany(optional) — The entry's field values.instanceNamestring?(optional) — The entry's instance name, or nil for the anonymous instance.
entity(id).component.add("Pool", EntityRecords.addData({ amount = 120 }, "mana"))
modules/EntityRecords/authoredComponentData
authoredComponentData(
A component instance's snapshot with the fields the instance wrote about its own runtime removed, leaving what states how it was CONFIGURED. A capture reads it to build the record, and whoever diffs a live entity against that record reads it too, so both sides speak the same fields.
local d = EntityRecords.authoredComponentData(id, ty, nil, snapshot)
modules/EntityRecords/captureRecord
captureRecord(rid: string, parentOriginalId: string?): any
Capture ONE entity into a template record. Reads LIVE component public
state (serialized component snapshots), not init data, so the record
matches what is on screen, and states the fields each instance's
configuration states (configuredFields): a field left to its declared
default stays out, so a later change to that default reaches whatever the
record rebuilds. Each component INSTANCE gets its own entry,
carrying instance_name when the instance has one, so a type the entity
carries several of comes back as the same several. The record also
carries the entity's own
active flag, every attribute it holds, and its lifecycle mode and
replication scope when either is other than the default. The entity's
runtime id IS its record original_id, so cross-entity component
references — which already point at runtime ids — round-trip and get
remapped on the next instantiate. Each component entry names where it
holds such a reference in entity_fields, taken from the component's
declared field kinds: a top-level field by its name, and a reference held
as a list element or struct subfield by its path from the field (an array
such as { "attachments", 1, "target" }), so a rebuild resolves exactly
those.
Parameters
ridstring— Runtime entity id to capture.parentOriginalIdstring?(optional) — Parent's original_id, or nil for a root record.
local rec = EntityRecords.captureRecord(id, nil)
modules/EntityRecords/carriesInstance
carriesInstance(rid: string, typeName: string, instanceName: string?): boolean
Whether the entity carries the component instance a record entry
names: the instance of typeName under instanceName, or the type's
anonymous instance when instanceName is nil. A loader asks this before
it puts an instance back, so a named instance is never read as already
present because the anonymous one is, and the reverse.
Parameters
ridstring— Runtime entity id.typeNamestring— Component type the entry names.instanceNamestring?(optional) — The entry's instance name, or nil for the anonymous instance.
if not EntityRecords.carriesInstance(id, "Pool", "mana") then entity(id).component.add("Pool", { name = "mana" }) end
modules/EntityRecords/componentIsCodeAttached
componentIsCodeAttached(rid: string, componentType: string): boolean
Whether another component's lifecycle attached this component instance, rather than an author putting it there. A composed asset brings its own machinery with it — a humanoid avatar attaches a character controller to the body it expands into — and that machinery comes back on its own wherever the composition does. A record that named it would put a second one beside the one the expansion just produced, and a rebuild that removed every component its records leave unnamed would tear the expansion off the entity it belongs to. Both sides of a rebuild ask this.
Reached through the _G singleton the origin module publishes, which is
the same answer the scene serializer takes for the same question; a load
order that has not published it yet reads every component as authored.
Parameters
ridstring— Runtime entity id carrying the instance.componentTypestring— Component type name as the entity reports it.
if EntityRecords.componentIsCodeAttached(id, "Humanoid") then continue end
modules/EntityRecords/compose
compose(
Build the flat record array by walking rootId's hierarchy. Skips
temporary entities and their descendants — scaffolding and editor-only
tooling stay out of a baked result. The explicit root is always captured:
the caller named THAT entity as the thing to serialize, so temporary
pruning applies to descendants.
local records = EntityRecords.compose(rootId)
modules/EntityRecords/composeMany
composeMany(
Compose several roots into one flat record array. A build captures a
SET of roots (a builder may spawn several unparented entities), not the
single root a bundle composes from. The roots are ordered the same way
siblings are — by rank, then name, then id.
local records = EntityRecords.composeMany({ idA, idB })
modules/EntityRecords/configuredComponentData
configuredComponentData(ref: any, data: any): any
A live component instance's snapshot limited to the fields its
configuration states (configuredFields). A field the instance leaves to
its declared default is left
out, so whatever is rebuilt from the result takes the component's default
as it stands then, rather than the value it had when this was read.
Parameters
refany(optional) — The live component instance (a component proxy).dataany(optional) — Snapshot of the instance's data.
local ComponentSnapshot = require("@builtin::modules.component_snapshot")
local d = EntityRecords.configuredComponentData(ref, ComponentSnapshot.snapshot(ref))
modules/EntityRecords/configuredFields
configuredFields(ref: any): { [string]: boolean }?
The fields one live component instance's configuration states: the keys of the table it was attached with, and every field written since (through its proxies, or by a replicated or undo write). That is the set a hot reload carries across a source edit; every other field holds the component's declared default, so a record that leaves it out lets a changed default reach the instance. Nil when the engine does not answer, which a caller reads as "every field".
Parameters
refany(optional) — The live component instance (a component proxy).
local set = EntityRecords.configuredFields(entity(id).component("Light"))
modules/EntityRecords/instanceNameOf
instanceNameOf(entry: any): string?
The instance name a component entry of a record states, or nil for the
type's anonymous instance. Every record shape names a component instance
the same way: a scene entity record, a captured entity record and a build
record each carry instance_name beside type on the entry of a named
instance, so an entity carrying several instances of one type comes back
carrying the same several.
Parameters
entryany(optional) — One entry of a record'scomponentslist.
local name = EntityRecords.instanceNameOf({ type = "Pool", instance_name = "mana" }) -- "mana"
modules/EntityRecords/instancesOf
instancesOf(rid: string, typeName: string?): { ComponentInstance }
The { type, instance?, data } records component.getAll answers for the
entity, normalised: instance is nil for the anonymous instance and the
instance's name otherwise. Narrowed to one type when typeName is given.
Parameters
ridstring— Runtime entity id.typeNamestring?(optional) — Component type to narrow to, or nil for every instance.
for _, inst in ipairs(EntityRecords.instancesOf(id, "Pool")) do print(inst.type, inst.instance) end
modules/FontAssetTypeRef/README
require("@builtin::assetTypes.font.behavior") -- FontAssetTypeRef
Hooks for .font assets. onCreate is the type's contribution to the generic asset.create("font", name, opts) flow (mirroring texture.assetType): it parses the font file ONCE into the baked, vectorized glyph format (data.zfnt) — the asset payload. onRegister loads that baked format via the engine font.register(name, zfnt) primitive — a font is a general CPU resource, so one registration makes fontFamily = "<name>" resolve on the egui UI text surface AND on text.* 2D/3D rendering, and feeds font.glyph / font.textMesh for true 3D text.
Usage: local FontAssetTypeRef = require("@builtin::assetTypes.font.behavior")
modules/FontAssetTypeRef/onChange
onChange(self, change)
Install the instance again when a file its registration reads is
written: face.json, data.zfnt, a raw font file, or the font or
coverage file an on-demand entry names. The font is then
selected by the names the descriptor now gives it and no longer by a name
it dropped, on every text surface, and text drawn in it is drawn again.
A folder that arrives whole installs once, unless onRegister already
installed it.
Parameters
selfany(optional) — The.fontinstance's AssetRef.changeany(optional) —{ path, asset, kind, ... }: the written file and how it arrived.
modules/FontAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
The .font type's contribution to asset.create("font", name, opts).
Parses the font file ONCE into the baked vectorized glyph format and stores
it as data.zfnt. The original font bytes are embedded inside the baked
payload, so no separate font file is kept. The heavy parse happens here, at
author time — onRegister then loads the result cheaply.
Parameters
namestring— The font asset name (also the registeredfontFamily).optsCreateOpts
asset.create("font", "Inter", { bytes = fontBytes, ext = "ttf" })
modules/FontAssetTypeRef/onRegister
onRegister(self)
Install this .font instance into the engine's text systems. Reads the
instance's baked data.zfnt and calls font.register(name, zfnt), which
loads the vectorized glyph data into the runtime store (for font.glyph /
font.textMesh) and feeds the embedded font bytes to the 2D text and egui
UI systems. Falls back to a raw font file for instances authored before
the baked layout. An instance whose face.json lists onDemand entries is
declared by their coverage instead (font.declare), and each entry's file
is read the first time text needs a character it covers.
Fired once per instance by the asset system (live on asset.create, and in
the world-load sweep). Guarded so a single bad font never errors the sweep.
Parameters
selfany(optional)
modules/FontAssetTypeRef/payloadReady
payloadReady(path: string): boolean
Whether a .font instance's payload is present to register from: its
baked data.zfnt, or, for an on-demand face, the face.json that lists its
chunks. The builtin boot registration asks this before firing onRegister;
on WASM a builtin leaf arrives asynchronously, so a read that returns nil
answers false and has started the fetch a later call finds landed.
Parameters
pathstring— VFS path of the.fontfolder.
modules/FrameBudget/README
require("@builtin::modules.frame_budget") -- FrameBudget
The share of a frame that cooperative engine work spends before it hands the frame back. Work that runs as a sequence of units on a task (a scene load applying its records, the world-load onRegister sweep) asks due() before each unit and yields once the frame's slice is spent, so a long piece of work runs across frames at the engine's frame rate rather than holding one frame for its whole length. One slice per frame is shared by every caller in the VM: what each caller runs between its readings of the slice in a frame (task.runTime, so none of what the rest of the frame runs) is charged to it. A unit is never split, so the first unit of a frame always runs, and a frame holds the slice plus the one unit that crossed it.
Usage: local FrameBudget = require("@builtin::modules.frame_budget")
modules/FrameBudget/due
due(ms: number?): boolean
Whether the caller hands the frame back before its next unit: it runs
on a coroutine that can yield, and this frame's slice has spent ms. Code
that cannot yield is answered false and runs its units in the frame it was
called in.
Parameters
msnumber?(optional) — Milliseconds the slice may spend (defaultFrameBudget.DEFAULT_MS).
if FrameBudget.due() then FrameBudget.wait() end
modules/FrameBudget/mark
mark(into: { [string]: any }?): { [string]: any }
A reading of how long the calling coroutine has run (task.runTime), for ranMs to measure the work it runs
from here: a budget of a caller's own, counted apart from the frame's shared slice. Written into into when given,
a table several pieces of work share by reference. The reading names its coroutine by a token of its own.
Parameters
into{ [string]: any }?(optional) — The table to write the reading into, or nil for a new one.
local mark = FrameBudget.mark() ... if FrameBudget.ranMs(mark) > 5 then FrameBudget.wait() FrameBudget.mark(mark) end
modules/FrameBudget/ranMs
ranMs(mark: { [string]: any }): number
Milliseconds the calling coroutine has run since mark was read on it: none of the time it spent suspended
(waiting on a frame, a read-back, or another coroutine it resumed). 0 when the mark was read on another coroutine.
Parameters
mark{ [string]: any }— A reading frommark.
if FrameBudget.ranMs(mark) > 5 then FrameBudget.wait() FrameBudget.mark(mark) end
modules/FrameBudget/remainingMs
remainingMs(ms: number?): number?
Milliseconds this frame's slice has left before due(ms) answers true,
never below zero, for work that bounds a unit by time itself (a native call
told how long it may run). Nil when the caller runs on a coroutine that
cannot yield: it runs its work in the frame it was called in, with no slice
to keep to.
Parameters
msnumber?(optional) — Milliseconds the slice may spend (defaultFrameBudget.DEFAULT_MS).
local left = FrameBudget.remainingMs()
modules/FrameBudget/spent
spent(): number
Milliseconds the budgeted work of the current frame has spent: the time each caller ran between its readings of the slice in this frame, summed over every caller. A caller's first reading in a frame charges nothing.
local ms = FrameBudget.spent()
modules/FrameBudget/sync
sync(fn: () -> ...any): ...any
Run fn without handing the frame back: due() answers false to every caller until it returns, so the work
its callees do between their checkpoints completes inside the call. For a caller whose result must stand when
the call returns. Answers what fn answers.
Parameters
fn() -> ...any— The function to run.
local entry = FrameBudget.sync(function() return effect:entry("burst") end)
modules/FrameBudget/wait
wait()
Hand the frame back: yield to the next frame and open that frame's
slice as the caller resumes, so the unit it runs next is charged to the
slice. A caller that does work of its own around the yield asks due()
and calls this; yield() is the two together.
if FrameBudget.due() then FrameBudget.wait() end
modules/FrameBudget/yield
yield(ms: number?): boolean
Yield to the next frame when due(ms) answers true. Called before each
unit of a long piece of work, so the work spends at most a slice of each
frame it runs across.
Parameters
msnumber?(optional) — Milliseconds the slice may spend (defaultFrameBudget.DEFAULT_MS).
for _, path in ipairs(paths) do FrameBudget.yield() print(vfs.read(path)) end
modules/FrameDriver/README
require("@builtin::modules.frameDriver") -- FrameDriver
A loop a library module runs on its own behalf once per frame, for as long as it has work: the driver behind a system that advances itself without an owner calling update(dt), such as an autoUpdate particle emitter or an effects.play.
The loop is a system task (task.spawnSystem), so it belongs to the
module rather than to whoever happened to be running when the first piece
of work arrived. A one-shot execute, a task scope, a component hook and a
scene entrypoint can each start it, and none of them ending stops it. It
runs while there is work and ends once there is none; the next ensure
starts it again. A loop that ended any other way (cancelled by handle,
halted by the watchdog, or torn down with its VM), whether at its frame
wait or in the middle of a step, is recognised by its task status, and
ensure starts a fresh one in its place.
With gameplayClock = true the loop steps on the gameplay clock: in play,
a frame that arrives while engine.paused is set calls nothing, and the
next frame after the pause lifts carries on from there. In edit the loop
keeps stepping, because there it is the editor's authoring preview, the
same standing editorUpdate(dt) has. engine.timeScale reaches the step
through the scheduler, which scales the delta task.wait() reports.
Usage: local FrameDriver = require("@builtin::modules.frameDriver")
modules/FrameDriver/gameplayClockRunning
gameplayClockRunning(): boolean
Whether the gameplay clock is running: false only in a play session that is paused. Edit mode reads as paused and still answers true, since a self-driven system there is the editor's preview.
if FrameDriver.gameplayClockRunning() then sys:update(dt) end
modules/FrameDriver/new
new(opts: Options): Driver
Make a driver. It starts on the first ensure and runs while hasWork
answers true.
Parameters
optsOptions—{ name, hasWork, step, gameplayClock?, maxStep? }, seeOptions.
local driver = FrameDriver.new({ name = "ripples", hasWork = function() return #live > 0 end, step = advanceAll, gameplayClock = true })
modules/FrameShape/README
require("@builtin::tests.fixtures.frame_shape") -- FrameShape
The shape of the frame the viewport draws, for a suite whose fixture or whose reading depends on it: the width over the height of the scene rect, the extent the frame covers at a distance, whether the frame was drawn at the scene rect's shape yet, and a scene rect drawn at a chosen shape for as long as a case needs it. The frame is the rect the engine draws the scene into: the headless framebuffer a native engine was started at, the browser window on the web, and whatever the editor's panels leave of either. A case written for one of those shapes and read on another reads a different part of the scene.
Usage: local FrameShape = require("@builtin::tests.fixtures.frame_shape")
modules/FrameShape/aspectOf
aspectOf(w: number, h: number): number
The width over the height of a rect of pixels.
Parameters
wnumber— The rect's width.hnumber— The rect's height.
local aspect = FrameShape.aspectOf(1920, 1080)
modules/FrameShape/frameHalfExtent
frameHalfExtent(distance: number): (number, number)
The half width and half height of the rectangle the viewport's frame
covers distance in front of the camera drawing it. Read off the frame as
it was drawn, so a fixture sized from it fills the frame whatever shape an
editor layout gives the scene rect.
Parameters
distancenumber— How far in front of the camera, in metres.
local halfW, halfH = FrameShape.frameHalfExtent(5)
modules/FrameShape/frameMatchesSceneRect
frameMatchesSceneRect(cameraId: string?): boolean
Whether the viewport's frame was drawn at the shape of the scene rect the engine reports now. A resize reaches the camera's frame a frame after the surface, and a fixture sized or a tile worked out off the frame before it would be for a shape that is gone.
Parameters
cameraIdstring?(optional) — The camera whose frame to read; the viewport camera when nil.
while not FrameShape.frameMatchesSceneRect() do task.wait() end
modules/FrameShape/widenTheSceneRect
widenTheSceneRect(aspect: number?): () -> ()
Draw the scene rect aspect times wider than it is tall, by changing
the surface's height and keeping its width. The panels an editor layout
puts under or over the scene take a share of that height, so the height
that gives the shape is found by measuring: each step resizes the surface,
reads the scene rect the layout drew at that size, and aims the next step
along the line through the two latest readings. The shape is asserted,
to within a tenth of aspect either way, rather than assumed, so a host
that keeps the size it has, or cannot draw the scene rect at that shape,
fails the case instead of running it at another shape. Call it from inside
a test: it registers a cleanup that puts the surface back, without
waiting, for a case that ends early.
Parameters
aspectnumber?(optional) — The width over the height to reach;WIDE_ASPECTwhen nil.
Returns () — What puts the surface back and waits for the host to realize it, for the case to call at its end so the frames that do it are drawn under that case rather than under whatever runs next.
local putBack = FrameShape.widenTheSceneRect(); --[[ … ]] putBack()
modules/FxFrameProbe/README
require("@builtin::tests.fixtures.fx_probe") -- FxFrameProbe
The reader half of the frame probe — the grid fx_frame_probe.renderFeature writes each frame, and the measurements taken off it. A suite requires this module and enables the feature; the feature records the target it writes here, so both halves address one target. They are separate assets because renderer.feature.create compiles a feature's init.luau as its own chunk rather than requiring it, so a feature cannot publish state to a caller through its own module table. What it is for: a returned screenshot is not evidence. A fully transparent emitter reports live particles, reports that it drew, and changes the image hash. A reader needs a magnitude, taken from the frame a viewer actually sees, that a known control is shown to move.
Usage: local FxFrameProbe = require("@builtin::tests.fixtures.fx_probe")
modules/FxFrameProbe/channelSums
channelSums(grid: { [string]: any }?): { [string]: number }
Sum each colour channel over the grid — how much red, green and blue the frame carries. What a colour parameter has to move.
Parameters
grid{ [string]: any }?(optional) — A grid fromread().
local c = probe.channelSums(probe.read())
modules/FxFrameProbe/faceTiles
faceTiles(
The tiles the middle fifth of a flat face is drawn in: a six by six grid of points over that fifth, each turned into the tile it lands in. The middle rather than the whole, because a tile is a downsample of many pixels and one straddling the face's silhouette carries the background with it.
local tiles, off = probe.faceTiles(view, { -4, 40.25, -4 }, { 8, 0, 0 }, { 0, 0, 8 })
modules/FxFrameProbe/litRegion
litRegion(grid: { [string]: any }?, baseline: { [string]: any }?, threshold: number): { [string]: number }
The size of the lit region: how many tiles rise threshold luminance
above baseline's same tile, and the radius of a disc with that area, in
tiles. This is the spatial reading — how WIDE something drew, which no
whole-frame number can answer.
Parameters
grid{ [string]: any }?(optional) — The grid to measure.baseline{ [string]: any }?(optional) — The grid of the same view with the subject absent.thresholdnumber— How far above the baseline tile a tile must rise to count.
local r = probe.litRegion(after, before, 6).radius
modules/FxFrameProbe/movedTiles
movedTiles(grid: { [string]: any }?, other: { [string]: any }?, threshold: number): number
How many tiles differ between two grids by at least threshold
luminance, in either direction. Zero says the two readings are the same
picture — which is what a reading that has not caught up with a change yet
also answers, so this is how a caller tells a still frame from one that has
not arrived.
Parameters
grid{ [string]: any }?(optional) — The grid to measure.other{ [string]: any }?(optional) — The grid to measure it against.thresholdnumber— How far a tile must differ to count.
if probe.movedTiles(now, before, 4) > 0 then --[[ the change landed ]] end
modules/FxFrameProbe/read
read(): { [string]: any }?
Read the last grid the probe wrote. Returns
{ width, height, tiles }, where tiles[y * width + x + 1] is that tile's
mean colour as { r, g, b } in 0..255, plus lum — the tile's luminance
on the same scale.
local grid = probe.read(); print(grid.tiles[1].lum)
modules/FxFrameProbe/rowOf
rowOf(tile: number): number
The row of the grid a tile from tileAt sits in, counted from 0 at
the top of the frame.
Parameters
tilenumber— A 1-based tile index.
local row = probe.rowOf(tile)
modules/FxFrameProbe/skyTiles
skyTiles(view: { [string]: any }, toward: { number }): ({ number }, number)
The tiles of the rows above the horizon, which is where sky is drawn
whatever shape the frame is. The horizon is the row a point level with the
camera is drawn in, as far along the ground direction toward toward as
the lens resolves; the row is read off the view's projection whether or
not that point falls inside the frame's columns. The row just above it and
the frame's top row are left out, so no tile read reaches the ground or
the frame's edge.
Parameters
view{ [string]: any }— A view fromcamera.viewData(id): itspositionis the eye.toward{ number }— A world point{ x, y, z }the camera looks toward; only its x and z are read.
local sky, horizonRow = probe.skyTiles(view, { 0, 40, 0 })
modules/FxFrameProbe/sphereTiles
sphereTiles(
The tiles the inner part of a sphere is drawn in: every tile whose
whole rect lies inside the sphere's outline drawn inner of the way out
from its middle. The outline is the circle along which a line from the
eye grazes the sphere, projected through the view the frame was drawn
under, so the tiles follow the sphere at whatever shape the frame is.
Whole tiles, and inside a margin, because a tile is a downsample of many
pixels and one straddling the silhouette carries the background with it.
local tiles, off = probe.sphereTiles(camera.viewData(cam.id), { -3.5, 0, 0 }, 1.5)
modules/FxFrameProbe/tileAt
tileAt(view: { [string]: any }, x: number, y: number, z: number): number?
The tile a world point is drawn in, worked out from the view the frame was drawn under. The grid covers the whole frame whatever shape the frame is, so a tile written down as a constant lands on a different part of the scene at every other shape; a tile worked out from the view lands on the point at every shape.
Parameters
view{ [string]: any }— A view fromcamera.viewData(id): itsviewProjis the matrix the frame was drawn with.xnumber— World x of the point.ynumber— World y of the point.znumber— World z of the point.
local tile = probe.tileAt(camera.viewData(cam.id), 0, 1, 0)
modules/FxFrameProbe/tilesColour
tilesColour(grid: { [string]: any }, tiles: { number }): { r: number, g: number, b: number, lum: number }
The mean colour of a set of tiles in a grid.
Parameters
grid{ [string]: any }— A grid fromread().tiles{ number }— 1-based tile indices, astileAt,faceTiles,sphereTilesandskyTileshand them back.
local c = probe.tilesColour(probe.read(), tiles)
modules/FxFrameProbe/tilesLuminance
tilesLuminance(grid: { [string]: any }, tiles: { number }): number
The mean luminance of a set of tiles in a grid.
Parameters
grid{ [string]: any }— A grid fromread().tiles{ number }— 1-based tile indices, astileAt,faceTiles,sphereTilesandskyTileshand them back.
local lum = probe.tilesLuminance(probe.read(), tiles)
modules/FxFrameProbe/totalLuminance
totalLuminance(grid: { [string]: any }?): number
Sum the grid's luminance — the whole frame's brightness as one number.
Parameters
grid{ [string]: any }?(optional) — A grid fromread().
local before = probe.totalLuminance(probe.read())
modules/GI.Scenarios/README
require("@builtin::systems.globalIllumination.scenarios") -- GI.Scenarios
Several baked lighting states per probe volume, blended at runtime.
A volume holds one bake, so a scene lit for noon cannot become a scene lit for dusk without baking again — which takes far longer than a transition is allowed to. Capturing each bake under a name and blending the captures turns that into an interpolation the frame can afford. Irradiance adds, so blending the spherical-harmonic coefficients is the same as blending the light that produced them. Each coefficient's fourth lane is not light, though: it carries the probe's per-axis visibility reach and the markers the sampler reads. Those describe the geometry the volume sits in, which every scenario shares, so they are carried from the heaviest-weighted scenario rather than averaged — the mean of two distances describes no wall that exists. Carrying them from the heaviest contributor also makes the ends of a transition exact: a blend that names one scenario at full weight reproduces that scenario's field lane for lane.
Usage: local GI.Scenarios = require("@builtin::systems.globalIllumination.scenarios")
modules/GI.Scenarios/blend
blend(volumeEntityId: string, weights: { [string]: number }) -> boolean
Publish the weighted mix of named scenarios to the renderer.
Parameters
volumeEntityIdstringweights{ [string]: number }
Returns boolean
modules/GI.Scenarios/capture
capture(volumeEntityId: string, name: string) -> number
Store the volume's currently published field under a name. Returns how many probes it holds.
Parameters
volumeEntityIdstringnamestring
Returns number
modules/GI.Scenarios/clear
clear(volumeEntityId: string)
Parameters
volumeEntityIdstring
modules/GI.Scenarios/field
field(volumeEntityId: string, name: string) -> { number }?
Parameters
volumeEntityIdstringnamestring
Returns { number }?
modules/GI.Scenarios/forget
forget(volumeEntityId: string, name: string)
Parameters
volumeEntityIdstringnamestring
modules/GI.Scenarios/list
list(volumeEntityId: string) -> { string }
Parameters
volumeEntityIdstring
Returns { string }
modules/GI.Scenarios/mix
mix(fields: { { number } }, weights: { number }) -> { number }
Blend baked SH fields by weight. Pure — no volume, no GPU.
Parameters
fields{ { number } }weights{ number }
Returns { number }
modules/GI.Scenarios/stats
stats() -> table
Returns table
modules/GI.SkyResponse/README
require("@builtin::systems.globalIllumination.skyResponse") -- GI.SkyResponse
A probe volume's sky term, evaluated at publish time instead of baked in.
A probe bake follows each path until it escapes, and what escapes carries
the sky's colour. Baking that in means the sky is fixed the moment the
bake finishes: a scene cannot dim its sky for dusk, or clear an overcast,
without paying for the bake again.
The sky enters the path integral as throughput * sky at the point a ray
escapes, and throughput — the product of the albedos the path already
passed through — does not depend on the sky at all. So the baked field
splits exactly into a term that has nothing to do with the sky and a term
that is linear in it, per channel:
field(sky) = lights + sky * aperture
lights is a bake under no sky. aperture is what a unit sky adds: how
much of it each probe can see, tinted by whatever the light passed through
on the way, so sky arriving through a red wall stays red.
Both come from real bakes at the same settings, and the bake seeds its
paths from the probe and sample index alone — so the two runs trace the
same paths and the subtraction that isolates the aperture carries no
sampling residual.
Usage: local GI.SkyResponse = require("@builtin::systems.globalIllumination.skyResponse")
modules/GI.SkyResponse/apply
apply(volumeEntityId: string, sky: { number }) -> boolean
Publish the volume's field for a sky colour. No bake.
Parameters
volumeEntityIdstringsky{ number }
Returns boolean
modules/GI.SkyResponse/calibrate
calibrate(volumeEntityId: string) -> table
Bake the volume twice — once with no sky, once with a unit sky — and keep the two terms the split needs.
Parameters
volumeEntityIdstring
Returns table
modules/GI.SkyResponse/calibrated
calibrated(volumeEntityId: string) -> boolean
Parameters
volumeEntityIdstring
Returns boolean
modules/GI.SkyResponse/clear
clear(volumeEntityId: string)
Parameters
volumeEntityIdstring
modules/GI.SkyResponse/combine
combine(lights: { number }, aperture: { number }, sky: { number }) -> { number }
The field for a sky colour, from the two calibrated terms. Pure.
Parameters
lights{ number }aperture{ number }sky{ number }
Returns { number }
modules/GI.SkyResponse/terms
terms(volumeEntityId: string) -> table?
Parameters
volumeEntityIdstring
Returns table?
modules/GaussianSplatAssetTypeBehavior/README
require("@builtin::assetTypes.gaussianSplat.behavior") -- GaussianSplatAssetTypeBehavior
Behaviour for the gaussianSplat asset type — how a capture becomes something standing in a scene. A cloud draws through a GaussianSplat component pointed at the container, so :instantiate() — the uniform contract every consumer reaches — spawns exactly that, in the axis convention the container recorded.
Usage: local GaussianSplatAssetTypeBehavior = require("@builtin::assetTypes.gaussianSplat.behavior")
modules/GaussianSplatAssetTypeBehavior/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Instantiate this capture — spawn an entity drawing the cloud, in the
axis convention the container recorded. The same name a bundle and an
avatar answer to, so an asset goes into a scene the same way whatever
kind it is.
Passing a target entityRef spawns the cloud as that entity's CHILD, so
an owner that tears down its children takes the cloud with it. With no
target the cloud is a fresh root.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional owningEntityRef— the cloud spawns as its child.opts{ [string]: any }?(optional) —{ position?, rotation?, scale?, name?, temporary? }— the base placement opts;temporarykeeps the spawn out of the saved scene.
local root = asset.resolve("room", "gaussianSplat"):instantiate()
local root = captureRef:instantiate(entity.spawn("mount"))
modules/GeneratorInspector/README
require("@builtin::systems.procgen.generator_inspector") -- GeneratorInspector
The Generator component's card on an entity. It replaces the card's generic settings section with one built from the bound graph: the graph it runs, as an asset picker, and which of its outputs it realizes; then groups — INPUTS, one row per input the graph declares in the control its declared type takes, each able to take an expression over the graph's own time in its place; TIMELINE, the transport, a scrubber across the range, the range itself, the frame rate, looping and wall time; COOK, what is cooking, what cooking has cost and the frame budget — and the Flatten action.
Usage: local GeneratorInspector = require("@builtin::systems.procgen.generator_inspector")
modules/GeneratorInspector/buildFieldSpecs
buildFieldSpecs(graph: any, params: { [string]: any }?): { FieldSpec }
Build the editable field descriptors for a graph: one spec per declared graph input, sorted by name, carrying the input's kind, its current value (the param override when set, else the declared default), the declared min/max range, the asset kind a reference input picks from, and whether the value changes over the graph's time. Pure — no UI, no entity access — so the field mapping is testable headless.
Parameters
graphany(optional) — A loaded proc graph (proc.load).params{ [string]: any }?(optional) — The component's current param-override table (may be nil).
modules/GuideAssetTypeRef/README
require("@builtin::assetTypes.guide.behavior") -- GuideAssetTypeRef
Per-instance methods exposed on every AssetRef<guide>. Loaded lazily by assetType.shared.ref.
Usage: local GuideAssetTypeRef = require("@builtin::assetTypes.guide.behavior")
modules/GuideAssetTypeRef/getGuide
getGuide(self): string?
Read the guide's guide.md body.
Parameters
selfany(optional)
local md = guideRef:getGuide()
modules/GuideAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { headings, wordCount },
parsed from this guide's own guide.md. A guide with no readable
guide.md returns an empty headings list and zero wordCount
rather than erroring.
Parameters
selfany(optional)
local headings = asset.inspect(guideRef).detail.headings
modules/ImporterAssetTypeRef/README
require("@builtin::assetTypes.importer.behavior") -- ImporterAssetTypeRef
Per-instance methods exposed on every AssetRef<importer>. Loaded lazily by assetType.shared.ref.
Usage: local ImporterAssetTypeRef = require("@builtin::assetTypes.importer.behavior")
modules/ImporterAssetTypeRef/getInitScript
getInitScript(self): string?
Read the importer's entry script as raw text.
Parameters
selfany(optional)
local src = importerRef:getInitScript()
modules/ImporterAssetTypeRef/getReadme
getReadme(self): string?
Read the importer's README.
Parameters
selfany(optional)
print(importerRef:getReadme())
modules/ImporterAssetTypeRef/run
run(self, payload: any): any
Invoke the importer with a payload (e.g. a path to the file to import). Loads the importer module on demand and calls its primary exported function. Raises a Luau error tagged with the importer's identity on load failure / missing entry.
Parameters
selfany(optional)payloadany(optional) — Argument forwarded verbatim to the importer entry.
importerRef:run("/zero/source/foo.glb")
modules/ImporterShared/README
require("@builtin::assetTypes.importer.shared") -- ImporterShared
The importer SYSTEM — shared by every .importer/ instance. Owns dispatch, origin-gating, content-gating, the asset.containing bundle skip, re-entrancy, output marking, and bundle relocation. The engine emits one generic "a source path was written" signal per write (onLooseWrite); this module decides whether any registered importer should claim it and runs the winner. Individual importers implement ONLY canImport(path, bytes) + import(ctx) — never trigger logic.
Usage: local ImporterShared = require("@builtin::assetTypes.importer.shared")
modules/ImporterShared/awaitJob
awaitJob(path: string, timeoutSecs: number?): ImportJob?
Wait until the latest job for path settles: a terminal state
(imported / failed / unclaimed / skipped / cancelled), or "owed", which
holds until play ends or the live session re-establishes (reason says
which) and so is returned at once rather than waited out.
The in-flight "queued" and "running" are waited through, until the
timeout elapses. Returns the job (nil when no job exists for the path at
all).
Parameters
pathstring— The source VFS path.timeoutSecsnumber?(optional) — Max seconds to wait (default 30).
modules/ImporterShared/cancelAllQueued
cancelAllQueued(): number
Cancel EVERY queued source that hasn't started importing yet, and every owed import, held until play ends or until the live session re-establishes (in-flight imports are left to finish). Use it to abandon a large accidental drop.
modules/ImporterShared/cancelQueued
cancelQueued(path: string): boolean
Cancel a source before it imports: a QUEUED one is dropped from the pump's queue, an OWED one (waiting for play to end or for the live session to re-establish) is dropped from the owed set, and its job settles as "cancelled". A source already importing is mid-parse and can't be unwound cleanly, so it is left to finish: returns false for a path that is already running, terminal, or was never queued or owed.
Parameters
pathstring— The queued or owed source VFS path.
modules/ImporterShared/explain
explain(path: string): { [string]: any }
Dry-run the dispatch gates for a path WITHOUT importing: does the file exist, which importers claim it, and which gate (if any) would stop an import right now. The answer to "I wrote this file and nothing happened".
Parameters
pathstring— The source VFS path.
modules/ImporterShared/extensionsOf
extensionsOf(ref: any): { string }?
The file extensions ref's importer declares it claims (M.extensions
in its init.luau), lower-case without the dot; nil when it declares none.
Parameters
refany(optional) — The importer asset.
local exts = ImporterShared.extensionsOf(asset.resolve("@builtin::importers.texture"))
modules/ImporterShared/importedAssets
importedAssets(): { { [string]: any } }
Every asset in the world carrying import provenance, newest at first.
Each row: { asset (path), importer (guid), source ({guid,path}), iteration, at }. Backed by the asset.list presence filter — one cross-type query.
modules/ImporterShared/job
job(path: string): ImportJob?
The latest import job recorded for an exact source path, or nil when no dispatch has reached a claimant for it.
Parameters
pathstring— The source VFS path.
modules/ImporterShared/jobs
jobs(filter: { state: string?, path: string?, limit: number? }?): { ImportJob }
Recent import jobs, newest first. Pass a filter to narrow: state
keeps one state, path substring-matches the source path, limit caps
the count (default 25).
Parameters
filter{ state: string?, path: string?, limit: number? }?(optional) — Optional{ state?: string, path?: string, limit?: number }.
modules/ImporterShared/jobsVersion
jobsVersion(): number
A number that moves each time an import job is recorded or its state changes: fold it into a signature to rebuild what lists the jobs.
parts[#parts + 1] = tostring(ImporterShared.jobsVersion())
modules/ImporterShared/listImporters
listImporters(): { { name: string, identity: string } }
Every registered importer: { name, identity } per .importer asset.
modules/ImporterShared/onAssetWrite
onAssetWrite(assetPath: string, path: string, origin: string?): string?
Engine-driven (through the asset-type change dispatcher): a file inside a
typed asset was written. When that asset's import record names the file as
the source the asset was imported from, the importers run again on it,
regenerating the asset in place. The record is the whole link: it follows
the source through a rename (by guid), and nothing else is watched. A write
of the same bytes under the same importer settings is skipped, and a write
made on a peer is left to that peer.
Parameters
assetPathstring— The typed asset the written file is inside.pathstring— The written file.originstring?(optional) — "local" for a write made on this client, "remote" for a peer's.
modules/ImporterShared/onLooseWrite
onLooseWrite(path: string, origin: string?)
Engine-driven: a source path with no enclosing typed-asset folder was written. Gate on origin + re-entrancy, then ENQUEUE it on the bounded import queue (default concurrency 1) — the pump reads the bytes, decides whether a registered importer claims it, applies the content + containment gates, and runs the winner, one import at a time.
Parameters
pathstring— The written VFS path.originstring?(optional) — "local" for a write made on this client, "remote" for a peer-synced write. Only "local" writes trigger — peers receive the originator's derived bundle as ordinary synced content.
modules/ImporterShared/queue
queue(): { ImportJob }
The live import backlog: queued sources (still waiting behind the
concurrency cap, in FIFO order), then the ones importing right now, then
the owed ones, held until play ends or the live session re-establishes
(sorted by path). The focused "what is the
importer doing this instant" view, distinct from jobs (the full
recent-dispatch log including terminal states).
modules/ImporterShared/reimportAsset
reimportAsset(assetPath: string): string?
Reimport a produced asset in place: resolve its source and re-run the importers on it (the containment gate regenerates the container's derived assets from the retained source). Returns the produced path, or nil when no source could be resolved.
Parameters
assetPathstring— The produced asset's path.
modules/ImporterShared/resolveImportSource
resolveImportSource(assetPath: string): string?
Resolve the source file a produced asset was imported from. Prefers the provenance source guid (survives rename/move), falls back to the recorded path, then to scanning the container for an importer-claimed file.
Parameters
assetPathstring— The produced asset's path (e.g. a.bundle).
modules/ImporterShared/runImporter
runImporter(importer: any, path: string): string?
Run ONE importer on path now and return the produced asset path, or
nil when that importer does not claim the file. runImporters hands a
source to the first claimant that takes it; this names the importer, for
a source two importers both claim or an importer being tried out. The
import runs exactly as a dispatched one does — synchronously, in the
calling task, with the importer's own settings as ctx.settings — and is
recorded as a job.
Parameters
importerany(optional) — The importer: an AssetRef, or its name or identity. pathstring— The raw source VFS path to import.
local out = Importers.runImporter("texture", "/zero/source/hero.png")
modules/ImporterShared/runImporters
runImporters(
Run the importers on path NOW and return the produced asset path
(a .bundle / .texture / .audio / …), or nil if no importer claims it.
The manual, deterministic counterpart to the engine's loose-write dispatch:
forced (no origin, content, or containment gate) and synchronous — it runs
in the calling task and returns only when the import is complete, so a
caller can write a raw source quietly (vfs.write(path, bytes, { quiet = true })) and then import it deterministically instead of racing the
watcher. A source that already lives inside its own output container
re-imports in place, regenerating the container's derived assets from the
retained source. While play runs and holds a source that predates it
where it stands (vfs.playHoldsInPlace), a fresh import of it is owed:
this returns nil, the job (M.job(path)) reads "owed" with reason
"play-lock", and the import runs when play ends or pauses. While the live
session is lost (vfs.sessionLost), and when a drop refuses a write the
import makes, the import is owed with reason "session-lost" the same way,
and runs when the session re-establishes.
modules/ImporterShared/runTargets
runTargets(target: any, opts: { recursive: boolean?, mode: string? }?): { [string]: any }
Import/reimport one target, an array of targets, or a folder. A produced
asset (with provenance) reimports in place; a loose source imports; a folder
is scanned (recursive by default) and its imported assets reimported + loose
sources imported, filtered by opts.mode ("all" | "new" | "existing").
Parameters
targetany(optional) — A VFS path string or an array of path strings.opts{ recursive: boolean?, mode: string? }?(optional) —{ recursive?: boolean (default true), mode?: "all"|"new"|"existing" }.
modules/ImporterShared/stats
stats(): { queued: number, running: number, owed: number, states: { [string]: number } }
Live queue counters: queued (sources waiting on the pump — the
authoritative backlog depth), running (imports in flight), owed
(imports held back until play ends, because the running play session
holds their source where it stands, or until the lost live session
re-establishes), and states (every recorded job tallied
by state). queued, running and owed are exact; states tallies the
job registry, which keeps every in-flight job plus the most recent
settled records.
modules/ImporterShared/writeOutcome
writeOutcome(path: string, sinceFrame: number?, timeoutSecs: number?): WriteOutcome?
Where the bytes a write put at path end up. A write outside every
typed asset folder is offered to the importers, and one that claims the
bytes may move them into the asset it makes. This waits, up to
timeoutSecs, for the dispatch that write set off to settle, and answers
with its outcome: nil when no importer claims the bytes (they stay at
path), else the import's state, the importer, the asset it made
(output), the file the bytes are in now (source, nil when the import
kept no copy) and a note stating all of it in a sentence. An import still
running when the wait runs out answers queued or running; an import
held back answers owed at once, the bytes staying at path until it
runs: reason "play-lock" when the running play session holds them,
until play ends or pauses, and "session-lost" while the live session is
lost, until it re-establishes; bytes an importer claims that no dispatch reached (a quiet write
fires none) answer not-started, the bytes staying at path.
Parameters
pathstring— The written VFS path, as the engine spells it (/zero/source/...).sinceFramenumber?(optional) — The engine frame (time.frameCount()) read before the write: a settled job recorded forpathbefore it answers for an earlier write.timeoutSecsnumber?(optional) — Max seconds to wait for the import to settle (default 10).
local outcome = ImporterShared.writeOutcome("/zero/source/art/hero.png", time.frameCount() - 1)
modules/ImporterShared/writeOutcomes
writeOutcomes(paths: { string }, sinceFrame: number?, timeoutSecs: number?): { [string]: WriteOutcome }
writeOutcome for several paths written together, such as the files of
one folder transfer, asked once every one of them has landed. One wait
bounds them all: each path is answered as writeOutcome answers it, with
whatever share of timeoutSecs is left when its turn comes, so a path
whose import is still running when the wait runs out answers queued or
running.
Parameters
paths{ string }— The written VFS paths, as the engine spells them (/zero/source/...).sinceFramenumber?(optional) — The engine frame (time.frameCount()) read before the first of the writes.timeoutSecsnumber?(optional) — Max seconds to wait for all of the imports to settle (default 10).
local outcomes = ImporterShared.writeOutcomes({ "/zero/source/art/a.png", "/zero/source/art/b.png" }, since)
modules/InputBindingAssetTypeRef/README
require("@builtin::assetTypes.inputBinding.behavior") -- InputBindingAssetTypeRef
Usage: local InputBindingAssetTypeRef = require("@builtin::assetTypes.inputBinding.behavior")
modules/InputBindingAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("inputBinding", name, opts).
Writes a record carrying every device class, so a binding is complete
the moment it exists.
Parameters
namestringoptsCreateOpts
asset.create("inputBinding", "boost", { label = "Boost", kind = "button", kbm = '{ B.key("ShiftLeft") }', gamepad = '{ B.padButton("left_shoulder") }', touch = '{ B.touchButton({ zone = "right-lower" }) }' })
modules/InputBindingAssetTypeRef/problemsWith
problemsWith(record: any, name: string): { string }
Check a binding record for the things that make it unusable, and return the problems rather than raising, so a tool can report every fault in a map at once instead of stopping at the first.
Parameters
recordany(optional) — The binding record to check.namestring— The binding's name, for the messages.
modules/InputMacroAssetTypeRef/README
require("@builtin::assetTypes.inputMacro.behavior") -- InputMacroAssetTypeRef
Per-instance methods exposed on every AssetRef<inputMacro>. Loaded lazily by assetType.shared.ref.
Usage: local InputMacroAssetTypeRef = require("@builtin::assetTypes.inputMacro.behavior")
modules/InputMacroAssetTypeRef/getEvents
getEvents(self): { any }?
Parse events.json into a Lua table.
Parameters
selfany(optional)
local events = macroRef:getEvents()
modules/InputMacroAssetTypeRef/getEventsRaw
getEventsRaw(self): string?
Read the macro's events.json body as raw JSON text.
Parameters
selfany(optional)
local raw = macroRef:getEventsRaw()
modules/InputMacroAssetTypeRef/length
length(self): number
Number of recorded events.
Parameters
selfany(optional)
print(macroRef:length())
modules/InputMacroAssetTypeRef/replay
replay(self): number
Replay the macro by handing its recorded events to the sim
toolbox's macro tool, which dispatches each timed input event
through the engine input surface. Returns the number of events
queued for replay.
Parameters
selfany(optional)
local n = macroRef:replay()
modules/InputMapAssetTypeRef/README
require("@builtin::assetTypes.inputMap.behavior") -- InputMapAssetTypeRef
Usage: local InputMapAssetTypeRef = require("@builtin::assetTypes.inputMap.behavior")
modules/InputMapAssetTypeRef/activateShape
activateShape(self): (string, string)
The type activate() answers for one map — a field per control it
declares, each a Handle.
Parameters
selfany(optional) — The map.
local text = M.refShapes.activate(mapRef)
modules/InputMapAssetTypeRef/onChange
onChange(self, change)
Re-activate this map after a write inside the instance, so an edit to its bindings takes hold in the running session. Only the map that is currently active is re-activated; a removal is ignored.
Parameters
selfany(optional) — The changed.inputMapasset's reference.changeany(optional) — The change record the asset dispatcher raised for the write.
modules/InputMapAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("inputMap", name, opts).
With opts.record, bakes it into both shapes a map is read in — the
"play it, bake it, tweak it" on-ramp Zin.map.bake drives.
init.luau returns the record's flat actions / axes tables, which
is what Zin.map.materialize reads. Beside it, one
<name>.inputBinding/ child per entry, which is what a controller
subscribes to through activate(). Each child carries all three
device classes, a class the baked map had nothing for written as
false with the reason beside it.
A binding that fails to serialize (an unknown kind, or an
axis/vector composite whose nested arm fails — the whole composite
drops) is dropped from init.luau with an
-- UNSERIALIZED kind: <kind> (<name>) comment line; a
function-valued axis gate / curve is dropped with a
-- <name>.gate omitted / -- <name>.curve omitted comment line.
An entry whose name no asset folder can take, or that lost every
device class, stays in init.luau alone and is named in the header
comment as a control the bake could not make.
With no opts.record, contributes nothing on top of the type's
template/ skeleton.
Parameters
namestringoptsCreateOpts
Zin.map.bake("my_scheme")
modules/InspectorAppLayout/README
require("@builtin::_templates.inspector_app.inspector_app_layout") -- InspectorAppLayout
Property-inspector shell on the raw widget tree — a section header and labelled field rows (text input, slider, checkbox) whose edits update the displayed state.
Usage: local InspectorAppLayout = require("@builtin::_templates.inspector_app.inspector_app_layout")
modules/InspectorProbe/README
require("@builtin::tests.fixtures.inspector_probe") -- InspectorProbe
Helpers the Inspector suites share: walk a published edui tree for its callback ids and label texts, mount an app over a render function, render an asset's Inspector, and build one section of an asset by id.
Usage: local InspectorProbe = require("@builtin::tests.fixtures.inspector_probe")
modules/InspectorProbe/callbackIds
callbackIds(node: any): { string }
Every string-valued callback prop in a published tree, depth first.
Parameters
nodeany(optional) — The tree.
local app, tree = Probe.mount(Test, function() return node end)
local ids = Probe.callbackIds(tree())
modules/InspectorProbe/dropUndoHistoryAtCleanup
dropUndoHistoryAtCleanup(Test: any)
Drop the undo history at the test's cleanup, after every cleanup registered later has run. An edit dispatched through an Inspector app is an undo step on the scratch asset the test removes, so the test ends with nothing to undo or redo. Raises naming the wait when the history is still held once the frame budget runs out.
Parameters
Testany(optional) — The Test API.
Probe.dropUndoHistoryAtCleanup(Test)
modules/InspectorProbe/fact
fact(rows: { any }, label: string): string?
The value a fact row shows beside label: the last text of the first
row whose first text is exactly label.
Parameters
rows{ any }— A section's rows.labelstring— The fact's label.
assert(Probe.fact(rows, "Splats") == "3")
modules/InspectorProbe/hasText
hasText(tree: any, needle: string): boolean
Whether any label text in tree contains needle.
Parameters
treeany(optional) — The tree.needlestring— Plain text to find.
local app, tree = Probe.mount(Test, function() return node end)
assert(Probe.hasText(tree(), "4 × 4"))
modules/InspectorProbe/idEndingWith
idEndingWith(tree: any, suffix: string): string
The callback id in tree ending with suffix; raises naming the ids the tree holds.
Parameters
treeany(optional) — The tree.suffixstring— The id's tail.
app:dispatch(Probe.idEndingWith(tree(), ":act:play"), nil)
modules/InspectorProbe/ids
ids(sections: { any }): string
The ids of sections, space-joined.
Parameters
sections{ any }— Sections.
assert(string.find(Probe.ids(sections), "texture"))
modules/InspectorProbe/mount
mount(Test: any, render: () -> any): (any, () -> any)
Mount an app whose tree is render(). At the test's cleanup the app is
unmounted and then the undo history is dropped (dropUndoHistoryAtCleanup).
Parameters
Testany(optional) — The Test API.render() -> any— Returns the node to publish.
Returns any) — (app, lastTree).
local app, tree = Probe.mount(Test, function() return node end)
modules/InspectorProbe/pngOf
pngOf(size: number, hex: string): string
A solid PNG of size×size pixels.
Parameters
sizenumber— Edge length in pixels.hexstring— Fill colour, e.g. "#336699".
local png = Probe.pngOf(4, "#ff00ff")
modules/InspectorProbe/renderAsset
renderAsset(Test: any, ref: any): (any, () -> any)
Mount the full Inspector for ref (generic plus declared sections).
Parameters
Testany(optional) — The Test API.refany(optional) — The asset.
Returns any) — (app, lastTree).
local app, tree = Probe.renderAsset(Test, texRef)
modules/InspectorProbe/rowsHave
rowsHave(rows: { any }, needle: string): boolean
Whether any row in a section's rows contains needle in a label.
Parameters
rows{ any }— A section's rows.needlestring— Plain text to find.
assert(Probe.rowsHave(rows, "vertices"))
modules/InspectorProbe/rowsHaveExactly
rowsHaveExactly(rows: { any }, text: string): boolean
Whether any label text in a section's rows is exactly text.
Parameters
rows{ any }— A section's rows.textstring— The whole text.
assert(Probe.rowsHaveExactly(rows, "3"))
modules/InspectorProbe/section
section(ref: any, id: string): ({ any }, any)
Build the section id of ref's Inspector. Raises naming the ids
present when id is absent, and the build problem when it fails.
Parameters
refany(optional) — The asset.idstring— The section id.
local rows = Probe.section(texRef, "texture")
modules/InspectorProbe/texts
texts(node: any): { string }
Every label text in a tree, depth first.
Parameters
nodeany(optional) — The tree.
local app, tree = Probe.mount(Test, function() return node end)
local all = Probe.texts(tree())
modules/InspectorProbe/texture
texture(Test: any, stem: string, size: number?, hex: string?, settings: { [string]: any }?): any
A scratch texture of size (default 4) pixels, removed at cleanup.
Parameters
Testany(optional) — The Test API.stemstring— Name stem.sizenumber?(optional) — Edge length (default 4).hexstring?(optional) — Fill (default "#336699").settings{ [string]: any }?(optional) — The texture's settings, where a case needs ones other than the defaults.
local tex = Probe.texture(Test, "sectTex", nil, nil, { compression = "rgba8" })
modules/LightmapDataAssetTypeRef/README
require("@builtin::assetTypes.lightmapData.behavior") -- LightmapDataAssetTypeRef
Per-instance methods on every AssetRef<lightmapData> — the baked-lighting container the bake flow writes and component awakes read. Entries are keyed (lightmaps by entity id, probe fields by field id); each entry pairs a manifest record with a raw f32 payload file inside the container.
Usage: local LightmapDataAssetTypeRef = require("@builtin::assetTypes.lightmapData.behavior")
modules/LightmapDataAssetTypeRef/beginBatch
beginBatch(self)
Hold the manifest open across a run of writes. Each setLightmap /
setProbeField still writes its payload file as it goes, but the manifest
is read once here and written once by commitBatch, instead of being
decoded and re-encoded per entry. A bake storing many entries into one
container is the case this exists for. Re-entrant calls are ignored, and
a batch left open by an error is closed by the next commitBatch.
Parameters
selfany(optional)
container:beginBatch()
for _, s in surfaces do container:setLightmap(s.id, s.meta, s.texels) end
container:commitBatch()
modules/LightmapDataAssetTypeRef/clearEntries
clearEntries(self)
Remove every entry and payload, leaving an empty manifest — the
container-wide teardown baking.clear uses for a full-scene clear.
Parameters
selfany(optional)
container:clearEntries()
modules/LightmapDataAssetTypeRef/commitBatch
commitBatch(self)
Write the manifest a beginBatch has been holding and close the batch.
No-op when no batch is open.
Parameters
selfany(optional)
container:commitBatch()
modules/LightmapDataAssetTypeRef/lightmap
lightmap(self, key: string): (LightmapEntry?, { number }?)
Read one entity's baked lightmap.
Parameters
selfany(optional)keystring— The receiver entity id.
local entry, texels = container:lightmap(entityId)
modules/LightmapDataAssetTypeRef/manifest
manifest(self)
The decoded manifest: { version, lightmaps = { [entityId] = entry }, probeFields = { [fieldId] = entry } }.
Parameters
selfany(optional)
local m = container:manifest()
modules/LightmapDataAssetTypeRef/onCreate
onCreate(name: string, opts: { scene: string? }?)
Create an empty baked-lighting container. The bake flow
(baking.all / Lightmap.bake / VolumeProbe.bake) fills it.
Parameters
namestringopts{ scene: string? }?(optional)
modules/LightmapDataAssetTypeRef/probeField
probeField(self, key: string): (ProbeFieldEntry?, { number }?)
Read one probe volume's baked field.
Parameters
selfany(optional)keystring— The volume's stable field id.
local entry, sh = container:probeField(fieldId)
modules/LightmapDataAssetTypeRef/removeLightmap
removeLightmap(self, key: string)
Remove one entity's lightmap entry and its payload file. No-op when the entry is absent.
Parameters
selfany(optional)keystring— The receiver entity id.
container:removeLightmap(entityId)
modules/LightmapDataAssetTypeRef/removeProbeField
removeProbeField(self, key: string)
Remove one probe volume's field entry and its payload file. No-op when the entry is absent.
Parameters
selfany(optional)keystring— The volume's stable field id.
container:removeProbeField(fieldId)
modules/LightmapDataAssetTypeRef/setLightmap
setLightmap(self, key: string, meta: { [string]: any }, texels: { number })
Store one entity's baked lightmap: writes the texel payload file and its manifest entry, replacing any prior entry under the same key.
Parameters
selfany(optional)keystring— The receiver entity id.meta{ [string]: any }—{ resolution, intensity }— the parameters the runtime needs to rebuild the lightmap and place it in the atlas.texels{ number }— Flat f32 RGBA texel array (resolution² × 4 floats, dilated, alpha = coverage).
container:setLightmap(entityId, { resolution = 256, intensity = 1 }, data)
modules/LightmapDataAssetTypeRef/setProbeField
setProbeField(self, key: string, meta: { [string]: any }, sh: { number })
Store one probe volume's baked field: writes the SH payload file and its manifest entry, replacing any prior entry under the same key.
Parameters
selfany(optional)keystring— The volume's stable field id.meta{ [string]: any }—{ boundsMin = {x,y,z}, boundsMax = {x,y,z}, res = {x,y,z}, count }.sh{ number }— Flat f32 SH L2 array — 36 floats per probe, X-fastest.
container:setProbeField(fieldId, { boundsMin = mn, boundsMax = mx, res = r, count = n }, sh)
modules/LoadingScreenAssetTypeRef/README
require("@builtin::assetTypes.loadingScreen.behavior") -- LoadingScreenAssetTypeRef
Per-instance methods for every AssetRef<loadingScreen>. Loaded lazily by asset_ref.module.
Usage: local LoadingScreenAssetTypeRef = require("@builtin::assetTypes.loadingScreen.behavior")
modules/LoadingScreenAssetTypeRef/isShown
isShown(self): boolean
Whether the world shows this screen while it loads: its settings name
this asset under [world] loading_screen.
Parameters
selfany(optional)
if not screenRef:isShown() then world.loading_screen = screenRef end
modules/LoadingScreenAssetTypeRef/preview
preview(self, seconds: number?): any
Show this loading screen over the whole window exactly as a boot of the
world draws it, for seconds (default 15): its pictures, colours, title,
text and tips, with the progress filling and the tips changing on the
screen's own clock. Capture it while it is up with
capture { source = "window" }. Pass 0 to take a preview down.
Parameters
selfany(optional)secondsnumber?(optional) — How long the preview stays up (default 15; 0 takes it down).
local p = screenRef:preview(20) -- then capture { source = "window" }
modules/LoadingScreenAssetTypeRef/spec
spec(self): any
The screen this asset states, every key it leaves out at the engine's
own look, and the problems that kept a key out. Pictures are paths
relative to /zero/source.
Parameters
selfany(optional)
local read = screenRef:spec(); print(read.spec.title, #read.problems)
modules/LoadingScreenShared/README
require("@builtin::assetTypes.loadingScreen.shared") -- LoadingScreenShared
The rules of a loadingScreen asset: the keys screen.yaml takes, the look a screen states nothing for, how the world's settings name its loading screen, and where each picture a screen names lives in the world. The engine's boot draws from what read answers here, and the type's Inspector and ref:spec() answer from the same rules.
Usage: local LoadingScreenShared = require("@builtin::assetTypes.loadingScreen.shared")
modules/LoadingScreenShared/folderFor
folderFor(identity: any): string?
The source-relative folder of the loadingScreen asset identity
names: a world asset's dotted identity (branding.title is
branding/title.loadingScreen) or a built-in one (@builtin::x.y).
Parameters
identityany(optional) — The identity[world] loading_screenholds.
modules/LoadingScreenShared/identityIn
identityIn(settingsText: any): (string?, string?)
The loading screen a .world_settings text names under
[world] loading_screen.
Parameters
settingsTextany(optional) — The text of.world_settings.
modules/LoadingScreenShared/parse
parse(text: any, folder: string): (Spec, { string })
Read a screen.yaml text into the screen it states, with every key it
leaves out at the default, and the problems that left a key out.
Parameters
textany(optional) — The text ofscreen.yaml.folderstring— The screen's folder relative to/zero/source, which a picture named inside it is relative to.
modules/LoadingScreenShared/read
read(read: (string) -> string?): any
The loading screen a world states, read through read: the settings
name a screen, and its screen.yaml states it.
Parameters
read(string) -> string?— A function taking a path relative to/zero/sourceand answering the file's text, or nil when the world holds none there.
modules/LoadingScreenShared/tipAt
tipAt(spec: Spec, elapsed: number): string?
The text one tip slot shows elapsed seconds into the load.
Parameters
specSpec— A screen fromparse.elapsednumber— Seconds since the screen went up.
modules/MaterialAssetTypeRef/README
require("@builtin::assetTypes.material.behavior") -- MaterialAssetTypeRef
Per-instance methods exposed on every AssetRef<material>. Loaded lazily by assetType.shared.ref via require("@builtin::assetTypes.material.behavior") the first time a material ref is touched in a VM.
Usage: local MaterialAssetTypeRef = require("@builtin::assetTypes.material.behavior")
modules/MaterialAssetTypeRef/applyToEntity
applyToEntity(self, entityId: string): boolean
Apply this material to an entity by setting the material field on its
Model / SkinnedModel component (where the renderer reads it). A material
only renders where there is a mesh.
Parameters
selfany(optional)entityIdstring— Target entity ID.
matRef:applyToEntity(playerId)
modules/MaterialAssetTypeRef/getDefinition
getDefinition(self): string?
Read the on-disk mat.yaml body as raw text. Use
vfs.write(self.path .. "/mat.yaml", ...) to write the file directly,
:setProperty / :setTexture followed by :saveDefinition to write the
current values into it, or :setShader to rewrite it for a new shader.
Parameters
selfany(optional)
local yaml = matRef:getDefinition()
modules/MaterialAssetTypeRef/getShader
getShader(self): string?
Read the shader identity currently bound to this material —
parses mat.yaml and returns the shader: field as a string. The
result is whatever the YAML names (a built-in like "pbr", a
guid, or a full identity like "@builtin::shaders.pbr"); pass it
to asset.resolve(..., "shader") to get a ref.
Parameters
selfany(optional)
local s = matRef:getShader()
modules/MaterialAssetTypeRef/getShaderRef
getShaderRef(self): any?
The shader this material draws with, resolved from its shader: field
read at the material's own path, so a ~ names the nearest root enclosing
the material.
Parameters
selfany(optional)
local props = matRef:getShaderRef():getProperties()
modules/MaterialAssetTypeRef/getTextures
getTextures(self): { [string]: { ref: string, name: string } }
The textures bound to this material's slots: slot name -> { ref, name },
the bound texture's guid and the id the material names it by.
Parameters
selfany(optional)
for slot, t in pairs(matRef:getTextures()) do print(slot, t.name) end
modules/MaterialAssetTypeRef/isRegistered
isRegistered(self): boolean
Whether this material exists as an asset — its mat.yaml is present.
Writing the asset is what registers the material, so file presence IS the
registration check.
Parameters
selfany(optional)
if matRef:isRegistered() then ... end
modules/MaterialAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: (re)register this material into the renderer's
MaterialRegistry whenever its .material is seeded (a baked builtin at boot,
or a world seed) or its mat.yaml is edited. This is the ONLY thing that
populates the registry for a material — the legacy boot-time library loader
(which registered every material by name) is gone; materials register
through their own assetType exactly as shaders do (__shader.compile). Keyed
by guid@checksum, the key a MaterialRef.id wears; an edit files under the
new version's key and moves every wearer onto it. Convergent + idempotent:
see registerToGpu.
Parameters
refany(optional)changeany(optional)
modules/MaterialAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("material", name, opts).
Pure: returns the mat.yaml content for the caller to persist to the
authored destination; the write registers the material definition
(CPU-side) — GPU resources are built later, only on actual use. Properties
resolve from the shader's properties.yaml overlaid by these overrides; no
shader compile happens at create. Flat non-reserved top-level keys on opts
are shader-property overrides (e.g. base_color = {1,0,0,1}, roughness = 0.3), admitted by the open schema and resolved against the shader's
properties.yaml inside the hook.
Parameters
namestring— Material identity (the instance name).optsCreateOpts
asset.create("material", "Gold", { shader = "pbr", base_color = {1, 0.84, 0, 1}, metallic = 1, roughness = 0.2 })
asset.create("material", "Glass", { shader = "pbr", base_color = {0.2, 0.9, 0.4, 0.45}, render = { blend = "alphaBlend", depth_write = false } })
modules/MaterialAssetTypeRef/onDelete
onDelete(ref)
Asset-type delete callback: release the renderer record a removed
.material folder filed. The teardown counterpart of onChange's
registration, so the type owns both halves of its runtime lifecycle the way
.component does. renderer.material.destroy drops the registry entry and the
bind group the renderer prepared under
that key; the module's own caches for the folder go with it. A material
authored afresh at the same path therefore files a new record instead of
inheriting the one the removed material left, and a surface still wearing
the key draws the renderer's fallback until it does.
Parameters
refany(optional)
modules/MaterialAssetTypeRef/previewMaterial
previewMaterial(self): { [string]: any }?
The material a surface preview paints this asset with: the material
itself. ref:preview() paints it on the mesh type.yaml names under
preview:.
Parameters
selfany(optional)
local surface = matRef:previewMaterial()
modules/MaterialAssetTypeRef/saveDefinition
saveDefinition(self): boolean
Persist the material's live runtime overrides into its mat.yaml (the
lazy/explicit flush). Property/texture sets are frame-fast and transient by
default (they live on the ref's runtime, wiped on mode change); call this to
bake the current values into the asset so they survive a restart. Routes
through the mat.yaml write → RegisterMaterial path. The changed values
are written where they already stand in the authored file, so its comments,
the order of its keys and blocks, and the spelling of the literals it was
written with all survive the save.
Parameters
selfany(optional)
matRef:saveDefinition()
modules/MaterialAssetTypeRef/setProperties
setProperties(self, patch: { [string]: any }): number
Set many properties at once, resolving each key against the shader's
vocabulary the way setProperty does. Entries the material's shader doesn't
expose are skipped (a generic patch table won't error on shader differences).
Each entry is judged and recorded the way setProperty judges and records
it, so a refused entry raises and leaves its property as it was.
Parameters
selfany(optional)patch{ [string]: any }— Table of{ [propertyName] = value }pairs.
matRef:setProperties({ roughness = 0.2, metallic = 0.9 })
modules/MaterialAssetTypeRef/setShader
setShader(self, shaderRef: any): (boolean, any)
Switch this material to a different shader by rewriting the material
asset itself (mat.yaml), then letting the asset-reload pipeline mark
every instance dirty so the renderer repacks. The full mat.yaml is
regenerated for the new shader's property vocabulary: current property
values and texture links are carried across by canonical ROLE (via
modules.material_remap), so MAIN_TEX→albedo→base_color_texture
and friends survive the swap to our best ability. Properties the new
shader does not expose are dropped; the name, builtin, parent,
description, and render: block are preserved verbatim. This modifies
the on-disk asset (or, in play mode, its runtime copy) — not a throwaway
registry entry — so the change persists and propagates to all instances.
Parameters
selfany(optional)shaderRefany(optional) — AnAssetRef<shader>(preferred) or a shader-identity string ("pbr","@builtin::shaders.unlit").
matRef:setShader(asset.resolve("@builtin::shaders.unlit", "shader"))
matRef:setShader("pbr")
modules/MaterialAssetTypeRef/writeProperty
writeProperty(self, propertyName: string, value: any): (boolean, string?)
Write one property into the material's mat.yaml — the authored value,
where setProperty is a runtime one. The session's own value for the
property is dropped, so the material reads what the file now holds. Inside
an undo operation the file write is recorded, so undoing the operation
puts the previous file back. A texture-typed name routes to
writeTexture, the way setProperty routes to setTexture.
Parameters
selfany(optional)propertyNamestring— Property name from the material's shader.valueany(optional) — New value (number, bool, or a numeric array for a color/vector).
local ok, why = matRef:writeProperty("roughness", 0.2)
modules/MaterialRemap/README
require("@builtin::modules.material_remap") -- MaterialRemap
Canonical property/texture-role dictionary for cross-shader value preservation. When a material swaps shaders the new shader exposes a DIFFERENT vocabulary (one shader's MAIN_TEX is another's albedo is a third's base_color_texture). This module maps any known alias onto a canonical role so values carry across the swap "to our best ability".
Usage: local MaterialRemap = require("@builtin::modules.material_remap")
modules/MaterialRemap/canonicalizeTextures
canonicalizeTextures(
Canonicalize texture-slot names so links survive a shader swap. Each known slot is rewritten to its canonical on-disk slot name; unknown slots pass through unchanged. (The engine does not yet expose a target shader's reflected texture-slot list, so canonicalizing to the builtin convention is the best-effort path — see material_remap module header.)
modules/MaterialRemap/propertyRole
propertyRole(name: string): string?
Canonical role for a scalar/color property name, or nil when unknown.
Parameters
namestring— Property name as it appears in a shader / mat.yaml.
material_remap.propertyRole("MAIN_COLOR") -- "base_color"
modules/MaterialRemap/remapProperties
remapProperties(
Remap a table of old property values onto a target shader's accepted property names. Direct name matches win; otherwise the old key's canonical role is matched against the role of each target name. Values whose role the target shader does not expose are dropped (best-effort preservation).
modules/MaterialRemap/roleShapePair
roleShapePair(role: string): ({ colour: string, scalar: string })?
The colour+scalar role pair a role belongs to, as { colour, scalar },
or nil when the role stands alone. Both halves answer with the same pair,
so a caller holding either one can ask which value shape belongs where.
Parameters
rolestring— A canonical role frompropertyRole.
material_remap.roleShapePair("emissive") -- { colour = "emissive", scalar = "emissive_intensity" }
modules/MaterialRemap/textureRole
textureRole(slot: string): string?
Canonical texture-slot role (and on-disk slot name) for a texture slot name, or nil when unknown.
Parameters
slotstring— Texture slot name as it appears in a shader / mat.yaml.
material_remap.textureRole("MAIN_TEX") -- "base_color_texture"
modules/MaterialSchema/README
require("@builtin::modules.material_schema") -- MaterialSchema
A shader's declared property vocabulary, and the routing of an authored key onto it. Every path that accepts material properties — the .material assetType and renderer.material.create — resolves the backing shader's properties.yaml through here, so the two agree on which keys are real, which are texture slots, and what to say about a key that is neither.
Usage: local MaterialSchema = require("@builtin::modules.material_schema")
modules/MaterialSchema/acceptsSlot
acceptsSlot(schema: Schema, slot: string): boolean
Whether a texture bound under slot reaches the bind group a schema
describes: true for a slot the shader declares, and true for every slot
while the schema holds no names at all (a shader whose vocabulary has not
been read yet, which every write stays permissive about).
Parameters
schemaSchema— ASchemafromforShader.slotstring— The texture slot name.
if not MaterialSchema.acceptsSlot(schema, "base_color") then print("not a slot") end
modules/MaterialSchema/declaredNames
declaredNames(schema: Schema): { string }
Every name a schema declares, sorted — properties and texture slots.
Parameters
schemaSchema— ASchemafromforShader.
local names = MaterialSchema.declaredNames(schema)
modules/MaterialSchema/declaredNamesList
declaredNamesList(schema: Schema): string
Comma-joined declared names, for the "not declared" diagnostic so the author sees exactly which keys the shader accepts.
Parameters
schemaSchema— ASchemafromforShader.
warn("declared: " .. MaterialSchema.declaredNamesList(schema))
modules/MaterialSchema/declaredSlotsList
declaredSlotsList(schema: Schema): string
Comma-joined texture slot names a schema declares, sorted, for the diagnostic on a binding to a slot the shader does not declare.
Parameters
schemaSchema— ASchemafromforShader.
warn("texture slots: " .. MaterialSchema.declaredSlotsList(schema))
modules/MaterialSchema/displacedMessage
displacedMessage(name: string, key: string, declared: string): string
The diagnostic for an authored key whose value another spelling of the same declared property took precedence over.
Parameters
namestring— The material's name or registry key.keystring— The authored key whose value did not apply.declaredstring— The declared property that took its value from another spelling.
warn(MaterialSchema.displacedMessage(name, "emissive_color", "emissive"))
modules/MaterialSchema/forShader
forShader(shader: string): Schema?
The declared vocabulary of the shader backing a material, split into
uniform properties and texture slots. Read from the shader assetType's
getProperties() (its properties.yaml).
Parameters
shaderstring— Shader identity, path, or short name ("pbr").
local s = MaterialSchema.forShader("pbr")
modules/MaterialSchema/isTextureSlotType
isTextureSlotType(kind: any): boolean
Whether a declared property type is a texture slot: texture (a 2D
texture) and texture_array (a 2D texture array, one binding holding every
layer) both bind through the material's textures.
Parameters
kindany(optional) — Thetypeaproperties.yamlentry declares.
MaterialSchema.isTextureSlotType("texture_array") -- true
modules/MaterialSchema/isTextureValue
isTextureValue(value: any): boolean
Whether a value is a texture binding rather than a scalar/vector.
A renderer.texture handle (kind == "TextureHandle") or any
AssetRef<texture> envelope. Scalar/vector values are bare numbers or
numeric arrays, so this never misfires on a colour like {1, 0, 0, 1}.
Parameters
valueany(optional) — The authored value.
MaterialSchema.isTextureValue(tex) -- true
modules/MaterialSchema/roleIndex
roleIndex(props: { [string]: boolean }): { [string]: string }
The role index for a set of declared property names: canonical role ->
the single declared name claiming it. A role two declared names both claim
is left out, so an authored spelling never resolves to an arbitrary one of
them. This is what turns emissive_color into the emissive a shader
declares, and ao_strength into its occlusion_strength.
Parameters
props{ [string]: boolean }— Declared property names, as a{ [name]: true }set.
local byRole = MaterialSchema.roleIndex({ emissive = true })
modules/MaterialSchema/route
route(schema: Schema, key: string, value: any): (Route, string)
Resolve an authored key against a schema: which surface it belongs to and under what name. Routes by the schema's texture slots and by the value's own shape (a texture value is a texture binding whatever the key is called), then by canonical role — so a spelling from another engine's convention reaches the property this shader declares for that role, under the name the shader declares it by.
Parameters
schemaSchema— ASchemafromforShader.keystring— The authored key.valueany(optional) — The authored value.
local route, name = MaterialSchema.route(schema, "color", {1,0,0,1})
modules/MaterialSchema/routeAll
routeAll(schema: Schema, authored: { [string]: any }): (
Route a whole authored property table at once, so two spellings that resolve to one declared property are settled the same way everywhere.
Parameters
schemaSchema— ASchemafromforShader.authored{ [string]: any }—{ [key] = value }as written by the author.
local props, tex, unknown = MaterialSchema.routeAll(schema, parsed)
modules/MaterialSchema/settle
settle(schema: Schema, claimed: { Claim }): (
Settle the authored values that resolved onto declared properties, so
every path that accepts material properties answers the same way. One
declared name takes one value — the spelling the shader declares verbatim,
else the first in key order, so the outcome is the authored table's rather
than the order pairs walked it in. Two spellings meeting on one half of a
colour+scalar pair the shader declares both halves of are not competing: a
number is the scalar and a vector is the colour, the reading the uniform
buffer already makes of them, so a material naming its glow colour under
one convention and its brightness under another keeps both values.
Parameters
schemaSchema— ASchemafromforShader.claimed{ Claim }— EveryClaimthat routed to a property.
local props, displaced = MaterialSchema.settle(schema, claims)
modules/MaterialSchema/undeclaredMessage
undeclaredMessage(name: string, key: string, shader: string, schema: Schema): string
The diagnostic for a key the shader declares under neither surface, naming the material, the key, the shader, and the accepted vocabulary. One wording for every path that accepts material properties.
Parameters
namestring— The material's name or registry key.keystring— The key that is not declared.shaderstring— The backing shader's name.schemaSchema— ASchemafromforShader.
warn(MaterialSchema.undeclaredMessage(name, key, shader, schema))
modules/MaterialSchema/undeclaredSlotMessage
undeclaredSlotMessage(name: string, slot: string, shader: string, schema: Schema): string
The diagnostic for a texture bound to a slot the shader does not declare, naming the material, the slot, the shader and the texture slots it declares; a slot name the shader declares as a property says so. One wording for every path that binds a material texture.
Parameters
namestring— The material's name or registry key.slotstring— The slot that is not declared.shaderstring— The backing shader's name.schemaSchema— ASchemafromforShader.
warn(MaterialSchema.undeclaredSlotMessage(name, slot, shader, schema))
modules/MaterialSchema/valueShape
valueShape(value: any): "scalar" | "vector" | "either"
What shape an authored value has, for the one question a colour+scalar
pair asks of it. A number is the scalar; a numeric array or an {r, g, b}
colour is the vector. Anything else answers "either" and stays with the
half its key claimed.
Parameters
valueany(optional) — The authored value.
MaterialSchema.valueShape(5) -- "scalar"
modules/MeshAssetTypeBehavior/README
require("@builtin::assetTypes.mesh.behavior") -- MeshAssetTypeBehavior
Behaviour for the mesh asset type — the disk + CPU side of the disk-asset ↔ GPU-mesh split. onCreate writes the engine-native ZMSH geometry payload as the container's data.zmsh primary; :load() decodes it into the CPU store and returns a CPU handle. Both go through the public renderer.mesh.* API — this behaviour calls no __ FFI directly.
Usage: local MeshAssetTypeBehavior = require("@builtin::assetTypes.mesh.behavior")
modules/MeshAssetTypeBehavior/getVertices
getVertices(self)
Read this mesh's vertices — one entry per vertex,
{ pos = {x,y,z}, normal = {x,y,z}, uv = {u,v} }. Requires the CPU copy to be
resident: turn on keepCpu (meshRef:setSettings({ keepCpu = true })) for an
in-use mesh. Errors loudly — naming the exact reason — rather than silently
loading a transient copy.
Parameters
selfany(optional)
local verts = meshRef:getVertices()
modules/MeshAssetTypeBehavior/handle
handle(self)
Materialize this mesh asset's live GPU resource (Disk→CPU→GPU) and return
its MeshHandle. The handle is cached on the interned ref's shared runtime
table — its presence IS "loaded to the GPU", so once materialised every later
call (and every consumer of the same asset) gets the SAME handle back
directly → ONE GPU entry, no re-work. (The mode-flip runtime wipe clears the
cache so a mode change re-materialises.) A component that renders a mesh holds
the mesh resource and calls this internally — you rarely call it by hand.
CPU lifecycle: the keepCpu setting (:settings/:setSettings) governs
whether the CPU copy survives the upload. DEFAULT (keepCpu = false): the CPU
copy is dropped right after the GPU upload (the GPU handle holds no data → no
double memory). keepCpu = true retains the CPU store for geometry reads/edits.
Clusters: the mesh draws through clusters from this call, on its lod0 set
until its bake lands. The clusterLod setting governs how deep the bake
builds. DEFAULT (clusterLod = true): the LOD hierarchy. clusterLod = false: one level of clusters, drawn at full detail.
Parameters
selfany(optional)
local h = meshRef:handle()
modules/MeshAssetTypeBehavior/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Instantiate this mesh — the uniform instantiate(target?, opts?)
contract every scene-instantiable asset answers to. A mesh becomes an
entity carrying a Model that renders it. With target the entity
spawns as a child of that owner (so an owning Asset component tears it
down with its other children); with no target it is a fresh root. The
base opts — position, rotation, scale, name, temporary — place
the root.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional owning entity ref.opts{ [string]: any }?(optional) —{ position?, rotation?, scale?, name?, temporary? }.
meshRef:instantiate(owner)
modules/MeshAssetTypeBehavior/load
load(self)
Load this .mesh asset's geometry into the guid-keyed CPU store and
return a CPU handle (the Disk→CPU step). The handle carries the guid, vertex
/ index counts, and per-handle geometry ops (getTriangles / getVertices /
getBounds / encode / unload) that read the Rust-side store — it holds no
geometry itself. Upload to the GPU with renderer.mesh.create(handle); the
DEFAULT is to handle:unload() right after. Delegates to
renderer.mesh.loadCpu (the sole __ caller).
Parameters
selfany(optional)
local cpu = meshRef:load(); local gpu = renderer.mesh.create(cpu); cpu:unload()
modules/MeshAssetTypeBehavior/morphTargets
morphTargets(self): { string }
The names of the shapes this mesh blends towards, in the order an
entity's ecs.MorphWeights addresses them — weight i drives the target
named at i. An imported model keeps the names its source file gave its
blend shapes, so a face is driven by the shape it means rather than by the
ordinal that shape imported at. A target the source never named reads as an
empty string, and a mesh with no morph targets returns an empty array.
Requires the mesh to be materialised (meshRef:handle(), or anything
rendering it) — it errors loudly naming that, rather than answering as
though the mesh carried no shapes.
Parameters
selfany(optional)
for i, name in meshRef:morphTargets() do print(i, name) end
modules/MeshAssetTypeBehavior/onChange
onChange(ref: any, change: { [string]: any })
React to a write inside this mesh asset. A write to the stored geometry
re-uploads it into the GPU mesh registered under this asset's guid, so
everything already rendering it draws the new shape. A settings write —
to the declared settings.yaml values file, or a legacy .metadata
block for content published before it existed — acts on whichever fields
it named: keepCpu and clusterLod are lifecycle settings governing
PER-ENGINE state (a CPU copy in this process's store, a cluster set
on this process's GPU), so they act on an already-materialised mesh right
away for EVERY origin — a synced peer's engine holds its own CPU/GPU
state that the write says just as much about as the one that made it;
lightmapUvs reconciles the second (lightmap) UV set — "generate"
(re)creates a non-overlapping unwrap into the second UV set, "none"
strips it, "keep" leaves the stored geometry untouched. The re-cook
round-trips the geometry through the codec, so tangents, skinning, and the
skeleton are preserved; it is the one part of this hook that WRITES
persisted content, so it alone stays local-origin-only (a peer's own
re-cook of the same settings would just be a second, redundant write of
the same bytes the sync already delivered) and play-mode-gated (the
play-lock): a setting flip never rewrites the persisted geometry while
the world is running; a resident mesh re-materialises on its next fetch.
Parameters
refany(optional) — The AssetReffor the changed container. change{ [string]: any }—{ path, asset, kind, origin, settings, settingsChanged }—paththe written file,assetthe container folder,kind"edited"/"seeded",origin"local"/"remote",settingsthe validated values andsettingsChangedwhat changed whenpathis the settings values file.
modules/MeshAssetTypeBehavior/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("mesh", name, opts). Pure:
returns the content-file map; asset.create writes it to the authored
destination, registering the .mesh asset under its minted guid. Disk-only —
nothing is uploaded to the GPU here (the GPU mesh is a separate, explicit
renderer.mesh.create step keyed by this asset's guid).
opts is raw geometry { positions, indices, normals?, uvs?, colors? }
(flat float / u32 arrays, encoded to data.zmsh via renderer.mesh.encode),
or a pre-encoded { bytes } payload (stored verbatim).
Parameters
namestring— Mesh identity (the instance name).optsCreateOpts
asset.create("mesh", "tree", { positions = {...}, indices = {...} })
modules/MeshAssetTypeBehavior/setSettings
setSettings(self, patch: { [string]: any })
Write a partial settings patch. The patch is checked against this
type's declared schema; a violation refuses the write naming every
problem. A valid write reaches onChange: keepCpu loads or drops the
CPU copy, clusterLod rebakes a mesh in use at the cluster depth it now
asks for — neither touches the stored geometry — and lightmapUvs
re-cooks the stored geometry's second UV set (edit mode only).
Parameters
selfany(optional)patch{ [string]: any }— Any subset of the schema's fields.
meshRef:setSettings({ keepCpu = true })
modules/MeshAssetTypeBehavior/setVertices
setVertices(self, positions)
Replace this mesh's vertex positions IN PLACE — indices, normals/uvs, and
skinning are preserved, the AABB recomputes, and the edit shows on screen (the
GPU re-fetches the changed CPU copy). Requires the CPU copy resident: turn on
keepCpu (meshRef:setSettings({ keepCpu = true })) for an in-use mesh. Errors
loudly — naming the reason — when the CPU copy isn't resident or the vertex
count doesn't match.
Parameters
selfany(optional)positionsany(optional) — One position per vertex: an array of{x,y,z}(or[x,y,z]), or a flat{x,y,z, ...}array. The count must match the mesh's vertex count.
local v = meshRef:getVertices()
local p = {}; for i, vert in ipairs(v) do p[i] = { vert.pos.x*0.01, vert.pos.y*0.01, vert.pos.z*0.01 } end
meshRef:setVertices(p) -- scale the mesh to 1/100
modules/MeshAssetTypeBehavior/settings
settings(self): { [string]: any }
Read this mesh asset's settings, with every declared default filled in.
Parameters
selfany(optional)
if meshRef:settings().keepCpu then ... end
modules/MeshAssetTypeBehavior/settingsPending
settingsPending(self): boolean
Whether a settings change to this mesh is still reading its stored
geometry. A clusterLod or keepCpu change on a mesh in use reads the
geometry before it rebakes the mesh or loads its CPU copy, and where the
geometry is fetched on first read that read spans frames. While it is in
flight this answers true; once it answers false every settings change made
so far has reached the mesh, a rebake it asked for is in
renderer.mesh.clusterBakes().inFlight or has landed, and the CPU copy is
as the latest keepCpu says.
Parameters
selfany(optional)
meshRef:setSettings({ clusterLod = false })
while meshRef:settingsPending() do task.wait() end
modules/ModuleAssetTypeRef/README
require("@builtin::assetTypes.module.behavior") -- ModuleAssetTypeRef
Per-instance methods exposed on every AssetRef<module>. Loaded lazily by assetType.shared.ref.
Usage: local ModuleAssetTypeRef = require("@builtin::assetTypes.module.behavior")
modules/ModuleAssetTypeRef/getExports
getExports(self): { { name: string, type: string } }?
The module's exported names and their value types — requires the module and reflects over the table it returns. Available for every module (world-authored or library), since a module is just an asset.
Parameters
selfany(optional)
for _, e in ipairs(modRef:getExports() or {}) do print(e.name, e.type) end
modules/ModuleAssetTypeRef/getInitScript
getInitScript(self): string?
Read the module's entry script as raw text.
Parameters
selfany(optional)
local src = modRef:getInitScript()
modules/ModuleAssetTypeRef/getReadme
getReadme(self): string?
Read the module's README body.
Parameters
selfany(optional)
print(modRef:getReadme())
modules/ModuleAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { exports }, where exports
is parsed from the module's own entry script (getInitScript) via
luau_introspect.moduleExports — name/kind/signature/desc of every
top-level export, read from the source text rather than a require()
reflection. Cached on the asset's content checksum, so re-inspecting
unchanged source is free. A module with no readable entry script
returns an empty exports list rather than erroring.
Parameters
selfany(optional)
local exports = asset.inspect(modRef).detail.exports
modules/ModuleAssetTypeRef/loadModule
loadModule(self): any
Require the module: the same module require(self.identity) answers
from the world's own code, for a world module and a library one alike. A
load failure raises a Luau error tagged with the module identity rather
than propagating the raw error.
Parameters
selfany(optional)
local mod = modRef:loadModule()
modules/ModuleAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: hot-reload this module whenever a
.luau / .lua file inside it is edited (or the module is seeded). A
user module reloads here; a library module has already reloaded through
the VFS write hook by the time this runs, and the reload here finds its
source unchanged. Mirrors the .material / .shader assetTypes owning
their own reload. Convergent: the reload only invalidates the require()
cache + fires watchers and never writes back into the asset folder.
Parameters
refany(optional)changeany(optional)
modules/ModuleAssetTypeRef/onRegister
onRegister(self)
Initial-registration callback: register every .luau / .lua file this
module owns — its entry AND its plain-file submodules — into the require()
layer, so require("<mod>.<sub>") resolves the instant it first registers
(fired before the world entrypoint runs). A .luau inside a NESTED
typed-asset folder (a nested .module / .component / …) belongs to that
asset and registers through its own onRegister, so it is skipped here.
Parameters
selfany(optional) — The per-instanceAssetRef<module>.
-- driven by the assetType lifecycle; not called directly
modules/NodeboxAssetTypeRef/README
require("@builtin::systems.procgen.nodebox.behavior") -- NodeboxAssetTypeRef
Per-instance methods exposed on every AssetRef<nodebox>.
Usage: local NodeboxAssetTypeRef = require("@builtin::systems.procgen.nodebox.behavior")
modules/NodeboxAssetTypeRef/getReadme
getReadme(self): string?
Read the nodebox's README.md body.
Parameters
selfany(optional)
print(boxRef:getReadme())
modules/NodeboxAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { nodes }, each { name, call, desc }
where call is the name a graph calls the node by (<box>.<node>).
Parameters
selfany(optional)
local nodes = asset.inspect(boxRef).detail.nodes
modules/NodeboxAssetTypeRef/listNodes
listNodes(self): { any }
List the node refs the box holds, each an AssetRef<procNode>.
Parameters
selfany(optional)
for _, n in ipairs(boxRef:listNodes()) do print(n.identity) end
modules/OpenVDB/README
require("@builtin::plugins.openvdb.surface") -- OpenVDB
OpenVDB, as a dense voxel grid: the .vdb importer's parser.
Usage: local OpenVDB = require("@builtin::plugins.openvdb.surface")
modules/OpenVDB/parse
parse(vdb: string | buffer)
Parse a .vdb file's bytes into a dense RGBA8 voxel grid.
Parameters
vdbstring | buffer— The file's bytes, as a string or a buffer.
modules/PackageAssetTypeRef/README
require("@builtin::assetTypes.package.behavior") -- PackageAssetTypeRef
Per-instance methods exposed on every AssetRef<package>. Loaded lazily by assetType.shared.ref.
Usage: local PackageAssetTypeRef = require("@builtin::assetTypes.package.behavior")
modules/PackageAssetTypeRef/getDefinition
getDefinition(self): string?
Read the package's package.yaml body as raw text.
Parameters
selfany(optional)
local raw = packageRef:getDefinition()
modules/PackageAssetTypeRef/getReadme
getReadme(self): string?
Read the package's README body.
Parameters
selfany(optional)
print(packageRef:getReadme())
modules/PackageAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { contents }, where
contents is { {name, type}, ... } sorted by name — the package's
own direct children (components, modules, tools, docs), enumerated via
vfs.list against the package's own path. Never reads/executes any
child's content.
Parameters
selfany(optional)
local contents = asset.inspect(packageRef).detail.contents
modules/PackageAssetTypeRef/listContents
listContents(self): { { name: string, isDirectory: boolean } }
List the package's child entries — every VFS entry one level below the package root. Use this to enumerate components, modules, tools, etc. shipped by the package.
Parameters
selfany(optional)
for _, e in ipairs(packageRef:listContents()) do print(e.name) end
modules/Particles.Curves/ColorSequence.new
ColorSequence.new(a, b?) -> ColorSequence
Three shapes: constant ({r,g,b}), two-point lerp (startColor, endColor), or keypoint table ({ {time=, value={r,g,b,a?}, envelope={r,g,b}?}, ... }).
Parameters
aany(optional)bany(optional)
Returns ColorSequence
modules/Particles.Curves/ColorSequence:evaluate
ColorSequence:evaluate(t: number) -> (r, g, b, a)
Deterministic per-channel sample.
Parameters
tnumber
Returns (r, g, b, a)
modules/Particles.Curves/ColorSequence:getKeypoints
ColorSequence:getKeypoints() -> {table}
Returns a fresh array of { time, value = {r,g,b,a}, envelope = {r,g,b} }.
Returns {table}
modules/Particles.Curves/ColorSequence:pack
ColorSequence:pack(buffer: {number}, offset: number) -> number
Pack the color curve into a flat float array; returns the next-write offset.
Parameters
buffer{number}offsetnumber
Returns number
modules/Particles.Curves/ColorSequence:sample
ColorSequence:sample(t: number, rng?: number) -> (r, g, b, a)
Sample with per-channel RGB envelope randomness (alpha is deterministic).
Parameters
tnumberrngnumber(optional)
Returns (r, g, b, a)
modules/Particles.Curves/NumberSequence.new
NumberSequence.new(a, b?) -> NumberSequence
Three shapes: constant (value), two-point lerp (start, end), or keypoint list ({ {time=, value=, envelope=}, ... }), whose entries also read positionally as ({ {time, value[, envelope]}, ... }). A field that is not a number is refused at the call.
Parameters
aany(optional)bany(optional)
Returns NumberSequence
modules/Particles.Curves/NumberSequence:evaluate
NumberSequence:evaluate(t: number) -> number
Deterministic interpolation at life-fraction t in [0, 1].
Parameters
tnumber
Returns number
modules/Particles.Curves/NumberSequence:getKeypoints
NumberSequence:getKeypoints() -> {table}
Returns a fresh array of { time, value, envelope } entries.
Returns {table}
modules/Particles.Curves/NumberSequence:pack
NumberSequence:pack(buffer: {number}, offset: number) -> number
Pack the curve into a flat float array; returns the next-write offset.
Parameters
buffer{number}offsetnumber
Returns number
modules/Particles.Curves/NumberSequence:sample
NumberSequence:sample(t: number, rng?: number) -> number
Envelope-randomized sample; rng (in [0, 1]) seeds the jitter.
Parameters
tnumberrngnumber(optional)
Returns number
modules/Particles.Curves/README
require("@builtin::deprecated.deprecatedParticles.curves") -- Particles.Curves
NumberSequence and ColorSequence — keyframe curves for VFX properties.
Animatable keyframe curves used by the particle system. Modelled on
Roblox's NumberSequence / ColorSequence so the muscle memory carries
over, with two differences:
- Up to 16 keypoints (Roblox caps at 20; we cap a bit lower so the GPU pack fits in a fixed-size param block).
- ColorSequence supports per-channel
envelope(RGB) — Roblox does not. Curves are immutable plain tables with a metatable. Build once, sample many times. The shader-side pack format is a flat float array — seeNumberSequence.pack/ColorSequence.packfor the contract. Usage: local size = NumberSequence.new({ { time = 0.0, value = 0.1 }, { time = 0.3, value = 1.0, envelope = 0.2 }, { time = 1.0, value = 0.0 }, }) print(size:evaluate(0.5)) -- deterministic interpolation print(size:sample(0.5)) -- envelope randomness applied local color = ColorSequence.new( { 1, 0.8, 0.2 }, -- yellow { 1, 0.1, 0.0 } -- red )
Usage: local Particles.Curves = require("@builtin::deprecated.deprecatedParticles.curves")
modules/Particles.Curves/isColorSequence
isColorSequence(x: any) -> boolean
True if x is a ColorSequence answering the calls one takes. A sequence that crossed a boundary preserving only its fields has its methods put back, so the value a caller tests is one it can go on to sample.
Parameters
xany(optional)
Returns boolean
modules/Particles.Curves/isNumberSequence
isNumberSequence(x: any) -> boolean
True if x is a NumberSequence answering the calls one takes. A sequence that crossed a boundary preserving only its fields has its methods put back, so the value a caller tests is one it can go on to sample.
Parameters
xany(optional)
Returns boolean
modules/Particles.Curves/new
new(a: any, b: any?): any
Parameters
aany(optional)bany?(optional)
NumberSequence.new(1.0)
NumberSequence.new(0.0, 1.0)
NumberSequence.new({ {time=0,value=0}, {time=1,value=1,envelope=0.1} })
NumberSequence.new({ {0, 0}, {1, 1, 0.1} })
modules/Particles.Meshes/README
require("@builtin::deprecated.deprecatedParticles.meshes") -- Particles.Meshes
Built-in source-mesh templates for mesh particles.
Source-mesh geometries for the mesh-particle path of the particle system.
Each built-in returns a table with positions (flat xyz array),
normals (flat xyz array), uvs (flat uv array), and indices (flat u32
array) — the shape particles.create expects under its mesh field.
Built-in kinds:
"cube" — 24 verts × 36 indices (face-normalled box)
"octahedron" — 24 verts × 24 indices (face-normalled octahedron)
"tetrahedron" — 12 verts × 12 indices (face-normalled tetrahedron)
"plane" — 4 verts × 6 indices (axis-aligned XY quad)
Custom geometry:
Pass mesh = { positions = {...}, normals = {...}, uvs = {...}, indices = {...} } directly to particles.create. The
module also accepts an asset ref (assetRef("identity", "mesh"))
but resolution happens through the engine's asset system — the
fast path is built-in kinds.
Usage: local Particles.Meshes = require("@builtin::deprecated.deprecatedParticles.meshes")
modules/Particles.Meshes/list
list() -> {string}
Returns the built-in mesh kind names.
Returns {string}
modules/Particles.Meshes/resolve
resolve(spec: string | table) -> table
Resolve a mesh spec to { positions, normals, uvs, indices }. Spec is one of "cube" | "octahedron" | "tetrahedron" | "plane", or a custom { positions, normals, uvs?, indices } table.
Parameters
specstring | table
Returns table
modules/Particles.Shapes/README
require("@builtin::deprecated.deprecatedParticles.shapes") -- Particles.Shapes
Emission-shape samplers — CPU-side, called at spawn time.
Spawn positions and initial velocity directions for the standard emission shapes. CPU sampling is fine here because it runs at most N times per frame where N = emission rate, not N = active particle count — and the math is trivial. Shapes (matching Roblox naming): point — emit from origin box — Volume / Surface sphere — Volume / Surface, partial = hemisphere cap cylinder — Volume / Surface, axis = Y disc — Surface (XZ plane), partial = annulus inner radius cone — Surface, partial = half-angle Styles: "volume" — uniform inside the shape "surface" — uniform on the shape's boundary inOut (determines initial velocity direction): "outward" — surface-normal outward "inward" — surface-normal inward "inandout" — random sign per particle
Usage: local Particles.Shapes = require("@builtin::deprecated.deprecatedParticles.shapes")
modules/Particles.Shapes/frame
frame(ax: number, ay: number, az: number): (number, number, number, number, number, number, number, number, number)
Build an orthonormal frame whose middle axis is the given direction. Shape samplers emit around a local +Y axis; this frame maps those local samples into world space so emission can be aimed along any vector. Returns 9 numbers — right, axis, forward — for allocation-free use in per-particle loops: world = local.x * right + local.y * axis + local.z * forward. The frame is the shortest rotation that turns +Y onto the direction, so the local X and Z axes keep as close to world X and Z as the turn allows: a direction along +X or -X turns about Z and keeps Z, one along +Z or -Z turns about X and keeps X, and -Y is the half turn about X. A zero-length or +Y direction returns the exact identity frame.
Parameters
axnumber— Direction X (any length; normalized internally).aynumber— Direction Y.aznumber— Direction Z.
local rx, ry, rz, ax2, ay2, az2, fx, fy, fz = Shapes.frame(0, 0, -1)
modules/Particles.Shapes/inOuts
inOuts() -> {string}
Returns the directions a sample aims in — outward, inward, inandout.
Returns {string}
modules/Particles.Shapes/sample
sample(shape: string, opts: table) -> (px, py, pz, dx, dy, dz)
Sample one spawn position + unit direction from the named shape. opts: { size = {x,y,z}, style = "volume"|"surface", inOut = "outward"|"inward"|"inandout", partial = number, spreadAngle = degrees }.
Parameters
shapestringoptstable
Returns (px, py, pz, dx, dy, dz)
modules/Particles.Shapes/shapes
shapes() -> {string}
Returns the supported shape names — point, box, sphere, cylinder, disc, cone.
Returns {string}
modules/Particles.Shapes/styles
styles() -> {string}
Returns the fill styles a shape is sampled with — volume, surface.
Returns {string}
modules/Particles.spawnBatches/README
require("@builtin::deprecated.deprecatedParticles.engine.spawnBatches") -- Particles.spawnBatches
The spawn batches an emitter keeps, as a min-heap on the clock each batch leaves the live bound at, and the count of particles they can still hold alive.
Usage: local Particles.spawnBatches = require("@builtin::deprecated.deprecatedParticles.engine.spawnBatches")
modules/Particles.spec/README
require("@builtin::deprecated.deprecatedParticles.engine.spec") -- Particles.spec
How the particle system reads an emitter spec: each field's value checked against the shapes it takes (a range, a size, a curve, a colour sequence, bursts, a direction, a number, a boolean, an enum, a vector, a table), with the refusal reported at the call that wrote it.
Usage: local Particles.spec = require("@builtin::deprecated.deprecatedParticles.engine.spec")
modules/Particles/M.list
M.list() -> {ParticleSystem}
Every live particle system this VM has created, newest last.
Returns {ParticleSystem}
modules/Particles/M.observe
M.observe(system: ParticleSystem?) -> table
One emitter's document, or — with no argument — the whole world's: { emitters, count, alive, capacity, spawned, silent, bytes, frame }.
Parameters
systemParticleSystem?(optional)
Returns table
modules/Particles/M.silenceReasons
M.silenceReasons() -> table
The closed set of reasons an emitter can be producing nothing, in the order they are resolved, each with what it means.
Returns table
modules/Particles/M.whySilent
M.whySilent(system: ParticleSystem) -> (string?, string?)
The reason one emitter is producing nothing and the detail line naming what it is about, or nil when it is producing.
Parameters
systemParticleSystem
Returns (string?, string?)
modules/Particles/ParticleSystem:billboard
ParticleSystem:billboard(): { [string]: any }
The camera frame this emitter's geometry was last built against: which camera supplied it, the world point it was read at, the right/up pair, and the direction that pair faces.
A sprite is a flat card placed in the compute pass against ONE camera frame,
so a view looking along normal sees it face-on and a view looking across
normal sees its edge. A mesh emitter spins each copy about the axis
running from it to position. When a frame drawn from somewhere else shows
an emitter that every count reports as producing, this is the reading that
says where its geometry is turned, and means names which part of the frame
this emitter's kind builds from.
local b = sys:billboard(); print(b.source, b.normal[1], b.normal[2], b.normal[3])
modules/Particles/ParticleSystem:clear
ParticleSystem:clear()
Kill every live particle by re-zeroing the state buffer, and take them out of the frame on the same call.
modules/Particles/ParticleSystem:destroy
ParticleSystem:destroy()
Release every GPU buffer and the render entity. Idempotent.
modules/Particles/ParticleSystem:emit
ParticleSystem:emit(count: number)
One-shot burst of N particles, independent of rate / enabled.
Parameters
countnumber
modules/Particles/ParticleSystem:getActiveCount
ParticleSystem:getActiveCount() -> number
How many particles are alive right now: the slots whose lifetime has not elapsed under the simulated time this emitter's dispatches have advanced. Falls to 0 when the last particle ages out.
Returns number
modules/Particles/ParticleSystem:getCastsShadows
ParticleSystem:getCastsShadows(): boolean
Whether this emitter's particles block light.
print(debris:getCastsShadows())
modules/Particles/ParticleSystem:getColliders
ParticleSystem:getColliders(): { any }
The colliders currently in force, in the shape setColliders takes —
so what comes out of one goes back into the other.
local n = #sys:getColliders()
modules/Particles/ParticleSystem:getCreator
ParticleSystem:getCreator(): { [string]: any }
Whose this emitter is. owner and name are the keys its creator
stated on the spec, and source and line are the code that made the call,
read off the stack — so an emitter nobody tagged still names the module it
came from. actor is the caller the creating call was attributed to and
actorName the ZeroMind account it authenticated as, and createdAt is
when the emitter was made, which orders two emitters one creator built
across separate loads.
local who = sys:getCreator(); print(who.owner, who.source, who.line)
modules/Particles/ParticleSystem:getDepthFade
ParticleSystem:getDepthFade() -> number
That distance.
Returns number
modules/Particles/ParticleSystem:getGpuBytes
ParticleSystem:getGpuBytes() -> table
Every GPU buffer this emitter holds, by name, plus their total.
Returns table
modules/Particles/ParticleSystem:getLightEmission
ParticleSystem:getLightEmission() -> number
That share.
Returns number
modules/Particles/ParticleSystem:getLightInfluence
ParticleSystem:getLightInfluence() -> number
That share.
Returns number
modules/Particles/ParticleSystem:getMaxCount
ParticleSystem:getMaxCount() -> number
Buffer cap.
Returns number
modules/Particles/ParticleSystem:getRenderEntity
ParticleSystem:getRenderEntity() -> string?
Entity id of the renderable a sprite emitter spawns at world origin; nil for a mesh emitter, which draws as a GPU population instead.
Returns string?
modules/Particles/ParticleSystem:getRenderLayer
ParticleSystem:getRenderLayer(): string
The render layers this emitter's particles draw on, as the space-separated name string every render-layer surface speaks.
print(smoke:getRenderLayer())
modules/Particles/ParticleSystem:getSimulatedTime
ParticleSystem:getSimulatedTime() -> number
Seconds of simulation this emitter's dispatches have advanced. Every particle's age is measured against this clock.
Returns number
modules/Particles/ParticleSystem:getSpawnedCount
ParticleSystem:getSpawnedCount() -> number
How many slots the emitter has filled since the last clear(), saturating at maxCount. The emission schedule's own total, and the span the draw covers.
Returns number
modules/Particles/ParticleSystem:isPlaying
ParticleSystem:isPlaying() -> boolean
True while the timeline emits: enabled, past delay, and inside duration (or looping / untimed).
Returns boolean
modules/Particles/ParticleSystem:isSorted
ParticleSystem:isSorted() -> boolean
Whether this emitter reorders its own particles back to front every frame.
Returns boolean
modules/Particles/ParticleSystem:isVisible
ParticleSystem:isVisible() -> boolean
Whether the emitter's population reaches the frame.
Returns boolean
modules/Particles/ParticleSystem:observe
ParticleSystem:observe() -> table
Everything the engine holds for this emitter in one document: population, capacity, timeline, GPU bytes, render-side liveness, the GPU's own confirmation of the population, and — when it is producing nothing — the reason from a closed set.
Returns table
modules/Particles/ParticleSystem:play
ParticleSystem:play(restart?: boolean)
Start (or re-arm) the emission timeline: resets the clock to -delay, re-arms scheduled bursts, and enables emission. restart = true also clears live particles.
Parameters
restartboolean(optional)
modules/Particles/ParticleSystem:requestCensus
ParticleSystem:requestCensus()
Ask the GPU to count its own live slots on the next dispatch. The answer arrives on a later frame and reads back through observe().confirmation.
modules/Particles/ParticleSystem:setAcceleration
ParticleSystem:setAcceleration(x, y, z: number)
Set the constant acceleration vector (combined with gravity + wind).
Parameters
xany(optional)yany(optional)znumber
modules/Particles/ParticleSystem:setBlendMode
ParticleSystem:setBlendMode(mode: string)
"alpha" (default) or "additive".
Parameters
modestring
modules/Particles/ParticleSystem:setBursts
ParticleSystem:setBursts(bursts: table)
Replace the scheduled-burst list ({ {time, count}, ... }); nil/empty removes the schedule.
Parameters
burststable
modules/Particles/ParticleSystem:setCastsShadows
ParticleSystem:setCastsShadows(on: boolean?)
State whether this emitter's particles block light. A caster is drawn into the shadow map as the geometry it is — a sprite emitter's quads as quads, a mesh emitter's copies as copies — and the surfaces behind it are shaded in shadow. The declaration reaches both emitter kinds, so it means the same thing whichever one carries it.
Parameters
onboolean?(optional) —trueto block light,falseto let it through. Omitted, the emitter goes back to the default, which is letting it through.
debris:setCastsShadows(true)
modules/Particles/ParticleSystem:setColliders
ParticleSystem:setColliders(colliders: { any }?): number
Replace the shapes this emitter's particles collide against. Each entry
is { kind = "plane" | "sphere" | "box" | "world", position = {x,y,z}, ... }
— a plane also takes normal, a sphere radius, a box halfExtents. A
world entry is the scene's own geometry, read from the distance field
sceneProxy builds: it takes only radius, how far from a surface a
particle counts as touching it. At most 8 are carried; the rest are dropped
and reported.
Parameters
colliders{ any }?(optional) — Array of collider descriptions.
sys:setColliders({ { kind = "world" } })
modules/Particles/ParticleSystem:setCollision
ParticleSystem:setCollision(mode: string?, opts: { [string]: any }?)
Choose what a particle does when it meets a collider.
Parameters
modestring?(optional) —"off","bounce","stop"or"kill".opts{ [string]: any }?(optional) — Optional{ restitution, friction }.restitutionis how much normal speed survives a bounce,frictionhow much tangential speed is lost on contact — both in [0, 1].
sys:setCollision("bounce", { restitution = 0.5, friction = 0.3 })
modules/Particles/ParticleSystem:setColor
ParticleSystem:setColor(value: ColorSequence | {number})
Per-particle color curve. A {number} array {r, g, b} is read as a constant color, and a list of such arrays as a ramp through them.
Parameters
valueColorSequence | {number}
modules/Particles/ParticleSystem:setDepthFade
ParticleSystem:setDepthFade(distance: number)
Set the distance, in world units, over which this emitter's particles dissolve into the surface drawn behind them. 0 turns the fade off.
Parameters
distancenumber
modules/Particles/ParticleSystem:setDirection
ParticleSystem:setDirection(x, y, z: number)
Aim emission: the shape's local +Y axis maps onto this world-space vector (positions and initial velocities both rotate). Pass nil to reset to the native +Y frame.
Parameters
xany(optional)yany(optional)znumber
modules/Particles/ParticleSystem:setDrag
ParticleSystem:setDrag(d: number)
Set the velocity damping factor (per-second exponential decay).
Parameters
dnumber
modules/Particles/ParticleSystem:setEnabled
ParticleSystem:setEnabled(b: boolean)
Pause / resume continuous emission. Does not kill live particles.
Parameters
bboolean
modules/Particles/ParticleSystem:setGravity
ParticleSystem:setGravity(x, y, z: number)
Set the gravity vector (m/s^2). Default {0, -9.81, 0}.
Parameters
xany(optional)yany(optional)znumber
modules/Particles/ParticleSystem:setLifetime
ParticleSystem:setLifetime(min: number, max?: number)
Per-particle lifetime range in seconds.
Parameters
minnumbermaxnumber(optional)
modules/Particles/ParticleSystem:setLightEmission
ParticleSystem:setLightEmission(share: number)
How much of itself each particle emits whatever the scene's light is, from 0 to 1. At 1 a particle is self-illuminated.
Parameters
sharenumber
modules/Particles/ParticleSystem:setLightInfluence
ParticleSystem:setLightInfluence(share: number)
How much of the scene's light these particles take, from 0 to 1.
Parameters
sharenumber
modules/Particles/ParticleSystem:setLook
ParticleSystem:setLook(look: string)
Parameters
lookstring— One of the eight look names.
sys:setLook("glow")
modules/Particles/ParticleSystem:setMaterial
ParticleSystem:setMaterial(materialName: string)
Replace the material applied to the render entity entirely.
Parameters
materialNamestring
modules/Particles/ParticleSystem:setOrientation
ParticleSystem:setOrientation(mode: string)
"FacingCamera" | "FacingCameraWorldUp" | "VelocityParallel" | "VelocityPerpendicular".
Parameters
modestring
modules/Particles/ParticleSystem:setOrigin
ParticleSystem:setOrigin(x, y, z: number)
Move the emitter to a new world-space origin.
Parameters
xany(optional)yany(optional)znumber
modules/Particles/ParticleSystem:setParam
ParticleSystem:setParam(name: string, value: number)
Generic setter — matches PARAM_LAYOUT keys or "user
Parameters
namestringvaluenumber
modules/Particles/ParticleSystem:setRate
ParticleSystem:setRate(r: number)
Set continuous emission rate (particles/sec).
Parameters
rnumber
modules/Particles/ParticleSystem:setRenderLayer
ParticleSystem:setRenderLayer(layers: any)
Put this emitter's particles on named render layers. A camera or a capture including the layer draws them and one excluding it does not, so a reflection probe, a portal camera, a minimap or a clean screenshot can take the scene with the emitter's effect in it or without. The layers reach both emitter kinds.
Parameters
layersany(optional) — A layer name, an array of names, or a space-separated string. Omitted, the emitter goes back to thedefaultlayer.
smoke:setRenderLayer("vfx")
modules/Particles/ParticleSystem:setRotSpeed
ParticleSystem:setRotSpeed(min: number, max?: number)
Per-particle rotation-speed range (degrees/sec).
Parameters
minnumbermaxnumber(optional)
modules/Particles/ParticleSystem:setRotSpeedCurve
ParticleSystem:setRotSpeedCurve(value: NumberSequence | number | {start, finish} | {table})
Rotation-speed curve — multiplies each particle's own rotSpeed across its life. Written the same four ways as the transparency curve.
Parameters
valueNumberSequence | number | {start, finish} | {table}
modules/Particles/ParticleSystem:setRotation
ParticleSystem:setRotation(min: number, max?: number)
Per-particle initial rotation range (degrees).
Parameters
minnumbermaxnumber(optional)
modules/Particles/ParticleSystem:setShape
ParticleSystem:setShape(opts: table)
Replace the emission shape — { kind, size, style, inOut, partial, spreadAngle } (any subset). Existing values are kept for omitted fields.
Parameters
optstable
modules/Particles/ParticleSystem:setSize
ParticleSystem:setSize(value: NumberSequence | number | {min, max} | {table})
Size, read the way create reads its size: a curve — a NumberSequence or the keypoint list {{time, value, envelope?}, ...} one is built from — is sampled per particle every frame on the GPU over base 1, and a number or {min, max} pair is the base each spawn samples under a constant curve of 1. Either way a particle draws at the size that was written.
Parameters
valueNumberSequence | number | {min, max} | {table}
modules/Particles/ParticleSystem:setSorted
ParticleSystem:setSorted(on: boolean?)
State whether this emitter reorders its own particles back to front every frame. nil hands the choice back to the blend mode.
Parameters
onboolean?(optional)
modules/Particles/ParticleSystem:setSpeed
ParticleSystem:setSpeed(min: number, max?: number)
Per-particle initial-speed range.
Parameters
minnumbermaxnumber(optional)
modules/Particles/ParticleSystem:setSquash
ParticleSystem:setSquash(value: NumberSequence | number | {start, finish} | {table})
X-dimension scale curve (>1 stretches, <1 squashes). Written the same four ways as the transparency curve.
Parameters
valueNumberSequence | number | {start, finish} | {table}
modules/Particles/ParticleSystem:setTexture
ParticleSystem:setTexture(texture: string)
Set the sprite texture (asset id or VFS path).
Parameters
texturestring
modules/Particles/ParticleSystem:setTransparency
ParticleSystem:setTransparency(value: NumberSequence | number | {start, finish} | {table})
Transparency curve (0 = opaque, 1 = invisible). A {start, finish} pair of numbers is read as a two-stop ramp — a table holding one number as that value across the whole life — and a keypoint list as the curve through its stops.
Parameters
valueNumberSequence | number | {start, finish} | {table}
modules/Particles/ParticleSystem:setUserParam
ParticleSystem:setUserParam(index: number, value: number)
Write one slot (1..32) of the 32-float user param block. Custom WGSL update shaders read these at params[31 + index].
Parameters
indexnumbervaluenumber
modules/Particles/ParticleSystem:setVisible
ParticleSystem:setVisible(on: boolean)
Whether the population the emitter holds reaches the frame. Emission is setEnabled; the draw is this, and a hidden emitter keeps its particles.
Parameters
onboolean
modules/Particles/ParticleSystem:setWind
ParticleSystem:setWind(x, y, z: number)
Set the wind vector (m/s).
Parameters
xany(optional)yany(optional)znumber
modules/Particles/ParticleSystem:simulate
ParticleSystem:simulate(t: number, stepDt?: number)
Deterministically advance the system by t seconds in fixed steps (default 1/60). Drives the full update — timeline, bursts, compute passes — so a system can be prewarmed or scrubbed to a known state.
Parameters
tnumberstepDtnumber(optional)
modules/Particles/ParticleSystem:stop
ParticleSystem:stop(clearParticles?: boolean)
Stop emitting. Live particles finish their lifetime unless clearParticles = true.
Parameters
clearParticlesboolean(optional)
modules/Particles/ParticleSystem:update
ParticleSystem:update(dt: number)
Step the simulation. Drives continuous emission, dispatches the compute update pass, and re-packs per-frame uniforms. Call once per frame.
Parameters
dtnumber
modules/Particles/README
require("@builtin::deprecated.deprecatedParticles.engine") -- Particles
Generic GPU-driven particle system — compute-shader simulation, zero-copy rendering.
A generic GPU particle substrate for VFX. Every active particle lives in a
GPU storage buffer; the simulation runs entirely as compute dispatches; the
per-frame vertex output is consumed directly by the renderer via
renderer.mesh.create (no readback, no CPU re-upload). Spawning happens
on the CPU (the bookkeeping cost is bounded by emission rate, not particle
count) and writes new particle slots straight into the GPU state buffer.
The module is one-stop: the high-level ParticleEmitter component
declared elsewhere in src/lua/lib/components/ is a thin wrapper around
this API.
Usage:
local particles = require("@builtin::deprecated.deprecatedParticles.engine")
local fire = particles.create({
maxCount = 2000,
rate = 100, -- particles/sec
lifetime = { 0.8, 1.6 },
speed = { 2.5, 4.0 },
shape = { kind = "cone", size = {1, 1, 1}, partial = 0.3 },
gravity = { 0, 1.5, 0 }, -- buoyant
drag = 0.6,
size = NumberSequence.new({
{ time = 0, value = 0.4 },
{ time = 0.3, value = 1.0, envelope = 0.2 },
{ time = 1, value = 0.0 },
}),
color = ColorSequence.new({ 1, 0.9, 0.3 }, { 0.8, 0.1, 0 }),
transparency = NumberSequence.new(0, 1),
texture = "@builtin::textures.fire_sprite",
blendMode = "additive",
})
-- Each frame:
fire:setOrigin(torch.position.x, torch.position.y, torch.position.z)
fire:update(dt)
See references/luau-cookbook.md#particles (zero-engine skill) for more
recipes — explosion bursts, magic swirls, custom WGSL update injection.
Usage: local Particles = require("@builtin::deprecated.deprecatedParticles.engine")
modules/Particles/create
create(spec: table) -> ParticleSystem
Allocate a new particle system: GPU buffers, registered compute shader, renderer.mesh.create-wrapped renderable. See the about block for the full spec field list. Returns a handle whose methods are summarised below.
Parameters
spectable
Returns ParticleSystem
modules/Particles/list
list(filter: any?): { any }
Every particle system this VM has created and not destroyed, in creation order — or, given a filter, the ones whose creator matches it. An emitter is something this module made, so the list is answered from its own registry rather than by walking entities.
Called with nothing it answers with every emitter in the VM, which is what
makes it the way to reach one whose creator has lost its handle, and
:getCreator() on an entry says whose that one is. A filter narrows it to
one creator's own, so a module sweeps what it left behind on a previous load
without touching anybody else's.
Parameters
filterany?(optional) — Optional. A string matches theownerkey a creator stated; a table matches every one ofowner,nameandsourcethat it names.
for _, sys in ipairs(Particles.list()) do print(sys:getActiveCount()) end
for _, sys in ipairs(Particles.list("starfield")) do sys:destroy() end
modules/Particles/observe
observe(system: any?): { [string]: any }
One emitter's reading, or — called with no argument — the whole world's:
every live emitter's document plus the totals they sum to. An engine with
no emitters answers count = 0 with an empty list, which reads differently
from an engine whose emitters are all silent.
Parameters
systemany?(optional) — Optional ParticleSystem to read; omitted, every live one.
local world = Particles.observe(); print(world.alive, world.silent)
modules/Particles/silenceReasons
silenceReasons(): { { reason: string, means: string } }
The closed set of reasons an emitter can be producing nothing, in the
order a reading resolves them — nearest cause first — each with what it
means. Every observe().reason is one of these.
for _, r in ipairs(Particles.silenceReasons()) do print(r.reason, r.means) end
modules/Particles/whySilent
whySilent(system: any): (string?, string?)
Why one emitter is producing nothing, from the closed set
silenceReasons() enumerates — or nil when it is producing. The second
return is the detail line naming what the reason is about.
Parameters
systemany(optional) — The particle system to ask about.
local why, detail = Particles.whySilent(fire)
modules/PluginAssetTypeRef/README
require("@builtin::assetTypes.plugin.behavior") -- PluginAssetTypeRef
The lifecycle of every AssetRef<plugin>: onCreate makes one, registering loads it, and a change to its component or manifest loads it again in place.
Usage: local PluginAssetTypeRef = require("@builtin::assetTypes.plugin.behavior")
modules/PluginAssetTypeRef/doSomething
doSomething(input: string): any
What doSomething does.
Parameters
inputstring— What the caller passes.
local answer = await({name}.doSomething("x"))
modules/PluginAssetTypeRef/onChange
onChange(self, change)
Load the plugin again when its component or its manifest changes.
Parameters
selfany(optional) — TheAssetRef<plugin>whose files changed.changeany(optional) —{ path, kind, origin }describing the write.
modules/PluginAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Make a new plugin asset: its manifest, README, surface module and search metadata, and its component when one is given.
Given bytes, the asset is made WITH its component in one write, so it
registers as a plugin that can load rather than as an empty folder that
is filled in afterwards. Without them it is a scaffold, and it loads when a
plugin.wasm is written into it.
Parameters
namestring— The plugin's name, which is also its identity in this world.optsCreateOpts
asset.create("plugin", "motion", { bytes = componentBytes })
modules/PluginAssetTypeRef/onDelete
onDelete(self)
Stop the plugin this asset loaded, because the asset is gone.
Parameters
selfany(optional) — TheAssetRef<plugin>that was removed.
modules/PluginAssetTypeRef/onRegister
onRegister(self)
Load the plugin this asset carries.
Parameters
selfany(optional) — TheAssetRef<plugin>registering.
modules/PluginShared/README
require("@builtin::assetTypes.plugin.shared") -- PluginShared
What every plugin's Luau surface is built on: calling the plugin it belongs to, listening to it, and asking the person to open one of its pages. Shipped by the TYPE, so no plugin implements any of it.
Usage: local PluginShared = require("@builtin::assetTypes.plugin.shared")
modules/PluginShared/awaitingPerson
awaitingPerson(): boolean
Whether a call to this plugin is waiting on a person.
modules/PluginShared/call
call(method: string, ...): any
Call one of the methods this plugin's plugin.yaml exposes.
Parameters
methodstring
modules/PluginShared/identity
identity(): string
This plugin's engine identity, for a caller that needs to name it.
modules/PluginShared/on
on(listener: (string, any) -> ())
Listen to this plugin's events, waiting for it to load first.
Parameters
listener(string, any) -> ()—function(eventType, payload).
modules/PluginShared/openUrl
openUrl(url: string): any
Ask the person to open one of this plugin's own declared pages.
Parameters
urlstring
modules/PopulationAssetTypeBehavior/README
require("@builtin::assetTypes.population.behavior") -- PopulationAssetTypeBehavior
Behaviour for the population asset type — a hardware-instanced population at rest. onCreate writes the recipe (population.json) plus the instance matrices as bytes (transforms.bin); :draw() turns that recipe back into live GPU buffers and draw registrations, and instantiate puts one entity in the scene that owns them for as long as it lives.
Usage: local PopulationAssetTypeBehavior = require("@builtin::assetTypes.population.behavior")
modules/PopulationAssetTypeBehavior/bounds
bounds(self): any
The box the drawn instances occupy — each variant's mesh
AABB carried through every one of its matrices, in the space the matrices
are taken in: the parent's own frame for a population drawn with a
parent, world space otherwise.
Parameters
selfany(optional)
local box = drawn:bounds()
modules/PopulationAssetTypeBehavior/count
count(self): number
Instances the engine reports drawing across every registration this holds. Read back from the renderer rather than from the recipe, so a registration that went away, or that the renderer turned away, counts as gone.
Parameters
selfany(optional)
print(drawn:count())
modules/PopulationAssetTypeBehavior/destroy
destroy(self)
Release every registration and its transform buffer. The draw is
dropped BEFORE its buffer is destroyed: a registration reserves slots
against the buffer it was given, so a buffer that goes away takes its
registration with it. The meshes belong to their .mesh assets and stay.
A second call finds an empty list and returns.
Parameters
selfany(optional)
drawn:destroy()
modules/PopulationAssetTypeBehavior/draw
draw(self, opts: { [string]: any }?): any
Rebuild this population's live draws: allocate a GPU transform buffer
per variant, upload that variant's run of transforms.bin into it,
resolve the mesh and material, and register one instanced draw. The
returned value OWNS those resources — hold it and call :destroy() to
release them; a registration nobody holds can be neither enumerated nor
dropped afterwards. With a parent the matrices are taken in that entity's
space and the draws move with it; without one they stand where the recipe
placed them in the world.
Parameters
selfany(optional)opts{ [string]: any }?(optional) —{ castsShadows? = true, renderLayer?, parent? }—parentis the entity (or its id) the copies stand in.
local drawn = populationRef:draw(); … ; drawn:destroy()
modules/PopulationAssetTypeBehavior/drawCalls
drawCalls(self): number
Draw calls this population costs — one per variant the renderer is
drawing, at any instance count. A variant the renderer turned away costs
nothing and is counted nowhere; :errors() says why.
Parameters
selfany(optional)
print(drawn:drawCalls())
modules/PopulationAssetTypeBehavior/errors
errors(self): { any }
Why this population is drawing less than its recipe asks for: one entry
per registration the renderer turned away, carrying the variant it belongs
to, the mesh it names and the renderer's own reason. A population drawing
everything it holds answers with an empty list, so this and :drawCalls()
agree with the frame.
Parameters
selfany(optional)
for _, e in ipairs(drawn:errors()) do warn(e.variant, e.error) end
modules/PopulationAssetTypeBehavior/inspectDetail
inspectDetail(self): any
asset.inspect type-specific detail: { total, variantCount, variants }, read straight from population.json — never allocates a
buffer or registers a draw. A population whose recipe can't be read
returns an empty detail rather than erroring.
Parameters
selfany(optional)
local n = asset.inspect(populationRef).detail.total
modules/PopulationAssetTypeBehavior/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Instantiate this population — the uniform instantiate(target?, opts?)
contract every scene-instantiable asset answers to. A population becomes
ONE entity carrying a Population component that references this asset:
the component rebuilds the live draws on awake and releases them on
destroy, so the scene records one entity for a population of any size and
a reload replaces the draws rather than stacking a second set. With
target the entity spawns as a child of that owner (so an owning Asset
component tears it down with its other children); with no target it is a
fresh root. The base opts — position, rotation, scale, name,
temporary — place the root.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional owning entity ref.opts{ [string]: any }?(optional) —{ position?, rotation?, scale?, name?, temporary? }.
populationRef:instantiate(owner)
modules/PopulationAssetTypeBehavior/onCreate
onCreate(name: string, opts: CreateOpts?): { [string]: string }
Generic-creation hook for asset.create("population", name, opts).
Pure: returns the content-file map; asset.create writes it to the
mode-aware destination. Each variant contributes its mesh + material to
population.json and its matrices to transforms.bin, in variant order.
Parameters
namestring— Population identity (the instance name).optsCreateOpts?(optional)
asset.create("population", "forest", { variants = { { mesh = meshGuid, material = matGuid, transforms = flat } } })
modules/PopulationAssetTypeBehavior/setRenderLayer
setRenderLayer(self, renderLayer: number)
Put every registration this holds on the render layers renderLayer
names. Constant time per registration — the transforms are not re-uploaded
and nothing is re-registered — so a population can follow a membership that
moves, and the next frame drawn tests its copies against the new one.
Parameters
selfany(optional)renderLayernumber— The membership bitmask, the same value:draw({ renderLayer })takes. At least one bit must be set.
drawn:setRenderLayer(mask)
modules/PopulationAssetTypeBehavior/settled
settled(self): boolean
Whether the renderer has answered for every registration this holds.
A registration is made a stage before the renderer sees it, so the frame it
is made in is one where nothing yet says whether the copies are drawn;
:errors() is complete from the frame this turns true.
Parameters
selfany(optional)
if drawn:settled() then print(#drawn:errors(), "variants failed") end
modules/PopulationAssetTypeBehavior/spec
spec(self): any
The recipe this population draws from: { version, total, variants },
where each variant carries { mesh, material?, materialKey?, count, offset } — the .mesh it draws, the material it draws with, how many
instances it holds, and where its matrices start in transforms.bin
(counted in instances).
Parameters
selfany(optional)
local total = populationRef:spec().total
modules/PopulationAssetTypeBehavior/transforms
transforms(self): string
The instance matrices as raw bytes — total * 64, little-endian f32,
column-major mat4 per instance, in variant order.
Parameters
selfany(optional)
local blob = populationRef:transforms()
modules/PostMetrics/README
require("@builtin::modules.postMetrics") -- PostMetrics
Instruments for judging a picture by numbers: FLIP against a golden, pixel metrics (banding, halo overshoot, temporal variance, ring energy, hue drift), CPU twins of the display curves and of the synthetic HDR chart, and scope pictures (histogram, waveform, vectorscope, false colour, banding zebra, tone curve). Every function takes a picture in any form one arrives in: a TextureCpuHandle, a frame renderer.presentedFrames returns, a capture result carrying base64 data, or PNG / ZTEX bytes. Pixel values are code values on the 0-255 scale the picture is delivered at unless a function says it reads light.
Usage: local PostMetrics = require("@builtin::modules.postMetrics")
modules/PostMetrics/banding
banding(frame: any, rect: Rect?, opts: { channel: string?, tolerance: number? }?): Banding
Banding along a ramp. The rectangle's columns are averaged over its
rows (so dither, which varies from row to row, averages into a smooth
profile and a quantised ramp does not), and the profile is read for how
long it stays flat. longestRun is the most consecutive columns holding
one value, distinctCodes how many distinct whole code values the
profile passes through, and steps how many times it changes value. A
ramp that climbs fewer code values than it has columns, undithered, holds
each one for several columns: a long longestRun is a visible band.
Give the rectangle several rows; one row of a dithered ramp has runs of
its own.
Parameters
frameany(optional) — The picture.rectRect?(optional) — The ramp's rectangle, its gradient running along x; the whole picture when nil.opts{ channel: string?, tolerance: number? }?(optional) —{ channel?, tolerance? }:toleranceis how far apart two values may be and count as one (default 0.001).
local b = postMetrics.banding(frame, { x = 0, y = 8, w = 256, h = 16 }); print(b.longestRun)
modules/PostMetrics/canvas
canvas(width: number, height: number, fill: { number }?): Canvas
A blank RGBA8 picture to draw into on the CPU, filled with one colour (code values, default black, opaque).
Parameters
widthnumber— Pixels across.heightnumber— Pixels down.fill{ number }?(optional) —{ r, g, b }in code values.
local c = postMetrics.canvas(64, 64)
modules/PostMetrics/chart.hide
chart.hide(name: string?)
Take the chart down again.
Parameters
namestring?(optional) — The namechart.showreturned (default "postMetrics_chart").
modules/PostMetrics/chart.light
chart.light(props: any, u: number, v: number): (number, number, number)
The light the chart holds at a point of the picture (u, v from
the top-left, 0..1), the CPU twin of the chart shader: what a reference
picture for the chart is built from. It returns the light before dither.
Parameters
propsany(optional) — The chart's properties (patternby number or name).unumber— Across, 0 at the left edge.vnumber— Down, 0 at the top edge.
local r, g, b = postMetrics.chart.light({ pattern = "greyWedge" }, 0.5, 0.5)
modules/PostMetrics/chart.patch
chart.patch(props: any, width: number, height: number, stop: number, half: string?, inset: number?): Rect
The pixel rectangle one column of a wedge pattern covers in a
width x height picture, inset by inset pixels on each side so a
reading stays clear of the edges between columns. half picks the top
("top") or bottom ("bottom") half of a colour wedge; nil covers the
whole height.
Parameters
propsany(optional) — The chart's properties.widthnumber— The picture's width.heightnumber— The picture's height.stopnumber— The column's exposure in whole stops.halfstring?(optional) —"top","bottom"or nil.insetnumber?(optional) — Pixels kept clear of each edge (default 1).
local rect = postMetrics.chart.patch({ pattern = "colorWedge" }, 168, 64, 4, "top")
modules/PostMetrics/chart.reference
chart.reference(props: any, width: number, height: number, curve: any, exposure: number?): any
The picture the display should present for the chart: every pixel's
chart light taken through curves.display with curve and exposure
and rounded to a code value. Held against the presented chart with
flip, it measures the display path against its reference; built with a
different curve, it measures how far the display path stands from that.
Parameters
propsany(optional) — The chart's properties.widthnumber— Pixels across, the presented chart's.heightnumber— Pixels down.curveany(optional) — The curve, ascurves.displaytakes it.exposurenumber?(optional) — The exposure (default 1).
local ref = postMetrics.chart.reference({ pattern = "colorWedge" }, 128, 64, postMetrics.curves.acesHuePreserving)
modules/PostMetrics/chart.show
chart.show(props: any?, name: string?): string
Draw the chart in place of the scene: register
@builtin::shaders.post.hdrChart first in the chain (on the scene
layer, in light) with props. Everything after it in the chain (the
effects registered after, and the display transform) draws over it.
Parameters
propsany?(optional) — The chart's properties (patternby number or name).namestring?(optional) — The effect's name (default "postMetrics_chart").
local name = postMetrics.chart.show({ pattern = "ramp", low = 0, high = 0.1 })
modules/PostMetrics/curves.aces
curves.aces(x: number): number
The ACES filmic fit of Narkowicz 2015 (__display__ curve 2),
applied to one channel.
Parameters
xnumber
modules/PostMetrics/curves.acesHuePreserving
curves.acesHuePreserving(r: number, g: number, b: number): (number, number, number)
ACES (Narkowicz) applied to a colour's largest channel, the colour scaled with it: the channels keep their ratios, so the hue a per-channel curve skews is kept. On grey it is the per-channel curve exactly.
Parameters
rnumbergnumberbnumber
modules/PostMetrics/curves.clamp
curves.clamp(x: number): number
The clamp curve (__display__ curve 0): light clipped to 0..1.
Parameters
xnumber
modules/PostMetrics/curves.display
curves.display(r: number, g: number, b: number, curve: any, exposure: number?): (number, number, number)
What the display transform __display__ presents for a colour in
light: exposure, then curve (0 clamp, 1 Reinhard, 2 ACES, 3 PBR
Neutral, or a function (r, g, b) -> (r, g, b)), then the sRGB encode,
in code values (0..255, unrounded).
Parameters
rnumber— Red, in light.gnumber— Green, in light.bnumber— Blue, in light.curveany(optional) — The curve's number, or a function.exposurenumber?(optional) — The multiplier on the light before the curve (default 1).
local r, g, b = postMetrics.curves.display(0.18, 0.18, 0.18, 3)
modules/PostMetrics/curves.pbrNeutral
curves.pbrNeutral(r: number, g: number, b: number): (number, number, number)
Khronos PBR Neutral (__display__ curve 3), over a colour in light.
The reference is the Khronos sample implementation
(https://github.com/KhronosGroup/ToneMapping).
Parameters
rnumbergnumberbnumber
modules/PostMetrics/curves.reinhard
curves.reinhard(x: number): number
Reinhard (__display__ curve 1): x / (1 + x).
Parameters
xnumber
modules/PostMetrics/expectGolden
expectGolden(frame: any, path: string, opts: any?): Golden
golden, raising its reason when the picture does not pass.
Parameters
frameany(optional) — The picture.pathstring— The golden's VFS path.optsany?(optional) — The optionsgoldentakes.
postMetrics.expectGolden(frame, here .. "/goldens/halo.png", { maxMean = 0.02 })
modules/PostMetrics/flip
flip(test: any, reference: any, opts: any?): any
NVIDIA FLIP of test against reference: how different the two look
to a viewer flipping between them, per pixel in 0..1, summarised. mean
is the number the reference evaluator reports for a pair; around 0.01 is
invisible flipping between them, around 0.1 a difference anybody sees.
Parameters
testany(optional) — The picture being judged.referenceany(optional) — The picture it is held against, of the same size.optsany?(optional) —{ rect?, pixelsPerDegree?, errorMap? }:rectsummarises one rectangle of the error map;errorMap = truehands back the per-pixel error as a grey picture.
local f = postMetrics.flip(frame, golden); print(f.mean)
modules/PostMetrics/golden
golden(frame: any, path: string, opts: any?): Golden
Compare a picture with the golden stored at path (a PNG), by FLIP.
It passes when the FLIP mean is at most maxMean (default
GOLDEN_MAX_MEAN) and, when maxP99 is given, its 99th percentile at
most that: tolerant of the noise one GPU, driver or platform puts on a
picture another drew, and failing at a change a viewer sees. status is
"matched", "differs", "size" (the two are not one size), "missing"
(no golden at path) or "recorded". record = true writes the picture
as the golden instead of comparing, which is how a golden is made or
remade after a change that is meant to change the picture.
Parameters
frameany(optional) — The picture.pathstring— The golden's VFS path, a.png.optsany?(optional) —{ maxMean?, maxP99?, rect?, pixelsPerDegree?, record?, errorMap? }
local g = postMetrics.golden(frame, asset.containing(__FILE__).path .. "/goldens/halo.png")
modules/PostMetrics/halfWidth
halfWidth(profile: { number }): number
The distance, in profile entries, at which a profile has fallen to half of its first entry, interpolated between the two entries either side.
Parameters
profile{ number }— A profile, from its source outward.
postMetrics.halfWidth(postMetrics.profile(frame, row))
modules/PostMetrics/haloOvershoot
haloOvershoot(frame: any, rect: Rect?, opts: { plateau: number?, channel: string?, linear: boolean? }?): Overshoot
Halo overshoot at an edge: how far a profile across a step between
two flat regions rises above the brighter plateau and falls below the
darker one. A sharpening or a ringing filter overshoots; a clean edge
stays between its plateaus. The plateaus are the means of the profile's
first and last plateau entries.
Parameters
frameany(optional) — The picture.rectRect?(optional) — A rectangle across the edge, its gradient running along x.opts{ plateau: number?, channel: string?, linear: boolean? }?(optional) —{ plateau?, channel?, linear? }:plateaudefaults to 4.
local e = postMetrics.haloOvershoot(frame, { x = 100, y = 60, w = 40, h = 8 })
modules/PostMetrics/hueDrift
hueDrift(colours: { any }): HueDrift
Hue drift of one colour across a series of readings (a saturated
patch over exposure, say): each reading's CIELAB hue angle, drift the
largest angle any reading stands from the first, and span the angle
between the two readings furthest apart. A tone curve that keeps a
colour's hue as it brightens drifts by nothing. Readings are colours in
light ({ r, g, b }) or results of meanColour.
Parameters
colours{ any }— The readings, in order.
local d = postMetrics.hueDrift({ postMetrics.meanColour(a, rect), postMetrics.meanColour(b, rect) }).drift
modules/PostMetrics/image
image(source: any): (any, boolean)
Load a picture (PNG / ZTEX bytes, a capture result, a presented
frame) into a TextureCpuHandle. A handle passes through unchanged.
Parameters
sourceany(optional) — The picture.
local cpu, loaded = postMetrics.image(vfs.read(path)); ...; if loaded then cpu:unload() end
modules/PostMetrics/lab
lab(r: number, g: number, b: number): { L: number, a: number, b_: number, chroma: number, hue: number }
CIELAB of a colour in linear light (sRGB primaries, D65 white):
lightness L, the opponent axes a and b_, chroma and hue (the
hue angle in degrees, 0..360).
Parameters
rnumber— Red, in light.gnumber— Green, in light.bnumber— Blue, in light.
postMetrics.lab(0.05, 0.1, 1.0).hue
modules/PostMetrics/meanColour
meanColour(frame: any, rect: Rect?): Colour
The mean colour of a rectangle: its code values, the light they decode to (averaged as light), and that light's CIELAB lightness, chroma and hue.
Parameters
frameany(optional) — The picture.rectRect?(optional) —{ x, y, w, h }; the whole picture when nil.
local patch = postMetrics.meanColour(frame, { x = 10, y = 10, w = 8, h = 8 })
modules/PostMetrics/picture
picture(source: any): any
A picture as an image value: returned from execute, a tool or a
probe, it reaches the caller as a picture (mcp.image).
Parameters
sourceany(optional) — The picture.
return postMetrics.picture(postMetrics.scopes.waveform(frame))
modules/PostMetrics/profile
profile(frame: any, rect: Rect?, opts: { axis: string?, channel: string?, linear: boolean? }?): { number }
The values along a rectangle of a picture: one per column (axis = "x", the default), each the mean over the rectangle's rows, or one per
row (axis = "y"). channel is "luma" (Rec. 709, the default), "r",
"g" or "b"; linear = true reads light (0..1) in place of code values.
Parameters
frameany(optional) — The picture.rectRect?(optional) —{ x, y, w, h }; the whole picture when nil.opts{ axis: string?, channel: string?, linear: boolean? }?(optional) —{ axis?, channel?, linear? }
local row = postMetrics.profile(frame, { x = 0, y = 40, w = 256, h = 1 })
modules/PostMetrics/ringEnergy
ringEnergy(frame: any, cx: number, cy: number, inner: number, outer: number): RingEnergy
The light in a ring around a point: the summed Rec. 709 luminance,
in light (0..1 per pixel, decoded from sRGB), of every pixel whose centre
lies at least inner and less than outer pixels from (cx, cy). The
energy a bloom spreads out of a source is the ring's energy with the bloom
less the same ring's without it.
Parameters
frameany(optional) — The picture.cxnumber— The ring's centre, in pixels from the left (a pixel's centre is +0.5).cynumber— The ring's centre, in pixels from the top.innernumber— The inner radius in pixels.outernumber— The outer radius in pixels.
local e = postMetrics.ringEnergy(frame, 64, 64, 4, 24).energy
modules/PostMetrics/scopes.falseColor
scopes.falseColor(frame: any, opts: { middleGrey: number? }?): any
False-colour exposure: each pixel painted by the band of stops its
light stands at relative to middleGrey (light, default 0.18): deep
purple below -6, blue to -4, cyan-blue to -2, grey to -0.5, green within
half a stop of middle grey, light grey to +2, yellow to +2.4, orange
above; pixels at code 255 in any channel are red (clipped) and at 0 in
every channel dark purple-black (crushed).
Parameters
frameany(optional) — The picture.opts{ middleGrey: number? }?(optional) —{ middleGrey? }
return postMetrics.picture(postMetrics.scopes.falseColor(frame))
modules/PostMetrics/scopes.histogram
scopes.histogram(frame: any, opts: { rect: Rect?, height: number? }?): any
A histogram picture: luma (grey) and the red, green and blue
channels (each drawn as its own line) over the 256 code values, left to
right, each column's height its share of the tallest bucket. rect is
the metering window: only the pixels inside it are counted.
Parameters
frameany(optional) — The picture.opts{ rect: Rect?, height: number? }?(optional) —{ rect?, height? }:heightdefaults to 128.
return postMetrics.picture(postMetrics.scopes.histogram(frame, { rect = { x = 0, y = 0, w = 64, h = 64 } }))
modules/PostMetrics/scopes.toneCurve
scopes.toneCurve(curves: { any }, opts: { evMin: number?, evMax: number?, size: number? }?): any
A tone curve plot: each curve's output code value (up) against its
input light from evMin to evMax stops around middle grey (across, on
a log scale), with middle grey and the output's 0 and 255 marked. A
curve is a __display__ curve number or a function (r, g, b) -> (r, g, b) over light.
Parameters
curves{ any }— The curves, each drawn in its own colour (white, orange, cyan, magenta, then repeating).opts{ evMin: number?, evMax: number?, size: number? }?(optional) —{ evMin?, evMax?, size? }: defaults -10, 10, 256.
return postMetrics.picture(postMetrics.scopes.toneCurve({ 2, 3 }))
modules/PostMetrics/scopes.vectorscope
scopes.vectorscope(frame: any, opts: { size: number? }?): any
A vectorscope: every pixel's chroma (Rec. 709 Cb across, Cr up) on a disc, brighter where more pixels share it. Grey sits at the centre; a saturated colour sits out toward the rim along its hue. Graticule: the rim and the directions of the six primaries and secondaries.
Parameters
frameany(optional) — The picture.opts{ size: number? }?(optional) —{ size? }: the scope's side in pixels (default 256).
return postMetrics.picture(postMetrics.scopes.vectorscope(frame))
modules/PostMetrics/scopes.waveform
scopes.waveform(frame: any, opts: { width: number? }?): any
A luma waveform: one column per column of the picture (resampled to
at most width), its pixels plotted by code value from the bottom (0) to
the top (255), brighter where more pixels share a value. A flat region is
a thin line, a gradient a slope, a clipped highlight a line along the top.
Parameters
frameany(optional) — The picture.opts{ width: number? }?(optional) —{ width? }: the most columns the scope has (default 512).
return postMetrics.picture(postMetrics.scopes.waveform(frame))
modules/PostMetrics/scopes.zebra
scopes.zebra(frame: any, opts: { minRun: number?, maxRun: number? }?): (any, number)
A banding zebra: the picture in grey, with diagonal magenta stripes
over every run of minRun or more pixels along a row that holds one code
value and ends in a step of one or two code values to its neighbour: a
contour a smooth gradient was quantised into. Flat regions with no step
at their end, and runs longer than maxRun, are left unmarked.
Parameters
frameany(optional) — The picture.opts{ minRun: number?, maxRun: number? }?(optional) —{ minRun?, maxRun? }: defaults 4 and 128.
local z, marked = postMetrics.scopes.zebra(frame)
modules/PostMetrics/temporalVariance
temporalVariance(frames: { any }, rect: Rect?, opts: { channel: string?, linear: boolean? }?): TemporalVariance
Temporal variance: how much each pixel changes across a run of
frames of the same view. Each pixel's variance over the frames is taken,
in code values squared (or light squared, linear = true), and the
rectangle summarised. A converged temporal resolve on a still view holds
every pixel; flicker, shimmer and crawl are variance.
Parameters
frames{ any }— Two or more pictures of one size, in order.rectRect?(optional) —{ x, y, w, h }; the whole picture when nil.opts{ channel: string?, linear: boolean? }?(optional) —{ channel?, linear? }
local f = renderer.presentedFrames({ frames = 16 }); local v = postMetrics.temporalVariance(f)
modules/PostMetrics/toImage
toImage(c: Canvas): any
A canvas as a TextureCpuHandle, for the metrics, flip and
picture. The caller unloads it.
Parameters
cCanvas— The canvas.
local cpu = postMetrics.toImage(c)
modules/PostMetrics/upturns
upturns(profile: { number }, tol: number): number
How many times a profile turns back UP by more than tol: a local
minimum followed by a rise of at least tol. A halo falls away from its
source and turns back up nowhere; a kernel taking taps on a grid
re-brightens at every tap.
Parameters
profile{ number }— A profile, from its source outward.tolnumber— The rise, in the profile's units, that counts as a turn.
postMetrics.upturns(postMetrics.profile(frame, row), 2)
modules/Prelude/README
require("@builtin::modules.prelude") -- Prelude
Auto-require globals available in every script without require(). Injects Entity, Physics, Transform, and Material as global Luau wrappers.
This script runs once after FFI registration. It requires builtin library
modules and exposes them as globals. Users never need to write:
local Entity = require(".entity_reflect")
Instead they just use Entity directly.
Only high-frequency, universally-useful APIs belong here.
Specialized modules (e.g. agent tools, editor UI) still use require().
Convention:
__name = raw FFI binding (Rust native call, never used directly by scripts)
Name = Luau wrapper (user-facing, auto-injected via this prelude)
Usage: local Prelude = require("@builtin::modules.prelude")
modules/PresetAssetTypeRef/README
require("@builtin::assetTypes.preset.behavior") -- PresetAssetTypeRef
Per-instance methods on every AssetRef<preset>, the onCreate hook that writes a checked preset.yaml, and the validation asset.validate and every edit run.
Usage: local PresetAssetTypeRef = require("@builtin::assetTypes.preset.behavior")
modules/PresetAssetTypeRef/applyTo
applyTo(self, entityId: string, componentType: string, overrides: { [string]: any }?): boolean
Write this preset's values, overrides laid on top, onto the
componentType component of entityId, field by field. Forwards to
preset.load, which warns once that preset.values replaces it.
Parameters
selfany(optional)entityIdstring— Target entity ID.componentTypestring— Component type name (e.g."Locomotion").overrides{ [string]: any }?(optional) — Optional shallow overrides applied on top of the preset.
modules/PresetAssetTypeRef/getDefinition
getDefinition(self): string?
Read the preset's preset.yaml body as raw text.
Parameters
selfany(optional)
local raw = presetRef:getDefinition()
modules/PresetAssetTypeRef/inspect
inspect(self): any
asset.inspect detail: the target, the format, the checked values,
every rejected field, and whether the target changed since it was pinned.
componentType names the component a component preset configures (nil
for any other target), and fieldValues is the same table as values.
Parameters
selfany(optional)
local detail = asset.inspect(presetRef).detail
local componentType = asset.inspect(presetRef).detail.componentType
modules/PresetAssetTypeRef/load_preset
load_preset(self, overrides: { [string]: any }?): { [string]: any }?
This preset as a plain table, overrides laid on top. Forwards to
preset.load, which warns once that preset.values replaces it.
Parameters
selfany(optional)overrides{ [string]: any }?(optional) — Optional table merged shallowly over the values.
modules/PresetAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Write a preset for opts.target's schema holding opts.values,
checked against that schema before anything is written.
Parameters
namestring— The preset's name.optsCreateOpts
modules/PresetDefaults/README
require("@builtin::modules.preset.defaults") -- PresetDefaults
The Preset Manager: the world's ordered [[presets]] rows in /zero/source/.world_settings. A row names one declarer (target), one preset for that declarer (preset) and a path glob (filter). When something a declarer governs is created — an asset of an assetType, an import an importer runs, a component added to an entity — the first row naming that declarer whose filter matches the new thing's path gives a layer of its settings. Rows are read only at creation.
Usage: local PresetDefaults = require("@builtin::modules.preset.defaults")
modules/PresetDefaults/batchLayers
batchLayers(targets: { any }, typeName: string, data: { [string]: any }?): { { targets: { any }, data: { [string]: any }? } }
The targets of a batch component add split into runs by the data each
takes: consecutive targets the same row reaches (or no row reaches) share
one run, each with the data forComponent gives its members. Adding the
runs in order adds the targets in the order given. A world whose rows
name nothing for typeName gives one run of every target.
Parameters
targets{ any }— Entity ids or proxies.typeNamestring— The component type.data{ [string]: any }?(optional) — The values the caller passed, or nil.
for _, g in ipairs(Defaults.batchLayers(ids, "Model", {})) do print(#g.targets) end
modules/PresetDefaults/check
check(value: any, _constraint: any): (boolean, string?)
The presetDefaultRow constraint's validator: a row passes when
rowProblems finds nothing.
Parameters
valueany(optional) — The row._constraintany(optional) — The constraint descriptor.
local ok, why = Defaults.check(row, { kind = "presetDefaultRow" })
modules/PresetDefaults/consultedAt
consultedAt(declarer: any): string?
Where a declarer's settings are consulted when something it governs
is created: "import" for an importer, "component.add" for a
component, "asset.create" for an assetType that declares one schema for
every instance. Nil for any other asset.
Parameters
declarerany(optional) — The declarer's AssetRef.
Defaults.consultedAt(asset.resolve("@builtin::importers.texture")) --> "import"
modules/PresetDefaults/entityPath
entityPath(id: string): string
An entity's hierarchy path: its ancestors' names from the root down
and its own, joined by /. A nameless entity contributes its id.
Parameters
idstring— The entity id.
Defaults.entityPath(id) --> "level/props/crate"
modules/PresetDefaults/forComponent
forComponent(entityId: string, typeName: string, data: { [string]: any }?): { [string]: any }?
The data a component add of typeName to entityId takes: data
as given, or a new table holding the first matching row's values with
data's own values laid over them, field by field. The row is read when
the component is added; a row edited later changes no component already
added. A row applies to what a scene build's capture scope adds
(entity.capturing()), in any mode and whoever runs the build, and
outside a build in edit mode. A component put back from existing content
takes none: one added inside materializing, and one a component's own
code adds outside a build, on any coroutine it runs. The component's own
public defaults fill whatever neither states.
Parameters
entityIdstring— The entity the component is added to.typeNamestring— The component type.data{ [string]: any }?(optional) — The values the caller passed, or nil.
local data = Defaults.forComponent(id, "Model", { model = "cube" })
modules/PresetDefaults/importerSettings
importerSettings(importerRef: any, sourcePath: string): ({ [string]: any }, Match?)
An importer's settings for importing sourcePath: its own values
with its first matching [[presets]] row (the filter read against the
source path under /source) laid over them, a struct group field by field.
Parameters
importerRefany(optional) — The importer.sourcePathstring— The source file being imported.
local s = Defaults.importerSettings(asset.resolve("@builtin::importers.texture"), "/source/sprites/hero.png")
modules/PresetDefaults/layerFor
layerFor(declarerGuid: string, relPath: string): ({ [string]: any }?, Match?)
The layer the Preset Manager gives a new thing declarerGuid governs
at relPath, and the row that gives it. A matching row whose preset does
not resolve, or is for another declarer, gives no layer and says why.
Parameters
declarerGuidstring— The declarer's guid.relPathstring— The new thing's path, asrelativePathOfgives it.
local values, match = Defaults.layerFor(asset.guid(importer), "sprites/hero.png")
modules/PresetDefaults/match
match(declarerGuid: string, relPath: string): (Row?, number?)
The first row naming declarerGuid whose filter matches relPath.
Parameters
declarerGuidstring— The declarer's guid.relPathstring— The new thing's path, asrelativePathOfgives it.
local row, index = Defaults.match(asset.guid(importer), "sprites/hero.png")
modules/PresetDefaults/materializing
materializing(fn: (...any) -> ...any, ...: any): ...any
Run fn with no Preset Manager row reaching a component add on this
thread — for code that puts back a component that already existed (a
peer's record, a saved scene's record, a template's clone).
Parameters
fn(...any) -> ...any— The function to run.argsany(optional)
Defaults.materializing(function() entity(id).component.add("Model", saved) end)
modules/PresetDefaults/normalize
normalize(input: RowInput): StoredRow
A row input as the row a world stores: its target and preset as guid
envelopes, its filter as a string. An absent target is the preset's own.
A target that does not resolve is kept as written so rowProblems names
it; a preset that does not resolve raises.
Parameters
inputRowInput—{ preset, target?, filter? }; preset and target take an AssetRef, envelope, guid or identity.
local row = Defaults.normalize({ preset = "pixel_art", filter = "sprites/**" })
modules/PresetDefaults/recordingStamps
recordingStamps(fn: (...any) -> ...any, ...: any): ...any
Run fn and return, before its own results, what the Preset
Manager rows gave the components added on this thread while it ran inside
a capture scope: per stampKey, the fields the row gave that the add's
caller did not state, sorted — a field of a group the caller stated only
partly as group.field.
Parameters
fn(...any) -> ...any— The function to run.argsany(optional)
local stamps, ids = Defaults.recordingStamps(entity.capture, builder)
modules/PresetDefaults/relativePathOf
relativePathOf(path: string): string?
The path a row's filter reads for path, without a leading slash: the
path under /source for a durable path, the path under
/zero/runtime/assets/ for a runtime asset. Nil for any other path.
Parameters
pathstring— A VFS path.
Defaults.relativePathOf("/zero/source/sprites/hero.png") --> "sprites/hero.png"
modules/PresetDefaults/removeAt
removeAt(index: number)
Remove the row at index and write every other row back exactly as
the file holds it — neither re-normalised nor checked, so a row can be
removed while another is broken.
Parameters
indexnumber— The row's index, asrows()reports it.
Defaults.removeAt(2)
modules/PresetDefaults/resolveValue
resolveValue(v: any): any?
A row value as the asset it names: an envelope by its guid, a string
by the guid .world_settings's .refs pinned for it, else by the string
itself as an identity or guid.
Parameters
vany(optional) — An envelope, a guid or identity string, or an AssetRef-shaped{ path, type }.
local ref = Defaults.resolveValue(row.target)
modules/PresetDefaults/rowProblems
rowProblems(row: any): ({ string }, any?, any?)
Every problem that keeps a row from applying, and the declarer and preset it resolves to.
Parameters
rowany(optional) — A stored row or a row input.
local problems = Defaults.rowProblems({ target = "@builtin::importers.texture", preset = "pixel_art" })
modules/PresetDefaults/rows
rows(): { Row }
The world's rows, in order, each resolved and with every problem that keeps it from applying.
for _, row in ipairs(Defaults.rows()) do print(row.index, row.targetName) end
modules/PresetDefaults/stampKey
stampKey(entityId: string, componentGuid: string, instanceName: string?): string
The key recordingStamps files a component instance under: its
entity, its component's guid and its instance name (empty for an
anonymous one).
Parameters
entityIdstring— The entity.componentGuidstring— The component's guid.instanceNamestring?(optional) — The instance name, or nil.
local key = Defaults.stampKey(id, asset.guid(asset.resolve("Model", "component")), nil)
modules/PresetDefaults/version
version(): number
The content version of the rows file: the engine's own count for
.world_settings, which moves the moment any change of the file lands,
whatever made it, and at no other time.
local v = Defaults.version()
modules/PresetDefaults/write
write(inputs: { RowInput })
Replace the world's rows. Every input is normalised and the whole set
checked first; any problem refuses the write, naming every one. The
[[presets]] block is replaced and the rest of the file kept.
Parameters
inputs{ RowInput }— The complete ordered rows.
Defaults.write({ { preset = "pixel_art", filter = "sprites/**" } })
modules/PresetDefaultsSection/README
require("@builtin::editor.edui.inspector.presetDefaultsSection") -- PresetDefaultsSection
The Preset Manager as an inspector section: the world's ordered [[presets]] rows, each a declarer chip, a preset chip that offers only presets for that declarer, and a filter glob, edited as typed fields through the Settings section, with move up / down, remove and add. An edit that leaves every row whole is one checked, undoable write of .world_settings. A row being filled in — just added, or given its declarer before its preset — stays in the section until it is whole, and shows what it still needs. Removing a row always writes, whatever the other rows hold. A row that cannot apply shows why.
Usage: local PresetDefaultsSection = require("@builtin::editor.edui.inspector.presetDefaultsSection")
modules/PresetDefaultsSection/context
context(): any
The section's context: the rows as values of the block's schema, a writer that checks and writes them, the chip predicate, and each row's problems as its rejection.
local ctx = PresetDefaultsSection.context()
modules/PresetDefaultsSection/render
render(): { any }
The section rendered with a fresh context.
local nodes = PresetDefaultsSection.render()
modules/PresetDefaultsSection/signature
signature(): string
A value that moves whenever what the section shows moves — the rows file's content version and the draft — for a panel's build signature.
sig ..= PresetDefaultsSection.signature()
modules/PresetDocument/README
require("@builtin::modules.preset.document") -- PresetDocument
A preset's preset.yaml. The typed form names the declarer the values are for (target) and the values themselves (values). target is written as a guid envelope, { __ref: <guid>, type: <type>, name: <name> }, which .refs pins by that guid; an identity string is accepted on read. The component-only form names a component by its registered name (component) and lists properties.
Usage: local PresetDocument = require("@builtin::modules.preset.document")
modules/PresetDocument/decode
decode(body: string): Doc
Decode a preset.yaml body. A body with a target is typed; a body
with component or properties is component-only. A component-only body
Yaml.decode refuses is read by the line parser presets have always been
read with. A typed body that does not decode, or whose target is neither
an envelope nor an identity string, raises.
Parameters
bodystring— The file's text.
local doc = Document.decode(vfs.read(path))
modules/PresetDocument/encode
encode(envelope: Envelope, values: { [string]: any }): string
The typed preset.yaml body for a target envelope and values.
Parameters
envelopeEnvelope— The target,{ __ref = <guid>, type = <type>, name = <name> }.values{ [string]: any }— The values.
local Target = require("@builtin::modules.preset.target")
local body = Document.encode(Target.envelopeFor(texType), { filter = "nearest" })
modules/PresetDocument/pathOf
pathOf(ref: any): string
The preset.yaml path of a preset asset.
Parameters
refany(optional) — The preset.
local path = Document.pathOf(presetRef)
modules/PresetDocument/read
read(ref: any): Doc
Read and decode a preset's preset.yaml.
Parameters
refany(optional) — The preset.
local doc = Document.read(presetRef)
modules/PresetDocument/write
write(ref: any, envelope: Envelope, values: { [string]: any })
Write the typed preset.yaml for a target envelope and values, raising
when the write does not land. Inside an open undo operation the write is
recorded into it, so undoing the operation puts back what the file held.
Parameters
refany(optional) — The preset.envelopeEnvelope— The target envelope.values{ [string]: any }— The values.
Document.write(presetRef, envelope, { filter = "nearest" })
modules/PresetGlob/README
require("@builtin::modules.preset.glob") -- PresetGlob
Path globs for Preset Manager rows. * matches any run of characters inside one path segment, ** any run across segments, **/ zero or more whole segments, ? one character other than /; every other character matches itself. A glob matches a whole path. The empty glob matches every path.
Usage: local PresetGlob = require("@builtin::modules.preset.glob")
modules/PresetGlob/match
match(glob: string, path: string): boolean
Whether path matches glob as a whole.
Parameters
globstring— The glob; "" matches everything.pathstring— A/-separated path.
Glob.match("sprites/**", "sprites/ui/button.png") --> true
modules/PresetHeal/README
require("@builtin::modules.preset.heal") -- PresetHeal
Rewrite a preset's preset.yaml into the form presets are written in, on a local edit of this world's own content. A typed document whose target is an identity string that resolves is rewritten with that target as a guid envelope; every value is kept as decoded, including any its target rejects. A component-only document whose component accepts every property it holds is rewritten in the typed form, its target the component, its values exactly as authored, and its legacy name moved to the .metadata title.
Usage: local PresetHeal = require("@builtin::modules.preset.heal")
modules/PresetHeal/forget
forget(ref: any)
Drop what this module remembers about ref, when the preset is removed.
Parameters
refany(optional) — The preset.
Heal.forget(presetRef)
modules/PresetHeal/ifNeeded
ifNeeded(ref: any, origin: string?): boolean
Heal ref on a local edit of this world's own preset: a typed
document naming its target by an identity string that resolves gets the
guid envelope; a component-only document whose component accepts every
property gets the typed form. A component-only document that cannot heal
stays as it is, and the reason is warned once. Convergent: a healed
document is left as it is.
Parameters
refany(optional) — The preset.originstring?(optional) — The edit's origin: "local" (or nil) heals; anything else does not.
Heal.ifNeeded(presetRef, change.origin)
modules/PresetHeal/writeTyped
writeTyped(ref: any, doc: any, declarer: any, values: { [string]: any })
Write values into ref's preset.yaml in the typed form, its target
declarer as a guid envelope. A component-only document's legacy name
moves to the .metadata title first, so every conversion from that form
keeps the name the same way. Inside an open undo operation both writes are
recorded into it.
Parameters
refany(optional) — The preset.docany(optional) — The documentrefholds now, asDocument.readdecoded it.declarerany(optional) — The declarer the values are for.values{ [string]: any }— The values to write.
local Document = require("@builtin::modules.preset.document")
Heal.writeTyped(presetRef, Document.read(presetRef), comp, values)
modules/PresetTarget/README
require("@builtin::modules.preset.target") -- PresetTarget
The declarer a preset's values are for: found by the guid its target envelope names (pinned in the preset's .refs) or by the identity string a hand-written target names, checked against that declarer's current schema, and compared with the checksum the pin recorded.
Usage: local PresetTarget = require("@builtin::modules.preset.target")
modules/PresetTarget/check
check(schema: any, values: { [string]: any }): ({ [string]: any }, { Violation })
Check values against schema field by field: the fields that pass,
and every violation by path, sorted.
Parameters
schemaany(optional) — The declarer's Field schema.values{ [string]: any }— The values.
local valid, rejected = Target.check(schema, { filter = "nearest" })
modules/PresetTarget/declarerOfAsset
declarerOfAsset(ref: any): (any, any)
The declarer governing an asset's settings and its schema: the asset's assetType when the type declares one schema for every instance, else the asset itself when it declares its own.
Parameters
refany(optional) — The asset.
local declarer, schema = Target.declarerOfAsset(texRef)
modules/PresetTarget/declarerOfComponent
declarerOfComponent(t: ComponentTarget): (any, any, any)
The component asset governing a component on an entity, its schema, and the live component proxy.
Parameters
tComponentTarget—{ entity = <id>, component = <name> }.
local comp, schema, proxy = Target.declarerOfComponent({ entity = id, component = "Model" })
modules/PresetTarget/describe
describe(ref: any): string
ref as a person reads it: its identity, else its name.
Parameters
refany(optional) — The declarer.
local name = Target.describe(texTypeRef) --> "@builtin::assetTypes.texture"
modules/PresetTarget/envelopeFor
envelopeFor(ref: any): Envelope
The envelope a preset writes as its target for ref: the guid it
resolves by, and the type and name a person reads it by. name is the
asset's plain name, never an identity, so the envelope's guid is the one
dependency .refs records for it.
Parameters
refany(optional) — The declarer.
local envelope = Target.envelopeFor(texTypeRef) --> { __ref = "8cc2…", type = "assetType", name = "texture" }
modules/PresetTarget/isComponentTarget
isComponentTarget(v: any): boolean
True when v names a component on an entity: { entity = <id>, component = <name> }.
Parameters
vany(optional) — The value.
if Target.isComponentTarget(into) then ... end
modules/PresetTarget/literalFor
literalFor(ref: any): string
The literal a preset's .refs pins for ref: its guid.
Parameters
refany(optional) — The declarer.
local guid = Target.literalFor(texTypeRef)
modules/PresetTarget/merge
merge(schema: any, current: { [string]: any }?, patch: { [string]: any }): { [string]: any }
patch laid over current, by the settings module's one merge rule
(Settings.mergeValues): a struct-kind field (including a resolved
Field.settingsOf group) merges field by field, anything else replaces.
Parameters
schemaany(optional) — The declarer's Field schema.current{ [string]: any }?(optional) — The values the asset has now.patch{ [string]: any }— The values laid over them.
local merged = Target.merge(schema, asset.settings(tex), values)
modules/PresetTarget/refuse
refuse(prefix: string, violations: { Violation })
Raise one error listing every violation under prefix.
Parameters
prefixstring— The error's first line.violations{ Violation }— The violations.
Target.refuse("preset.setValues refused:", violations)
modules/PresetTarget/resolve
resolve(presetRef: any, doc: any): Resolved
Resolve a typed document's target. An envelope resolves by its guid;
pinned is true once the preset's .refs pins that guid, and changed
is true while the pinned checksum differs from the target's current one.
An identity string resolves by identity and reads as unpinned.
Parameters
presetRefany(optional) — The preset whose.refsholds the pin, or nil for a document read on its own.docany(optional) — The decoded typed document.
local Document = require("@builtin::modules.preset.document")
local target = Target.resolve(presetRef, Document.read(presetRef))
modules/PresetTarget/resolveLiteral
resolveLiteral(literal: string): Resolved
Resolve an identity string or a guid, unpinned.
Parameters
literalstring— The declarer's identity or guid.
local target = Target.resolveLiteral("@builtin::assetTypes.texture")
modules/PresetTarget/valuesOf
valuesOf(presetRef: any, doc: any): ({ [string]: any }, Report, Resolved?)
A preset document's values and the report preset.values answers:
a typed document's values checked against its target's current schema
(the valid ones returned, every refused one listed by path), or a
component-only document's values as authored with what its component
would refuse. Raises naming the target when a typed document's target
does not resolve or declares no schema.
Parameters
presetRefany(optional) — The preset the document is read from.docany(optional) — The decoded document (Document.read).
local Document = require("@builtin::modules.preset.document")
local values, report, target = Target.valuesOf(p, Document.read(p))
modules/Preview/README
require("@builtin::modules.preview") -- Preview
Render an asset's preview in the preview studio. ref:preview() renders any asset by the recipe its type declares under preview: in its type.yaml, through these primitives: they spawn temporary entities, frame an offscreen camera over them, render one frame, read it back as a PNG, and tear down. Scheduled previews drain through one serial work queue whose drainer renders in shared batches — subjects settle together and capture concurrently — so a world-scale backfill completes in seconds per hundred assets while the engine stays responsive.
Usage: local Preview = require("@builtin::modules.preview")
modules/Preview/__deviceState
__deviceState(): string
The render device state the preview work queue renders by, read
each time the queue decides whether a queued render can draw:
renderer.deviceState(). A test that has to meet the queue on a device in
another state assigns a function returning that state here and puts this
one back when it ends.
modules/Preview/backdrop
backdrop(): { number }
The studio backdrop's colour in a finished preview, as 0-255
{ r, g, b } — what every pixel of a preview reads where no subject
stands. Measured from a frame of the empty studio the first time it is
asked for.
local bg = preview.backdrop()
modules/Preview/fitToSilhouette
fitToSilhouette(cam: { [string]: any }, shoot: (number, number) -> string?, passes: number?,
Move a camera until what it photographs of its subject stands centred
in the frame and spans TARGET_SPAN (82%) of it, measured from the
pixels. The box's centre is not the silhouette's — a posed model leans, a
lamp's head sits above its post, an effect's faint outer sparks reach past
its bright core — so each pass takes a small shot, finds the subject as
every pixel standing off the backdrop (the shot's own corner), re-aims the
camera at the silhouette's centre and moves it in or out by how far the
silhouette reaches. A subject's share of the frame does not scale evenly
with distance, so each correction is measured again at the framing it
produced. It is how an asset preview is framed; a shot over any flat
backdrop frames the same way.
local settled = preview.fitToSilhouette(cam, shoot)
modules/Preview/fromEntities
fromEntities(makeFn: () -> any, opts: { [string]: any }?): PreviewResult
Instantiate entities via makeFn, auto-frame an offscreen camera to their
bounds, render one frame, and return the still PNG (base64) + stats. Spawned
entities are marked temporary and despawned after the render. Renders are
serialised on the shared preview rig; renders requested while the preview
queue is draining a batch join its shared pass, so each still shows only
its own subject at single-render wall-clock.
Parameters
makeFn() -> any— Function returning an entity id/proxy or array of them to preview.opts{ [string]: any }?(optional) —{ size? = { width, height }, angle? = { yaw, pitch }, entityBudget?, backdrop?, fit? }—entityBudgetis the most entities the subject may compose, roots and everything under them (default 2000); past it the result is unavailable and says how many it composed.backdropnames one ofpreview.backdrops(default"studio").fitis{ minShare?, keep? }, how the camera is fitted to what it sees (preview.fitToSilhouette): a subject that is mostly empty space, such as a spray of sparks, frames on its body with a smallminShareand akeepbelow 1.
preview.fromEntities(function() local e = entity.spawn("x"); e.component.add("Model", { model = meshRef:handle() }); return e end)
modules/Preview/fromRecipe
fromRecipe(ref: any, recipe: { [string]: any }, opts: { [string]: any }?): PreviewResult
Render ref by the preview recipe its type declares (see
@builtin::assetTypes.assetType.shared.previewRecipe). instantiate
stands the asset in the studio through its own instantiate. surface
paints the material the type's ref.previewMaterial returns on
recipe.mesh. image fits the first of recipe.files the asset holds to
the frame, on the studio backdrop, rendering nothing — its result carries
rendered = false. ref:preview() is what calls this; a caller holding a
ref calls that.
Parameters
refany(optional) — The AssetRef to render.recipe{ [string]: any }— The type's recipe,{ kind, mesh?, files?, angle? }.opts{ [string]: any }?(optional) —{ size? = { width, height }, angle? = { yaw, pitch }, live? }.
preview.fromRecipe(ref, { kind = "surface", mesh = "sphere" })
modules/Preview/inputsFingerprint
inputsFingerprint(ref: any): string?
A fingerprint of the content an asset's preview pictures: every file
of the asset that can change the picture, and the version of every asset
those files reference. Its README.md and .metadata, its preview.png and
where the asset sits are not part of it, so describing, renaming or moving
an asset leaves it unchanged. A render records it in the preview it
writes; isCurrent compares the two.
Parameters
refany(optional) — The asset's AssetRef.
print(preview.inputsFingerprint(matRef))
modules/Preview/isCurrent
isCurrent(ref: any): boolean
Whether an asset's preview.png pictures the asset as it is now: it
exists and the fingerprint it recorded matches inputsFingerprint. A
preview rendered before the asset's content last changed, or one that
records no fingerprint, is not current.
Parameters
refany(optional) — The asset's AssetRef.
if not preview.isCurrent(matRef) then preview.schedulePreview(matRef) end
modules/Preview/liveFromEntities
liveFromEntities(makeFn: () -> any, opts: { [string]: any }?): PreviewResult
Instantiate entities via makeFn and hold them under a live orbiting
camera instead of capturing a still: the returned session's rtHandle
names a render target that camera writes EVERY frame (a UI image node
with src = rtHandle shows it live), setOrbit(yaw, pitch, dist?)
moves the camera around the subject's measured centre, and dispose()
despawns the subject, light and camera and destroys the target. The
session holds a key light over the subject the way a still render does.
fromEntities routes here when opts.live is true, so every type's
ref:preview({ live = true }) returns one of these with no wiring.
Parameters
makeFn() -> any— Function returning an entity id/proxy or array of them to preview.opts{ [string]: any }?(optional) —{ live = true, size? = { width, height }, angle? = { yaw, pitch }, entityBudget?, deferFraming? }—entityBudgetbounds the subject exactly asfromEntitiesdoes.deferFramingreturns the session as soon as the subject stands, without waiting for it to report bounds: the camera and light stand for a unit box until the subject measures, and are placed again whenever its bounds change by more than a quarter of its extent (getBoundsanswers the bounds the session stands for).
local p = matRef:preview({ live = true })
modules/Preview/onWritten
onWritten(fn: (path: string) -> ()): () -> ()
Call fn(assetPath) whenever an asset's preview file is written with
new bytes — a consumer showing the picture, which asked for it with
schedulePreview(ref, { requested = true }), redraws when it lands.
Parameters
fn(path: string) -> ()— Called with the asset's folder path.
Returns () — A function that stops fn being called.
local stop = preview.onWritten(function(path) print("new picture for", path) end)
modules/Preview/queueStateOf
queueStateOf(path: string): { [string]: any }?
Where the preview work queue stands on one asset.
Parameters
pathstring— The asset's VFS path, with or without the/zeroprefix.
local s = preview.queueStateOf("/source/gold.material")
modules/Preview/queueStatus
queueStatus(): { [string]: any }
Report the preview work queue: how many renders are pending, the batch currently rendering, what holds the queue when it is waiting, session totals, and the most recent failures. Reading it starts a drain when work is queued and none is running, so a queue whose drain stopped resumes on the next read.
local s = preview.queueStatus(); print(s.pending, s.active, s.held)
modules/Preview/recordedFingerprint
recordedFingerprint(ref: any): string?
The fingerprint an asset's preview.png recorded when it was rendered, or nil when there is no preview or it records none.
Parameters
refany(optional) — The asset's AssetRef.
print(preview.recordedFingerprint(matRef))
modules/Preview/registerDerivedHooks
registerDerivedHooks(): { string }
Register the <type>.preview derive hook of every asset type that
declares a preview recipe, so staging such an asset reserves its
preview.png. The hook is required when the type's type.yaml lists
preview.png under files.required. A type already registered is left as
it is.
modules/Preview/renderForReservation
renderForReservation(snapshot: any, reservation: any): (boolean, string?, string?)
Render the preview a derive reservation asks for: the staged content
snapshot holds, pictured through its type's ref:preview() at 256x256
and returned as PNG bytes recording the fingerprint of that content. The
render waits while the engine is in play mode. When the live asset is
still the staged content it renders from the live asset; when it was
edited or removed after it was staged, the staged files are mounted under
/zero/source/tmp/derive-snapshots/<fingerprint>/ and rendered from that
copy, which is removed again however the render ends. The copy lands whole,
every staged file at once, and a reference it makes to the asset or to an
asset within it (a material's own texture) names that asset's copy, so the
picture is of the staged files alone. An asset the stage
holds no file of is refused with the reason. A subject that draws
nothing has no picture: the answer is true, nil, "empty", which the
derive runner settles as an empty reservation.
Parameters
snapshotany(optional) — The derive snapshot of the asset:path,files,deps,read.reservationany(optional) — The reservation row; itsexpected_fingerprint, when set, is the fingerprint the picture records.
local ok, bytes, kind = preview.renderForReservation(snapshot, row)
modules/Preview/renderStaleFor
renderStaleFor(paths: { string }): { string }
Queue a render for every asset holding one of paths whose type
declares a preview recipe and whose preview is missing or not current
(isCurrent), given the paths of staged files or asset folders: each
asset on the way down to a path is asked, since a bundle's picture holds
its interior material's. Staging does not call it. The renders run on the
preview queue, so the caller waits for none of them, and each new picture
is a change to the asset's preview.png. The queue's own rules still apply:
library, dependency and scratch content keep the picture they carry, and
a private subasset with no preview renders only when something asks for
its picture.
Parameters
paths{ string }— VFS paths of staged files or asset folders.
preview.renderStaleFor({ "/zero/source/gold.material/mat.yaml" })
modules/Preview/rendering
rendering(): boolean
Whether a preview render is under way: a batch of the work queue, or a render holding the preview rig. A render under way stands the scratch it draws through (its subjects, its capture targets, the clock its deterministic captures pin), and all of it goes when the render ends. A queued entry is under way once the batch that takes it begins.
Each is known by the engine frame it began on and bounded by the frames it
can last: a batch by preview.RENDER_FRAMES, a hold of the rig by the
frames past which the next waiter takes the rig. One older than its bound
was left by a pass that stopped existing, and reads as ended. The answer
reads the same from any caller.
while preview.rendering() do task.wait() end
modules/Preview/schedulePreview
schedulePreview(ref: any, opts: { [string]: any }?)
Queue a writePreview for ref on the preview work queue. Something
that needs the picture calls this: a view that shows the asset
(requested), a backfill over a world, renderStaleFor. An edit of
the asset queues nothing; its preview goes stale until one of those asks.
Schedules that land while the asset is queued render once, reading the
asset as it is when its turn comes. Renders drain in
shared batches in schedule order; poll queueStatus for progress. Only
world source content under /zero/source/ is queued: scratch
(/source/tmp/) carries no preview, and library content
(/source/libs/) and pulled dependencies (/source/deps/) keep the
picture they were committed or published with, which a direct
writePreview call redraws. The queue renders in edit mode: what is
scheduled while the engine plays stays pending and renders once the
engine is back in edit.
Parameters
refany(optional) — The asset's AssetRef.opts{ [string]: any }?(optional) —{ debounce?: number, requested?: boolean }—debounceis the seconds the entry waits before its render becomes eligible (default 1; a backfill pass over settled content passes 0).requestedsays something wants this asset's picture: a private subasset (asset.isPrivateSubasset) is previewed only when requested or when it already holds a preview.
preview.schedulePreview(matRef)
modules/Preview/staleAssets
staleAssets(root: string?): { string }
The world's own assets whose preview.png pictures content they no
longer hold: every instance of a type that declares a preview recipe,
under root when one is given, that has a preview which is not current
(isCurrent). Library, dependency and scratch content keep the picture
they carry and are not listed. Reads only; staging the asset renders its
current picture.
Parameters
rootstring?(optional) — A path prefix to narrow the walk to; the whole world when absent.
for _, p in ipairs(preview.staleAssets()) do print(p) end
modules/Preview/writePreview
writePreview(ref: any, opts: { [string]: any }?): (boolean, string?)
Render an asset's preview via its type's ref:preview() and persist it
as preview.png inside the asset folder. The preview is the asset's
visual description — it syncs and publishes like any other file, feeds
image-based search, and gives browsers a thumbnail. Skips scratch content
(/source/tmp/). Writes only when the rendered bytes differ from the
existing file, so re-rendering an unchanged asset produces no sync traffic.
This call is how a library or dependency asset's picture is redrawn: the
preview queue leaves that content with the picture it carries, and in a
--dev engine the file written here for a @builtin asset lands in the
source checkout, to be committed with the asset.
Parameters
refany(optional) — The asset's AssetRef — its type must exposepreview(material, texture, bundle).opts{ [string]: any }?(optional) — Forwarded toref:preview(); defaults to a 256×256 render.
preview.writePreview(matRef)
modules/ProcGraphAssetTypeBehavior/README
require("@builtin::systems.procgen.procGraph.behavior") -- ProcGraphAssetTypeBehavior
Per-instance methods exposed on every AssetRef<procGraph> — a .procGraph asset is a serialized procedural graph (proc.graph.v1). The methods below let callers use the graph THROUGH its ref (ref:eval("output:mesh"), ref:inputs(), ref:asOp()) instead of round-tripping through the proc module + a path string. asOp is also how the op registry resolves a .procGraph referenced as a graph node: the type owns "how a graph becomes an op", the evaluator's registry delegates to it. Loaded lazily by assetType.shared.ref via require("@builtin::systems.procgen.procGraph.behavior") the first time a procGraph ref is touched in a VM.
Usage: local ProcGraphAssetTypeBehavior = require("@builtin::systems.procgen.procGraph.behavior")
modules/ProcGraphAssetTypeBehavior/asOp
asOp(self): any
Wrap this graph as an op def so it can be used as a NODE in another
graph: its params mirror this graph's declared inputs, its outputs mirror
this graph's declared outputs, and its version folds this graph's structure
with every content op it references (so an edit anywhere beneath re-keys the
wrapping node). The op registry resolves a graph node whose op is a .procGraph
ref through this method — the type owns the graph-as-op mapping; the
evaluator's wrapGraphAsOp is the library that does the heavy folding.
Parameters
selfany(optional)
local opDef = procRef:asOp()
modules/ProcGraphAssetTypeBehavior/compile
compile(self): { [string]: any }
Compile this asset's init.luau into its graph.json — the serialized
form the evaluator loads when another graph composites this one, and the
file whose write makes every live Generator bound to this asset re-cook.
This is the SOURCE step, not the evaluation step: it produces the graph, it
does not run it (that is a cook, which the Generator drives).
The type compiles on its own whenever the source is written, so calling this
is only for forcing it — a rebuild after restoring a file, or a script that
wants the node count back.
Parameters
selfany(optional)
local r = procRef:compile()
modules/ProcGraphAssetTypeBehavior/eval
eval(self, target: string, opts: any?): any
Evaluate one output of this graph and return the produced value
(Geometry / Population / Texture / Material / Bundle / …). target is an
output name ("mesh"), or an explicit "output:<name>" / "node:<id>[:<out>]"
selector. opts forwards to proc.eval ({ inputs = { … }, seed = N }) so
the graph's exposed inputs can be overridden per call.
Parameters
selfany(optional)targetstring— Output name or selector.optsany?(optional) — Optional{ inputs, seed, … }(seeproc.eval).
local mesh = procRef:eval("mesh", { inputs = { radius = 3 } })
modules/ProcGraphAssetTypeBehavior/graph
graph(self): any
This asset's procedural graph, built from its init.luau source. The
source is the graph's definition, so this answers with what the asset
currently describes rather than with whatever was last compiled.
Parameters
selfany(optional)
local g = procRef:graph()
modules/ProcGraphAssetTypeBehavior/inputs
inputs(self): { [string]: any }
The graph's declared inputs — the parameters that drive it, each with its procgen type and default. This is the vocabulary a Generator exposes as editable overrides.
Parameters
selfany(optional)
for name, decl in pairs(procRef:inputs()) do print(name, decl.type) end
modules/ProcGraphAssetTypeBehavior/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Put this graph in the scene — the uniform instantiate(target?, opts?)
contract every scene-instantiable asset answers to. An entity carrying a
Generator bound to this asset: the Generator cooks the graph and keeps
the result as that entity's managed children, re-cooking whenever the
graph or its params change — so the scene holds a live instance of the
description, not a frozen copy of one evaluation. With target the
generator spawns as a child of that owner (so an owning Asset component
tears it down with its other children); with no target it is a fresh
root. The base opts — position, rotation, scale, name,
temporary — place the root.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional owning entity ref.opts{ [string]: any }?(optional) —{ position?, rotation?, scale?, name?, temporary?, output?, params? }—outputnames which declared output to realize,paramsseeds the graph's exposed inputs.
local gen = procRef:instantiate()
local gen = procRef:instantiate(nil, { params = { rockCount = 800 } })
modules/ProcGraphAssetTypeBehavior/onChange
onChange(ref, change)
Change callback: recompile whenever the entry source is written. The
graph.json this produces lands inside the same folder, which is what a
live Generator bound to this asset watches — so editing the source is the
whole update path, with no build step between writing and seeing it.
Writes to any other file in the folder (that graph.json, the README, the
sidecars) are not the definition and do not recompile — by the path filter
here, and by the compiled-source guard for a change that names no path.
Parameters
refany(optional)changeany(optional)
modules/ProcGraphAssetTypeBehavior/onRegister
onRegister(self)
Initial-registration callback: compile the graph the moment the instance
registers, so an asset restored without a graph.json — or one whose source
changed while the engine was down — has its compiled form before anything
composites or cooks it.
Parameters
selfany(optional)
modules/ProcGraphAssetTypeBehavior/outputs
outputs(self): { string }
The graph's declared output names (sorted). Each is a value the graph
produces and a valid eval target.
Parameters
selfany(optional)
local outs = procRef:outputs()
modules/ProcGraphAssetTypeBehavior/preview
preview(self, opts: { [string]: any }?): { [string]: any }
Render this graph to a still through the shared preview rig — the
image preview.writePreview persists as the asset's preview.png, the
picture search shows the graph by. The graph stands in the preview studio
on a Generator of its own; an effect is brought to a representative
moment (the one it names with g:still, else halfway through the range it
plays, or two seconds into a timeline with no end) before the frame is
taken, so the picture is the effect in motion rather than its first frame.
A timeline with an end is moved to that moment; one with no end is played
to it, since what it shows then is everything its solvers simulated
before.
Parameters
selfany(optional)opts{ [string]: any }?(optional) —{ size? = { width, height }, angle? = { yaw, pitch } }.
local shot = graphRef:preview({ size = { width = 256, height = 256 } })
modules/ProcGraphAssetTypeBehavior/promote
promote(self, opts: { [string]: any }?): { [string]: any }
Make this graph a node: a .procNode that declares this graph's inputs as its own, calls this
graph with them and gives its outputs. This graph keeps its code and every graph calling it by its
path; the node puts it among the nodes procgen.searchNodes finds and a graph calls by name, and it
stays this graph's: editing this graph changes what the node makes. procgen.promote is the tool form.
Parameters
selfany(optional)opts{ [string]: any }?(optional) — Optional{ name, into, description, tags }: the node's name (default: this graph's), the folder it goes in (default: the one holding this graph), what it does and the tags search finds it by (default: this graph's own.metadata).
local made = procRef:promote({ description = "A rim of rocks around a disc." })
modules/ProcGraphAssetTypeBehavior/stillTime
stillTime(self): number
The moment a still of this graph shows: the one it names with
g:still, else halfway through the range it plays, or two seconds into a
timeline with no end.
Parameters
selfany(optional)
gen:seek(graphRef:stillTime())
modules/ProcGraphAssetTypeBehavior/validate
validate(self): { any }
Type-check this graph's connections. Returns proc.validate's diagnostic
list (empty when the graph is well-typed) — each entry is
{ level, code, node, input, expected, actual, suggestions }.
Parameters
selfany(optional)
for _, d in ipairs(procRef:validate()) do warn(d.code, d.node, d.input) end
modules/ProcNodeAssetTypeBehavior/README
require("@builtin::systems.procgen.procNode.behavior") -- ProcNodeAssetTypeBehavior
Registration lifecycle for .procNode assets — custom procedural operations authored as content. An instance's init.luau returns either a GRAPH (return proc.define(...) — the node carrying its own pipeline, the self-contained form) or a def table (op-style { inputs, params, outputs, eval } for a hand-written eval). What a node takes and gives is read from that source without running it (asset.interface), the interface: block of the type's type.yaml saying how; this behaviour loads the node's op into the proc op registry, keyed by the asset's stable GUID, when a build first runs it, and again on every edit after that.
Usage: local ProcNodeAssetTypeBehavior = require("@builtin::systems.procgen.procNode.behavior")
modules/ProcNodeAssetTypeBehavior/load
load(ref)
Load this node's op from its entry source into the proc op registry: the registry calls it the first time a build runs the node.
Parameters
refany(optional)
modules/ProcNodeAssetTypeBehavior/onChange
onChange(ref, _change)
Change callback: a node a build has loaded loads again from its current
entry source whenever its .procNode is written, and the version bump
propagates the edit to every graph that reaches the node. A node no build
has run has nothing loaded: its interface is read from the source as it now
stands.
Parameters
refany(optional)_changeany(optional)
modules/ProcNodeAssetTypeBehavior/onDelete
onDelete(ref)
Delete callback: unregister this node's op when its .procNode folder
is removed. The delete ref carries no guid (the folder is already gone), so
the guid is resolved from the removed folder path via the registry's
path->guid index. A graph referencing it afterward errors loudly at eval —
resolution is push-model, never a silent fallback. A node moved to another
folder keeps its guid and stays registered at the folder it moved to.
Parameters
refany(optional)
modules/ProcNodeAssetTypeBehavior/onRegister
onRegister(self)
Initial-registration callback. The node's interface is read from its source wherever the asset index lists it, so nothing runs here unless a build already loaded the node, which then loads again.
Parameters
selfany(optional)
modules/ProcNodeAssetTypeBehavior/validate
validate(ref): { { code: string, message: string, severity: string? } }
The node's own rules: its source declares its interface as literals, so what it takes and gives reads without running it; its entry source loads and returns a def or a graph; and it registers as an op.
Parameters
refany(optional)
modules/ProcPackAssetTypeBehavior/README
require("@builtin::systems.procgen.procPack.behavior") -- ProcPackAssetTypeBehavior
Registration lifecycle for .procPack assets — a FAMILY of procedural operations authored as content. The instance's init.luau returns a pack table whose ops map op id to def, and this behaviour registers the whole map through registry.registerPack, so every op is validated exactly as a builtin is and tagged with the pack it came from. Ops registered this way carry the STABLE STRING IDS the pack names them with, which is what separates a pack from a .procNode — a single op keyed by its asset guid.
Usage: local ProcPackAssetTypeBehavior = require("@builtin::systems.procgen.procPack.behavior")
modules/ProcPackAssetTypeBehavior/onChange
onChange(ref, _change)
Change callback: re-register the family whenever the .procPack is
seeded or its entry script is edited. Every op is re-registered from the
current source and the version bump propagates the edit to every graph that
reaches any of them; an op the edit removed is unregistered.
Parameters
refany(optional)_changeany(optional)
modules/ProcPackAssetTypeBehavior/onDelete
onDelete(ref)
Delete callback: unregister every op this pack registered, and the
pack itself, when its .procPack folder is removed. A graph naming one of
its ops afterwards errors loudly at eval rather than cooking against a
definition that no longer exists, and registry.pack answers nil.
Parameters
refany(optional)
modules/ProcPackAssetTypeBehavior/onDependencyChange
onDependencyChange(ref, _change)
Dependency callback: a module the pack's entry requires re-ran, so the op definitions the pack built from it are built again from the module as it now stands, and every graph reaching one of them recooks.
Parameters
refany(optional)_changeany(optional)
modules/ProcPackAssetTypeBehavior/onRegister
onRegister(self)
Initial-registration callback: register this pack's whole family the
moment the instance first registers, so a graph loaded in the same
world-ready sweep can resolve every op in it. Idempotent with onChange.
Parameters
selfany(optional)
modules/ProcPackAssetTypeBehavior/ops
ops(self): { string }
The op ids this pack registers, sorted: the ids its ops table
declares, as its last completed registration read them. The former ids
its aliases maps onto them answer only as aliases. A pack whose last
registration did not complete, or that was never registered here, reads
its entry script to answer.
Parameters
selfany(optional)
for _, id in ipairs(packRef:ops()) do print(id) end
modules/ProcPackAssetTypeBehavior/registered
registered(path: string): boolean
Whether the pack at path has a registration that completed in this VM: every op its last
registration declared stands in the registry. A registration still under way, or one that did not
complete, answers false.
Parameters
pathstring— The pack's folder path.
if not behavior.registered(path) then behavior.onRegister(ref) end
modules/ProcRecordAssetTypeRef/README
require("@builtin::systems.procgen.procRecord.behavior") -- ProcRecordAssetTypeRef
Per-instance methods exposed on every AssetRef<procRecord>.
Usage: local ProcRecordAssetTypeRef = require("@builtin::systems.procgen.procRecord.behavior")
modules/ProcRecordAssetTypeRef/definition
definition(self): any
The record kind this asset defines: what its init.luau returns through proc.record.
Parameters
selfany(optional)
local def = asset.resolve("@builtin::systems.procgen.records.material", "procRecord"):definition()
modules/PunctualLight/README
require("@builtin::tests.fixtures.punctual_light") -- PunctualLight
The engine's punctual-light response in Luau, for the suites that predict what light a point light puts on a surface: the windowed inverse-square falloff a light's radius defines, the radiance that falloff delivers, and the shading model's own answer at the one geometry that has a closed form — the surface normal, the direction to the camera and the direction to the light all the same vector. The falloff is a port of zero_punctual_falloff in engine_bindings.shaderModule, which is the one curve every reader of a light's reach answers from. The response is a port of zpbr_direct_full in pbr_shading.shaderModule, evaluated at that geometry, where every angular term is 1 and the microfacet lobes collapse to constants.
Usage: local PunctualLight = require("@builtin::tests.fixtures.punctual_light")
modules/PunctualLight/dielectricF0
dielectricF0(ior: number, reflectance: number): number
A dielectric's reflectance at normal incidence, from its index of
refraction and the artist reflectance knob — zpbr_dielectric_f0. The
PBR shader's defaults (ior 1.5, reflectance 0.5) give 0.04.
Parameters
iornumber— The surface's index of refraction.reflectancenumber— The [0, 1] reflectance knob, neutral at 0.5.
local f0 = PunctualLight.dielectricF0(1.5, 0.5)
modules/PunctualLight/falloff
falloff(dist: number, radius: number): number
How much of a punctual light's emitted power arrives at dist: the
inverse-square law, windowed to zero at the light's radius. The engine's
own curve, zero_punctual_falloff.
Parameters
distnumber— Distance from the light to the shaded point, in world units.radiusnumber— The light's reach — a Light component'srange.
local a = PunctualLight.falloff(2.0, 8.0)
modules/PunctualLight/normalIncidenceResponse
normalIncidenceResponse(
The light a surface answers for one radiance arriving along its own normal, while the camera also looks along that normal.
zpbr_direct_full evaluated where the normal, the view direction and the
light direction coincide: the half-vector is the normal, so every one of
n·h, n·v, v·h and n·l is 1, the Fresnel term is F0 itself, the GGX
distribution is α²/(π·α⁴) and the Smith visibility is 1 at any
roughness. What is left is a diffuse lobe and a specular lobe that are
both constants of the surface, which is what lets a case state the light
it expects as a number.
This models the diffuse and specular lobes alone — the ones a bare metal or dielectric surface shades with. Clearcoat, sheen, fibre, anisotropy and iridescence are lobes the PBR shader adds on top where a material's own properties ask for them.
local L = PunctualLight.normalIncidenceResponse(
modules/PunctualLight/radiance
radiance(color: { number }, intensity: number, dist: number, radius: number): { number }
The radiance one punctual light delivers at dist: its colour times
its intensity times the falloff at that distance. The quantity the shading
loop hands the BRDF, for a light with no cone, no cookie and no shadow.
Parameters
color{ number }— The light's colour, one entry per channel.intensitynumber— The light's intensity.distnumber— Distance from the light to the shaded point, in world units.radiusnumber— The light's reach — a Light component'srange.
local r = PunctualLight.radiance({ 1, 0.6, 0.3 }, 4, 2.0, 8.0)
modules/Queue/README
require("@builtin::modules.api.engine.ecs.queue") -- Queue (also available as global 'queue')
Defer FFI mutations across frames — queue(fn) -> (ok, err, drainPromise).
Inside the body, write FFI calls (entity.spawn, component.add, position.set,
etc.) enqueue rather than execute synchronously. The engine's per-frame
drainer applies them in FIFO order with a per-frame budget.
Returns (true, nil, drainPromise) on success, (false, err, nil) if
the body throws — in which case the mutations the body queued are
dropped so they do not later apply; what other code queued stays.
drainPromise is a promise handle that resolves once every mutation
queued inside fn has been applied by the engine drainer.
await(drainPromise) blocks the calling coroutine until full drain —
use this to gate post-queue work (scene/layer load fires onLoad after
the drain promise resolves). If nothing was queued (e.g. an empty fn),
the promise resolves before queue() returns.
Nested queue() runs in the already-active queue mode: the depth counter
is re-entrant, and an inner body that throws drops only what it queued.
See docs/plans/2026-05-06-luau-queue-deferred-mutations.md for the full
design (drain budget, error semantics, future per-key fences for reads).
Usage: local Queue = require("@builtin::modules.api.engine.ecs.queue") Also available as global: queue
modules/Random/README
require("@builtin::modules.random") -- Random (also available as global 'Random')
Seeded random-number generators. Each generator holds its own stream, so any number of independent, reproducible sequences run side by side, and none of them draws from or reseeds math.random.
A generator made from a seed produces the same sequence on every
platform and every build: the same seed gives the same numbers on a
native engine and in the browser, run after run.
local rng = Random.new(1234) -- the same seed, the same stream
local roll = rng:nextInteger(1, 6) -- integer in [1, 6], both ends included
local t = rng:nextNumber() -- float in [0, 1)
local x = rng:nextNumber(-5, 5) -- float in [-5, 5)
Members every generator answers:
rng:nextNumber() float in [0, 1), 53 random bits
rng:nextNumber(min, max) float in [min, max)
rng:nextInteger(min, max) integer in [min, max], both ends included,
every value equally likely
rng:clone() an independent generator at the same position:
it draws what this one would draw next
rng:state() the position as a 32-character hex string a
save, a record or a network message can hold
Random.fromState(rng:state()) makes a generator that continues the
sequence from where rng stood, so a saved level, a replayed AI
decision or a regenerated design picks up exactly where it left off.
Random.new() with no seed takes its seed from the clock.
math.random is a different thing: one stream per Luau VM, shared by
every script in that VM and reseeded for all of them by
math.randomseed. A generator here is a value of its own; drawing from
one moves no other.
The algorithm is xoshiro128** (Blackman and Vigna) over 32-bit words.
A seed is read as the bits of its IEEE-754 double: the low word and the
high word each go through the MurmurHash3 32-bit finalizer to give the
first two state words, and the last two are mixed from those, so every
distinct number is a distinct stream. nextNumber() joins the top 27
bits of one output and the top 26 of the next into a 53-bit fraction;
nextInteger rejects the draws that would bias the range.
Usage: local Random = require("@builtin::modules.random") Also available as global: Random
modules/Random/fromState
fromState(state: string): RandomGenerator
Make a generator that continues a sequence from a position
rng:state() recorded. It draws exactly what the recorded generator
drew next, so a save holds the string and a load picks the stream up.
Parameters
statestring— The 32-character hex stringrng:state()returned.
local resumed = Random.fromState(Random.new(7):state())
modules/Random/new
new(seed: number?): RandomGenerator
Make a generator with its own stream. The same seed gives the same
sequence on every platform and build; any number of generators run side
by side without moving one another or math.random. With no seed it
takes one from the clock, and rng:state() records where it stands.
Parameters
seednumber?(optional) — Any finite number; every distinct number is a distinct stream. Omitted, the clock seeds it.
local roll = Random.new(42):nextInteger(1, 6)
local jitter = Random.new(42):nextNumber(-0.5, 0.5)
local clockSeeded = Random.new()
modules/RenderError/README
require("@builtin::modules.renderError") -- RenderError
Shared "this render is broken" marker. visibleError(entityId) swaps an entity to the builtin ERROR text model + error material, so a failed render reads as an unmistakable 3D "ERROR" sign on screen instead of empty pixels — empty silently reads as "fine" and a broken object gets mistaken for working. Every render component (built-in Model / SkinnedModel, or a user-authored one) calls this, so the error model is defined in ONE place: change it here and every render component updates.
Usage: local RenderError = require("@builtin::modules.renderError")
modules/RenderError/visibleError
visibleError(entityId: string, reason: string?): boolean
Swap entityId to the builtin ERROR marker so a broken render is
unmistakable on screen. Un-skins the entity first (a bad skeleton can't
collapse the marker), binds the ERROR mesh + error material via the public
ecs.* API, and logs the reason at error level. Returns true if the marker
was applied.
Parameters
entityIdstring— The entity whose renderable becomes the ERROR marker.reasonstring?(optional) — Short human string describing what failed (logged).
renderError.visibleError(self.entityId, "mesh never became GPU-resident")
modules/RenderFeatureAssetTypeRef/README
require("@builtin::assetTypes.renderFeature.behavior") -- RenderFeatureAssetTypeRef
Per-instance methods exposed on every AssetRef<renderFeature>. Loaded lazily by assetType.shared.ref the first time a renderFeature ref is touched in a VM. A render feature is an init.luau exporting { setup?(ctx), render(ctx), teardown?(ctx) }; :enable() instantiates it (the engine begins calling its render(ctx) hook every frame) and returns a live handle, also visible under /zero/runtime/renderFeatures/.
Usage: local RenderFeatureAssetTypeRef = require("@builtin::assetTypes.renderFeature.behavior")
modules/RenderFeatureShared/README
require("@builtin::assetTypes.renderFeature.shared") -- RenderFeatureShared
Shared helpers + the authoring contract for renderFeature modules.
Usage: local RenderFeatureShared = require("@builtin::assetTypes.renderFeature.shared")
modules/ReportFormatter/README
require("@builtin::systems.worldValidation.reportFormatter") -- ReportFormatter
Filtering + formatting helpers for the world validation report. Pure functions: every call returns a new value, never mutates the input report.
Three exports: filter (re-filter an existing Report without
re-scanning the VFS), format (render to a string in one of
four shapes), and summary (one-line health line). All three
are pure — they never mutate the input report.
Usage: local ReportFormatter = require("@builtin::systems.worldValidation.reportFormatter")
modules/ReportFormatter/filter
filter(report, opts)
Return a new Report containing only problems that match the
filter options. Counts are recomputed from the filtered set so
the caller can trust counts against the visible problems list.
Pure — the input report is not mutated.
Parameters
reportany(optional) — Report produced by the main validator.optsany(optional) — Filter options —{ severity, category, source, code, path (Lua pattern), includePlaceholders (default true), limit }.
local errs = ReportFormatter.filter(r, { severity = "error" })
local libsOnly = ReportFormatter.filter(r, { source = "library:@builtin" })
modules/ReportFormatter/format
format(report, format)
Render a Report into a string in the chosen format.
Parameters
reportany(optional) — Report produced by the main validator.formatany(optional) — One of"human"(default),"markdown","json","summary". Unknown values fall back to"human".
print(ReportFormatter.format(r, "human"))
local md = ReportFormatter.format(r, "markdown")
modules/ReportFormatter/summary
summary(report)
Compact one-line health summary string —
world: NE/NW libraries: NE/NW total: OK|FAIL.
Parameters
reportany(optional) — Report produced by the main validator.
print(ReportFormatter.summary(r))
modules/ResourceHandle/README
require("@builtin::modules.resource_handle") -- ResourceHandle
Recognises a live GPU resource handle — the { kind = "<Category>Handle", category, guid, name } table renderer.mesh.create, renderer.material.create and renderer.texture.create return. Every boundary that carries a component field value out of the session that produced it consults this to tell a handle from an AssetRef.
Usage: local ResourceHandle = require("@builtin::modules.resource_handle")
modules/ResourceHandle/forget
forget(owner: string)
Let go of every handle parked for owner. A parked handle is put back
by a load that builds the entity from its record inside this session, so
once no record names the entity, nothing reads it again.
Parameters
ownerstring— The entity id the handles were parked under.
ResourceHandle.forget(id)
modules/ResourceHandle/isLive
isLive(v: any): boolean
Whether a value is a live GPU resource handle.
Parameters
vany(optional) — Any component field value.
ResourceHandle.isLive(renderer.mesh.create(geometry)) -- true
modules/ResourceHandle/label
label(v: any): string
A short phrase naming a handle, for a message about the value.
Parameters
vany(optional) — A handle table.
ResourceHandle.label(meshHandle) -- "mesh handle 'msh_grass_1'"
modules/ResourceHandle/park
park(owner: string, componentType: string, dropped: { [string]: any }?, instanceName: string?)
Hold the live handles one component instance's durable record left out,
keyed by the entity and component instance they came from, until forget
lets go of the entity. Each call replaces what that instance had parked
before.
Parameters
ownerstring— The entity id the component sits on.componentTypestring— The component's type name.dropped{ [string]: any }?(optional) — The{ field = handle }map left out of the record, or nil when the component's record carries every field it holds.instanceNamestring?(optional) — The instance's name, or nil for the type's anonymous instance.
ResourceHandle.park(id, "@builtin::components.Model", { model = mesh })
modules/ResourceHandle/withParked
withParked(data: any, owner: string, componentType: string, instanceName: string?): (any, number)
The component field map to apply, with every field this session parked
for owner's instance of componentType and the record does not carry put
back.
Parameters
dataany(optional) — A component's{ field = value }map from a record.ownerstring— The entity id the component is being applied to.componentTypestring— The component's type name.instanceNamestring?(optional) — The instance's name, or nil for the type's anonymous instance.
ResourceHandle.withParked(record.data, id, "@builtin::components.Model")
modules/ResourceHandle/withoutLive
withoutLive(data: any): (any, { [string]: string }?)
The component field map to apply, with any live-handle value left out — the form a value read from durable content takes in a session other than the one that minted it. The field falls back to the component's declared default, and the caller reports what it stood for.
Parameters
dataany(optional) — A component's{ field = value }map.
ResourceHandle.withoutLive(record.data) -- data, nil
modules/RigAssetTypeBehavior/README
require("@builtin::assetTypes.rig.behavior") -- RigAssetTypeBehavior
Behaviour for the rig asset type — a skeleton's disk shape. The payload is rig.json: ordered bones with names, parent hierarchy, the node index each maps to, rest local transform and inverse-bind matrix, where its bind pose comes from (bind), plus the author's overrides — per avatar type, the roles an author set by hand. How the rig maps onto an avatar type (which bone is the hips, the left hand, ...) is derived from the bones whenever it is asked for, and the overrides are laid over it. A rig is its own primitive: a skinned mesh references a rig, an animation references its source rig, and retargeting maps one rig onto another. The format is text, so an agent can open it and read or correct it with an edit.
Usage: local RigAssetTypeBehavior = require("@builtin::assetTypes.rig.behavior")
modules/RigAssetTypeBehavior/onChange
onChange(self, _change)
Drop the cached decode and every qualification made from it when the rig's
content changes — a hot-reload, a re-import or an override edit — so the next read
re-derives from the new rig.json.
Parameters
selfany(optional) — The rig AssetRef that changed._changeany(optional) — What happened to it; the caches are dropped whatever it was.
modules/RigAssetTypeBehavior/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("rig", name, opts). Returns the
content-file map; asset.create writes it to the authored destination,
registering the .rig asset under its minted guid. A profile or humanoid
section in the incoming document is dropped: how a rig maps onto an avatar type
is derived from its bones.
Parameters
namestring— Rig identity (the instance name).optsCreateOpts
asset.create("rig", "PolygonSyntyCharacter", { json = rigJson })
modules/RigAssetTypeBehavior/onReplace
onReplace(dest: string, files: { [string]: string }): { [string]: string }
Replacement hook: when asset.create writes a rig over one already at
dest (a re-import re-deriving the rig from its source file), the replaced
rig's overrides are carried into the new document, so what an author set by
hand survives. Overrides the new document states itself win for their type.
Parameters
deststring— The folder of the rig being replaced.files{ [string]: string }— The filesonCreateproduced for the new rig.
modules/SceneAssetTypeRef/README
require("@builtin::assetTypes.scene.behavior") -- SceneAssetTypeRef
Per-instance methods exposed on every AssetRef<scene>. Loaded lazily by assetType.shared.ref.
Usage: local SceneAssetTypeRef = require("@builtin::assetTypes.scene.behavior")
modules/SceneAssetTypeRef/build_scene
build_scene(self, opts: { save: boolean?, record: boolean?, layer: any?, trigger: string? }?): any
Run this scene's build.luau against what it resolves right now and
land what it declares in the scene — for the case where something the
builder reads changed and the file did not. Writing build.luau already
runs the build, so a call after a write is unnecessary.
content() writes the scene's entities and editorOnly() writes the ones
that are present while authoring and absent in play; each is reconciled
against the entities the last build placed, so an entity keeps its id
across every rebuild and anything else in the scene is left alone.
Runs in edit mode on a LOADED scene — the entities it lands on are the live
ones. opts.save = false leaves the result unsaved; by default the scene is
saved, which is what puts the build in scene.json. opts.record = false
lands the result in the live scene alone: nothing it creates, changes or
takes away reaches the scene's unsaved edits or scene.json.
A call made while a build for this scene is running returns that build
right away instead of starting a second one — a build the scheduler is
still advancing. One whose task was cancelled, or that stopped for any
other reason without returning, hands the scene back to this call, which
runs the build. A build that a newer write to build.luau replaces stops
where it stands and leaves the scene to the rebuild that write asked for.
Parameters
selfany(optional)opts{ save: boolean?, record: boolean?, layer: any?, trigger: string? }?(optional) — Optional{ save = false }or{ record = false }.
layers.active.asset:build()
modules/SceneAssetTypeRef/discard_scene
discard_scene(self, opts: any): boolean
Discard this scene's UNSAVED (dirty) edits and restore its saved
scene.json. When the scene is LOADED, the overlay is deleted and the live
layer is respawned from canonical (with the scene-load gate held so the
respawn is not re-marked dirty); when it is NOT loaded, the on-disk overlay
is simply deleted. Edit-mode overlay only — not the play-mode baseline.
Parameters
selfany(optional)optsany(optional) — Optional{ to = <name|path> }, or a bare name/path string, to target a scene other than this asset's own path.
sceneRef:discard()
modules/SceneAssetTypeRef/getBuildScript
getBuildScript(self): string?
Read the scene's build.luau body as raw text.
Parameters
selfany(optional)
local src = sceneRef:getBuildScript()
modules/SceneAssetTypeRef/getEntrypoint
getEntrypoint(self): string?
Read the scene's entrypoint.luau body as raw text.
Parameters
selfany(optional)
local code = sceneRef:getEntrypoint()
modules/SceneAssetTypeRef/getSceneJson
getSceneJson(self): { [string]: any }?
Parse the scene's scene.json into a Lua table.
Parameters
selfany(optional)
local s = sceneRef:getSceneJson()
modules/SceneAssetTypeRef/getSceneJsonRaw
getSceneJsonRaw(self): string?
Read the scene's scene.json body as raw JSON text.
Parameters
selfany(optional)
local raw = sceneRef:getSceneJsonRaw()
modules/SceneAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { entityCount, entityNames, player }, parsed from the scene's own scene.json — never executes
entrypoint.luau. A scene whose scene.json can't be read/parsed
returns an empty detail rather than erroring.
Parameters
selfany(optional)
local entityNames = asset.inspect(sceneRef).detail.entityNames
modules/SceneAssetTypeRef/listEntities
listEntities(self): { string }
List the entity names declared at the top level of the scene's JSON body. Best-effort; nested children are not flattened.
Parameters
selfany(optional)
for _, n in ipairs(sceneRef:listEntities()) do print(n) end
modules/SceneAssetTypeRef/load_scene
load_scene(self, opts: { [string]: any }?): any
Load this scene into the root ("main") slot. Equivalent to
layers.load(self) — the AssetRef envelope is passed straight
through, so the loader threads scene identity by guid. Pass
opts for additive overlays / persistence / origin offset (same
shape as layers.load's second argument).
Parameters
selfany(optional)opts{ [string]: any }?(optional) — Optional load options forwarded tolayers.load.
sceneRef:load()
sceneRef:load({ additive = true, name = "hud_overlay" })
modules/SceneAssetTypeRef/onChange
onChange(ref, change)
A write inside a .scene folder. A write to build.luau re-runs the
build on the loaded scene, which is what makes an edit to the code show up
in the scene without reloading it. The rebuild finishes after the write has
returned, and posts a notice naming the scene and how many entities each
surface placed — the write's own answer is that the file was written. A
write that arrives while a rebuild is running gets a rebuild of its own once
that one finishes, and several such writes get the single run that reads
them all. A rebuild lands and saves over several frames; until it is
through, layers.rebuildInFlight() reads true and a flip to play is
refused. A write to entrypoint.luau reloads the layer holding the scene
without rebuilding it: the previous load's onUnload runs and the tasks,
callbacks and entities that load started end, then the new code runs and
its onEditLoad fires. That reload also finishes after the write has
returned and posts a notice saying whether the layer came back whole, and
writes landing while it runs get one more reload once it finishes. A write
holding the code the layer already runs (only comments and whitespace
count as none) reloads nothing. Both apply in edit mode; an edit made in
play runs at the scene's next load. A write to build.luau builds in
every session sharing the world that has the scene loaded, whichever
session made it. The session that made it records and saves what its
build lands; every other one lands the build in its live scene alone, and
the records and the save of the session that made the write land on the
same entities, since each entity a build creates takes the id every
session derives for it. When the session that made the write does not have
the scene loaded, the scene's next save, or its next load, puts the build
in scene.json.
Parameters
refany(optional) — The scene whose folder was written.changeany(optional) —{ path, asset, type, kind, origin }.
__zero_dispatch_asset_change("/zero/source/scenes/main.scene/build.luau")
modules/SceneAssetTypeRef/onCreate
onCreate(_name: string): { [string]: string }
Generic-creation hook for asset.create("scene", name). A new scene is
the type's template shape verbatim.
Parameters
_namestring
asset.create("scene", "my_level")
modules/SceneAssetTypeRef/save_scene
save_scene(self, opts: any): any
Publish this scene's current state to its canonical scene.json. When
the scene is LOADED, its live scenegraph is captured into canonical; when
it is NOT loaded, its pending dirty overlay is promoted into canonical.
Either way the durable scene.json ends up reflecting the authored state.
opts.to (a scene name or path) saves to a different scene ("save as").
opts.layer is the layer holding this scene, for a caller that already has
it: a scene is findable through layers.list only once its load has
registered it, so a save made DURING that load names its layer itself and
captures the live scenegraph rather than reading it as unloaded.
Parameters
selfany(optional)optsany(optional) — Optional{ to = <name|path>, layer = <SceneProxy> }, or a bare name/path string.
sceneRef:save()
layers.active.asset:save({ to = "level_2" })
modules/SceneAssetTypeRef/validate
validate(self): { { code: string, severity: string, message: string } }
Semantic content validation for a scene: the player-setup rule set run
over this scene's scene.json, surfaced through asset.validate, plus a
warning when the scene has no explicit sky entity.
Parameters
selfany(optional)
modules/SceneBuild/README
require("@builtin::assetTypes.scene.shared.build") -- SceneBuild
Runs a builder function in an entity capture scope and composes what it created into records, then reconciles records into the scene with ids held stable across rebuilds. Also holds the build surface a build script reads, whose build.asset authors the assets a build produces and hands back the same one on every run the code has not changed.
Usage: local SceneBuild = require("@builtin::assetTypes.scene.shared.build")
modules/SceneBuild/attribute
attribute(refusals: { Refusal }): { Refusal }
Read a refusal's traceback for the one frame that belongs to the code being built. A build composed from several contributors reports this so an author reads which contributor was refused rather than which build ran.
Parameters
refusals{ Refusal }— The refusal arrayentity.capturehands back.
local named = SceneBuild.attribute(select(4, entity.capture(fn)))
modules/SceneBuild/buildSurface
buildSurface(folder: string, sourceDigest: string): BuildSurface
The build surface a build script reads: the operations that belong to
the build itself rather than to the scene it states. build.asset(kind, name, produce) is the asset a build makes — produce runs when the build
script changed and its result is authored at <folder>/<name>.<kind>,
and every other run hands back that same asset, guid and all, without
running produce at all. The returned AssetRef is what a component field
names, so the reference survives the save and the reload.
Parameters
folderstring— The build's own folder, which the assets it produces are authored inside.sourceDigeststring— The digest of the build script running now, asM.digestreports it — what decides whether an asset it produced is still the asset the code states.
local surface = SceneBuild.buildSurface(dir, SceneBuild.digest(src))
modules/SceneBuild/digest
digest(source: string): string
A short, stable digest of a script's source. Two different scripts give different digests, and the same script gives the same one on every machine and every run — which is what makes it the answer to "did the code that produced this change?".
Parameters
sourcestring— The script body to digest.
local key = SceneBuild.digest(vfs.read(path))
modules/SceneBuild/drift
drift(owner: string?): { Drift }
Where the live scene disagrees with the build that states it. Every entity a build placed records what that build last said about each of its properties, so anything an author has changed since reads back differently — and this is that list: the entity, the property, what the build said, and what the scene holds now.
These are the values a rebuild KEEPS. A build repeating itself leaves them
alone, and only a build that states something DIFFERENT about that property
takes it back. So this is what to read to know that a scene and its
build.luau disagree, and where, before deciding which should win.
Property names are the ones the build records: n name, i internal,
p position, r rotation, s scale, and a:<name> for an attribute.
Parameters
ownerstring?(optional) — Optional build name, asM.ownerOfreports it, to read just that build. Omitted, every build-owned entity in the scene is read.
for _, d in ipairs(SceneBuild.drift()) do print(d.name, d.property) end
modules/SceneBuild/isStatedNothingRefusal
isStatedNothingRefusal(err: any): boolean
Whether err is the refusal reconcile raises for a build that stated no records while its scene
loads over entities an earlier build placed. The refusal is about the module's text, which a later request
for the same text states again, so a caller keeps the text it built as the one that stands.
Parameters
errany(optional) — The value a build raised.
local refused = SceneBuild.isStatedNothingRefusal(err)
modules/SceneBuild/landed
landed(key: string, landing: Landing)
Record that the build landing stands for is through. An entry a later
build of the same scene put in its place stands.
Parameters
keystring— The key the scene is known by.landingLanding— The entrynoteLandingrecorded for this build.
SceneBuild.landed(guid, entry)
modules/SceneBuild/landing
landing(): { { scene: string, startedBy: string } }
The builds landing in the live scene right now, one row per scene, ordered by scene. A build lands over many frames, and while one is landing the live scene holds part of what it produces and part of what the build before it produced. An entry whose build stopped without saying so is dropped here.
if #SceneBuild.landing() == 0 then engine.mode = "play" end
modules/SceneBuild/landingFor
landingFor(scene: { guid: string?, path: string? }): { scene: string, startedBy: string }?
The build landing in the live scene for one scene, named by its guid or by the folder it is stored in, or nil while none is. A build of that scene is carrying its records into the scene's layer and saving it, over many frames, while this answers a row; an entry whose build stopped without saying so is dropped here. A caller running on the build's own coroutine is that build, and is answered nil.
Parameters
scene{ guid: string?, path: string? }—{ guid, path }of the scene, either one or both.
while SceneBuild.landingFor({ guid = ref.guid, path = ref.path }) do task.wait() end
modules/SceneBuild/noteLanding
noteLanding(key: string, landing: Landing)
Record that a build of the scene known as key is landing, from the
moment it is started until it is through. The entry replaces any standing
one for the same scene.
Parameters
keystring— The key the scene is known by: its guid, else its path.landingLanding—{ scene, startedBy, advancing }: the scene's name, what started the build, and a function answering whether the build is still being carried out.
SceneBuild.noteLanding(guid, { scene = "main", startedBy = "a write to build.luau", advancing = function() return true end })
modules/SceneBuild/notePreview
notePreview(entityId: string, values: { [string]: any }, componentType: string?): nil
Record the values an author left on entityId, an entity a build owns.
The build states that entity from its own source, so the values hold until
it runs again — and M.takePreview is what the next run reads to say which
of them it replaced and with what. Each record REPLACES the one before it:
what it states is everything the entity carries now, so a name dropped
between two records is dropped here too.
Parameters
entityIdstring— Runtime entity id of the owned entity.values{ [string]: any }— The values the entity carries now, by name.componentTypestring?(optional) — The component that states them, so a rebuild knows to state that type again instead of leaving it to the scene.
SceneBuild.notePreview(id, { count = 9 }, "SceneModule")
modules/SceneBuild/noteSourceWrite
noteSourceWrite(guid: string, origin: string?): nil
Record that a file of the asset guid, which a build is stated from
(a .sceneModule a placement builds), was written, and by which session.
Every session holding a build stated from it rebuilds; the session that
made the write records what its rebuild lands, and every other session
lands it in its live scene alone.
Parameters
guidstring— The asset's guid.originstring?(optional) —"local"for a write this session made (the default),"remote"for one another session sharing the world made.
SceneBuild.noteSourceWrite(ref.guid, change.origin)
modules/SceneBuild/ownerOf
ownerOf(entityId: string): string?
The build that placed entityId, or nil when no build placed it. A
reconcile writes the name of the build onto every entity it places, as an
attribute the scene records beside the entity's name and transform, so the
answer holds across a reload — and an entity an author spawned carries no
owner at all.
Parameters
entityIdstring— Runtime entity id.
if SceneBuild.ownerOf(id) ~= nil then print("a build states this") end
modules/SceneBuild/previewedComponentType
previewedComponentType(entityId: string): string?
The component type that recorded a preview for entityId, or nil when
none is waiting. A component that records one is SAYING that a build states
its fields and that it announces the replacement itself — so a rebuild
states that type again rather than leaving it to the scene, which is what
lets the announcement happen. Every other component is merged.
Parameters
entityIdstring— Runtime entity id of the owned entity.
if SceneBuild.previewedComponentType(id) == "SceneModule" then end
modules/SceneBuild/reconcile
reconcile(
Apply records to the scene under target, reusing the entities a
previous reconcile left behind. A record that maps to a live entity
updates THAT entity — same runtime id, so every reference to it survives
the rebuild — and only a record with no live entity spawns one. The
entity it spawns takes an id derived from owner, target and the
record's identity, so every session sharing the world that runs the same
build creates it under the same id, and the records one session's build
writes land on the entity another session's build created. Entities
the previous build held that this one no longer emits are despawned. A
SceneModule placement the previous build stated on an entity and this
one does not goes together with the entities it built beneath it.
Name, transform, hidden, active, attributes, lifecycle mode, network scope,
whether the entity's live state replicates, and components are all made to
match the record, so a rebuild that drops a component or an attribute drops
it from the scene. Each of them is a diff:
what already matches the record is left exactly as it is, so a rebuild that
changed nothing changes nothing — a running component keeps running and the
scene stays clean. Only entities the build owns are touched: anything else
under target is left exactly as it was.
A component field holding an entity reference is resolved as the records
are applied: a reference to an entity of the SAME build points at the
entity this reconcile landed it on, and a reference to any other entity
keeps pointing where it did.
owner names the build. Every entity it places carries that name and the
record's identity as attributes of its own, which is what lets a rebuild
find the entities the last one placed without anything being remembered
between them — the pair is in the scene, and a reload brings it back with
the entity. Two builds sharing a target stay out of each other's way by
using different owners.
A record's identity is its place in the hierarchy — the chain of names
from the build root down to it — so dropping, inserting or reordering a
sibling leaves every other entity where it was. Several children of
one parent sharing a name are told apart by their rank among those,
counted in the order the builder created them.
local ids = SceneBuild.reconcile(records, root, "chairs")
local ids, created = SceneBuild.reconcile(records, layer, "build")
SceneBuild.reconcile(SceneBuild.run(build), layers.active, "build")
modules/SceneBuild/recordDrift
recordDrift(rec: any): { string }
Where an entity RECORD disagrees with what the build that placed it
last stated: the question M.drift asks of the live scene, asked of a
record the way scene.json and a scene's unsaved edits hold it. A record
carries the build's statement in its own attributes, so a property that
reads differently from that statement is one changed since the build ran,
and an attribute the record holds that the build never stated is one added
since. The record's name, transform and attributes are compared, numbers
within the precision a saved record keeps.
Parameters
recany(optional) — An entity record:name,transform = { position, rotation, scale }andattributes.
local drifted = SceneBuild.recordDrift(record)
modules/SceneBuild/run
run(builder: () -> ()): ({ any }, { Refusal })
Run builder inside an entity capture scope and return the records for
every entity it created. The builder writes ordinary spawn code — real
entity.spawn, real component.add, real loops — and the entities it
creates are real for the duration of the call. They are composed into
records and then despawned, so run leaves the scene untouched and hands
back data. Reconciling that data into a scene is M.reconcile.
The builder's entities are despawned even when it raises, so a failed
build never leaks a half-built hierarchy into the scene.
What a component the builder attached created while running its own
lifecycle belongs to that component: the record names the COMPONENT, and
the same lifecycle runs again wherever the record is put back, so the
entities come from there rather than from records of their own. That covers
a nested build — a placement the builder makes runs its own module and owns
what it lands — and every other component that expands into entities.
An operation the scope refused is refused BEFORE it lands, so the records
describe the live world exactly as the builder left it, and a builder that
ran to its end around a refusal somebody caught for it composes what it
did make. Every such refusal comes back as the second return, naming the
contributor it stopped, for the caller to report alongside what it baked.
Parameters
builder() -> ()— Function taking no arguments; spawns whatever it wants.
local records, refused = SceneBuild.run(function() entity.spawn("chair") end)
modules/SceneBuild/sourceOf
sourceOf(owner: string): string?
The file that states the build named owner — what the reconcile
running that build passed as opts.source. Nil for a build that has not
run in this session and for one that named no source.
Parameters
ownerstring— Build name, asM.ownerOfreports it.
local file = SceneBuild.sourceOf(SceneBuild.ownerOf(id))
modules/SceneBuild/sourceWrittenHere
sourceWrittenHere(guid: string): boolean
Whether the latest write to the asset guid this session saw was its
own, so a rebuild stated from it records what it lands. True for a write
this session made and for an asset it has seen no write to; false when
another session wrote it last, whose own rebuild records the change, and
whose records reach this session.
Parameters
guidstring— The asset's guid.
local record = SceneBuild.sourceWrittenHere(ref.guid)
modules/SceneBuild/states
states(owner: string, key: string): boolean?
Whether the build named owner placed an entity for the record
identity key the last time it ran in this session. An entity carrying
that pair that is gone from the scene was taken away by the build when the
build no longer states it, and by an author when the build still does: the
build's next run would put it back.
Parameters
ownerstring— Build name, asM.ownerOfreports it.keystring— The record identity, as the entity'sbuildKeyattribute holds it.
local stillStated = SceneBuild.states(owner, key)
modules/SceneBuild/takePreview
takePreview(entityId: string): { [string]: any }?
Take the values M.notePreview recorded for entityId and clear them.
Each set of values is read once — by whichever run of the build states that
entity next.
Parameters
entityIdstring— Runtime entity id of the owned entity.
local set = SceneBuild.takePreview(id)
modules/SceneModuleAssetTypeRef/README
require("@builtin::assetTypes.sceneModule.behavior") -- SceneModuleAssetTypeRef
Per-instance methods exposed on every AssetRef<sceneModule>. Loaded lazily by assetType.shared.ref.
Usage: local SceneModuleAssetTypeRef = require("@builtin::assetTypes.sceneModule.behavior")
modules/SceneModuleAssetTypeRef/build
build(self, params: { [string]: any }?): ({ any }, { SceneBuild.Refusal })
Run this module's builder with params and return the entity records
it built. The builder runs inside the entity capture scope, so it writes
ordinary spawn code and what it created comes back as data — the scene is
untouched by the call. SceneBuild.reconcile is what lands the records.
Parameters
selfany(optional)params{ [string]: any }?(optional) — Per-placement input overrides, keyed by declared input name. An input the table omits resolves to its declared default. A builder that ran to its end around an operation the scope refused — one it caught itself, or one something between it and the refused call caught — hands back the records for what it did make, and every such refusal beside them: the operation was refused before it landed, so the records describe the scene as the builder left it.
local records, refused = moduleRef:build({ seed = 3 })
modules/SceneModuleAssetTypeRef/getInitScript
getInitScript(self): string?
Read the module's entry script (init.luau / init.lua) as raw text.
Parameters
selfany(optional)
local src = moduleRef:getInitScript()
modules/SceneModuleAssetTypeRef/inputs
inputs(self): { InputSpec }
The inputs this module declares, sorted by name — each one's name, its
Field kind, its declared default, and, for a closed-set input, the
members it accepts. This is what an inspector renders as widgets and what
a caller reads to learn which params a placement can set.
The script runs once per change to a file of the module or to a module it requires; later calls answer from that run. A script whose declarations depend on anything else it reads at its top level (world state, the clock, another asset's content) is answered from the run that last read it until one of those files changes. A script that fails to load runs again on the next call.
Parameters
selfany(optional)
for _, i in ipairs(moduleRef:inputs()) do print(i.name, i.kind) end
modules/SceneModuleAssetTypeRef/inputsSignature
inputsSignature(ref: any): string
Text that moves when what inputs() answers for this module can have
moved beyond the module's own files: the versions of the modules its
script requires, as its last run found them. Empty before a run.
Parameters
refany(optional) — The sceneModule.
parts[#parts + 1] = require(behavior).inputsSignature(moduleRef)
modules/SceneModuleAssetTypeRef/inspectDetail
inspectDetail(self): any
asset.inspect type-specific detail: { inputs } — the declared
inputs, as :inputs() reports them. A module whose entry script cannot be
loaded reports an empty input list rather than erroring.
Parameters
selfany(optional)
local declared = asset.inspect(moduleRef).detail.inputs
modules/SceneModuleAssetTypeRef/instantiate
instantiate(self, target: EntityRef?, opts: { [string]: any }?): (EntityRef, { [string]: string })
Instantiate this module — the uniform instantiate(target?, opts?)
contract every scene-instantiable asset answers to, and what makes a
sceneModule placeable wherever a scene-instantiable asset is accepted.
With target it builds with opts.params and reconciles the records
under that entity, owned by that entity: the entities a previous build
placed there name it as their owner and are UPDATED in place, so ids hold
across every rebuild and across a reload.
With no target it places the module the way an author places any asset:
one entity carrying a SceneModule component bound to this module. That
component is what runs the build. The base opts — position, rotation,
scale, name, temporary — place the root either way.
Parameters
selfany(optional)targetEntityRef?(optional) — Optional owning entity ref.opts{ [string]: any }?(optional) —{ position?, rotation?, scale?, name?, temporary?, params?, handBack?, record? }—paramsseeds the module's declared inputs;handBackspreads the build's reconcile across frames, andrecord = falselands it in the live scene alone, asSceneBuild.reconciletakes them.
moduleRef:instantiate(owner, { params = { seed = 3 } })
modules/SceneModuleAssetTypeRef/onChange
onChange(ref: any, change: { [string]: any })
A write inside a .sceneModule folder. Records which session wrote the
module: the reload of every placement it reaches rebuilds in each session
holding the placement, the session that made the write records what its
rebuild lands, and every other one lands it in its live scene alone.
Parameters
refany(optional) — The module whose folder was written.change{ [string]: any }—{ path, asset, type, kind, origin }.
__zero_dispatch_asset_change("/zero/source/fort.sceneModule/init.luau")
modules/SceneModuleAssetTypeRef/onDelete
onDelete(ref: any)
Asset-type delete callback: the inputs a removed module declared are forgotten.
Parameters
refany(optional) — The removed module.
modules/SceneModuleInspector/README
require("@builtin::modules.editor.scene_module_inspector") -- SceneModuleInspector
The SceneModule component's card on an entity: the bound module's identity, the file that states the placement, the module's DECLARED inputs as editable rows, and a Rebuild action. It replaces the card's generic settings section.
Usage: local SceneModuleInspector = require("@builtin::modules.editor.scene_module_inspector")
modules/SceneModuleInspector/buildFieldSpecs
buildFieldSpecs(declared: { any }, params: { [string]: any }?): { FieldSpec }
Build the editable field descriptors for a module's declared inputs: one spec per input, sorted by name, carrying the input's kind, its current value (the param override when the placement set one, else the declared default), and the members a closed-set input accepts. Pure — no UI, no entity access — so the field mapping is testable headless.
Parameters
declared{ any }— The module's declared inputs, asmoduleRef:inputs()reports.params{ [string]: any }?(optional) — The placement's current param-override table (may be nil).
modules/SceneModuleInspector/statedIn
statedIn(entityId: string): string?
The file the build that placed entityId is written in, for a
placement a build made. That build states the placement's params every time
it runs, so the rows below read as a preview of what it would state
rather than as the placement's own settings. Nil for a placement an author
made, whose params are the author's.
Parameters
entityIdstring— The inspected entity's id.
local file = SceneModuleInspector.statedIn(id)
modules/SceneRuntime/README
require("@builtin::assetTypes.scene.shared") -- SceneRuntime
The scene runtime — what a .scene folder does when it is loaded, saved, built, or swapped.
A <name>.scene/ folder carries scene.json (the entity arrangement),
an optional build.luau (the code author's half — see scene.assetType's
README), an optional entrypoint.luau, and a scene_dirty/ overlay of
unsaved edits. Reading, composing, and writing all four is what this
runtime does, and it lives here because that is the scene type's own
behaviour.
| Field | Responsibility |
|---|---|
loader | Reads scene.json v6/v7, composes canonical + dirty overlay, spawns the entities, runs the entrypoint. |
saver | Persists scene state as a delta overlay, promotes it to canonical, and answers what is still unsaved. |
build | Runs a build.luau in an entity capture scope and composes what it spawned into records. |
observe | The read side — per-scene counts and costs layers and loader write. |
swapOrchestrator | Drives multiplayer room transitions across a scene swap. |
Fields resolve LAZILY. The prelude installs swapOrchestrator and starts | |
saver's dirty writer in a fixed order; a table that required all five on | |
| load would take that ordering away from it. |
Usage: local SceneRuntime = require("@builtin::assetTypes.scene.shared")
modules/ScriptValidator/README
require("@builtin::systems.worldValidation.scriptValidator") -- ScriptValidator
Per-file Luau / Lua script validator. Wraps lsp.check to return real parser + type-check diagnostics for a single script, on top of cheap textual sanity checks (read failure, empty file).
Each script gets the full LSP pass — lsp.check(path, opts) from
the engine's embedded Luau LSP. Severity, line, column, code, and
message are taken straight from the LSP and re-wrapped in the
validator's Problem shape. The LSP diagnostics carry stable
codes (unknown-global, type-error, parse-error, …) — we
forward them verbatim so callers can severity = "error" or
code = "parse-error" and get exactly the rows they expect.
Two cheap textual checks run BEFORE the LSP is invoked:
script.read_failed(error) —vfs.readreturned nil (file deleted between scan and read, or unreadable).script.empty(warning) — zero non-whitespace content. These don't duplicate anything the LSP produces — the LSP is skipped when read fails (no source to feed it) and the empty check is informational about the file rather than the code.
Usage: local ScriptValidator = require("@builtin::systems.worldValidation.scriptValidator")
modules/ScriptValidator/validate
validate(script, opts)
Validate a single script. Combines two cheap textual checks
(script.read_failed, script.empty) with the embedded Luau
LSP's full diagnostic pass via lsp.check(path).
Parameters
scriptany(optional) —{ path, name }script entry fromvfsScanner.optsany(optional) — Reserved for future use; currently ignored.
local problems = ScriptValidator.validate({ path = "/source/foo.luau", name = "foo.luau" })
modules/ScriptValidator/validateBatch
validateBatch(scripts, opts)
Validate a batch of scripts and flatten the per-script problem lists into one array.
Parameters
scriptsany(optional) — Array of script entries fromvfsScanner.optsany(optional) — Reserved for future use.
local all = ScriptValidator.validateBatch(bucket.scripts)
modules/ServiceAssetTypeRef/README
require("@builtin::assetTypes.service.behavior") -- ServiceAssetTypeRef
Per-instance methods exposed on every AssetRef<service>. Loaded lazily by assetType.shared.ref. These act on the SPECIFIC service the reference points to — asset.resolve("mesh_gen","service"):invoke{...} runs THAT service.
Usage: local ServiceAssetTypeRef = require("@builtin::assetTypes.service.behavior")
modules/ServiceAssetTypeRef/balance
balance(self): (number?, string?)
Read the caller's current credit balance — the balance every service draws from. Returns (nil, errMsg) when not signed in.
Parameters
selfany(optional)
local credits = serviceRef:balance()
modules/ServiceAssetTypeRef/cost
cost(self, operation: string?, input: { [string]: any }?): (number?, string?)
The declared credit cost of an operation (the provider's up-front estimate; the exact charge is returned on each generation). Defaults to the primary / only operation.
Parameters
selfany(optional)operationstring?(optional) — Optional operation name.input{ [string]: any }?(optional)
local c = serviceRef:cost()
modules/ServiceAssetTypeRef/frameworkInputs
frameworkInputs(self, operation: string?): { { [string]: any } }
The inputs a call on this service takes on top of what the operation
declares — operation, naming which of the service's operations to run,
and asset_path, naming where the run writes what it generates. Each row
reads as a declared input does: { name, type, required, desc, framework = true }.
Parameters
selfany(optional)operationstring?(optional) — The operation these apply to. Omit for the service's default.
local extra = serviceRef:frameworkInputs("sfx")
modules/ServiceAssetTypeRef/getDefinition
getDefinition(self): string?
Read this service's declaration source (init.luau).
Parameters
selfany(optional)
local src = serviceRef:getDefinition()
modules/ServiceAssetTypeRef/getReadme
getReadme(self): string?
Read this service's README.md body.
Parameters
selfany(optional)
print(serviceRef:getReadme())
modules/ServiceAssetTypeRef/info
info(self): { [string]: any }
A one-line summary of this service: its offering, what it produces, the operations it offers, and which of them a call runs when it names none.
Parameters
selfany(optional)
local i = serviceRef:info()
modules/ServiceAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { methods, description },
where methods is this service's declared operations — the top-level
keys of its operations = { ... } table, parsed from the declaration's
own source text — and description is the declaration's top-level
summary, also parsed from source. A service with no readable
declaration returns an empty methods list rather than erroring.
Parameters
selfany(optional)
local methods = asset.inspect(serviceRef).detail.methods
modules/ServiceAssetTypeRef/invoke
invoke(self, input: { [string]: any }?): { [string]: any }
Run a generation for this service. Picks the operation from
input.operation (or the service's only / primary operation), runs its
declared pipeline as a background task, and returns immediately with a
generation handle. An input the operation does not declare is refused here,
before anything is charged. Watch the run with the services toolbox
status tool (or the watch tool) until it reads completed; that row's
asset is the finished, spawnable asset. Consumes credits — check
:cost() and :balance() first.
Parameters
selfany(optional)input{ [string]: any }?(optional) —{ prompt, ..., operation?, asset_path? }— the operation's inputs.
local g = asset.resolve("mesh_gen","service"):invoke({ prompt = "a treasure chest" })
modules/ServiceAssetTypeRef/onCreate
onCreate(name: string, opts: { [string]: any }): { [string]: string }
Generic-creation hook for asset.create("service", name, opts). Returns
the scaffold content files for a new service declaration.
Parameters
namestring— Service identity (the instance name).opts{ [string]: any }
asset.create("service", "mesh_gen", { offering = "origozero/mesh_gen" })
modules/ServiceAssetTypeRef/operations
operations(self): { { [string]: any } }
List this service's callable operations and their declared inputs,
output, and credit cost — the per-service surface to read before invoking.
framework carries the inputs the CALL takes on top of what the operation
declares (:frameworkInputs()).
Parameters
selfany(optional)
for _, op in ipairs(serviceRef:operations()) do print(op.name, op.cost) end
modules/ServiceAssetTypeRef/resume
resume(self, record: { [string]: any }): { [string]: any }
Pick a recorded run of this service up where an earlier engine left it. Runs on world load for every run that did not finish; the record names the operation, the step in flight and the job it submitted, and the run continues from there without paying for the same work again.
Parameters
selfany(optional)record{ [string]: any }— A run record as the framework'sServiceTask.durablereturns it.
asset.resolve("mesh_gen","service"):resume(record)
modules/ServiceFramework/README
require("@builtin::assetTypes.service.shared") -- ServiceFramework
The runtime every .service instance declares against — reached via asset.containing(__FILE__).modules.shared. The TYPE owns all the machinery (metered invoke, the submit→poll→download→write pipeline, the async generation handle, error classification); an instance only declares its surface with Service.define{...}. A normal generation service is pure data — no per-instance logic.
Usage: local ServiceFramework = require("@builtin::assetTypes.service.shared")
modules/ServiceFramework/balance
balance(_self: any): ({ [string]: any }?, string?)
Read what the caller can spend on this service: spendable (the number
an operation's cost must fit inside), with pool (the account balance) and
agentRemaining (what is left of the caller's own allocation, when it works
under one) behind it. Returns (nil, errMsg) when not signed in.
Parameters
_selfany(optional)
local credits = asset.resolve("mesh_gen","service"):balance().spendable
modules/ServiceFramework/cost
cost(self: any, operation: string?, input: { [string]: any }?): (number?, string?)
The declared credit cost of an operation: what a run of it spends when the call names none of the options that cost extra. This is the up-front figure to budget against — an operation that makes several metered calls declares what the RUN costs, not what one of its steps does. An option documented as costing more adds to it, so a call naming one spends above this figure. Defaults to the primary/only operation.
Parameters
selfany(optional)operationstring?(optional) — Optional operation name.input{ [string]: any }?(optional)
local c = asset.resolve("mesh_gen","service"):cost()
modules/ServiceFramework/define
define(spec: { [string]: any }): any
Declare a metered service. An instance's init.luau calls this with its
surface — the offering identity and one or more operations — and returns
the result. The TYPE runs the pipeline; the instance writes no machinery.
Parameters
spec{ [string]: any }—{ name, description, offering, output?, primary?, retry?, operations }. An operation'sresultis either a single file (bytes/url) or a SET (files), and a set assembles one asset:files = { { as, url } }fetches each map into the asset's own folder (an entry statesbytesinstead ofurlwhen a step already bound its content),pack = { { as, channels = { r, g, b, a } } }gathers named maps' channels into one raster where a slot samples several properties from one image (a channel is a constant 0-255, a file name for its red, or"file.g"for a stated channel), andbind = { slot = name }binds fetched and packed maps to the asset's slots. A map that reaches no slot is named on the job row and in the log.retryis{ attempts?, delay? }— how many times a call refused for a reason that describes the moment (a rate limit, a busy gateway, a write conflict) is sent again, and the first wait in seconds between attempts, which doubles each time. Defaults to 4 attempts starting at 1 second. An operation may declare its ownretryto override the service's.
return Service.define({ offering = "origozero/mesh_gen", operations = { generate = { ... } } })
modules/ServiceFramework/frameworkInputs
frameworkInputs(self: any, operation: string?): { { [string]: any } }
The inputs a call on this service takes on top of what the operation
declares — operation, naming which of the service's operations to run,
asset_path, naming where the run writes what it generates, and
durable, stating whether that is filed on canonical /source while play
runs. Each row
is { name, type, required, desc, framework = true }, the same shape a
declared input reads as. operation is required of a service that
declares no default; asset_path is offered by an operation that writes a
single file, and left out by one that authors a folder of them under a
name of its own. The operation row's text names the operation THIS
service runs when a call omits it, or the ones a call chooses between.
Parameters
selfany(optional)operationstring?(optional) — The operation these apply to. Omit for the service's default.
local extra = asset.resolve("audio_gen","service"):frameworkInputs("sfx")
modules/ServiceFramework/info
info(self: any): { [string]: any }
A one-line summary of this service for discovery: its offering, what it produces, and the operations it offers.
Parameters
selfany(optional)
local i = asset.resolve("mesh_gen","service"):info()
modules/ServiceFramework/invoke
invoke(self: any, input: { [string]: any }?): { [string]: any }
Run a generation for this service. Picks the operation from
input.operation (or the service's primary / only operation), checks the
operation's declared cost against the caller's balance/budget up front —
raising with a legible reason if it can't be afforded — then runs the
pipeline as a background task. An input the operation does not declare is
refused here, before anything is charged. Returns immediately with a
generation handle. Watch the task — the services toolbox status tool
(or the watch tool) — until status == "completed", then the finished
asset is that row's asset. The engine auto-imports the raw output into
a spawnable asset (a mesh becomes a .bundle, an image a .texture, a
sound a .soundClip); that imported asset, not the raw file, is what the
completed result points to, ready to spawn. Consumes credits; check
:cost() and :balance() first.
A run files its asset where the caller's writes landed when it was
requested: started outside the caller's play session, it files the asset
on canonical /source even when it completes during play; started inside
it, on the play shadow. input.durable states it outright (true: source,
false: wherever the writes of that moment land). The finished status
record carries durability, where what the run filed stands.
Parameters
selfany(optional)input{ [string]: any }?(optional) —{ prompt, ..., operation?, asset_path?, durable? }: the operation's inputs.
local g = asset.resolve("mesh_gen","service"):invoke({ prompt = "a treasure chest" })
modules/ServiceFramework/operations
operations(self: any): { { [string]: any } }
List this service's callable operations and their declared inputs,
output, and credit cost — the per-service surface an agent reads before
invoking. framework carries the inputs the call takes on top of what the
operation declares (:frameworkInputs()).
requireOneOf lists the groups of inputs a call must name at least one of.
Parameters
selfany(optional)
for _, op in ipairs(asset.resolve("mesh_gen","service"):operations()) do print(op.name, op.cost) end
modules/ServiceFramework/resume
resume(self: any, record: { [string]: any }): { [string]: any }
Pick a run of this service up where an earlier engine left it. The record names the operation, its inputs, the step in flight, the bindings the steps before it produced, and the provider or gateway job that step already submitted; the run continues from there, waiting on that job rather than paying for the same work again, and lands its asset the way an uninterrupted run does. Runs on world load for every recorded run that did not finish.
Parameters
selfany(optional)record{ [string]: any }— A run record asServiceTask.durablereturns it.
asset.resolve("mesh_gen", "service"):resume(record)
modules/ServiceFramework/resumeAll
resumeAll(): number
Pick up every recorded run that did not finish: the ones an earlier engine submitted and did not live to collect. Runs when the world has loaded. A run's service is waited for rather than assumed present, because a service can be authored in the world and register a moment after the library's own; each run resumes on its own task, so one that has to wait holds up none of the others.
require("@builtin::assetTypes.service.shared").resumeAll()
modules/ServiceRunAssetTypeRef/README
require("@builtin::assetTypes.serviceRun.behavior") -- ServiceRunAssetTypeRef
Per-instance methods on every AssetRef<serviceRun> — one generation's durable record: what it was asked to make, the gateway job doing the work, and the state that job reached.
Usage: local ServiceRunAssetTypeRef = require("@builtin::assetTypes.serviceRun.behavior")
modules/ServiceRunAssetTypeRef/finished
finished(self): boolean
Whether this run reached a terminal state. A run that is neither completed nor failed was still working when it was last heard from.
Parameters
selfany(optional)
if not run:finished() then print("still out there") end
modules/ServiceRunAssetTypeRef/jobId
jobId(self): string?
The gateway job this run's work is running under. The job outlives the engine that submitted it, so this is what reaches an already-paid result when the run did not finish here.
Parameters
selfany(optional)
local id = asset.resolve("gen_4f2a_0", "serviceRun"):jobId()
modules/ServiceRunAssetTypeRef/record
record(self): { [string]: any }
This run's record: { id, service, operation, prompt, jobId, status, progress, assetPath, error }.
Parameters
selfany(optional)
local rec = asset.resolve("gen_4f2a_0", "serviceRun"):record()
modules/ServicesDescribe/README
require("@builtin::tools.services.shared.describe") -- ServicesDescribe
Fill in the descriptions a world's assets are still missing, many at a call. The assets are the ones a type asks to say what they are (a README, or about.yaml for a type) whose description is missing or still starts with the [[describe]] placeholder. A call of the describe service carries many assets, packed whole into as few calls as fit; the model answers each asset on a line of its own, and the text it returns for each is written into the description file the type declares, so the result is an ordinary file the author can edit.
Usage: local ServicesDescribe = require("@builtin::tools.services.shared.describe")
modules/ServicesDescribe/__configure
__configure(changes: { [string]: number })
Change how the tool waits, for a case that runs it against a stand-in.
Parameters
changes{ [string]: number }— Any ofparallel,pollSeconds,waitSeconds,settleSeconds,budget(bytes a call carries),maxAssets(assets a call carries).
Describe.__configure({ pollSeconds = 0.05 })
modules/ServicesDescribe/describe
describe(options: Options?): Report
Find, or fill in, the descriptions the assets of a world still need.
find (the default mode) lists the assets that lack the description their
type asks for, the file and keys each needs, and how many calls filling them
makes (a call costs 1 credit, so that is also the price), and writes
nothing. all fills every asset find lists, and assets fills the ones it
names. The default scope is what blocks the current push; scope = "world"
takes every asset the world holds that a type asks to describe. A call of
the describe service carries many assets, packed whole into as few calls
as fit, several calls at once; each asset is answered written, failed
(with the reason) or skipped (with the reason), and a reply that is
missing or malformed for one asset fails that asset only. What is written is
an ordinary file the author can edit; only the description file or keys a
type declares are written, text an author wrote is never replaced, and
library, installed and machine-local content is never touched.
Parameters
optionsOptions?(optional) —{ mode?: "find" | "all" | "assets", scope?: "push" | "world", assets?: { string }, instructions?: string, examples?: { string } }.instructionsis added to what the model is told, andexamplesnames assets whose descriptions show the shape wanted.
local report = Describe.describe({ mode = "find" })
modules/ShaderAssetTypeRef/README
require("@builtin::assetTypes.shader.behavior") -- ShaderAssetTypeRef
Per-instance methods exposed on every AssetRef<shader>. Loaded lazily by assetType.shared.ref.
Usage: local ShaderAssetTypeRef = require("@builtin::assetTypes.shader.behavior")
modules/ShaderAssetTypeRef/compileKey
compileKey(key: string): string
Compile the shader key key (guid@checksum) for the materials waiting
on it: the asset holding exactly that guid at that checksum (the guid's home
when its bytes are that version, else a copy of that version held beside it)
is compiled through the same path an edit runs. The engine calls this when a
material first waits on a key, again when an asset under the key's guid
arrives or changes, and again for a key answered "absent" once the asset
index holds that version. While a world's content is being replaced, the
index can state a version whose files are not all there to read; such a
folder has nothing to compile yet, and the key is answered "absent" so it
is asked for again.
Parameters
keystring— The shader key,guid@checksum.
require("@builtin::assetTypes.assetType.shared.ref").loadTypeModule("shader").compileKey(key)
modules/ShaderAssetTypeRef/compileStatus
compileStatus(self): { status: string, error: string?, key: string?, pending: string? }
This shader's latest compile outcome, read without the engine log.
Returns { status, error?, key?, pending? } for the key the shader
compiles under (guid@checksum of the version at its path): status is
"compiled", "failed" (with error, the compiler's message) or
"pending" (not compiled yet, or compiled with part of its verdict still
being reached, which pending names: the material resolve's gate runs off
the frame thread). A properties.yaml that getProperties refuses reads
"failed", with error the same refusal, because the shader is not
compiled against it. Compilation is async (a write queues it), so a
"pending" right after editing means check again next frame. A write
succeeding and getProperties returning a schema do not mean the WGSL
compiled; this does.
Parameters
selfany(optional)
local s = shaderRef:compileStatus(); if s.status == "failed" then print(s.error) end
modules/ShaderAssetTypeRef/compiledWgsl
compiledWgsl(self): string?
The WGSL the shader compiler received for this shader, exactly as it
received it. What getWgsl returns is the body as written; this is what
that body became — the generated group(1) material interface above it, the
domain's framework and entry points around it, every #include expanded
and every #ifdef resolved. A compile error's line numbers, and the handle
index naga prints where it has no name, are positions in THIS text, so a
compileStatus() of "failed" is read against it. It answers for a failed
compile as well as a clean one, and needs no material, entity or draw.
Parameters
selfany(optional)
local s = shaderRef:compileStatus()
if s.status == "failed" then print(s.error, shaderRef:compiledWgsl()) end
modules/ShaderAssetTypeRef/domain
domain(self): string
The render domain this shader's body declares with its first
// @domain: <name> line — what entry points and framework the engine
builds around it: "surface" (the default), "post-process", "screen",
"sky", "compute". A further spelling (postprocess, screenspace,
ui) answers as the domain it names; a name the compiler refuses answers
as written.
Parameters
selfany(optional)
if shaderRef:domain() == "post-process" then print(shaderRef:getSpace()) end
modules/ShaderAssetTypeRef/getGlsl
getGlsl(self): string?
Read the GLSL body, when present. Returns nil for WGSL-only shaders.
Parameters
selfany(optional)
local glsl = shaderRef:getGlsl()
modules/ShaderAssetTypeRef/getPasses
getPasses(self): { { name: string, entry: string, scale: number, inputs: { string } } }
The passes this post-process shader declares, from passes: in its
properties.yaml, in the order they are drawn. Each entry is
{ name, entry, scale, inputs }; scale is 0 on the last pass, which
draws at the view's size. A shader that declares none is one pass.
Parameters
selfany(optional)
for _, p in ipairs(shaderRef:getPasses()) do print(p.name, p.entry, p.scale) end
modules/ShaderAssetTypeRef/getProperties
getProperties(self): { { [string]: any } }
List this shader's declared material properties (parsed from
properties.yaml). Each entry is { name, type, default, min?, max? }.
This is the editor-discovery surface, and the SAME parse the compile uses.
Raises, naming the file, when properties.yaml is text the YAML decoder
refuses (with the line) or one of its lists holds anything but a list of
mappings (with the key).
Parameters
selfany(optional)
for _, p in ipairs(shaderRef:getProperties()) do print(p.name, p.type) end
modules/ShaderAssetTypeRef/getSourceCode
getSourceCode(self): string?
Read the primary shader body (shader.wgsl) as raw text.
Parameters
selfany(optional)
local src = shaderRef:getSourceCode()
modules/ShaderAssetTypeRef/getSpace
getSpace(self): string
The space this post-process shader's fragment() reads and returns,
from space: in its properties.yaml: "light" (the default) or
"display". The word the file declares, verbatim — an effect registered
from a shader whose space: names something else renders in "light"
and the engine log carries the spelling it was handed.
Parameters
selfany(optional)
print(asset.resolve("@builtin::shaders.post.lut", "shader"):getSpace())
modules/ShaderAssetTypeRef/getWgsl
getWgsl(self): string?
Read the WGSL body directly, ignoring the GLSL fallback. Use
when you need to detect "is this shader WGSL-native?" vs the
generic getSourceCode lookup that auto-falls-back.
Parameters
selfany(optional)
local wgsl = shaderRef:getWgsl()
modules/ShaderAssetTypeRef/listBindings
listBindings(self): { string }
List which top-level uniform / storage-buffer block names
appear in the shader source — best-effort regex parse. Useful to
cross-check against material:getPropertyNames() when debugging a
"property doesn't exist" gap. Not a full WGSL parser; complex
shaders with macros may report incomplete results.
Parameters
selfany(optional)
for _, name in ipairs(shaderRef:listBindings()) do print(name) end
modules/ShaderAssetTypeRef/listMaterialsUsing
listMaterialsUsing(self): { string }
List the material identities currently bound to this shader, by scanning the registered material catalogue. O(n) over the material list; cache the result if you call it on a hot path.
Parameters
selfany(optional)
for _, m in ipairs(shaderRef:listMaterialsUsing()) do print(m) end
modules/ShaderAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: (re)compile the shader whenever its WGSL body
or properties.yaml is written, and bring materials already bound to it onto
the declared property list when that list changed shape. This is the ONLY
thing that compiles a .shader — the implicit "WGSL written → recompile" path
is gone — so it fires on the initial create (the template write) AND on every
later edit, with no world reload. Convergent: see compileShader.
Parameters
refany(optional)changeany(optional)
modules/ShaderAssetTypeRef/onDelete
onDelete(ref)
Asset-type delete callback: release what a removed .shader folder
registered. The teardown counterpart of onChange's compile: under the key
the shader compiled under, its programs and their variants, its composed
WGSL, its compile status and its diagnostic go with the asset, and so do the
per-path records this module kept for it. A shader authored afresh at the
same path compiles as a new one.
Parameters
refany(optional)
modules/ShaderAssetTypeRef/onDependencyChange
onDependencyChange(ref, _change)
Dependency callback: a reference the shader names bound to its target —
an #include of a module that did not exist when the shader last compiled.
The shader compiles again against the module now there.
Parameters
refany(optional)_changeany(optional)
modules/ShaderAssetTypeRef/previewMaterial
previewMaterial(self): ({ [string]: any }?, string?)
The material a surface preview paints this shader with: a transient
one built from the shader at its properties.yaml defaults, which is the
shader as it looks before anyone tunes it. Only a surface shader has a
surface to paint; a post-process, sky or compute shader answers nil and
the reason. ref:preview() paints the result on the mesh type.yaml
names under preview: and releases the material after the render.
Parameters
selfany(optional)
local surface, why = shaderRef:previewMaterial()
modules/ShaderAssetTypeRef/schemaParseCount
schemaParseCount(): number
How many times a shader's properties.yaml has been parsed in this
session, across every shader and every surface that reads one — the
editor-discovery method, the compile, the alias registration and the alias
lookup. A read whose bytes match the parse already held answers from it and
leaves this unchanged, so the count rises once per distinct revision of a
file rather than once per read.
local m = require("@builtin::assetTypes.assetType.shared.ref").loadTypeModule("shader"); local before = m.schemaParseCount(); ref:getProperties(); print(m.schemaParseCount() - before)
modules/ShaderAssetTypeRef/setWgsl
setWgsl(self, source: string): boolean
Overwrite the WGSL body on disk. Hot-reload picks the new body up on the next frame so any material using this shader recompiles. Returns true on success.
Parameters
selfany(optional)sourcestring— New WGSL source.
shaderRef:setWgsl(myWgsl)
modules/ShaderAssetTypeRef/shadingModel
shadingModel(self): string
Which shading model this shader's body uses, and with it what the engine can take the shader apart into.
"engine-lit" — the body exposes fn surface(...) -> PbrSurface. It hands
the engine a surface (albedo, roughness, metallic, emissive, normal,
occlusion) and the engine lights it, so the capture tool's PBR debug passes
read real material channels.
"self-shading" — the body exposes fn fragment(...) -> vec4<f32> and
returns the finished pixel. There is no separate albedo to read, so those
same passes render what the body returns.
"unknown" — no readable body, or one that exposes neither entry point.
The test is the literal one the compiler applies to the same source, so this reports the model the shader was actually built as.
Parameters
selfany(optional)
if shaderRef:shadingModel() == "self-shading" then print("albedo pass shows final colour") end
modules/ShaderModuleAssetTypeRef/README
require("@builtin::assetTypes.shaderModule.behavior") -- ShaderModuleAssetTypeRef
Per-instance methods exposed on every AssetRef<shaderModule>. Loaded lazily by assetType.shared.ref.
Usage: local ShaderModuleAssetTypeRef = require("@builtin::assetTypes.shaderModule.behavior")
modules/ShaderModuleAssetTypeRef/getSource
getSource(self): string?
Read this module's WGSL (module.wgsl) as raw text.
Parameters
selfany(optional)
local src = moduleRef:getSource()
modules/ShaderModuleAssetTypeRef/onRegister
onRegister(self)
Initial-registration callback: file this module's WGSL under every name
it answers to the moment the instance first registers, so a shader that
#includes it resolves on its first compile rather than only after the
module has been written once this session. Idempotent — the guard below
skips a re-register of identical source.
Parameters
selfany(optional)
modules/ShaderModuleAssetTypeRef/register
register(self): string?
Read this module's WGSL through the VFS and file what it holds now under every name it answers to, so a shader compiled next expands this text. Files unconditionally: the registry answers whether the text moved, and keeps the catalog generation still when the same bytes arrive again.
Parameters
selfany(optional)
local wgsl = moduleRef:register()
modules/ShaderModuleAssetTypeRef/setSource
setSource(self, src: string): boolean
Overwrite this module's WGSL. Every shader that includes it recompiles on the next frame.
Parameters
selfany(optional)srcstring— New WGSL source.
moduleRef:setSource(myWgsl)
modules/Slots/README
require("@builtin::modules.slots") -- Slots
The rules of the slot family: which entities are slots, the path each slot answers to, which part fills it, whether a part fits it and why not, and building or emptying the part that fills it. The Slot, Assembly and Part components call into it; content reads it through them. A slot is a place on an entity that another part fills: an entity carrying a Slot component (its transform is where the part attaches), or a role socket of a Humanoid (righthand, head, ...), which a part fills the way Humanoid:attach seats an item. The nearest Assembly on or above a slot holds what fills it, by the slot's path: the slot's name, under the path of the slot whose part it stands in (engine/turbo). An Assembly on the root of a part built into a slot passes its slots to the Assembly holding that part; any other Assembly below holds its own, so an assembled object parented under another keeps its own configuration.
Usage: local Slots = require("@builtin::modules.slots")
modules/Slots/afterOperation
afterOperation(fn: () -> ())
Run fn now, or once the undoable operation open on this peer
closes. A part is built from the configuration that names it, so the
building stays out of the step that changed the configuration: undoing
the step puts the configuration back and the parts follow it.
Parameters
fn() -> ()— The work to run.
modules/Slots/apply
apply(entry: any, guid: string?): any?
Make a slot hold guid: leave the fill standing when it already holds
that part, otherwise remove the fill and build the part in its place.
Only this slot's branch changes.
Parameters
entryany(optional) — A slot entry.guidstring?(optional) — The guid of the part to hold, or nil to hold nothing.
modules/Slots/currentFill
currentFill(entry: any): (any?, any?)
The entity filling a slot right now, and the record it carries.
Parameters
entryany(optional) — A slot entry.
modules/Slots/decide
decide(config: any, entry: any): (string?, string)
What fills a slot under a configuration: the configured part, an explicit empty, or the slot's default.
Parameters
configany(optional) — The holder's configuration ({ [path] = guid | false }), or nil.entryany(optional) — A slot entry.
modules/Slots/declaredFits
declaredFits(ref: any): ({ string }, string?)
The slot kinds a part declares it fits: the fits of the Part
component at the root of a bundle, or the fits list of the asset's
.metadata for any other asset.
Parameters
refany(optional) — The part's AssetRef.
modules/Slots/discover
discover(rootId: string): { any }
Every slot at and under rootId, in breadth-first order: each
Slot component, and each role socket of a Humanoid, with its path.
A descendant whose own Assembly holds its slots (holdsOwnSlots) is
left out with everything under it.
Parameters
rootIdstring— The entity to walk from (an Assembly's entity).
modules/Slots/fits
fits(entry: any, part: any): (boolean, string, any?)
Whether a part fits a slot, and why not. A part fits when it is an
asset a scene can hold, the slot's kind is empty or among the kinds the
part declares it fits, and the part carries every tag the slot names.
Parameters
entryany(optional) — A slot entry (discover), or any table withpath,kind,tags.partany(optional) — The part: an AssetRef, identity, guid or path.
modules/Slots/holderOf
holderOf(entityId: string): any?
The Assembly that holds what fills the slots at and under
entityId: the nearest one on the entity or its ancestors, and when that
one stands on the root of a part built into a slot, the one holding that
part, climbing on the same way.
Parameters
entityIdstring— The entity to look from.
modules/Slots/holdsOwnSlots
holdsOwnSlots(e: any): boolean
Whether e carries an Assembly that holds its own slots: one on
an entity that is no part built into a slot.
Parameters
eany(optional) — The entity.
modules/Slots/nameOf
nameOf(slot: any): string
The name a Slot component answers to: its name, or the name of
the entity it is on when that is empty.
Parameters
slotany(optional) — The Slot component proxy.
modules/Slots/partRef
partRef(part: any): (any?, string?)
Resolve whatever names a part to its asset: an AssetRef, an identity, a guid or a path.
Parameters
partany(optional) — The part to resolve.
modules/Slots/pathOf
pathOf(slot: any): string
The path a Slot answers to under the Assembly that holds it.
Parameters
slotany(optional) — The Slot component proxy.
modules/SoundClipAssetTypeRef/README
require("@builtin::assetTypes.soundClip.behavior") -- SoundClipAssetTypeRef
Hooks for .soundClip assets. onCreate is the type's contribution to the generic asset.create("soundClip", name, opts) flow (mirroring texture.assetType). onChange keeps a managed container's data.zaud encoded payload in sync when its settings.yaml (or, for content published before it existed, its legacy .metadata settings) are edited, or its retained source audio is rewritten — the asset type reacting to writes inside its own instances (the type-level analogue of a component's onAssetReload). This hook owns every re-encode after the container exists. The settings themselves are declared in settings.luau and read/written through asset.settings / asset.setSettings.
Usage: local SoundClipAssetTypeRef = require("@builtin::assetTypes.soundClip.behavior")
modules/SoundClipAssetTypeRef/audition
audition(self): string?
Play this clip once through the mixer, unpositioned, replacing any clip
auditioning. The voice plays on a temporary host entity the scene never
saves and the entity listings leave out; the host is removed when the
mixer reports the voice ended, and on the frame after stopAudition or a
later audition.
Parameters
selfany(optional)
clipRef:audition()
modules/SoundClipAssetTypeRef/auditionVoice
auditionVoice(self): any?
This clip's audition in progress: its host entity and the mixer's view of the voice (nil until the mixer has it).
Parameters
selfany(optional)
local a = clipRef:auditionVoice(); if a and a.voice then print(a.voice.mixerState) end
modules/SoundClipAssetTypeRef/info
info(self): (any?, string?)
Read the header of this soundClip asset's data.zaud payload: how long
the clip runs, the rate it plays at, how many channels it interleaves,
which codec holds it, how many packets it is in, and where its loop points
sit. Read off the header, so a script timing a caption to a line of
narration pays a header read per clip where :pcm() would decode every
sample. The sampleRate here is the rate the payload holds;
:settings().sampleRate is the resample target the encode was ASKED for,
where 0 means the source's own rate was kept.
Parameters
selfany(optional)
local info = clipRef:info(); task.wait(info.durationMs / 1000)
modules/SoundClipAssetTypeRef/lastAuditionEnd
lastAuditionEnd(self): { host: string, reason: string }?
How this clip's most recent audition ended, once its host is gone: "ended" (the mixer reported it played through), "stopped", "replaced" (a later audition), "unvoiced" (no output, a mixer rendering nothing, or the mixer turned it away), "timeout" (the mixer rendered past the clip's length with no end reported), "neverArrived" (the voice never reached the mixer) or "hostGone".
Parameters
selfany(optional)
local last = clipRef:lastAuditionEnd(); if last then print(last.reason) end
modules/SoundClipAssetTypeRef/loopSeam
loopSeam(self): (any?, string?)
Measure what this clip's samples do where a whole-clip loop wraps — the
reading that says whether the clip can be looped without a click. The
wrap's own step is reported against the step the signal ordinarily makes
between neighbouring samples, so the figure is in the units the signal
moves in and a quiet ambience reads the same way as a loud drone. A clip
whose partials wrap reads near 1; one carrying a strike at its head and
silence at its tail reads in the tens, and seamless is ratio <= threshold. Taken on the decoded payload, so it answers for what the codec
left behind — including for a clip that arrived already encoded.
Parameters
selfany(optional)
local seam = clipRef:loopSeam(); if not seam.seamless then print(seam.ratio) end
modules/SoundClipAssetTypeRef/onChange
onChange(ref: any, change: { [string]: any })
React to a write inside a .soundClip/ instance, keeping the encoded
data.zaud payload in sync. Rewriting the container's retained source
audio — source.<ext>, or an imported file kept under its own name beside
data.zaud — re-encodes from the new bytes; a rewrite carrying the bytes
the payload was already encoded from, under the same encode settings,
does nothing. A settings write — to the declared settings.yaml values
file, or a legacy .metadata block for content published before it
existed — re-encodes from the container's source when the encode-relevant
fields (codec, bitrateKbps, vbr, sampleRate, forceMono,
loopStart, loopEnd) actually changed: the retained source, or —
for a PCM-baked container — the decoded data.zaud itself. loadType
decides how the clip reaches the mixer, not what the payload holds, so it
never drives a re-encode on its own — the generic per-asset reload
dispatch already reaches every Audio component referencing this clip on
any write here, and it asks clipRef:streams afresh on
each rebuild, so the next source built from this clip picks up the new
mode. data.zaud / README.md writes are ignored. The dispatcher's
same-asset guard suppresses the re-dispatch of our own synchronous
data.zaud write, so no loop forms.
Parameters
refany(optional) — The AssetReffor the changed container. change{ [string]: any }—{ path, asset, type, kind, origin, settings, settingsChanged }—pathis the written file,assetthe container folder,kind"edited"/"seeded",origin"local"/"remote",settingsthe validated values andsettingsChangedwhat changed whenpathis the settings values file.
modules/SoundClipAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("soundClip", name, opts). Pure:
returns the content-file map; the caller (asset.create) writes it to the
authored destination (/source/<name>.soundClip/) and that write registers
the soundClip asset.
Two input shapes, mirroring how clips originate:
- PCM —
{ pcm, sampleRate, channels }: generated / decoded interleaved f32 samples, in any containeraudio.encodePcmreads — abuffer, a binary string of little-endian f32, or a flat number array (no source file). Encoded to the canonicaldata.zaudpayload (the engine's ZAUD format) viaaudio.encodePcm.data.zaudis the primary the runtime decodes — so a generated clip becomes a persistent, reload-stable asset addressed by guid. - ENCODED AUDIO —
{ bytes, ext }: OGG / MP3 / WAV / FLAC source bytes, kept verbatim assource.<ext>, withdata.zaudencoded from them against the instance's settings.
Parameters
namestring— SoundClip identity (the instance name).optsCreateOpts
asset.create("soundClip", "beep", { pcm = buffer.create(960 * 4), sampleRate = 48000, channels = 1 })
asset.create("soundClip", "music", { bytes = oggBytes, ext = "ogg" })
modules/SoundClipAssetTypeRef/onDelete
onDelete(ref: any)
Asset-type delete callback: a removed clip's audition ends, and how its last audition ended is forgotten.
Parameters
refany(optional) — The removed clip (its guid when the removal knew it, and its path).
modules/SoundClipAssetTypeRef/pcm
pcm(self): (string?, number?, number?)
Decode this soundClip asset's data.zaud payload into its samples, the
rate they play at, and the number of channels they interleave.
Parameters
selfany(optional)
local pcm, sr, ch = clipRef:pcm()
modules/SoundClipAssetTypeRef/setSettings
setSettings(self, patch: { [string]: any })
Write a partial settings patch. The patch is checked against this
type's declared schema; a violation refuses the write naming every
problem. A valid write reaches onChange: an encode-relevant field
(codec, bitrateKbps, vbr, sampleRate, forceMono, loopStart,
loopEnd) re-encodes data.zaud; loadType never re-encodes — it
decides how the next Audio source built from this clip reaches the
mixer.
Parameters
selfany(optional)patch{ [string]: any }— Any subset of the schema's fields.
clipRef:setSettings({ bitrateKbps = 64, forceMono = true })
modules/SoundClipAssetTypeRef/settings
settings(self): { [string]: any }
Read this soundClip asset's settings, with every declared default
filled in. The settings say how the clip is encoded and where its loop
points sit; what its samples do where a whole-clip loop wraps is
clipRef:loopSeam().
Parameters
selfany(optional)
if clipRef:settings().forceMono then ... end
modules/SoundClipAssetTypeRef/stopAudition
stopAudition(self): boolean
Stop this clip's audition: it stops being the audition in progress at once, and its host is removed on the next frame.
Parameters
selfany(optional)
clipRef:stopAudition()
modules/SoundClipAssetTypeRef/streams
streams(self, bytes: string?): boolean
Whether a source playing this clip holds it streaming: loadType
"streaming" does, "decompressOnLoad" does not, and "auto" streams a clip
that runs longer than 5 seconds.
Parameters
selfany(optional)bytesstring?(optional) — The clip'sdata.zaudpayload when the caller already holds it.
local s = ecs.AudioSource{ clip = c, streaming = c:streams(bytes) }
modules/StyleAssetTypeRef/README
require("@builtin::assetTypes.style.behavior") -- StyleAssetTypeRef
Per-instance methods exposed on every AssetRef<style>. Loaded lazily by assetType.shared.ref.
Usage: local StyleAssetTypeRef = require("@builtin::assetTypes.style.behavior")
modules/StyleAssetTypeRef/getInitScript
getInitScript(self): string?
Read the style's entry script as raw text.
Parameters
selfany(optional)
local src = styleRef:getInitScript()
modules/StyleAssetTypeRef/getReadme
getReadme(self): string?
Read the style's README.
Parameters
selfany(optional)
print(styleRef:getReadme())
modules/StyleAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { tokenCategories }, the
top-level keys of the style's own M.tokens = { ... } table literal,
parsed from the entry script's source text via
luau_introspect.tableLiteralKeys — never requires the style.
Cached on the asset's content checksum, so re-inspecting unchanged
source is free. A style with no readable entry script returns an
empty detail rather than erroring.
Parameters
selfany(optional)
local tokenCategories = asset.inspect(styleRef).detail.tokenCategories
modules/StyleAssetTypeRef/loadTheme
loadTheme(self): any
Load the style module and return its exported theme table. Raises a Luau error tagged with the style identity if the require fails.
Parameters
selfany(optional)
local theme = styleRef:loadTheme()
modules/Test.valueText/README
require("@builtin::assetTypes.testSuite.shared.valueText") -- Test.valueText
How the test framework renders a value nested inside a table for test output: structurally, with bounded breadth, depth and string length, in a deterministic order.
Usage: local Test.valueText = require("@builtin::assetTypes.testSuite.shared.valueText")
modules/Test.worldReadings/README
require("@builtin::assetTypes.testSuite.shared.worldReadings") -- Test.worldReadings
Readings the test framework takes of engine-wide state around a test: each facet a queued teardown moves (entities, layers, render features, render targets, loads in flight), and which editor chrome screens the window shows.
Usage: local Test.worldReadings = require("@builtin::assetTypes.testSuite.shared.worldReadings")
modules/Test.worldReadings/residentRenderTargets
residentRenderTargets(): number
Readings the test framework takes of engine-wide state around a test: each facet a queued teardown moves (entities, layers, render features, render targets, loads in flight), and which editor chrome screens the window shows.
modules/TestSuiteAssetTypeRef/README
require("@builtin::assetTypes.testSuite.behavior") -- TestSuiteAssetTypeRef
Per-instance methods exposed on every AssetRef<testSuite>. Loaded lazily by assetType.shared.ref. These methods act on the SPECIFIC asset instance the reference points to — asset.resolve(id, "testSuite"):run() runs only THAT suite. Running every suite is the tests toolbox's job (it iterates asset.list("testSuite") and calls :run() on each); it is deliberately not offered here.
Usage: local TestSuiteAssetTypeRef = require("@builtin::assetTypes.testSuite.behavior")
modules/TestSuiteAssetTypeRef/getReadme
getReadme(self): string?
Read this suite's README.md body.
Parameters
selfany(optional)
print(suiteRef:getReadme())
modules/TestSuiteAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { testCount, testNames },
parsed from Test.it("<name>", ...) calls in this suite's own
init.luau text. A string scan, not a suite run — inspecting a suite
never registers or executes its tests. A suite with no readable
init.luau returns an empty testNames list rather than erroring.
Parameters
selfany(optional)
local testNames = asset.inspect(suiteRef).detail.testNames
modules/TestSuiteAssetTypeRef/run
run(self, opts: { quiet: boolean? }?): any
Run THIS test suite (only this one) and return its results. Refuses in play mode — tests are an edit-mode / authoring concern, not gameplay. The run is cooperative (the framework yields a frame between tests) so it never blocks the engine or trips the execute watchdog.
Parameters
selfany(optional)opts{ quiet: boolean? }?(optional) — Optional{ quiet }.
local r = asset.resolve("vfs", "testSuite"):run()
modules/TestSuiteAssetTypeRef/tests
tests(self): { { name: string, skip: boolean } }
List the tests this suite declares (loads THIS asset's init.luau to
read its registered Test.it / Test.skip names; does not run them).
Parameters
selfany(optional)
for _, t in ipairs(suiteRef:tests()) do print(t.name) end
modules/TextureAssetTypeRef/README
require("@builtin::assetTypes.texture.behavior") -- TextureAssetTypeRef
Hooks for .texture assets. onCreate is the type's contribution to the generic asset.create("texture", name, opts) flow (mirroring material.assetType). onChange keeps a MANAGED container's data.ztex encoded payload in sync when its settings.yaml (or, for content published before it existed, its legacy .metadata settings) are edited, or its retained source image is rewritten — the asset type reacting to writes inside its own instances (the type-level analogue of a component's onAssetReload). The loose-image → container PROMOTE step is the separate texture.importer (loose-write seam); this hook owns every re-encode AFTER the container exists. The settings themselves are declared in settings.luau and read/written through asset.settings / asset.setSettings.
Usage: local TextureAssetTypeRef = require("@builtin::assetTypes.texture.behavior")
modules/TextureAssetTypeRef/compressionFor
compressionFor(settings: { [string]: any }, isLegacy: boolean): { compression: string, textureType: string }
What a texture is compressed as, and as what type, given its
settings. isLegacy says the settings predate compression (stored
before it was a setting, whatever older format they name): such a
texture is compressed as it should have been — a nearest-filtered one is
pixel art, a sprite held exactly as rgba8; a high-precision one (rgba16,
rgba32f) keeps its format; every other one is uastc. Settings that name
compression keep it, so a texture whose settings say rgba8 is never
compressed. The one decision the local-edit heal (settingsHealed) and
an on-device compressor of legacy content both make.
Parameters
settings{ [string]: any }— The texture's settings, as a read reports them.isLegacyboolean— Whether the stored settings predatecompression.
M.compressionFor({ compression = "rgba8", filter = "nearest", textureType = "color" }, true) -- { compression = "rgba8", textureType = "sprite" }
modules/TextureAssetTypeRef/handle
handle(self)
Put this texture asset on the GPU under its own guid and return its
TextureHandle at once. The asset's bytes are decoded off the frame and
the texture lands on the device when the decode finishes, a frame or more
later: a material naming the guid draws the shader's default for that
slot until then and rebinds when it arrives, and
renderer.texture.isResident(guid) reports the arrival. The handle is
cached on the interned ref's shared runtime table for as long as
something holds the one it handed out, so every consumer and material slot
naming the asset over that time gets the SAME handle back → ONE GPU entry.
Once the last of them lets go, the next call asks for the asset again and
is answered with a handle on the texture the device already holds under
that guid — which is also what a mode flip's runtime wipe leads to. The
material binds this handle's guid; it never creates the GPU texture itself.
CPU lifecycle: governed by the asset's declared keepCpu setting
(texRef:setSettings({ keepCpu = true })). By DEFAULT (false) the decoded
pixels are dropped right after the GPU upload (the GPU handle holds no
data → no double-memory cost); with keepCpu = true the CPU store keeps
them for later pixel reads / edits. A keepCpu change reaches an
already-materialised texture too — onChange's applyKeepCpu loads or
drops the CPU copy the moment the setting changes, not only here.
Parameters
selfany(optional)
local h = texRef:handle() -- bind h.guid on a material; it draws once resident
modules/TextureAssetTypeRef/info
info(self): (any?, string?)
Read the header of this texture asset's compiled data.ztex payload:
the pixel format it was compiled to, as its compression and
colorSpace too, how many texels it is across and
down, how many mip levels and array layers it carries, the sampler
recorded in it (filter, wrapU, wrapV, anisotropy), and, for a
sequence, each layer's display time
and the length of one pass. Read off that payload's own header, so a
compiled texture answers how big it is for a header read where :load()
decodes its pixels and :handle() uploads them. A container whose
primary is a source image answers (nil, err), and :load() reads its
size. The compression and colorSpace here are what the payload
holds; :settings() holds what the encode was ASKED for.
Parameters
selfany(optional)
local i = texRef:info(); print(i.width .. "x" .. i.height)
modules/TextureAssetTypeRef/load
load(self)
Load this .texture asset's pixels into the guid-keyed CPU store and
return a CPU handle for per-pixel access (no GPU readback). The handle holds
no pixels — only the guid, dims, texel format, and the read/write/encode/
unload ops. The pixels stay at the precision they were authored with:
handle.format is "rgba8", "rgba16" or "rgba32f", and :readPixel
reports channels in that format's own units. Upload to the GPU with
renderer.texture.create(handle); the DEFAULT is to handle:unload()
after. The handle's :encode() re-encodes the (possibly edited) pixels
into a fresh ZTEX blob for asset.create("texture", …), at the same
format.
Parameters
selfany(optional)
local cpu = texRef:load(); local r,g,b,a = cpu:readPixel(3, 4); cpu:unload()
modules/TextureAssetTypeRef/normalizeSettings
normalizeSettings(values: { [string]: any }, stored: { [string]: any }?): { [string]: any }
Map every older spelling a stored file or a write may carry to the
fields and members the schema declares: an older filter keyword to
linear / nearest, an anisotropy given as a number to its string
(8 → "8"), compression = "bc7" to "uastc", maxDimension = 0
(no cap) to 8192, and format + srgb to colorSpace +
compression (an explicit srgb sets the colour space of an rgba8,
uastc or bc7 format; the high-precision formats stay linear). An srgb given without a format
applies to the compression the same table names, else to the asset's
stored one, so { srgb = true } leaves an rgba16 texture linear. A table
that names both an older field and its replacement keeps the
replacement's value. A format no schema declared stays under its own
name, so the schema check refuses it naming the field. Returns a new table.
Parameters
values{ [string]: any }— A settings table in any spelling.stored{ [string]: any }?(optional) — The asset's current values, whenvaluesis a patch over them.
M.normalizeSettings({ format = "bc7_srgb", maxDimension = 0 }) -- { colorSpace = "srgb", compression = "uastc", maxDimension = 8192 }
modules/TextureAssetTypeRef/onChange
onChange(ref: any, change: { [string]: any })
React to a write inside a .texture/ instance, keeping the encoded
data.ztex payload in sync. Rewriting the container's retained source
image — source.<ext>, or an imported image kept under its own name
beside data.ztex — re-encodes from the new bytes; a rewrite carrying
the bytes the payload was already encoded from does nothing. A settings
change that touches only the sampler fields (filter, wrapU, wrapV,
anisotropy) on a container holding data.ztex rewrites the payload's
header with them (renderer.texture.withSampler): every level keeps its
bytes and no preview is rendered, because no pixel changed. A settings
change that touches an encode-affecting field (textureType,
colorSpace, compression, generateMipmaps, maxDimension,
alpha, alphaIsTransparency) re-encodes from the container's source:
the managed source.<ext>, a plain container's image primary, or — for a
raw-pixel container — the data.ztex payload itself, re-encoded whole
(every layer and its display time kept) and read back with straight
alpha. A raw-pixel container's payload is its only source, so
what an earlier encode discarded stays discarded: after alpha = "none"
its alpha is opaque, and after alphaIsTransparency its transparent
texels keep the colour dilation gave them. Whatever rewrote the payload
— a re-encode here, or a data.ztex written directly or arriving from a
peer — the texture this engine has on the GPU under the asset's guid is
uploaded again from it, so every material, UI image and effect sampling
the guid draws the new pixels, size, format, colour space, mip chain,
filter, wrapU, wrapV and anisotropy, and a resident CPU copy is decoded
again. A keepCpu change acts on the texture's CPU
residency instead (applyKeepCpu) and never re-encodes on its own — and,
because CPU residency is PER-ENGINE state, it acts for EVERY origin: a
synced peer's write says exactly as much about its own process as a local
one does about this one. Everything that WRITES persisted content — the
source re-encode and the settings-driven re-encode — stays local-origin-only; a
peer receives that content through the ordinary sync instead of
reproducing the write itself. It fires on a write to the declared
settings.yaml values file only when change.settingsChanged is
non-empty — an identical rewrite carries an empty diff and does nothing —
or on a legacy .metadata settings block for content published before
the values file existed, which carries no diff and so re-encodes
unconditionally. README.md writes are ignored. The dispatcher's
same-asset guard suppresses the re-dispatch of our own synchronous
data.ztex write, so no loop forms.
Parameters
refany(optional) — The AssetReffor the changed container. change{ [string]: any }—{ path, asset, type, kind, origin, settings, settingsChanged }—pathis the written file,assetthe container folder,kind"edited"/"seeded",origin"local"/"remote",settingsthe validated values andsettingsChangedwhat changed whenpathis the settings values file.
modules/TextureAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("texture", name, opts). Pure:
returns the content-file map; the caller (asset.create) writes it to the
authored destination (/source/<name>.texture/) and that write registers
the texture asset. Disk-only — nothing is uploaded to the GPU here.
Two input shapes, mirroring how textures originate:
- RAW PIXELS —
{ rgba, width, height }: a generated / decoded pixel buffer (no source image). Encoded to the canonicaldata.ztexpayload (the engine'sZTEXformat;zero_texture::blob) via__texture.encode, at the resolvedopts.settings.compressionandopts.settings.colorSpace.data.ztexis the primary the renderer uploads — so a generated texture becomes a persistent, reload-stable asset addressed by guid, never an ephemeral GPU handle.compressionpicks the on-disk storage:"uastc"blocks (a new texture's default), 8 bits per channel with"rgba8"(a sprite's), or"rgba16"/"rgba32f"for a data raster (height / displacement field, baked lightmap, imported elevation) whose values 8 bits would quantize. A cook that drops texels (maxDimension, the power-of-two resample) keeps every one assource.ztex, so a later settings change re-encodes from them. - ENCODED IMAGE —
{ bytes, ext }: PNG / JPEG / WebP / … source bytes, stored verbatim as the<name>.<ext>primary (the renderer image-decodes on upload; the same shapeasset.createproduced before).
Parameters
namestring— Texture identity (the instance name).optsCreateOpts
asset.create("texture", "skyGradient", { rgba = pixels, width = 256, height = 256 })
asset.create("texture", "terrain_height", { rgba = heights, width = 512, height = 512, settings = { compression = "rgba16" } })
asset.create("texture", "pixel_icon", { rgba = pixels, width = 16, height = 16, settings = { compression = "rgba8", filter = "nearest" } })
asset.create("texture", "bricks", { bytes = imageBytes, ext = "jpg" })
modules/TextureAssetTypeRef/setSettings
setSettings(self, patch: { [string]: any })
Write a partial settings patch. The patch is checked against this
type's declared schema; a violation refuses the write naming every
problem. A valid write reaches onChange: an encode-affecting field
(textureType, colorSpace, compression, generateMipmaps,
maxDimension, effort, uastcRdo, alpha, alphaIsTransparency) re-encodes data.ztex;
a write naming only sampler fields (filter, wrapU, wrapV,
anisotropy) rewrites the payload's header and keeps every level's
bytes; keepCpu loads or drops the CPU copy instead, without touching
the encoded bytes.
Parameters
selfany(optional)patch{ [string]: any }— Any subset of the schema's fields.
texRef:setSettings({ filter = "nearest" })
modules/TextureAssetTypeRef/settings
settings(self): { [string]: any }
Read this texture asset's settings, with every declared default filled
in. The table also answers the older format and srgb names, read
from colorSpace + compression: format is "srgb", "linear",
"uastc_srgb", "uastc", "rgba16" or "rgba32f", and srgb is true for
the srgb colour space. Both are read-only: a write names colorSpace /
compression.
Parameters
selfany(optional)
if texRef:settings().filter == "nearest" then ... end
modules/TextureAssetTypeRef/settingsCorrections
settingsCorrections(values: { [string]: any }, _name: string, _opts: { [string]: any }?): ({ [string]: any }?, { [string]: string }?)
Cross-field settings correction Settings.applyCorrections applies
on every settings write — once a create's layers (schema defaults, this
type's own settingsDefaults, the Preset Manager, an importer, the
caller) have merged, and on every later asset.setSettings: a
high-precision compression stores the raster verbatim and linear, so
it carries no mip chain, no max-dimension downsample and no sRGB colour
space — the encoder refuses all three structurally. Overrides
generateMipmaps / maxDimension / colorSpace to the only values a
high-precision compression allows. Whether that lands SILENTLY or
REFUSES the write is applyCorrections' call, based on whether the
writer named the field being overridden — the second return here
supplies the "why" for that refusal message, naming the compression that
made it necessary. Reads values; returns the correction rather than
writing to it.
Parameters
values{ [string]: any }— The fully resolved settings, after every layer has merged._namestring_opts{ [string]: any }?(optional)
local fix, why = M.settingsCorrections({ compression = "rgba16", generateMipmaps = true }, "height", {})
modules/TextureAssetTypeRef/settingsDefaults
settingsDefaults(name: string, opts: { [string]: any }?, asked: { [string]: any }?): { [string]: any }
The create-time settings this type contributes to a new asset's
values, layered above the schema's own declared defaults and below every
other layer (Preset Manager, importer, caller) — resolveForCreate calls
this once per create, so an explicit override from any later layer
replaces what it returns here. textureType follows the created name's
own data-map convention: "normalMap" for a _normal/_nrm/_n/...
suffixed name, "mask" for a _rough/_metal/_ao/_height/_disp/
_mask/... one, "color" otherwise; the colour space then follows the
type (settingsDerivedDefaults). A new texture is uastc with a
maxDimension of 4096; a sprite (a textureType a layer above names)
is rgba8, drawn exactly as given; a high-precision source (a 16-bit
PNG, a Radiance .hdr) leaves compression to the layers above. When
opts.ztex is a pre-encoded payload whose header reads, its
colorSpace, compression, filter, wrapU, wrapV, anisotropy,
textureType, alpha and alphaIsTransparency are what was actually
written, and the settings describe what is stored.
Parameters
namestring— The instance name being created.opts{ [string]: any }?(optional) — The creation opts passed toasset.create.asked{ [string]: any }?(optional) — What the layers above this one (Preset Manager, importer, caller) name.
local layer = M.settingsDefaults("brick_normal", {}, {}) -- { textureType = "normalMap", compression = "uastc", maxDimension = 4096 }
modules/TextureAssetTypeRef/settingsDerivedDefaults
settingsDerivedDefaults(
The fields whose default follows textureType, for a write that set
or changed it: colorSpace (srgb for color and sprite, linear for
normalMap and mask), alphaIsTransparency (true for sprite) and wrapU /
wrapV (clamp for sprite — drawn whole — and repeat otherwise). The
settings framework applies a returned field only where the same write
did not name it, so a create or patch that names its own colour space
keeps it.
M.settingsDerivedDefaults({ textureType = "sprite" }, {}, { textureType = true }) -- { colorSpace = "srgb", alphaIsTransparency = true, wrapU = "clamp", wrapV = "clamp" }
modules/TextureAssetTypeRef/settingsHealed
settingsHealed(values: { [string]: any }, stored: { [string]: any }): { [string]: any }?
The settings a local edit heals for a texture whose stored settings
predate compression (they name no compression): the compression and
texture type compressionFor answers for it. maxDimension heals as an
older "no cap" reads (normalizeSettings), so a healed 8K texture stays
8K. Nothing else changes. Settings that name compression heal nothing.
Parameters
values{ [string]: any }— The texture's settings, as a read reports them.stored{ [string]: any }— The settings exactly as stored.
M.settingsHealed({ compression = "rgba8", textureType = "color", filter = "linear" }, { format = "srgb" }) -- { compression = "uastc", textureType = "color" }
modules/TextureRef/README
require("@builtin::modules.texture_ref") -- TextureRef
The GPU key a material's texture slot binds by, resolved from whatever form the author wrote it in. Every path that accepts a texture reference — the .material assetType, renderer.material.create, renderer.material.setTexture — resolves through here, so the same string binds the same texture wherever it is written.
Usage: local TextureRef = require("@builtin::modules.texture_ref")
modules/TextureRef/isProcedural
isProcedural(ref: string): boolean
Whether a reference is one the GPU texture cache resolves on its own
(color: / default: / runtime:), so it must be passed through untouched
rather than looked up as an asset.
Parameters
refstring— The reference string.
TextureRef.isProcedural("color:1,0,0,1") -- true
modules/TextureRef/resolve
resolve(ref: any, altIdentity: string?, site: string?): (string, string)
Resolve a texture reference to the resident GPU key the renderer binds a
slot by, materialising the texture on the way. Accepts a guid, an asset
identity, a bare name, a .texture path, or the image path a texture was
imported from. color: / default: / runtime: forms and live GPU handles
(a video frame, a render target) pass through untouched. An array:a|b|c
reference resolves each layer the same way, materialising every layer
texture the array is assembled from, and answers the array keyed by the
layers' resolved keys.
Parameters
refany(optional) — The authored reference.altIdentitystring?(optional) — Optional second candidate, tried whenrefresolves to nothing — a slot's stable identity, so a binding whose guid was orphaned by a delete + recreate still finds the texture the author named.sitestring?(optional) — Optional VFS path of the asset whose file holds the reference — a material resolving its ownmat.yamlslots. A package-relative~.textures.xthen expands against the package enclosing that asset, and a reference that asset's.refsrecorded resolves to the texture recorded there. A site inside a carried mount resolves the reference within that mount.
TextureRef.resolve("wall.texture") -- "9f2c…", "asset"
TextureRef.resolve("array:grass.texture|rock.texture") -- "array:9f2c…|41ab…", "array"
modules/TextureRef/unresolvedMessage
unresolvedMessage(ref: string, what: string): string
The message describing a reference that names no texture. Bound anyway, the slot renders the shader's declared fallback, so the caller says this rather than letting the material render as though nothing was asked for.
Parameters
refstring— The unresolved reference.whatstring— The call being made, for the message's subject.
TextureRef.unresolvedMessage("sky.jpg", "renderer.material.setTexture")
modules/ToolAssetTypeRef/README
require("@builtin::assetTypes.tool.behavior") -- ToolAssetTypeRef
Per-instance methods exposed on every AssetRef<tool>. Loaded lazily by assetType.shared.ref.
Usage: local ToolAssetTypeRef = require("@builtin::assetTypes.tool.behavior")
modules/ToolAssetTypeRef/getDefinition
getDefinition(self): string?
Read the tool's definition — its init.luau source, which carries
the typed signature and the --!desc/--!arg/--!return/--!example
docstring that together form the tool's schema.
Parameters
selfany(optional)
local raw = toolRef:getDefinition()
modules/ToolAssetTypeRef/getInitScript
getInitScript(self): string?
Read the tool's entry script as raw text.
Parameters
selfany(optional)
local src = toolRef:getInitScript()
modules/ToolAssetTypeRef/getReadme
getReadme(self): string?
Read the tool's README body.
Parameters
selfany(optional)
print(toolRef:getReadme())
modules/ToolAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { desc, args, returns, examples, signature }, parsed from the tool's own entry script
(getInitScript) via luau_introspect.docstrings — the same
--!desc/--!arg/--!return/--!example docstring that documents the
tool's schema. Cached on the asset's content checksum, so re-inspecting
unchanged source is free. A tool with no readable entry script returns
an empty detail rather than erroring.
Parameters
selfany(optional)
local args = asset.inspect(toolRef).detail.args
modules/ToolAssetTypeRef/run
run(self, args: any): any
Invoke the tool's entry script. Requires the tool's identity
and calls the first function it exports — the canonical
function M.<name>(args) shape every tool ships. args is
forwarded verbatim. Raises a Luau error (tagged with the tool's
identity) on load or invocation failure rather than returning a
swallowed nil — failing loudly matches the rest of the engine's
tool dispatch surface.
Parameters
selfany(optional)argsany(optional) — Optional table of arguments to pass to the tool's entry.
toolRef:run({ subject = "world" })
modules/ToolAssetTypeRef/wrap
wrap(fn: (...any) -> ...any, regionName: string): (...any) -> ...any
Standardize a single tool function into a ZmToolResult-returning call.
THIS is where the tool-result contract lives — the engine's tool-bind
paths (boot + runtime) apply wrap to every tool function so the result
type is a system guarantee, never the individual tool's choice. The tool
body returns its raw value, returns the Lua failure convention
(nil, reason), or raises with error(msg); wrap produces the
canonical envelope { ok, value | error, durationMs, tool } from all
three — a (nil, reason) return becomes { ok = false, error = reason }
instead of silently dropping the reason and reporting a bare success
with no value. Timing is measured with the engine profiler: a region
named for the tool is opened when the call is invoked and closed when it
returns, so each invocation is both timed (region elapsed ->
durationMs) and visible as a profiler region. Each envelope is also
reported into the running task's tool-result buffer, which execute()
auto-surfaces as the response's toolResults.
A tool that states MORE than one value on success — a path AND what that
path holds — keeps them: the envelope carries the first as value, and
every value past it follows the envelope out, so local a, b, c = tools.use(...) reads the tool the way the tool's own signature declares
it. Keeping only the first turns every such declaration into a promise
nobody can read.
Parameters
fn(...any) -> ...anyregionNamestring
Returns ...any
modules/ToolAssetTypeRef/wrapToolbox
wrapToolbox(box: { [string]: any }, namespace: string): { [string]: any }
Wrap every function on a toolbox table so each tool call returns a
ZmToolResult (see wrap). Non-function fields pass through untouched.
Parameters
box{ [string]: any }namespacestring
modules/ToolboxAssetTypeRef/README
require("@builtin::assetTypes.toolbox.behavior") -- ToolboxAssetTypeRef
Per-instance methods exposed on every AssetRef<toolbox>. Loaded lazily by assetType.shared.ref.
Usage: local ToolboxAssetTypeRef = require("@builtin::assetTypes.toolbox.behavior")
modules/ToolboxAssetTypeRef/getReadme
getReadme(self): string?
Read the toolbox's README.md body.
Parameters
selfany(optional)
print(toolboxRef:getReadme())
modules/ToolboxAssetTypeRef/hasShared
hasShared(self): boolean
Check whether the toolbox ships a shared.module/.
Parameters
selfany(optional)
if toolboxRef:hasShared() then ... end
modules/ToolboxAssetTypeRef/inspect
inspect(self): any
asset.inspect type-specific detail: { tools }, where tools is
{ name, desc } for every *.tool/ child the toolbox owns, walked
directly from the toolbox's own folder — desc is the child tool's
own --!desc docstring line, read from its entry script without
requiring the tool module. A toolbox with no readable folder returns
an empty tools list rather than erroring.
Parameters
selfany(optional)
local boxTools = asset.inspect(toolboxRef).detail.tools
modules/ToolboxAssetTypeRef/listTools
listTools(self): { any }
List the tool refs the toolbox carries. Walks the toolbox
folder, finds every *.tool/ child, and resolves each to an
AssetRef<tool>.
Parameters
selfany(optional)
for _, t in ipairs(toolboxRef:listTools()) do print(t.identity) end
modules/Trails/README
require("@builtin::systems.trails.trails") -- Trails
Continuous ribbon geometry that follows a moving point.
A trail is a strip of quads threaded along the positions something
occupied over the last few seconds. Each recorded point contributes two
vertices, offset either side of the direction of travel, and consecutive
points are joined into a continuous surface — so a spark, a wingtip
vapour trail or a sword arc is one mesh rather than a queue of sprites
that betrays its spacing when the subject moves fast.
Width, colour and opacity run from the head (the newest point) to the tail
(the oldest), indexed by each point's age rather than its position in the
list, so the fade reads the same whether the subject is crawling or
sprinting.
ribbon is pure: the same points, camera and settings produce the same
arrays, so a trail's geometry can be checked without a scene.
Usage: local Trails = require("@builtin::systems.trails.trails")
modules/Trails/expire
expire(path: table, now: number) -> number
Drop points older than lifetime. Returns how many went.
Parameters
pathtablenownumber
Returns number
modules/Trails/newPath
newPath(opts: table?) -> table
A fresh path. lifetime seconds a point survives, minDistance metres before a new one is recorded, maxPoints the ring's bound.
Parameters
optstable?(optional)
Returns table
modules/Trails/pathOf
pathOf(id: string) -> table?
Parameters
idstring
Returns table?
modules/Trails/push
push(path: table, x: number, y: number, z: number, now: number) -> boolean
Record the head position when it has travelled minDistance from the last point. Returns whether a point was recorded.
Parameters
pathtablexnumberynumberznumbernownumber
Returns boolean
modules/Trails/register
register(id: string, path: table)
Parameters
idstringpathtable
modules/Trails/ribbon
ribbon(path: table, opts: table) -> table?
Build the ribbon over a path's points — flat positions / normals / uvs / colors / indices, the shape renderer.mesh.create takes. nil under two points, which is no surface.
Parameters
pathtableoptstable
Returns table?
modules/Trails/stats
stats() -> table
Returns table
modules/Trails/unregister
unregister(id: string)
Parameters
idstring
modules/Transform/README
require("@builtin::modules.transform") -- Transform (also available as global 'Transform')
Math helpers for positions, rotations, and directions on transforms. Exposed as the global Transform table; entity-aware helpers accept an id string or an entity proxy.
Usage: local Transform = require("@builtin::modules.transform") Also available as global: Transform
modules/Transform/direction
direction(fromX: number, fromY: number, fromZ: number, toX: number, toY: number, toZ: number): (number, number, number)
Normalized direction vector from point A to point B. Returns zeros when the two points coincide (within ~0.001 units).
Parameters
fromXnumber— From x.fromYnumber— From y.fromZnumber— From z.toXnumber— To x.toYnumber— To y.toZnumber— To z.
local dx, dy, dz = Transform.direction(0, 0, 0, 1, 0, 0)
modules/Transform/directionBetween
directionBetween(entityA: string | EntityRef, entityB: string | EntityRef): (number, number, number)
Normalized world-space direction from one entity to another, read from their world positions. Returns zeros if either entity can't be resolved.
Parameters
entityAstring | EntityRef— Source entity (id string or proxy).entityBstring | EntityRef— Target entity (id string or proxy).
local dx, dy, dz = Transform.directionBetween("cam", "target")
modules/Transform/distance
distance(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): number
Euclidean distance between two world-space positions.
Parameters
x1number— First point x.y1number— First point y.z1number— First point z.x2number— Second point x.y2number— Second point y.z2number— Second point z.
local d = Transform.distance(0, 0, 0, 1, 1, 1)
modules/Transform/distanceBetween
distanceBetween(entityA: string | EntityRef, entityB: string | EntityRef): number?
Distance between two entities in world space. Each entity's world position is what is measured, so a parent's offset counts toward the distance the way the scene shows it.
Parameters
entityAstring | EntityRef— First entity (id string or proxy).entityBstring | EntityRef— Second entity (id string or proxy).
local d = Transform.distanceBetween("cam", "box")
modules/Transform/euler
euler(qx: number, qy: number, qz: number, qw: number): (number, number, number)
Convert quaternion to euler angles (yaw, pitch, roll) in radians.
Parameters
qxnumber— Quaternion x.qynumber— Quaternion y.qznumber— Quaternion z.qwnumber— Quaternion w.
local yaw, pitch, roll = Transform.euler(0, 0, 0, 1)
modules/Transform/eulerToQuat
eulerToQuat(yaw: number, pitch: number?, roll: number?): (number, number, number, number)
Identity-aware overload of euler-to-quaternion. Uses the negative-yaw
convention shared with quatFromYaw, quatFromYawPitch, lookAtQuat, and
T.euler extraction — so T.euler(T.eulerToQuat(y, p, r)) returns
(y, p, r). Order is yaw (Y) then pitch (X) then roll (Z).
Parameters
yawnumber— Y-axis rotation in radians.pitchnumber?(optional) — X-axis rotation in radians. Defaults to 0.rollnumber?(optional) — Z-axis rotation in radians. Defaults to 0.
local qx, qy, qz, qw = Transform.eulerToQuat(math.pi / 2)
modules/Transform/lerp
lerp(ax: number, ay: number, az: number, bx: number, by: number, bz: number, t: number): (number, number, number)
Linearly interpolate between two positions.
Parameters
axnumber— Start x.aynumber— Start y.aznumber— Start z.bxnumber— End x.bynumber— End y.bznumber— End z.tnumber— Interpolation factor[0, 1].
local x, y, z = Transform.lerp(0, 0, 0, 1, 1, 1, 0.5)
modules/Transform/lerp1
lerp1(a: number, b: number, t: number): number
Linearly interpolate two scalars.
Parameters
anumber— Start value.bnumber— End value.tnumber— Interpolation factor[0, 1].
local v = Transform.lerp1(0, 10, 0.5)
modules/Transform/lerpAngle
lerpAngle(a: number, b: number, t: number): number
Lerp between two angles via the shortest arc; returns a value in [-pi, pi].
Parameters
anumber— Start angle in radians.bnumber— End angle in radians.tnumber— Interpolation factor[0, 1].
local a = Transform.lerpAngle(0, math.pi, 0.5)
modules/Transform/localToWorld
localToWorld(px: number, py: number, pz: number, pqx: number, pqy: number, pqz: number, pqw: number, lx: number, ly: number, lz: number): (number, number, number)
Transform a local-space position into world space using a parent pose.
Parameters
pxnumber— Parent position x.pynumber— Parent position y.pznumber— Parent position z.pqxnumber— Parent rotation x.pqynumber— Parent rotation y.pqznumber— Parent rotation z.pqwnumber— Parent rotation w.lxnumber— Local x.lynumber— Local y.lznumber— Local z.
local wx, wy, wz = Transform.localToWorld(px, py, pz, pqx, pqy, pqz, pqw, lx, ly, lz)
modules/Transform/lookAt
lookAt(entityOrId: string | EntityRef, txOrTarget: any, ty: any?, tz: number?, up: any?): (boolean, string?)
Make an entity face a world position. The target slot accepts three
explicit coordinates, one point as { x, y, z } / { x =, y =, z = } / a
vector, or an entity — an id string, an entity NAME, or a proxy — whose
WORLD position is resolved. A table carrying an entity id reads as that
entity; any other table reads as the point it spells. The subject slot
takes the three entity spellings.
Everything here is world space: the subject and the target are
read as entity(id).position and the aim is written as
entity(id).rotation, so a parent under either one moves the entity and
the aim still lands on the point named.
Returns whether the rotation was written, so a caller that named an entity
the scene does not carry learns the aim did not happen instead of reading
a stale orientation back as the answer.
Parameters
entityOrIdstring | EntityRef— Entity id, name, or proxy for the entity to rotate.txOrTargetany(optional) — A number (world x), a point table, or an entity id / name / proxy whose world position is resolved as the look-at target.tyany?(optional) — World y of the target. Omitted whentxOrTargetis a point or an entity.tznumber?(optional) — World z of the target. Omitted whentxOrTargetis a point or an entity.upany?(optional) — Optional world up hint deciding the roll —{ x, y, z },{ x =, y =, z = }or a vector. World +Y when omitted. It never bends the aim; it only says which way is up around it. When the target slot is an entity or a point this is the third argument, and when it is coordinates the fifth.
Transform.lookAt("cam", 0, 1, 0)
Transform.lookAt("cam", "box") -- resolve target entity position
Transform.lookAt(cam, box) -- entity proxies for both
Transform.lookAt("cam", { 0, 1, 0 }) -- one point table
Transform.lookAt("cam", "box", { 0, 0, 1 }) -- rolled to a +Z up
modules/Transform/lookAtQuat
lookAtQuat(fx: number, fy: number, fz: number, tx: number, ty: number, tz: number): (number?, number?, number?, number?)
Compute quaternion to look from origin position toward a target.
Returns four components (qx, qy, qz, qw), or nil when the from
and to points are too close to derive a meaningful direction.
Parameters
fxnumber— Origin x.fynumber— Origin y.fznumber— Origin z.txnumber— Target x.tynumber— Target y.tznumber— Target z.
local qx, qy, qz, qw = Transform.lookAtQuat(0, 0, 0, 1, 0, 1)
modules/Transform/lookRotation
lookRotation(fx: number, fy: number, fz: number, tx: number, ty: number, tz: number, ux: number?, uy: number?, uz: number?): (number?, number?, number?, number?)
The rotation that aims an entity standing at one world point at another,
with a world up hint deciding the roll. Where lookAtQuat derives the aim
from yaw and pitch alone — clamping the pitch just short of vertical, so a
point directly overhead comes back a twentieth of a degree off — this builds
all three axes, so the aim lands on the point at any elevation and straight
up and straight down are ordinary cases.
The aimed axis is the entity's local -Z, the same forward quatFromBasis,
Transform.lookAt and entity(id):lookAt state and the direction
entity(id).transform.forward reads back.
The up hint is a world direction the entity's own +Y is turned toward as
far as the aim allows; it never bends the forward axis. A hint parallel to
the aim leaves the roll undetermined, and a hint of no length names no
direction — both fall back to a stable roll rather than a NaN.
Parameters
fxnumber— Eye x — where the entity stands.fynumber— Eye y.fznumber— Eye z.txnumber— Target x — the world point it faces.tynumber— Target y.tznumber— Target z.uxnumber?(optional) — Up hint x. World +Y when the hint is omitted.uynumber?(optional) — Up hint y.uznumber?(optional) — Up hint z.
local qx, qy, qz, qw = Transform.lookRotation(0, 2, 10, 0, 1, 0)
entity("cam").rotation = { Transform.lookRotation(0, 2, 10, 0, 1, 0) }
-- a dutch tilt: the same aim, rolled by leaning the up hint
local q = { Transform.lookRotation(0, 2, 10, 0, 1, 0, 0.2, 1, 0) }
modules/Transform/normalizeAngle
normalizeAngle(a: number): number
Normalize an angle into [-pi, pi].
Parameters
anumber— The angle in radians.
local a = Transform.normalizeAngle(3 * math.pi)
modules/Transform/orbit
orbit(centerX: number, centerY: number, centerZ: number, radius: number, height: number, angle: number): (number, number, number, number, number, number, number)
Position + rotation for orbiting around a center point. Returns the world position followed by the orientation that faces the center.
Parameters
centerXnumber— Center x.centerYnumber— Center y.centerZnumber— Center z.radiusnumber— Horizontal distance from the center.heightnumber— Vertical offset fromcenterY.anglenumber— Orbital angle in radians.
local x, y, z, qx, qy, qz, qw = Transform.orbit(0, 1, 0, 5, 2, t)
modules/Transform/quatFromAxisAngle
quatFromAxisAngle(ax: number, ay: number, az: number, angle: number): (number, number, number, number)
Create quaternion from axis and angle (radians). Returns the identity quaternion when the axis is degenerate (length < 0.001).
Parameters
axnumber— Axis x.aynumber— Axis y.aznumber— Axis z.anglenumber— Rotation angle in radians.
local qx, qy, qz, qw = Transform.quatFromAxisAngle(0, 1, 0, math.pi)
modules/Transform/quatFromBasis
quatFromBasis(rx: number, ry: number, rz: number, ux: number, uy: number, uz: number, fx: number, fy: number, fz: number): (number, number, number, number)
Build the rotation whose right, up and forward ARE the given axes. Where
lookAtQuat derives a rotation from a direction alone — yaw and pitch, with
pitch clamped just short of straight up or down and no say in the roll — this
states all three axes, so a view straight down has a defined image-up instead
of whatever the yaw implied. The axes are expected orthonormal and are used as
given: right and up are the entity's local +X and +Y, forward its local
-Z (the direction it faces).
Parameters
rxnumber— Right axis x.rynumber— Right axis y.rznumber— Right axis z.uxnumber— Up axis x.uynumber— Up axis y.uznumber— Up axis z.fxnumber— Forward axis x.fynumber— Forward axis y.fznumber— Forward axis z.
local qx, qy, qz, qw = Transform.quatFromBasis(1,0,0, 0,1,0, 0,0,-1) -- identity
-- looking straight down with the subject's front toward the top of frame
local qx, qy, qz, qw = Transform.quatFromBasis(1,0,0, 0,0,-1, 0,-1,0)
modules/Transform/quatFromYaw
quatFromYaw(yaw: number): (number, number, number, number)
Create quaternion from yaw (Y-axis rotation) in radians. Uses the
negative-yaw convention shared with quatFromYawPitch, lookAtQuat,
and T.euler extraction — so T.euler(T.quatFromYaw(y)) round-trips
to y.
Parameters
yawnumber— Rotation in radians around the Y axis.
local qx, qy, qz, qw = Transform.quatFromYaw(math.pi / 2)
modules/Transform/quatFromYawPitch
quatFromYawPitch(yaw: number, pitch: number): (number, number, number, number)
Create quaternion from yaw and pitch in radians.
Parameters
yawnumber— Y-axis rotation in radians.pitchnumber— X-axis rotation in radians.
local qx, qy, qz, qw = Transform.quatFromYawPitch(0, math.pi / 4)
modules/Transform/quatIdentity
quatIdentity(): (number, number, number, number)
Identity quaternion (0, 0, 0, 1).
local qx, qy, qz, qw = Transform.quatIdentity()
modules/Transform/quatInverse
quatInverse(qx: number, qy: number, qz: number, qw: number): (number, number, number, number)
Quaternion inverse. Equal to the conjugate for unit quaternions.
Parameters
qxnumber— Quaternion x.qynumber— Quaternion y.qznumber— Quaternion z.qwnumber— Quaternion w.
local ix, iy, iz, iw = Transform.quatInverse(qx, qy, qz, qw)
modules/Transform/quatMul
quatMul(ax: number, ay: number, az: number, aw: number, bx: number, by: number, bz: number, bw: number): (number, number, number, number)
Quaternion multiplication: returns qa * qb (composition: rotate
by qb then qa).
Parameters
axnumber— Left quat x.aynumber— Left quat y.aznumber— Left quat z.awnumber— Left quat w.bxnumber— Right quat x.bynumber— Right quat y.bznumber— Right quat z.bwnumber— Right quat w.
local qx, qy, qz, qw = Transform.quatMul(ax, ay, az, aw, bx, by, bz, bw)
modules/Transform/quatRotateVec
quatRotateVec(qx: number, qy: number, qz: number, qw: number, vx: number, vy: number, vz: number): (number, number, number)
Rotate a 3-vector by a quaternion.
Parameters
qxnumber— Quaternion x.qynumber— Quaternion y.qznumber— Quaternion z.qwnumber— Quaternion w.vxnumber— Vector x.vynumber— Vector y.vznumber— Vector z.
local rx, ry, rz = Transform.quatRotateVec(qx, qy, qz, qw, 1, 0, 0)
modules/Transform/quatToEuler
quatToEuler(qx: number, qy: number, qz: number, qw: number): (number, number, number)
Convert quaternion to (yaw, pitch, roll). Alias of euler with
the explicit name so callers don't have to remember the order.
Parameters
qxnumber— Quaternion x.qynumber— Quaternion y.qznumber— Quaternion z.qwnumber— Quaternion w.
local yaw, pitch, roll = Transform.quatToEuler(qx, qy, qz, qw)
modules/Transform/readVec3
readVec3(value: Vec3Input, label: string?): { number }
Normalize a vector a caller wrote to a plain { x, y, z } array.
Accepts a positional array {1, 2, 3}, a keyed table
{x =, y =, z =}, or a live vec handle. Missing components read as 0.
Raises when the value is not a vector; label names the caller in
that error.
Parameters
valueVec3Input— The vector to normalize.labelstring?(optional) — Name reported in the error when the value is not a vector. Defaults to "Transform".
local v = Transform.readVec3({ x = 1, y = 2, z = 3 })
modules/Transform/slerp
slerp(ax: number, ay: number, az: number, aw: number, bx: number, by: number, bz: number, bw: number, t: number): (number, number, number, number)
Spherical linear interpolation between two quaternions. Picks the shortest path (flips sign if dot < 0). Falls back to lerp+normalize when the two quats are very close (avoids div-by-zero on near-parallel inputs).
Parameters
axnumber— Start quaternion x.aynumber— Start quaternion y.aznumber— Start quaternion z.awnumber— Start quaternion w.bxnumber— End quaternion x.bynumber— End quaternion y.bznumber— End quaternion z.bwnumber— End quaternion w.tnumber— Interpolation factor[0, 1].
local qx, qy, qz, qw = Transform.slerp(0, 0, 0, 1, 1, 0, 0, 0, 0.5)
modules/Transform/snapVec3
snapVec3(v: { number }, step: number | Vec3Input): { number }
Quantize each component of a vector to the nearest multiple of
step — a number for uniform steps, or a vector for per-axis steps.
A step of 0 on an axis leaves that axis at its exact value.
Parameters
v{ number }— The vector to quantize, as{ x, y, z }.stepnumber | Vec3Input— Uniform step size, or a per-axis vector of step sizes.
local v = Transform.snapVec3({ 1.4, 2.6, -0.4 }, 1)
modules/Transform/toQuaternion
toQuaternion(rotation: any, label: string?): { number }
Normalize a rotation a caller wrote to a { qx, qy, qz, qw }
quaternion. Accepts a quaternion ({x,y,z,w} or {x=,y=,z=,w=}) or
euler DEGREES ({pitch,yaw,roll} or {pitch=,yaw=,roll=}), so one
call site takes whichever form the caller finds natural. This is the
reading every rotation-taking surface in the engine shares, so a
quaternion and euler degrees mean the same thing at all of them.
Raises when the value matches no form; label names the caller in that
error, and a value that is one of the shapes a quaternion helper returns
is named as such along with the packing it goes in as.
Parameters
rotationany(optional) — The rotation to normalize, in any form of theRotationInputunion.labelstring?(optional) — Name reported in the error when the value is not a rotation. Defaults to "Transform".
local q = Transform.toQuaternion({ pitch = 0, yaw = 90, roll = 0 })
modules/Transform/tryQuaternion
tryQuaternion(rotation: any, label: string?): ({ number }?, string?)
Read a rotation a caller wrote WITHOUT raising: returns the
canonical { qx, qy, qz, qw }, or nil and the message describing what
arrived. The forms are the RotationInput union — a quaternion
({x,y,z,w} or {x=,y=,z=,w=}) or euler DEGREES ({pitch,yaw,roll} or
{pitch=,yaw=,roll=}). Takes any value because reporting on a value that
is none of those forms is the whole job; a setter built on this raises the
returned message itself, so the error points at the line that wrote the
value rather than at the reading.
Parameters
rotationany(optional) — The value to read as a rotation.labelstring?(optional) — Name reported in the message. Defaults to "Transform".
local q, why = Transform.tryQuaternion(value, "myTool")
modules/Transform/vec.add
vec.add(ax: number, ay: number, az: number, bx: number, by: number, bz: number): (number, number, number)
Component-wise vec3 addition.
Parameters
axnumber— First vector x.aynumber— First vector y.aznumber— First vector z.bxnumber— Second vector x.bynumber— Second vector y.bznumber— Second vector z.
local x, y, z = Transform.vec.add(1, 2, 3, 4, 5, 6)
modules/Transform/vec.cross
vec.cross(ax: number, ay: number, az: number, bx: number, by: number, bz: number): (number, number, number)
Cross product a x b.
Parameters
axnumber— First vector x.aynumber— First vector y.aznumber— First vector z.bxnumber— Second vector x.bynumber— Second vector y.bznumber— Second vector z.
local cx, cy, cz = Transform.vec.cross(1, 0, 0, 0, 1, 0)
modules/Transform/vec.dot
vec.dot(ax: number, ay: number, az: number, bx: number, by: number, bz: number): number
Dot product of two vec3s.
Parameters
axnumber— First vector x.aynumber— First vector y.aznumber— First vector z.bxnumber— Second vector x.bynumber— Second vector y.bznumber— Second vector z.
local d = Transform.vec.dot(1, 0, 0, 0, 1, 0)
modules/Transform/vec.length
vec.length(x: number, y: number, z: number): number
Euclidean length of a vec3.
Parameters
xnumber— Vector x.ynumber— Vector y.znumber— Vector z.
local len = Transform.vec.length(1, 2, 3)
modules/Transform/vec.normalize
vec.normalize(x: number, y: number, z: number): (number, number, number)
Normalize a vec3. Returns zeros when the input is degenerate (length < 1e-8).
Parameters
xnumber— Vector x.ynumber— Vector y.znumber— Vector z.
local nx, ny, nz = Transform.vec.normalize(0, 5, 0)
modules/Transform/vec.scale
vec.scale(x: number, y: number, z: number, s: number): (number, number, number)
Component-wise scalar multiplication of a vec3.
Parameters
xnumber— Vector x.ynumber— Vector y.znumber— Vector z.snumber— Scalar factor.
local x, y, z = Transform.vec.scale(1, 2, 3, 2)
modules/Transform/vec.sub
vec.sub(ax: number, ay: number, az: number, bx: number, by: number, bz: number): (number, number, number)
Component-wise vec3 subtraction (a - b).
Parameters
axnumber— First vector x.aynumber— First vector y.aznumber— First vector z.bxnumber— Second vector x.bynumber— Second vector y.bznumber— Second vector z.
local x, y, z = Transform.vec.sub(4, 5, 6, 1, 2, 3)
modules/Transform/worldToLocal
worldToLocal(px: number, py: number, pz: number, pqx: number, pqy: number, pqz: number, pqw: number, wx: number, wy: number, wz: number): (number, number, number)
Transform a world-space position into a parent's local space.
Parameters
pxnumber— Parent position x.pynumber— Parent position y.pznumber— Parent position z.pqxnumber— Parent rotation x.pqynumber— Parent rotation y.pqznumber— Parent rotation z.pqwnumber— Parent rotation w.wxnumber— World x.wynumber— World y.wznumber— World z.
local lx, ly, lz = Transform.worldToLocal(px, py, pz, pqx, pqy, pqz, pqw, wx, wy, wz)
modules/UiMotionCapture/README
require("@builtin::modules.ui_motion_capture") -- UiMotionCapture
Publishes the UI-animation capture views — the UI analogues of the motion_vectors pass. capture pass=ui_motion shows WHERE the UI is animating (change-magnitude heatmap); capture pass=ui_motion_flow shows WHICH WAY it is moving (directional optical flow). Each view's drawing feature is created on demand the first time it is captured, so a session that never selects one pays nothing.
Usage: local UiMotionCapture = require("@builtin::modules.ui_motion_capture")
modules/UiMotionCapture/register
register()
Register the ui_motion (change magnitude) and ui_motion_flow
(directional flow) capture views. Idempotent — safe to call at boot and
again later; re-registering keeps each view's channel.
require("@builtin::modules.ui_motion_capture").register()
modules/Validator/README
require("@builtin::systems.worldValidation.validator") -- Validator
Orchestrator for the world validator. Composes vfsScanner + scriptValidator + assetValidator + reportFormatter into one call that produces a Report with world and library buckets cleanly separated.
The validator does ONE pass over the VFS to discover every
script and asset, then dispatches each entry to the appropriate
per-type validator (scripts → scriptValidator → lsp.check; asset
folders → assetValidator → asset.validate). It does not spawn
entities or allocate GPU resources. Repeated calls are
independent — there is no shared mutable state across runs.
The four helper modules (vfsScanner, scriptValidator,
assetValidator, reportFormatter) sit alongside this module at
the package root and are pulled in via the ~.X package-relative
form so the whole package is position-independent — moving it to
any identity continues to resolve correctly without code edits.
Usage: local Validator = require("@builtin::systems.worldValidation.validator")
modules/Validator/check
check(opts)
Validate authored content. By DEFAULT scopes to YOUR world —
everything under /source/ EXCEPT /source/libs/ — because imported
libraries and engine builtins are not yours to validate (and scanning
the whole builtin tree is slow and noisy). Pass opts.scope to widen:
"libraries" for every imported library, "library:<name>" for one,
"all" for world + libraries together. The cargo check equivalent
for a Zero world.
Parameters
optsany(optional) — Optional table —scope?: "world"|"libraries"|"library:<name>"|"all"(default"world") plus filter fields forwarded to the formatter:{ severity, category, code, source, path, includePlaceholders, limit }.
local r = Validator.check() -- your world only
local r = Validator.check({ severity = "error" }) -- your world, errors only
local r = Validator.check({ scope = "all" }) -- world + imported libraries
modules/Validator/filter
filter(report, opts)
Re-filter an existing Report without re-scanning the VFS.
Forwards to reportFormatter.filter; the resulting Report's
counts are recomputed from the visible problems.
Parameters
reportany(optional) — Report produced by any of the validate* functions.optsany(optional) — FilterOpts —{ severity, category, code, source, path, includePlaceholders, limit }.
local errs = Validator.filter(report, { severity = "error" })
modules/Validator/format
format(report, format)
Render a Report into a string. format selects the renderer.
Parameters
reportany(optional) — Report produced by any of the validate* functions.formatany(optional) —"human"(default) /"markdown"/"json"/"summary".
print(Validator.format(report, "human"))
local md = Validator.format(report, "markdown")
modules/Validator/placeholders
placeholders()
Enumerate the registered placeholder checks. Each placeholder is a check the validator runs today but with a stub implementation — listing them tells callers which validations still need real primitives wired up.
for _, ph in ipairs(Validator.placeholders()) do print(ph.code) end
modules/Validator/saveReport
saveReport(report, path, opts)
Render a Report and write it to path. Format is taken from
opts.format if present, otherwise inferred from the destination
extension (.md → markdown, .json → json, anything else → human).
Returns (ok, message?).
Parameters
reportany(optional) — Report produced by any of the validate* functions.pathany(optional) — Destination VFS path (e.g./source/.validation/run.md).optsany(optional) — Optional{ format }override.
Validator.saveReport(report, "/source/.validation/run.md")
Validator.saveReport(report, "/source/audit.json", { format = "json" })
modules/Validator/summary
summary(report)
Compact one-line health summary —
world: NE/NW libraries: NE/NW total: OK|FAIL.
Parameters
reportany(optional) — Report produced by any of the validate* functions.
print(Validator.summary(Validator.check()))
modules/Validator/validateLibraries
validateLibraries(opts)
Validate every imported library under /source/libs/. The
returned Report has world = nil and libraries populated for
every library that exists on disk.
Parameters
optsany(optional) — Optional filter table — same shape asM.check.
local r = Validator.validateLibraries()
local r = Validator.validateLibraries({ source = "library:@builtin" })
modules/Validator/validateLibrary
validateLibrary(name, opts)
Validate ONE named library under /source/libs/<name>/. When
the library does not exist, the Report carries a single
library.missing error against that name so callers can tell a
clean run from a missing-dependency run.
Parameters
nameany(optional) — Library directory name (e.g."@builtin","@mylib").optsany(optional) — Optional filter table — same shape asM.check.
local r = Validator.validateLibrary("@builtin")
local r = Validator.validateLibrary("@mylib", { severity = "error" })
modules/Validator/validateWorld
validateWorld(opts)
Validate ONLY the world's authored content (/source/
excluding /source/libs/). The returned Report has world
populated and libraries = {}.
Parameters
optsany(optional) — Optional filter table — same shape asM.check.
local r = Validator.validateWorld()
local r = Validator.validateWorld({ severity = "error" })
modules/ValueType/README
require("@builtin::modules.value_type") -- ValueType
Converts a handle-backed value type — ColorSequence, NumberSequence — between the live object a session holds and the durable payload its serialize() produces. Every boundary that writes a component field to a record, or applies a record back onto a component, converts here.
Usage: local ValueType = require("@builtin::modules.value_type")
modules/ValueType/bind
bind(v: any, kind: string): any
Put a value type's methods back on a value read out of a component
field. Field.table keeps the table it is handed without its metatable and
gives that stored table back on every read, so binding once makes the field
answer :evaluate / :keypoints for the rest of the session.
Parameters
vany(optional) — A live value carrying a handle.kindstring— The kind to bind as whenvnames none itself.
ValueType.bind(component.color, "ColorSequence"):evaluate(0)
modules/ValueType/isLive
isLive(v: any): boolean
Whether a value is a live handle-backed value type — the form that holds a session-local curve handle.
Parameters
vany(optional) — Any component field value.
ValueType.isLive(NumberSequence.new(0, 1)) -- true
modules/ValueType/isPayload
isPayload(v: any): boolean
Whether a value is the durable payload of a handle-backed value type — the form a record carries.
Parameters
vany(optional) — Any component field value.
ValueType.isPayload(NumberSequence.new(0, 1):serialize()) -- true
modules/ValueType/keypoints
keypoints(v: any, kind: string): { any }?
The keypoint list a value holds, whichever of the two forms it is in.
A caller that knows the field's type passes it as kind so a bare
{ __h = n } — a handle written by a session that named no kind — is still
read as that type.
Parameters
vany(optional) — A live value, a durable payload, or a bare handle table.kindstring— The kind to readvas whenvnames none itself.
ValueType.keypoints(field, "ColorSequence")
modules/ValueType/kindOf
kindOf(v: any): string?
The kind name a value declares, when it is one this module converts.
Parameters
vany(optional) — Any component field value.
ValueType.kindOf(ColorSequence.new({1, 0, 0})) -- "ColorSequence"
modules/ValueType/revive
revive(v: any): any?
The live value a durable payload names, rebuilt in this session.
Parameters
vany(optional) — Any component field value.
ValueType.revive(record.color)
modules/ValueType/serialize
serialize(v: any): any?
The durable payload for a live value — what a record stores in place of the session-local handle.
Parameters
vany(optional) — Any component field value.
ValueType.serialize(field) -- { kind = "ColorSequence", keypoints = {...} }
modules/ValueType/withRevived
withRevived(data: any): (any, number)
The component field map to apply, with every durable payload rebuilt as the live value it names — the counterpart of the saver writing payloads in place of handles.
Parameters
dataany(optional) — A component's{ field = value }map from a record.
ValueType.withRevived(record.data)
modules/VfsScanner/README
require("@builtin::systems.worldValidation.vfsScanner") -- VfsScanner
Recursive /source/ walker for the world validator. Separates world content from imported libraries so downstream validators can attribute every problem to the right bucket.
An asset root is any folder whose name has a registered asset
type suffix (Foo.component, bar.module, Baz.toolbox, …).
When the scanner crosses one it records the root and does NOT
recurse into it as raw files — the asset validator handles the
interior. Scripts (.luau, .lua) discovered outside any asset
root are also recorded (e.g. _shared.luau siblings inside a
toolbox, or stray top-level scripts).
Usage: local VfsScanner = require("@builtin::systems.worldValidation.vfsScanner")
modules/VfsScanner/assetSuffixes
assetSuffixes(): { string }
Expose the registered asset-suffix list (read-only). External callers that want to recognise asset folders the same way the scanner does can iterate this list.
for _, s in ipairs(VfsScanner.assetSuffixes()) do print(s) end
modules/VfsScanner/listLibraryNames
listLibraryNames(): { string }
Enumerate the immediate children of /source/libs/. Each
child is a library identity (e.g. @builtin, @mylib). Returns
an empty array if /source/libs/ does not exist.
for _, name in ipairs(VfsScanner.listLibraryNames()) do print(name) end
modules/VfsScanner/scanAll
scanAll()
Convenience: scan world + every imported library in one call.
local scan = VfsScanner.scanAll(); print(#scan.world.assets)
modules/VfsScanner/scanLibraries
scanLibraries(): { [string]: any }
Walk every imported library and return a map keyed by name.
local libs = VfsScanner.scanLibraries(); for n, b in pairs(libs) do print(n, #b.assets) end
modules/VfsScanner/scanLibrary
scanLibrary(name: string)
Walk one named library under /source/libs/<name>/. The
returned Bucket's rootPath is the library root so callers can
derive relative paths cheaply.
Parameters
namestring— Library directory name (e.g."@builtin").
local bucket = VfsScanner.scanLibrary("@builtin")
modules/VfsScanner/scanWorld
scanWorld()
Walk only the world bucket — everything under /source/
except /source/libs/. The scanner stops recursing whenever it
reaches an asset-suffixed folder; asset interiors are handled by
the assetValidator.
local bucket = VfsScanner.scanWorld()
modules/WorkflowAssetTypeRef/README
require("@builtin::assetTypes.workflow.behavior") -- WorkflowAssetTypeRef
Per-instance methods exposed on every AssetRef<workflow>. Loaded lazily by asset_ref.module.
Usage: local WorkflowAssetTypeRef = require("@builtin::assetTypes.workflow.behavior")
modules/WorkflowAssetTypeRef/getManifest
getManifest(self): { [string]: any }
Read and parse workflow.yaml: what this workflow is, when it is
reached for, and the phases it moves through.
Parameters
selfany(optional)
local m = wf:getManifest()
modules/WorkflowAssetTypeRef/getSource
getSource(self): string?
Read the program itself — the JavaScript body that runs when the workflow is started.
Parameters
selfany(optional)
local src = wf:getSource()
modules/WorkflowAssetTypeRef/inspect
inspect(self): { [string]: any }
What this workflow is, without running it: its description, when to
reach for it, the phases it moves through, and what it expects in args.
Parameters
selfany(optional)
local info = wf:inspect()
modules/WorkflowAssetTypeRef/start
start(self, args: { [string]: any }?): { [string]: any }
Start a run of this workflow. Returns immediately: the run is already
executing, and it parks the moment it asks its first question. Answer what
it asks through the workflow toolbox — the run decides what comes next.
Parameters
selfany(optional)args{ [string]: any }?(optional) — Optional table handed to the program as itsargs.
local run = wf:start({ concept = "outrun a tornado" })
modules/World/README
require("@builtin::modules.world") -- World (also available as global 'world')
Public Luau API for the bound world. Composes internal __world FFI primitives with per-mode slot defaults (world_defaults), source-control toolbox (world_vcs), and the connected-users registry (connected_users) into a single namespace. Usage: world.guid() -- current world GUID, nil if none world.swap(guid) -- bind to another world (promise) world.avatar_default_edit = ref -- per-mode avatar default world.on("player_join", cb) -- world-level event hooks Implemented as a thin Luau wrapper. The world global is a plain table whose __index metatable falls through to the internal __world namespace for unknown reads. Other library modules (world_defaults, world_vcs, connected_users) attach their surfaces via installInto(world) from prelude.luau; their metatable wrappers chain through this base layer correctly.
Usage: local World = require("@builtin::modules.world") Also available as global: world
modules/Yaml/README
require("@builtin::modules.yaml") -- Yaml
YAML decode + encode for authored engine content. Supports the YAML subset engine configs use: block mappings + sequences (a sequence may sit at its key's own column), flow collections (on one line or continued over several), typed plain scalars, quoted strings, comments, literal and folded block scalars, an optional leading ---. Unsupported constructs (anchors, aliases, tags, directives, multi-document streams, tab indentation) raise with the offending line number.
Usage: local Yaml = require("@builtin::modules.yaml")
modules/Yaml/decode
decode(text: string): any
Decode a YAML document into a Luau value. Raises (with the line number) on malformed input or constructs outside the supported subset — never misparses silently.
Parameters
textstring— The YAML document text.
local doc = Yaml.decode(vfs.read(path))
modules/Yaml/decodeWithComments
decodeWithComments(text: string): (any, boolean)
Decode a YAML document and report whether it carries a comment — by
the decoder's own rule: a # at a line's start or after whitespace,
outside a quoted scalar (a quote opens one only where a scalar can begin,
so a plain scalar may carry an apostrophe) and outside a block scalar.
What re-encoding the value would drop.
Parameters
textstring— The YAML document text.
local doc, commented = Yaml.decodeWithComments(vfs.read(path))
modules/Yaml/encode
encode(value: { [any]: any }): string
Encode a Luau table as a YAML document (block style, two-space indent, sorted keys). Raises on values YAML can't represent (functions, userdata, non-string mapping keys).
Parameters
value{ [any]: any }— The table to encode.
vfs.write(path, Yaml.encode({ contract = "weapon", values = v }))
modules/Yaml/flowEntries
flowEntries(text: string): ({ FlowEntry }, string)
Split a flow collection written on one line, { a: 1, b: [2, 3] } or
[x, { y: 2 }], into its top-level entries as written: each entry's key
(unquoted; nil for a sequence item) and its value text, trimmed, with
nested collections, quoted scalars and the literal spelling of every value
kept. Raises with the decoder's own message on text that is not one
well-formed flow collection, so it accepts exactly what decode reads as a
flow value.
Parameters
textstring— The flow collection's text.
for _, e in Yaml.flowEntries("{ exposure: 1.5, tint: [1, 0, 0] }") do print(e.key, e.value) end
local entries, trailing = Yaml.flowEntries("{ exposure: 1.5 } # brighter")
modules/ZJsAssetTypeRef/README
require("@builtin::packages.zerojs.zJs.behavior") -- ZJsAssetTypeRef
Per-instance methods exposed on every AssetRef<zJs>. Loaded lazily by asset_ref.module the first time a zJs ref is touched in a VM. A zJs asset is a <name>.zJs/ folder whose main.js holds a JavaScript ES module. The methods here surface the static write-time diagnostics the type computes for that module and execute it: run / runAsync for a script or module, and exports to read a module's export namespace as a Luau table.
Usage: local ZJsAssetTypeRef = require("@builtin::packages.zerojs.zJs.behavior")
modules/ZJsAssetTypeRef/check
check(self): { ok: boolean, diagnostics: { Diagnostic } }
Static diagnostics for THIS module's main.js: parse errors plus imports
that do not resolve to a zJs module. Reads the cache onChange maintains,
running the parse+resolve pipeline once on a cold reference.
Parameters
selfany(optional)
local r = asset.resolve("greeter", "zJs"):check(); if not r.ok then ... end
modules/ZJsAssetTypeRef/exports
exports(self, opts: { env: { [string]: any }? }?): any
Evaluate THIS module as an ES module on a fresh VM and return its export
namespace marshaled to a Luau table: each named export plus default.
Cross-asset imports resolve through the live asset index, so a JS library
built from several .zJs assets is consumed as one table. Refuses when the
module carries diagnostics, naming the first; a cycle, an unresolved import,
or a thrown module body surfaces as a Luau error.
Parameters
selfany(optional)opts{ env: { [string]: any }? }?(optional)
local lib = asset.resolve("mathlib", "zJs"):exports(); print(lib.add(1, 2))
modules/ZJsAssetTypeRef/onChange
onChange(ref, change)
Asset-type change callback: recompute this module's static diagnostics
whenever its main.js is edited or the whole instance is seeded. Convergent:
it reads the source and asset index and replaces the ref's cached pipeline
result; it never writes to the VFS. Edits to sidecars (README.md,
.metadata) leave the cache untouched.
Parameters
refany(optional)changeany(optional)
modules/ZJsAssetTypeRef/onCreate
onCreate(name: string, opts: CreateOpts): { [string]: string }
Generic-creation hook for asset.create("zJs", name, opts). Pure: returns
the instance's content file map for the caller to persist. opts.source, when
given, becomes main.js verbatim; otherwise a hello-world module naming the
instance is scaffolded from the template.
Parameters
namestring— zJs module identity (the instance name).optsCreateOpts
asset.create("zJs", "greeter", { source = "export const x = 1" })
modules/ZJsAssetTypeRef/run
run(self, opts: { env: { [string]: any }? }?): any
Execute THIS module on a fresh JavaScript VM and marshal the result to
Luau. A plain script (no imports or exports) runs as a script and returns
its completion value; a module evaluates through the module graph and returns
nil, since module evaluation has no completion value. opts.env seeds host
values as JavaScript globals. Refuses when the module carries diagnostics,
naming the first, and directs a script that leaves asynchronous work pending
to runAsync.
Parameters
selfany(optional)opts{ env: { [string]: any }? }?(optional)
local sum = asset.resolve("calc", "zJs"):run({ env = { base = 10 } })
modules/ZJsAssetTypeRef/runAsync
runAsync(self, opts: { env: { [string]: any }?, timeoutMs: number? }?): any
Execute THIS module's program on a fresh VM under the asynchronous runner,
driving armed timers and pending promises to completion. Returns the engine
run handle: poll handle.done, then read handle.ok / handle.value /
handle.error, or call handle:await() from a yieldable context.
opts.timeoutMs bounds a never-settling run. Refuses when the module carries
diagnostics, naming the first.
Parameters
selfany(optional)opts{ env: { [string]: any }?, timeoutMs: number? }?(optional)
local h = asset.resolve("job", "zJs"):runAsync({ timeoutMs = 1000 }); h:await()
modules/ZinputActions/README
require("@builtin::modules.zinput.actions") -- ZinputActions
DEPRECATED: A control asset carries what an action carried, plus the gamepad and touch an action never had. Author an .inputMap with .inputBinding children, activate it, and subscribe: local map = public.inputMap:activate() then map.jump:onPressed(fn). See man topics/input.
Usage: local ZinputActions = require("@builtin::modules.zinput.actions")
modules/ZinputActions/_clearHandlers
_clearHandlers()
Test-only: clear every handler (does NOT touch action definitions).
Zin.actions._clearHandlers()
modules/ZinputActions/_dispatchHandlers
_dispatchHandlers(firstTickThisFrame: boolean?)
Internal: dispatch action handlers. Called by Zin.tick after
axes/chords advance. Fires Begin/End/Change/Held handlers
based on each action's polling state this tick.
firstTickThisFrame is false on a same-engine-frame re-tick (e.g.
the autoTick worker and an explicit Zin.tick both land in one
frame): edge fires (Begin/End/Change) are per-frame events and
must not fire twice, so they are gated to the first tick of the
frame. Held is a per-tick redeliver and still fires every call.
A nil argument is treated as the first tick (edges fire).
Parameters
firstTickThisFrameboolean?(optional) — Whether this is the frame's first dispatch pass.
Zin.actions._dispatchHandlers()
modules/ZinputActions/_owns
_owns(handle: number): boolean
Internal: cross-API ownership probe. Used by Zin.disconnect to
route handles to the right disconnect implementation, since
Zin.input.on* and Zin.actions.bind share a handle namespace.
Parameters
handlenumber— The numeric handle to probe.
if Zin.actions._owns(h) then Zin.actions.disconnect(h) end
modules/ZinputActions/_resetUnknownWarnings
_resetUnknownWarnings()
Test-only: forget which names have already been reported as unregistered, so a fresh suite sees the warning again.
Zin.actions._resetUnknownWarnings()
modules/ZinputActions/_setAllocator
_setAllocator(fn: () -> number)
Internal: wire a shared id allocator, so handles from this module
and from Zin.input.on* never collide. Called once at module-load
time from zinput/init.luau.
Parameters
fn() -> number— The allocator function that returns the next handle id.
M._setAllocator(allocateZinHandle)
modules/ZinputActions/_setEnsureBindingsFn
_setEnsureBindingsFn(fn: () -> ())
Internal: wire the lazy-default-map hook. Called once at module-
load time from zinput/init.luau.
Parameters
fn() -> ()— The hook invoked on a cold read (name not in the registry).
M._setEnsureBindingsFn(ensureDefaultBindings)
modules/ZinputActions/_setEnsureLiveFn
_setEnsureLiveFn(fn: () -> ())
Internal: wire the liveness hook. Called once at module-load
time from zinput/init.luau.
Parameters
fn() -> ()— The hook invoked on every cold-checked read below.
M._setEnsureLiveFn(ensureInputLive)
modules/ZinputActions/_settled
_settled(): boolean
Internal: whether the most recent dispatch pass delivered nothing and saw nothing held. The tick's quiescence gate reads it.
if Zin.actions._settled() then ... end
modules/ZinputActions/active
active(name: string): boolean
True if an action is currently active in the input context
stack. An action is "active" iff its declared context matches the
top of the context stack (so push("ui") suppresses every
non-"ui" action).
Parameters
namestring— The action name.
if Zin.actions.active("jump") then ... end
modules/ZinputActions/bind
bind(name: string, fn, opts: BindOpts?): ActionHandle?
Register a handler. Returns a numeric handle (also accepted by
Zin.input.disconnect). Returns nil if name is not a defined
action. The handler ends with the context that bound it as well: a
component's with that component instance, a module body's with the
module's next run.
Parameters
namestring— The action name.fnany(optional) — Handlerfn(name, state, io, gpe) -> "sink" | any.optsBindOpts?(optional) — Optional{ priority, fire, once }.
local h = Zin.actions.bind("jump", function() print("jump") end)
modules/ZinputActions/clear
clear()
Wipe every defined action. Primarily for tests.
Zin.actions.clear()
modules/ZinputActions/define
define(spec: ActionSpec)
Define one or more actions. Each entry replaces any existing action under the same name; other actions are preserved.
Parameters
specActionSpec— Map ofname -> binding | { binding... } | { context, binding(s) }.
Zin.actions.define({ jump = Zin.bindings.key("Space") })
modules/ZinputActions/disconnect
disconnect(handle: ActionHandle): boolean
Tear down a handler returned by bind. Idempotent.
Parameters
handleActionHandle— The handle frombind(oronPressed/onReleased/etc).
Zin.actions.disconnect(h)
modules/ZinputActions/get
get(name: string): ActionEntry?
Internal: the registry record behind a name, for profile capture and conflict indexing. Returns nil if the action is not defined.
Parameters
namestring— The action name.
local entry = Zin.actions.get("jump")
modules/ZinputActions/handlerCount
handlerCount(name: string): number
Number of registered handlers for an action (0 if none / unknown).
Parameters
namestring— The action name.
assert(Zin.actions.handlerCount("jump") == 1)
modules/ZinputActions/has
has(name: string): boolean
True if an action with this name is defined.
Parameters
namestring— The action name to test.
if Zin.actions.has("jump") then ... end
modules/ZinputActions/held
held(name: string): boolean
True if any binding on the action is currently delivering input. For boolean bindings: any held. For axis/vector bindings: non-zero magnitude. Suppressed by context gating.
Parameters
namestring— The action name.
if Zin.actions.held("attack") then print("swing") end
modules/ZinputActions/heldTime
heldTime(name: string): number?
Seconds the action has been held, taken as the MAX held-time
across the action's boolean bindings. Returns nil if no binding
is held or if the action is gated off by the current input
context. Vector / axis bindings are skipped — use a held-time
threshold against Zin.axes.value for held-direction analogs.
Parameters
namestring— The action name.
local t = Zin.actions.heldTime("interact")
modules/ZinputActions/names
names(): { string }
All defined action names, in arbitrary order.
for _, n in ipairs(Zin.actions.names()) do print(n) end
modules/ZinputActions/onChanged
onChanged(name: string, fn, opts: BindOpts?): ActionHandle?
Fire on axis/vector value delta (state = "Change"). For boolean
actions Change fires on every press AND release transition — use
onPressed / onReleased instead if you only want edges.
Parameters
namestring— The action name.fnany(optional) — Handlerfn(name, state, io, gpe).optsBindOpts?(optional) — Optional{ priority, once }.
Zin.actions.onChanged("move", function(_, _, io) print(io.value) end)
modules/ZinputActions/onHeld
onHeld(name: string, fn, opts: BindOpts?): ActionHandle?
Fire every tick while held (state = "Held"). Fires whenever
held() is true at dispatch time, regardless of value change.
Inherits the action's context constraint (no per-handler context
filter).
Parameters
namestring— The action name.fnany(optional) — Handlerfn(name, state, io, gpe).optsBindOpts?(optional) — Optional{ priority, once }.
Zin.actions.onHeld("interact", function(_, _, io) print("charge", io.value) end)
modules/ZinputActions/onPressed
onPressed(name: string, fn, opts: BindOpts?): ActionHandle?
Fire on rising edge (state = "Begin"). Sugar for bind with
fire = {"Begin"}.
Parameters
namestring— The action name.fnany(optional) — Handlerfn(name, state, io, gpe).optsBindOpts?(optional) — Optional{ priority, once }.
Zin.actions.onPressed("jump", function() ... end)
modules/ZinputActions/onReleased
onReleased(name: string, fn, opts: BindOpts?): ActionHandle?
Fire on falling edge (state = "End"). Sugar for bind with
fire = {"End"}.
Parameters
namestring— The action name.fnany(optional) — Handlerfn(name, state, io, gpe).optsBindOpts?(optional) — Optional{ priority, once }.
Zin.actions.onReleased("attack", function() ... end)
modules/ZinputActions/pressed
pressed(name: string): boolean
True if any boolean binding on the action was just pressed
this frame — the press EDGE, so it fires once per press no matter
how long the input is held. Use it for one-shot input: fire, jump,
pause, undo. For continuous input that should repeat every frame
the input is down, read the level instead with
Zin.state.keyDown(key). Axis/vector bindings do not contribute to
press edges. Suppressed by context gating.
Parameters
namestring— The action name.
if Zin.actions.pressed("jump") then ... end
modules/ZinputActions/reason
reason(name: string): string
Why a named action is not delivering, from the closed set this
registry can distinguish: unknownControl (no action is registered
under the name — the value readers answer their neutral value, which is
not a reading), contextInactive (registered, but its context is not
on top of the stack), atRest (live, and the devices it binds are not
being driven), or delivering.
Parameters
namestring— The action name.
if Zin.actions.reason("jump") == "unknownControl" then ... end
modules/ZinputActions/released
released(name: string): boolean
True if any boolean binding on the action was just released this frame. Suppressed by context gating.
Parameters
namestring— The action name.
if Zin.actions.released("attack") then ... end
modules/ZinputActions/remove
remove(name: string)
Remove an action by name. No-op if not defined.
Parameters
namestring— The action name to remove.
Zin.actions.remove("jump")
modules/ZinputActions/repeated
repeated(name: string, opts: { delay: number?, period: number? }?): boolean
Should a synthetic repeat fire this frame for the action?
Returns true if any of the action's boolean key bindings reports
State.keyRepeatFired. Mouse bindings are skipped (use a hold-
time threshold for press-and-hold UX). Suppressed by context
gating.
Parameters
namestring— The action name.opts{ delay: number?, period: number? }?(optional) — Optional{ delay, period }override of the global repeat defaults.
if Zin.actions.repeated("scrollLeft") then ... end
modules/ZinputActions/value
value(name: string): any
Read the action's current value.
- Axis binding → number in [-1, 1]
- Vector binding →
{ x, y }numbers in [-1, 1] - Boolean binding → 1 when held, 0 when not (consumers usually use
held()instead; this exists so a single API works for any kind) When multiple bindings exist, the first one whose kind matches the caller's expectation wins (axis > vector > boolean in declaration order). When suppressed by context, returns the identity value for the first binding's kind: 0 for axis/boolean,{ x = 0, y = 0 }for vector.
Parameters
namestring— The action name.
local mv = Zin.actions.value("move") -- { x, y }
modules/ZinputAxes/README
require("@builtin::modules.zinput.axes") -- ZinputAxes
DEPRECATED: An axis1 / axis2 control carries the same deadzone, smoothing, curve and invert, and reads a stick and a dragging thumb as well as a key. Author an .inputMap with .inputBinding children, activate it, and subscribe: local map = public.inputMap:activate() then map.move:onInput(fn). See man topics/input.
Usage: local ZinputAxes = require("@builtin::modules.zinput.axes")
modules/ZinputAxes/_resetGateWarnings
_resetGateWarnings()
Test-only: reset the once-per-axis gate-error warning state so a fresh suite can verify warning behavior again.
Zin.axes._resetGateWarnings()
modules/ZinputAxes/_resetUnknownWarnings
_resetUnknownWarnings()
Test-only: forget which names have already been reported as unregistered, so a fresh suite sees the warning again.
Zin.axes._resetUnknownWarnings()
modules/ZinputAxes/_setEnsureBindingsFn
_setEnsureBindingsFn(fn: () -> ())
Internal: wire the lazy-default-map hook. Called once at module-
load time from zinput/init.luau.
Parameters
fn() -> ()— The hook invoked on a cold read (name not in the registry).
M._setEnsureBindingsFn(ensureDefaultBindings)
modules/ZinputAxes/_setEnsureLiveFn
_setEnsureLiveFn(fn: () -> ())
Internal: wire the liveness hook. Called once at module-load
time from zinput/init.luau.
Parameters
fn() -> ()— The hook invoked on every cold-checked read below.
M._setEnsureLiveFn(ensureInputLive)
modules/ZinputAxes/_settled
_settled(): boolean
Internal: whether every axis sits at zero, current and target alike. The tick's quiescence gate reads it: the axes are read again after an evaluation or a change to the registry, and every call between those answers from the last read.
if Zin.axes._settled() then ... end
modules/ZinputAxes/advance
advance(dt: number)
Parameters
dtnumber
modules/ZinputAxes/clear
clear()
Wipe every axis and its state. Primarily for tests.
Zin.axes.clear()
modules/ZinputAxes/define
define(spec: AxisSpec)
Define one or more axes. Each entry replaces any existing axis of the same name; other axes are preserved.
Parameters
specAxisSpec— Map ofname -> { binding, deadzone?, smoothing?, curve?, invert?, context?, gate? }.
Zin.axes.define({ aim_x = { binding = ..., deadzone = 0.05 } })
modules/ZinputAxes/get
get(name: string): AxisDef?
Internal introspection: definition record (or nil).
Parameters
namestring— The axis name.
local def = Zin.axes.get("aim_x")
modules/ZinputAxes/has
has(name: string): boolean
True if an axis with this name is defined.
Parameters
namestring— The axis name.
if Zin.axes.has("aim_x") then ... end
modules/ZinputAxes/names
names(): { string }
All defined axis names, in arbitrary order.
for _, n in ipairs(Zin.axes.names()) do print(n) end
modules/ZinputAxes/raw
raw(name: string): any
Read the raw, unsmoothed, unshaped value of the underlying
binding. For vector bindings returns {x,y}; for everything else
returns a number in [-1, 1]. Useful for debugging or comparing
pre/post processing.
Parameters
namestring— The axis name.
print(Zin.axes.raw("aim_x"))
modules/ZinputAxes/reason
reason(name: string): string
Why a named axis is not delivering, from the closed set this
registry can distinguish: unknownControl (no axis is registered under
the name — the value readers answer zero, which is not a reading),
contextInactive (registered, but its context is not on top of the
stack), gateRefused (its own gate answered no), atRest (live, and
the binding it reads is not being driven), or delivering.
Parameters
namestring— The axis name.
if Zin.axes.reason("look") == "gateRefused" then ... end
modules/ZinputAxes/remove
remove(name: string)
Remove an axis. No-op if not defined.
Parameters
namestring— The axis name.
Zin.axes.remove("aim_x")
modules/ZinputAxes/value
value(name: string): any
Read the smoothed, shaped, context-gated value.
Scalar axes return a number in [-1, 1].
Vector axes return {x, y} numbers in [-1, 1].
Returns 0 / {x=0,y=0} if the axis isn't defined.
Parameters
namestring— The axis name.
local mv = Zin.axes.value("move") -- { x, y }
modules/ZinputMap/README
require("@builtin::modules.zinput.map") -- ZinputMap
DEPRECATED: An .inputMap asset with .inputBinding children is the map, and Zin.scheme is the live set: several can be live at once, each declaring the groups it suppresses. Zin.map.bake(name) writes the active map out as one, which is the migration. See man topics/input.
Usage: local ZinputMap = require("@builtin::modules.zinput.map")
modules/ZinputMap/_reactivate
_reactivate(record: any): any
Re-apply the active map from a changed record — the edit-in-place
path an .inputMap asset takes when its source is written while it is
live. Who asked for the map is carried across: a write to its source
is the same map with new bindings, not a caller taking it up.
Parameters
recordany(optional) — The map record, freshly read from its source.
Zin.map._reactivate(record)
modules/ZinputMap/_reset
_reset()
Test-only: clear active-map state (the profile registry keeps whatever was applied).
Zin.map._reset()
modules/ZinputMap/activate
activate(record: any): any
Activate a map record: materialize it and apply the flattened
result as the live binding set (through the profile registry, so
persistence and conflict surfaces keep working). Per-class axis
bindings beyond the primary register as <axis>@<class> sibling
axes; consumers that combine device values read both (e.g.
look + look@touch).
Parameters
recordany(optional) — The map (or profile) record, or an inputMap asset ref.
Zin.map.activate(require("@builtin::inputMaps.default"))
modules/ZinputMap/activeName
activeName(): string?
The active map's name, or nil.
if Zin.map.activeName() == "default" then ... end
modules/ZinputMap/addTouchButton
addTouchButton(actionName: string, buttonOpts: Bindings.TouchButtonOpts, emitKey: string?): any
Add a touchButton binding to an action's touch class on the
active effective map, then re-flatten and re-activate so it takes
effect immediately. Creates the action entry if actionName
doesn't exist yet (the overlay's synthetic emit:<code> buttons).
Parameters
actionNamestring— The action to attach the button to.buttonOptsBindings.TouchButtonOpts— The optionsZin.bindings.touchButtontakes - the button's zone, label, icon glyph, layout and appearance.emitKeystring?(optional) — Optional key code — when set and the action has no kbm class yet, seeds it withB.key(emitKey)so a synthetic action is self-contained from the moment it's created.
Zin.map.addTouchButton("emit:KeyF", { label = "Cast" }, "KeyF")
modules/ZinputMap/bake
bake(name: string): any
Write the active effective map as a new inputMap asset —
synthesis made explicit and editable. The snapshot includes every
live entry, overlay-registered emit:<code> actions included.
Returns the created ref.
Parameters
namestring— The new asset's name.
Zin.map.bake("my_scheme")
modules/ZinputMap/bindingsFor
bindingsFor(eff: any, name: string, class: string): any
The effective bindings for one action or axis and device class.
Parameters
effany(optional) — An effective map (from materialize/effective).namestring— The action or axis name.classstring— "kbm" | "gamepad" | "touch".
local touch = Zin.map.bindingsFor(eff, "jump", "touch")
modules/ZinputMap/effective
effective(): any
The active map's effective form, or nil before any activation.
local eff = Zin.map.effective()
modules/ZinputMap/ensureActive
ensureActive(): any
Ensure a map is active: keeps the current one, else activates the builtin default map. The bootstrap the on-screen controls and controllers call.
Zin.map.ensureActive()
modules/ZinputMap/isFallback
isFallback(): boolean
Whether the active map is the fallback ensureActive armed on
its own, rather than one a caller activated. A reader that presents
the map to a player — the on-screen controls — asks this to tell a
scheme a world offered from the keyboard floor under a name that was
read.
if not Zin.map.isFallback() then print(Zin.map.effective()) end
modules/ZinputMap/materialize
materialize(record: any): any
Materialize a map record into its effective form: extends chain resolved (child wins per action/axis/class), then the touch class synthesized from the kbm shape wherever absent. Returns { name, description, actions = { [name] = { context, classes, synthesized = { touch = true? } } }, axes = { ... } }.
Parameters
recordany(optional) — The map (or profile) record.
local eff = Zin.map.materialize(require("@builtin::inputMaps.default"))
modules/ZinputMap/removeTouchButton
removeTouchButton(actionName: string, binding: any): boolean
Remove a touchButton binding previously added via
addTouchButton, then re-flatten and re-activate. Drops the
action entry entirely once every class is empty — cleanup for
synthetic emit:<code> actions the overlay created.
Parameters
actionNamestring— The action the binding was added to.bindingany(optional) — The binding table returned byaddTouchButton.
Zin.map.removeTouchButton("emit:KeyF", binding)
modules/ZinputObserve/README
require("@builtin::modules.zinput.observe") -- ZinputObserve
Usage: local ZinputObserve = require("@builtin::modules.zinput.observe")
modules/ZinputObserve/_publish
_publish()
Internal: publish this layer's half of the engine's input
observation for the current frame. Called once per frame from
Zin.tick while Zin.observe.wanted() holds.
Zin.observe._publish()
modules/ZinputObserve/arm
arm(on: boolean?)
Hold the engine's input observation open, so /runtime/input and
input.observe() carry this layer's half of the document every frame.
A read of either arms it for a window of frames on its own; this is for
a test or a tool that wants it building continuously.
Parameters
onboolean?(optional) — Arm (the default) or disarm.
Zin.observe.arm(true)
modules/ZinputObserve/armedFrames
armedFrames(): number
How many more frames the arming window has left. A read of
Zin.observe.frame(), input.observe() or /runtime/input sets it
back to the full window; every frame that passes takes one off it, and
0 means nothing is observing.
print(Zin.observe.armedFrames())
modules/ZinputObserve/control
control(name: string): any
Everything known about one named control in a single call: which maps contribute it, its bindings per device class, its subscriber count, the value it reported on the most recent tick, whether that reached a subscriber, and — when it is live and silent — why.
Parameters
namestring— The control name.
local c = Zin.observe.control("move")
modules/ZinputObserve/frame
frame(): any
The mapping layer's account of the most recent tick: every live map, every live control with what it did and why, and what the tick cost.
The window is ONE tick — the most recent one. Reading consumes nothing, so any number of observers in the same frame all get the same answers.
local f = Zin.observe.frame()
modules/ZinputObserve/means
means(reason: string): string?
What one reason name means, or nil for a name outside the set.
Parameters
reasonstring— The reason name.
print(Zin.observe.means("gateRefused"))
modules/ZinputObserve/reasons
reasons(): { any }
The closed set of reasons a control resolves to, each with what it means and what to do about it. The resolver answers with exactly one of these names.
for _, r in ipairs(Zin.observe.reasons()) do print(r.name, r.means) end
modules/ZinputObserve/wanted
wanted(): boolean
Whether the engine wants this layer's half of the input observation
built this frame — true while something has read input.observe() or
/runtime/input recently enough.
if Zin.observe.wanted() then ... end
modules/ZinputObserve/whySilent
whySilent(name: string): any
Why a named control is not reaching the game right now, as one
reason from the closed set Zin.observe.reasons() lists, with the
particulars behind it.
Resolves against the devices as they are at the moment of the call, so
it answers for a control the tick has never reached and for one that
does not exist. The layer field says which of the three naming layers
answered — the live maps' controls, the action registry, or the axis
registry — since a name can be live in one and unknown in the others.
Parameters
namestring— The control name.
local why = Zin.observe.whySilent("look")
modules/animGraph/README
require("@builtin::modules.api.engine.animGraph") -- animGraph (also available as global 'animGraph')
Per-entity engine animation graph over the __animGraph FFI: clips, mixers, 2D blend spaces, crossfade, weights, and graph state. Each call routes onto the entity's AnimGraphComponent (auto-resolved from script context or passed explicitly).
Usage: local animGraph = require("@builtin::modules.api.engine.animGraph") Also available as global: animGraph
modules/animation/README
require("@builtin::modules.api.engine.animation") -- animation (also available as global 'animation')
Observe what the engine is animating: every body it is posing, the clips driving each one and where their playheads are, how many of a body's bones a clip's retarget reached, and — for a body that is not moving — the one reason why, from a closed set. Ragdoll a skinned character or creature (animation.ragdoll): its skeleton carried by physics bodies for a death, a knockout, a hit reaction or a limp limb, every bone body a body the Physics calls take.
Usage: local animation = require("@builtin::modules.api.engine.animation") Also available as global: animation
modules/animation/animating
animating(): { AnimationBody }
The bodies the engine measured a changing pose on — what is animating right now.
for _, b in animation.animating() do print(b.entity, b.clips[1] and b.clips[1].name) end
modules/animation/bodies
bodies(): { AnimationBody }
Every body the engine holds animation state for.
for _, b in animation.bodies() do print(b.entity, b.matched .. "/" .. b.total) end
modules/animation/body
body(entityId: string | EntityRef): AnimationBody?
The report for one body, or nil when the engine holds no animation state for it. Accepts the body itself or any ancestor of it, so a character root answers for the skinned body underneath it.
Parameters
entityIdstring | EntityRef— The entity's stable id, or an EntityRef.
local b = animation.body(hero.id); print(b and b.reason)
modules/animation/clips
clips(entityId: string | EntityRef): { AnimationClip }
The clips contributing to a body's pose right now, with their playheads and their retarget coverage.
Parameters
entityIdstring | EntityRef— The entity's stable id, or an EntityRef.
for _, c in animation.clips(hero.id) do print(c.name, c.time, c.matched) end
modules/animation/coverage
coverage(entityId: string | EntityRef): (number, number)
How many of a body's bones the clips driving it actually reach.
Returns (matched, total). A clip that retargets onto nothing reads
(0, 50) while its playhead advances; a partial retarget reads its own
count, so 3 of 50 is as visible as none.
Parameters
entityIdstring | EntityRef— The entity's stable id, or an EntityRef.
local m, t = animation.coverage(hero.id); print(m .. "/" .. t)
modules/animation/declare
declare(entityId: string, facts: { [string]: any })
Publish what an animator is running on a body, so the observation names
its clips, playheads and retarget coverage beside the pose the engine
measures. The shipped animators declare through AnimGraph:publish; a
custom animator calls this itself, once per frame it runs.
Parameters
entityIdstring— The body the animator drives.facts{ [string]: any }—{ driver, bound, playing, outputKind, failure, clips }, where each clip is{ name, nodeKind, time, duration, playing, finished, looping, weight, matched, total, unmatched }.
animation.declare(body.id, { driver = "MyAnimator", playing = true, clips = {} })
modules/animation/forget
forget(entityId: string)
Drop the declaration and the pose evidence the engine holds for one body. An animator calls this when it releases a body, so the observation reports the body as undriven from the next frame.
Parameters
entityIdstring— The body to drop.
animation.forget(body.id)
modules/animation/observe
observe(): AnimationObservation
Report what the engine is posing right now and why a body is not moving. One read covering every body the engine holds animation state for, each with the pose evidence the engine measured on its armature beside the clips the animator driving it declared. Answers in edit mode as well as play mode.
local a = animation.observe(); print(a.animatingCount, a.riggedBodyCount)
for _, b in animation.observe().bodies do print(b.entity, b.animating, b.reason) end
modules/animation/ragdoll
ragdoll(entityId: string | EntityRef, opts: (boolean | RagdollOptions)?): string
Ragdoll a skinned body: its skeleton is carried by physics bodies that
fall, tumble and pose the mesh, for a death, a knockout, a hit reaction, a
stunt fall or a limp limb. Works on any rigged skeleton: a humanoid (the
built-in avatar and any imported humanoid rig) gets bodies sized for each
body part and anatomical joints (hinged knees and elbows, cones at the
shoulders, hips and neck); any other rig (a quadruped, a bird, a tail, a
robot arm) gets a capsule along every bone and ball joints. The first call
builds the ragdoll on the next frame, false included (its bodies follow
the animation until it is switched on, so its bones can be read and
jointed first); animation.ragdollState reads it back. false hands the
body back to its animation, and true ragdolls it again.
The options table takes active (default true), limp (bone names: only
those bones and the bones below them go limp while the rest keep
animating), mass (the whole body's mass in kilograms; by default bodies
weigh 1000 kg per cubic metre of collider, about 120 kg for the built-in
avatar, so pass a person's 60 to 90 kg for a lifelike one) and bones (bone
name -> { shape = "capsule" | "box" | "sphere" | "none", radius, length, size = {x, y, z}, mass, joint = "ball" | "hinge" | "fixed", swing, twist, hinge = {min, max}, strength, damping }, sizes in metres and angles in
degrees). A description different from the last one rebuilds the ragdoll.
On a humanoid a bone is also named by its humanoid role (hips, spine,
chest, neck, head, leftshoulder, leftarm, leftforearm,
lefthand, leftupleg, leftleg, leftfoot and the right ones), so
one description fits every humanoid rig.
Each bone body is the body of that bone's armature entity (its id in
ragdollState), so every Physics call takes it: Physics.addJoint to
hold a hand to a ledge (breakable with breakForce), Physics.applyImpulseAtPoint
for a hit, Physics.getVelocity, Physics.bodyState and Physics.contacts
to measure a fall.
Parameters
entityIdstring | EntityRef— The skinned entity, or any entity above it (a character root).opts(boolean | RagdollOptions)?(optional) —true/false, or aRagdollOptionstable.
animation.ragdoll(enemy.id) -- collapse it
animation.ragdoll(enemy.id, false) -- back to its animation
animation.ragdoll(hero.id, { limp = { "leftarm" } }) -- one limp arm
animation.ragdoll(dummy.id, { mass = 75, bones = { head = { mass = 5, swing = 30 }, leftleg = { hinge = { -140, 0 } } } })
local hand = animation.ragdollBone(hero.id, "righthand"); Physics.addJoint(hand, ledge, { kind = "ball", breakForce = 3000 })
modules/animation/ragdollBone
ragdollBone(entityId: string | EntityRef, bone: string): string?
The entity a ragdoll's bone body answers to, by bone name or, on a
humanoid, by humanoid role (head, righthand, ...): the id to
pass Physics.addJoint, Physics.applyImpulseAtPoint,
Physics.getVelocity, Physics.bodyState, Physics.contacts and every
other Physics call. nil until the ragdoll is built, or when that bone
has no body of its own.
Parameters
entityIdstring | EntityRef— The skinned entity, or any entity above it.bonestring— The bone's name in the skeleton.
local head = animation.ragdollBone(dummy.id, "head"); print(Physics.getVelocity(head))
modules/animation/ragdollState
ragdollState(entityId: string | EntityRef): RagdollState?
The ragdoll built on a skinned body: whether the simulation drives
it, its total mass, and every bone body with the entity it answers to (the
bone's armature entity), its shape and size in metres, its mass read off
the solver, whether it is simulated, and its joint. built reads false
until the engine has built it (the frame after animation.ragdoll), and
problems names anything the description asked for that the skeleton
could not give. Under multiplayer replication reads which peer simulates
the ragdoll (the owner of the synced entity at or above the body; every
other peer shows it from that peer's bone poses) and what it costs on the
wire.
Parameters
entityIdstring | EntityRef— The skinned entity, or any entity above it.
local r = animation.ragdollState(hero.id); for _, b in r.bones do print(b.bone, b.mass, b.joint and b.joint.kind) end
modules/animation/whyStill
whyStill(entityId: string | EntityRef): (string?, string?)
Why the body on an entity is not animating. Returns nil when it IS
animating, and otherwise one of deactivated, noRiggedSkeleton,
noGraph, clipUnreadable, noOutputNode, retargetPending, retargetMatchedNoRoles,
stopped, finished, paused, poseNotApplied, poseUnchanged — the
nearest cause, so the answer names the thing to change. A second return
carries the animator's own words when it could not build a graph.
An entity the engine holds no animation state for is answered from the
entity itself, in the same order the engine resolves a body it does hold:
one carrying no rigged Skeleton is noRiggedSkeleton, and a rigged one
nothing drives is noGraph. An id no entity carries is neither — the
reason is nil and the detail says so.
Parameters
entityIdstring | EntityRef— The entity's stable id, or an EntityRef.
local why, detail = animation.whyStill(hero.id); if why then print(why, detail) end
modules/antiAliasing/README
require("@builtin::systems.antiAliasing.antiAliasing") -- antiAliasing
Edge antialiasing from the finished frame — the stair-stepping along a high-contrast silhouette is replaced by a gradient, without softening the regions on either side of it.
Usage: local antiAliasing = require("@builtin::systems.antiAliasing.antiAliasing")
modules/antiAliasing/active
active(): boolean
Whether the antialiasing pass is running this frame.
if antiAliasing.active() then ... end
modules/antiAliasing/disable
disable()
Turn edge antialiasing off and release the pass. The settings are kept,
so a later enable() brings back the same tuning.
antiAliasing.disable()
modules/antiAliasing/enable
enable(opts: AntiAliasingOpts?): AntiAliasingState
Turn edge antialiasing on and set it. Any omitted field keeps its current value.
Parameters
optsAntiAliasingOpts?(optional) — Antialiasing settings — seeAntiAliasingOpts.
antiAliasing.enable({ edgeThreshold = 0.125 })
modules/antiAliasing/get
get(): AntiAliasingState
The antialiasing settings currently in force.
local t = antiAliasing.get().edgeThreshold
modules/antiAliasing/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = antiAliasing.paramsBuffer()
modules/ao.shared/README
require("@builtin::systems.ambientOcclusion.aoShared") -- ao.shared
The parts every ambient-occlusion technique has in common: the WGSL prelude its kernel is written against, and the render targets, filter and passes that turn a per-pixel visibility term into shading.
A technique differs from its siblings in one thing only: how it estimates, for one pixel, what fraction of the hemisphere above the surface is visible. Everything either side of that estimate — reconstructing the surface from depth and normal, sizing the screen-space reach of a world-space radius, filtering the result across the noise the estimate carries, and multiplying it into the frame — is the same work whichever estimate produced it. So it lives here once. A technique file is its kernel and nothing else, which is what makes the three readable against each other.
Usage: local ao.shared = require("@builtin::systems.ambientOcclusion.aoShared")
modules/ao.shared/feature
feature(name: string, kernel: AssetRef<computeShader>) -> table
Build the render feature for one technique from its kernel shader.
Parameters
namestringkernelAssetRef<computeShader>
Returns table
modules/ao.shared/scale
scale() -> number
The fraction of the frame's resolution the occlusion is computed at.
Returns number
modules/ao.shared/setScale
setScale(scale: number)
Parameters
scalenumber
modules/ao/README
require("@builtin::systems.ambientOcclusion.ao") -- ao
Screen-space ambient occlusion — the contact darkening in corners, creases and where objects meet. Without it every concave region is lit exactly like a flat one.
Usage: local ao = require("@builtin::systems.ambientOcclusion.ao")
modules/ao/active
active(): boolean
Whether the occlusion pass is running this frame.
if ao.active() then ... end
modules/ao/clear
clear()
Turn occlusion off and release the pass. The other settings are kept,
so a later set({ intensity = ... }) brings back the same look.
ao.clear()
modules/ao/get
get(): AoState
The occlusion settings currently in force.
local r = ao.get().radius
modules/ao/paramsBuffer
paramsBuffer(): any?
The buffer the AO kernel reads. It belongs to whichever technique is running, and is remade when the technique swaps, so the pass binds what this hands it rather than looking it up.
local p = ao.paramsBuffer()
modules/ao/qualityLevels
qualityLevels(): { [string]: { slices: number, steps: number, scale: number } }
What each quality level costs: slices × steps taps per pixel (total
slices * steps * 2, the same for every technique), computed on a grid
scale of the frame's resolution.
local cost = ao.qualityLevels().ultra
modules/ao/set
set(opts: AoOpts?): AoState
Set the scene's ambient occlusion. Any omitted field keeps its current
value, so a call can adjust one knob without restating the rest. An
intensity of 0 turns occlusion off and releases the pass.
Parameters
optsAoOpts?(optional) — Occlusion settings — seeAoOpts.
ao.set({ technique = "hbao", intensity = 0.9, radius = 1.5 })
modules/ao/techniques
techniques(): { [string]: string }
The techniques that can be selected, each with what it does.
for name in pairs(ao.techniques()) do print(name) end
modules/asset/README
require("@builtin::modules.api.engine.asset") -- asset (also available as global 'asset')
Asset resolver, ref envelope builder, sidecar metadata. Public Luau surface over the __asset Internal FFI namespace.
Usage: local asset = require("@builtin::modules.api.engine.asset") Also available as global: asset
modules/asset/add_tag
add_tag(ref: RefArg, tag: string)
Add a tag to the asset's .metadata.tags. Idempotent.
Creates the sidecar and the tags array if missing.
Parameters
refRefArg— Any name the asset has.tagstring— Tag to add.
asset.add_tag("brick", "wip")
modules/asset/alias
alias(ref: RefArg, alias: string): boolean
Add a name the asset answers to. asset.resolve, leaf
shorthand, and the typed-argument coercion that content refs
travel through all reach the asset by the alias from here on,
exactly as they do by its identity — so a material naming a
shader by its alias resolves, and content written against an
older name keeps working after a rename. The name survives
writes to the asset's own files.
Raises when the name already resolves to a DIFFERENT asset — an
alias extends the identity namespace and never takes a name out
of another asset's hands — and when it is shaped like a guid or
a VFS path, forms that resolve before identity lookup, so an
alias in that shape could never answer.
Parameters
refRefArg— The asset gaining the name.aliasstring— The additional name. Any identity form: a bare leaf (standard) or a scope-qualified path (@builtin::shaders.legacy).
asset.alias("@builtin::shaders.pbr", "standard")
modules/asset/aliases
aliases(ref: RefArg): { string }
The additional names this asset answers to, beyond its own
identity — what asset.alias registered, plus the
package-relative ~pkg.tail form when the asset lives inside a
package.
Parameters
refRefArg— Any name the asset has.
for _, n in asset.aliases("pbr") do print(n) end
modules/asset/canCreate
canCreate(typeName: string): boolean
Whether asset.create can instance typeName: the type declares
creation logic (a behavior.luau onCreate hook) or ships a
template/ skeleton the hookless fallback clones. A type with neither
— one whose instances only arrive by import — answers false. The query
a creation UI derives its offering from, so what it offers is what
asset.create accepts.
Parameters
typeNamestring— Registered asset type (e.g. "material", "scene").
if asset.canCreate(kind) then asset.create(kind, name) end
modules/asset/categories
categories(): { string }
List every asset category the engine currently recognises.
Use to discover valid type argument values for the rest of
asset.*.
for _, c in asset.categories() do print(c) end
modules/asset/containing
containing(path: string): AssetRef?
Walk path and its ancestors and return an AssetRef handle for
the INNERMOST registered category-folder containing it — the typed asset
that directly owns the path (e.g. main.scene for
"/source/scenes/main.scene/scene.json"; for a folder that is itself a
registered asset, that asset). Returns nil for paths outside any
registered asset.
Parameters
pathstring— VFS path to inspect.
local a = asset.containing("/source/scenes/main.scene/scene.json")
modules/asset/cpuResident
cpuResident(ref: RefArg, typeName: string?): boolean
True when the asset is CPU-resident — a live script-component context
holds it (a component's assetRef field, or an imperative
asset.resolve/ref made while a component is the caller), which is what
warms its bytes into memory. The CPU pool is a different pool from the
device's: asset.observe().cpu lists it, asset.observe().textures /
.meshes list what the device holds, and an asset can be in one and not
the other.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.typeNamestring?(optional) — Category to restrict the match to. Omit to search every category.
if asset.cpuResident(ref) then print("bytes are warm") end
modules/asset/create
create(typeName: string, name: string, opts: { [string]: any }?): (AssetRef, { durable: boolean, survivesRestart: boolean?, warning: string?, playShadow: string?, shadowed: { string }?, scratch: { string }? })
Instance a new asset of an existing type. Runs the type's
behavior.luau onCreate(name, opts) hook to produce the asset's
files, then writes them under /source/<folder>/<name>.<type>/
(/source/<name>.<type>/ when no folder is given). This is the
single generic asset-creation API. Refuses to clobber an existing
edit-mode asset unless opts.overwrite = true, which re-authors it in
place and keeps the existing guid (only the checksum changes). Pairs with
asset.exists for content generators that re-run over the same names.
A create made from a script component's callback or a scene entrypoint is
output the world reproduces on every load, so it is filed in the ephemeral
/runtime/assets/ store instead, where the saved manifest never carries a
second copy of it. name and folder spell the same IDENTITY in either
store, so a reference written against that identity resolves the asset
wherever the call filed it, and one generator run from an execute and
from a component names one asset.
Parameters
typeNamestring— The asset category to instance — one ofasset.categories().namestring— The new asset's name.opts{ [string]: any }?(optional) — Optional table forwarded to the type'sonCreatehook, minus five framework keys consumed here and never seen by the hook:folder(a relative subfolder path under/sourceto author the asset in, with/between its folders as ingame/materials, so generated content groups instead of accumulating at the source root; those folders joined by dots prefix the asset's identity,game.materials.<name>),into(author INSIDE a resolved container ref),dest(an absolute destination path),overwrite(re-author in place, keeping the guid), anddurable(file every content file this create writes on canonical/sourcewith play still running, in place of the play shadow, and raise with the reason when they cannot become source, the same key, meaning the same thing, thatvfs.writetakes). Every type accepts all five whatever its own contract declares;asset.describe(typeName).frameworkParamsnames them, and a rejection prints them under the type's own parameters.
local m = asset.create("material", "brick", { shader = "pbr" })
local s = asset.create("shader", "glow", { folder = "fx" }) -- s.path: /zero/source/fx/glow.shader, s.primary: /zero/source/fx/glow.shader/shader.wgsl
local wgsl = vfs.read(s.primary) -- the created asset's content file, read by the path the ref names
local mesh = asset.create("mesh", "tree", { positions = {...}, indices = {...} })
local mesh = asset.create("mesh", "rock", { positions = {...}, indices = {...}, folder = "terrain/props" })
local mesh = asset.create("mesh", name, { positions = p, indices = i, overwrite = true }) -- idempotent rebuild
local clip, d = asset.create("soundClip", "hit", { pcm = buf, sampleRate = 48000, channels = 1 })
if not d.durable then log.warn(d.warning) end
local c = asset.create("soundClip", "step", { pcm = buf, sampleRate = 48000, channels = 1, durable = true }) -- lands on source during play
modules/asset/declareReferenceArg
declareReferenceArg(call: string, position: number, assetType: string)
Declare that call's argument at 1-based position names an
asset of type, so a string literal written there is recorded as a
reference. The positional counterpart of
asset.declareReferenceField, for a call that takes its asset as a
plain argument — including a world's own spawn helper, which is
where a name most often stops being visible to the reference graph.
A lookup whose asset is its FIRST argument (asset.resolve and its
siblings) is already read and needs no declaration. Only a literal —
or a name the file holds in a top-level string constant — is
recorded; anything computed is reported as a dynamic resolve.
An asset type states the same declaration as content, in the
references.args of its type.yaml, which every reference table
reads from the moment the type registers.
Parameters
callstring— The callee as it is written at a call site.positionnumber— Which argument holds the name, counting from 1.assetTypestring
asset.declareReferenceArg("spawnModel", 3, "mesh")
modules/asset/declareReferenceField
declareReferenceField(call: string, field: string, assetType: string)
Declare that call's options table names an asset of type in
its field, so a string literal written there is recorded as a
reference by whatever writes the file. This is what puts an API
that takes an asset BY NAME into the reference graph: the named
asset becomes a dependency, travels with the content that names it
into a pack or a pull, and a name nothing answers to becomes an
unresolved dependency worldValidation reports and the push gate
refuses. A field holding a TABLE of names — a material's textures
— records every name in it. Declare once, beside the API; a call
taking its asset as the FIRST positional argument is already read
and needs no declaration. Only a literal is recorded; a computed
name resolves at runtime and is reported as a dynamic resolve.
An asset type states the same declaration as content, in the
references.fields of its type.yaml, which every reference table
reads from the moment the type registers.
Parameters
callstring— The callee as it is written at a call site.fieldstring— The options-table field holding the name, read at the table's own level.assetTypestring
asset.declareReferenceField("fx.beam", "material", "material")
modules/asset/declareReferenceKey
declareReferenceKey(assetType: string, key: string, refType: string, via: ("asset_ref" | "settings_of")?)
Declare that, in a data file belonging to an assetType asset,
the top-level key names an asset of type ("*" for any type) — a
.material's mat.yaml naming the shader it draws with and the
textures it binds. The names a format holds are references as surely
as ones written in code: recording them carries a material's shader
along with the material into a pack or a pull, and turns a name nothing
answers to into an unresolved dependency instead of a surface that
renders as the magenta error material. A key holding a table of
names records one per entry; a { __ref = <guid> } envelope names its
guid. via is the provenance the file's .refs records: "asset_ref"
(default) for an asset the file uses, "settings_of" for the declarer
whose settings schema the file's values follow. A type states the keys
of its own files as content, in the references.keys of its
type.yaml, which every reference table reads from the moment the type
registers.
Parameters
assetTypestring— The category owning the file, e.g. "material".keystring— The top-level key holding the name(s).refTypestringvia("asset_ref" | "settings_of")?(optional) — "asset_ref" or "settings_of".
asset.declareReferenceKey("material", "shader", "shader")
asset.declareReferenceKey("preset", "target", "*", "settings_of")
modules/asset/deprecation
deprecation(ref: RefArg): Deprecation.Deprecation?
Whether an asset is deprecated, why, and what replaces it. An asset is
deprecated when its own .metadata carries "deprecated": { "reason": "<one line why>", "replacedBy": "<identity>" }, when a container holding
it at any depth does (a package, a toolbox, a folder asset), or when its
asset type does. A deprecated asset still resolves and loads by identity
and guid; search surfaces do not offer it, and resolving it warns once per
session.
Parameters
refRefArg— Asset handle, identity, guid or VFS path.
local d = asset.deprecation("@builtin::deprecated.deprecatedParticles.DeprecatedParticleEmitter")
modules/asset/deps
deps(ref: RefArg, type: string?): DepsResult
Return the asset's outbound dependency graph — every other asset recorded as a content dependency of it.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
for _, d in asset.deps("main.scene").deps do print(d.asset_guid) end
modules/asset/describe
describe(typeName: string): DescribeResult
The creation contract for an asset type: the parameters its
onCreate(name, opts) hook accepts, as data. kind is "schema"
(typed contract), "legacy" (untyped opts — anything passes), "none"
(template scaffold — takes no opts), or "error" (the type's schema
failed to parse; error says why). contract is the human-readable
rendering validation errors print. frameworkParams and
frameworkContract carry the options asset.create consumes itself:
folder, into, dest, overwrite, durable, which every type
accepts and none declares.
Parameters
typeNamestring— Registered asset type to describe (e.g. "texture").
local contract = asset.describe("texture").contract
modules/asset/diagnose
diagnose(ref: RefArg): any
Why one asset can or cannot be used, read from the engine rather than
from what the caller asked for. Always carries usable; when false,
reason is one of asset.unusableReasons() and detail is the engine's
own message. primary names the file the type's declared primary list
resolved to, the file a load of the asset reads. The
payload's bytes are read by the engine's own decoder wherever it has one
for that container, so usable is the verdict a load would reach and the
call costs that decode.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.
local d = asset.diagnose("myTex") if not d.usable then print(d.reason, d.detail) end
modules/asset/exists
exists(name: string, typeName: string): boolean
Parameters
namestringtypeNamestring
modules/asset/get_field
get_field(ref: RefArg, key: string): any
Read one top-level field from the asset's .metadata.
Parameters
refRefArg— Any name the asset has.keystring— Field name.
local author = asset.get_field("brick", "author")
local tags = asset.get_field("tree", "tags") -- → a Luau table
modules/asset/gpuResident
gpuResident(ref: RefArg): boolean
True when the device holds a texture or mesh under this asset's guid, read off the inventory the renderer publishes.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.
print(asset.gpuResident("@builtin::models.Sample.DamagedHelmet"))
modules/asset/guid
guid(ref: RefArg, type: string?): string
Return the guid for an asset.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local g = asset.guid("@builtin::components.Camera")
modules/asset/has_field
has_field(ref: RefArg, key: string): boolean
True when the asset's .metadata carries the named field.
Parameters
refRefArg— Any name the asset has.keystring— Field name.
if asset.has_field("brick", "author") then end
modules/asset/has_tag
has_tag(ref: RefArg, tag: string): boolean
True when the asset's .metadata.tags contains tag.
Parameters
refRefArg— Any name the asset has.tagstring— Tag to check for.
if asset.has_tag("brick", "wip") then end
modules/asset/identity
identity(ref: RefArg, type: string?): string
Return the canonical identity for an asset.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local id = asset.identity("brick")
modules/asset/import
import(path: string, opts: { importerSettings: { [string]: { [string]: any } }? }?): string?
Import a raw source file NOW and return the produced asset path
(a .bundle for a model, .texture for an image, .audio for a
sound, …), or nil if no importer claims it. While play runs and holds the
source where it stands (vfs.playHoldsInPlace), the import is owed: this
returns nil, the source's job in tools.use("importers", "status") reads
owed, and the import runs when play ends or pauses. This is the deterministic,
on-demand counterpart to the engine's automatic import-on-write: it runs
in the calling task and returns only when the import is complete. Pair it
with a quiet write — vfs.write(path, bytes, { quiet = true }) lands the
raw bytes without firing the automatic importer, then asset.import(path)
imports them under your control, so you can act on the result instead of
polling for the import to appear.
Parameters
pathstring— The raw source VFS path to import (e.g. a just-written.glb).opts{ importerSettings: { [string]: { [string]: any } }? }?(optional) — Optional{ importerSettings = { <importer name> = { <setting> = value } } }: settings for this import only, laid over the claiming importer's own. A setting that importer does not declare is an error.
local bundle = asset.import("/zero/source/generated/chest.glb")
local bundle = asset.import("/zero/source/generated/chest.glb", { importerSettings = { model = { keepSource = false } } })
modules/asset/inspect
inspect(ref: RefArg, type: string?): InspectRecord
Everything known about one asset in a single record: identity, guid,
source, type, scope and origin, its description and tags, the ref methods
its type exposes, and the type's own inspect detail when it declares one.
The read-everything counterpart to asset.resolve, which hands back a ref.
Parameters
refRefArg— AnAssetRef, an identity string, or a path.typestring?(optional) — Narrow the resolve to one asset type when assets of several categories answer to the same bare name.
local rec = asset.inspect("@builtin::materials.default")
local rec = asset.inspect(name, "mesh"); print(rec.guid, #rec.tags)
modules/asset/interface
interface(ref: RefArg, category: string?): AssetInterface?
What the asset declares it takes and gives, read from its source
without running it: the interface its type's interface: block says its
sources declare (a .procNode declares one). description is what it
does; each of inputs carries its name, type, default, min, max,
options, optional and description as the declaration states them (a
vector default reads as { ["$vector"] = { x, y, z } }); each of
outputs its name and from, what makes it. problems lists each part
of the declaration that is not written as literals, which a push refuses.
The same data travels with the source's reference table to ZeroMind.
Parameters
refRefArg— Any name the asset has.categorystring?(optional) — Category hint (optional).
local iface = asset.interface("@builtin::systems.procgen.nodes.points.disc", "procNode")
modules/asset/isPrivateSubasset
isPrivateSubasset(path: string): boolean
Whether the asset at path is a private subasset: nested inside
another asset whose type does not broadcast its subassets — a .bundle's
interior meshes, materials and textures, an effect's own materials. A
private subasset is part of its parent: it is not listed, searched or
installed on its own, and it is excused from the files that describe an
asset. Whether nested assets are private is the enclosing asset's type's
to say: broadcasts_subassets: true in its type.yaml (a .package)
makes its members public, and an asset nested in no other asset is never
private. The same rule asset.list applies, where subassets = true is
what reaches private subassets.
Parameters
pathstring— The asset's VFS folder path.
asset.isPrivateSubasset("/zero/source/models/tree.bundle/material/Bark.material") -- true
modules/asset/list
list(type_or_opts: (AssetCategory | ListOpts)?, scope: string?, opts: ListOpts?): ListResult
Query registered assets, returning each match as a resolved
AssetRef handle. Every filter narrows the same enumeration and
they compose: path selects a VFS subtree (the folder and
everything under it), type keeps only those asset types within
it, scope keeps only that scope, and fields keeps only assets
whose .metadata matches. type and path each take one value or
a list matching any of its entries, and all / any / none
group whole filters — none excludes what it matches. order,
limit, and offset shape the result: matches come back ordered
by identity unless order names another field
(name / path / type / guid).
subassets decides how deep the enumeration reaches into composite
assets. An enumeration returns the assets each container broadcasts,
which its type declares: a .package and a .toolbox broadcast
theirs, so their members are listed on their own, and a .bundle
keeps its interior meshes, materials and rigs to itself, so they are
reached through the bundle and a list of the folder holding it comes
back without them. subassets = true enumerates those private
interiors as well — what an asset is built out of, beside what the
world offers.
Each entry is the same envelope asset.resolve returns (__ref /
type / name / guid / identity / path), so it can be passed
anywhere an AssetRef is accepted, and the result carries
:first() / :random() / :filter() / :sort() and friends.
type takes the same values asset.categories() lists. The first
positional argument is a path when it is absolute, a type
otherwise. A type naming none of those values raises, naming it
and any near spelling, so an empty result means a type the engine
has. A type-group name stands for a family of those types rather
than naming one (model for glb/gltf/fbx/obj, and image,
text, config and script for theirs), so it lists whichever
members the engine carries, and raises naming them when it carries
none. An unknown key raises,
as does a table setting both type and its older spelling
category.
A static (literal) type or path makes the enumeration part of the
calling file's content dependencies when it is saved — the set
travels with published content, so consumers get at-least the
authoring world's assets.
Parameters
type_or_opts(AssetCategory | ListOpts)?(optional) — Type or VFS path filter (a static literal so the enumeration can be captured for publish), or the full query table.scopestring?(optional) — Scope filter (when first arg is a type).optsListOpts?(optional) — The query table — seeListOpts.
local hero = asset.list({ path = "/zero/source/props", type = "mesh", fields = { tags = "hero" } }):first()
local parts = asset.list({ path = "/zero/source/models", type = "mesh", subassets = true }) -- a bundle's interior meshes too
modules/asset/listRevision
listRevision(): (number, number)
Two numbers that together move whenever what asset.list could answer
changes: an asset made, removed, moved or renamed, a name it answers to
added, a file created in or removed from an asset's folder (a new entity
in the open scene writes one), or the index rebuilt. Rewriting a file
that already exists leaves them still, and so does a write to a path no
asset can sit at. The copies play makes resident in the runtime-asset
layer move neither number. Hold the pair beside something derived from a
listing and list again only when either differs, so a per-frame reader
lists only on the frames where the answer can have changed.
local e, g = asset.listRevision() if e ~= held.e or g ~= held.g then held.list = asset.list("texture") end
modules/asset/list_field_values
list_field_values(key: string): { any }
Distinct values seen for the named field across every
asset's .metadata.
Parameters
keystring— Field name.
local authors = asset.list_field_values("author")
modules/asset/list_fields
list_fields(): { string }
Distinct top-level field keys observed across every asset's
.metadata. Useful for tooling discovering custom keys in use.
for _, k in asset.list_fields() do print(k) end
modules/asset/meta
meta(ref: RefArg, type: string?): AssetMeta
Read the asset's engine-owned identity record (guid /
checksum). Distinct from .metadata (agent-editable);
for that use asset.metadata.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local m = asset.meta("brick") -- { guid = ..., checksum = ... }
modules/asset/metadata
metadata(ref: RefArg, type: string?): AssetMeta
Read the asset's agent-editable .metadata sidecar as a
Lua table. Missing sidecar returns {}. Distinct from
asset.meta (engine-owned).
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local md = asset.metadata("brick")
modules/asset/observe
observe(): any
What the engine is holding for content right now, in one reading:
textures and meshes (one row per resource the device holds, each with
the bytes it costs, its dimensions or buffer split, and where it came
from), cpu (one row per asset a live script-component context holds),
offDevice (one row per mesh nothing displays, whose GPU buffers were
given back: held is "definition" when the engine keeps the mesh's
whole CPU definition and "source" when it keeps only the stored file
source it reads the mesh from again, and bytes is the CPU memory that
costs), and totals: the aggregates those rows sum to, so the listing
reconciles against renderer.textureMemory() and renderer.gpuMemory()
(offDeviceBytes sums the offDevice rows).
Each pool is named because they are different pools: an asset can be on
the device and not CPU-resident, or the reverse. devicePublished is
false when no renderer has published an inventory and cpuPublished when
the scripting VM has not published its pool — an engine that cannot answer
reads differently from one answering with nothing resident.
local r = asset.observe() print(#r.textures, r.totals.textureBytes)
modules/asset/pathHolding
pathHolding(guid: string, checksum: string): string?
The VFS path holding the asset guid at exactly the version whose
content checksum is checksum (the pair asset.meta reports): the guid's
home when its bytes are that version, else a copy of that version held
beside it, such as an installed dependency's. Returns nil when this world
holds that asset at no such version.
Parameters
guidstring— The asset's guid.checksumstring— The content checksum of the version wanted.
local m = asset.meta(asset.resolve("@builtin::shaders.pbr", "shader")); local path = asset.pathHolding(m.guid, m.checksum)
modules/asset/pending
pending(): { count: number, entries: { PendingReference } }
Every asset reference a component on this engine holds that no asset
answers yet. A reference arrives ahead of its bytes when a peer delivers a
component whose asset has not synced here, when the carried mount it
names is still filling, or when a scene applies before the content it
names. Each one applies by itself the moment its asset resolves: a
component waiting on it runs its awake() then, and a write held for a
component already running (held) lands then and reaches its
onPropertyChanged. state is pending, or refused when the carried
mount the reference names settled without its content; reason and
detail say why. A refused reference applies if a later mount of that
key brings the content. A reference inside a list or struct field waits
the same way at its place in the field (path, such as skins[2] or
look.skin), the field keeps every other value it holds, and the
reference applies in place. Every peer of a world holds and applies the
references it was delivered the same way.
local waiting = asset.pending()
if waiting.count > 0 then print(waiting.entries[1].reference, waiting.entries[1].state) end
repeat task.wait() until asset.pending().count == 0
modules/asset/preview
preview(ref: RefArg, opts: { [string]: any }?, type: string?): { [string]: any }
Render a preview of an asset. Resolves the ref and dispatches to its
type's preview ref-method when present; otherwise returns the
{ available = false } sentinel ("no preview available for this type").
Parameters
refRefArg— Any name the asset has.opts{ [string]: any }?(optional) — Optional{ size = { width, height }, angle = { yaw, pitch } }.typestring?(optional) — Category hint (optional).
local p = asset.preview("@builtin::materials.gold", { size = { width = 512, height = 512 } })
modules/asset/primaryFile
primaryFile(ref: RefArg): any
The file the asset type's declared primary list resolves to inside
this asset, as the loader itself resolves it. A *.<ext> entry resolves
the lowest-named file with that extension, and never the asset's
preview.png, the picture rendered from it. resolved is false when no
declaration matched and path is then absent; declared is the type's
own primary list in match order.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.
print(asset.primaryFile("myTex").path)
modules/asset/ref
ref(ref: RefArg, type: string?): AssetRef
Build a reference handle for an asset — the canonical ref
envelope constructor. Identical shape to asset.resolve;
preferred name for the author-side use case (embedding refs in
YAML / JSON / Luau output).
Naming the asset here reads exactly as naming it in asset.resolve,
down to raising on a miss: a literal is recorded as this source's
dependency, a computed name is a dynamic resolve — free in a tool,
refused on the gameplay path. asset.exists(name, type) is the probe a
computed name can ask.
Parameters
refRefArg— The asset to reference — an identity, a guid, a VFS path, or a handle.typestring?(optional) — Category hint (optional).
local r = asset.ref("animations.idle", "animation")
modules/asset/reloadPending
reloadPending(ref: RefArg, typeName: string?): boolean
True while a write to this asset still owes it a reload — the write is inside the settle window that collects one authoring step's writes, or its reload is queued and the engine has not run it yet. False means every content change written so far has reached its subscribers, so a consumer bound to the asset now cannot be interrupted by a reload the earlier writes already earned. The recording is synchronous with the write, so a call made right after one already reads true.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.typeNamestring?(optional) — Category to restrict the match to. Omit to search every category.
repeat task.wait() until not asset.reloadPending(ref)
modules/asset/reloadSeq
reloadSeq(ref: RefArg, typeName: string?): number
How many content-change reloads this asset has been through — the
count of onAssetReload dispatches the engine has RUN for it. A write to
a file inside an asset does not reload it on the spot: the writes of one
authoring step are collected for a settle window and the reload runs on a
later frame. Read this, write, then poll for a larger number to learn the
write's reload has actually reached subscribers. Monotonic per asset and
session-scoped; 0 for an asset whose content has not changed since boot.
Parameters
refRefArg— Any name the asset has — handle, identity, guid, name or path.typeNamestring?(optional) — Category to restrict the match to. Omit to search every category.
local at = asset.reloadSeq(ref)
vfs.write(asset.source(ref) .. "/graph.json", encoded)
repeat task.wait() until asset.reloadSeq(ref) > at
modules/asset/remove_field
remove_field(ref: RefArg, key: string)
Remove one top-level field from the asset's .metadata.
No-op when the field isn't present.
Parameters
refRefArg— Any name the asset has.keystring— Field name.
asset.remove_field("brick", "author")
modules/asset/remove_tag
remove_tag(ref: RefArg, tag: string)
Remove a tag from the asset's .metadata.tags. No-op when
the tag isn't present.
Parameters
refRefArg— Any name the asset has.tagstring— Tag to remove.
asset.remove_tag("brick", "wip")
modules/asset/resolve
resolve<C>(ref: RefArg, type: (C & string)?): AssetRef<C>
Find an asset. The returned handle carries every name form
the asset has (guid, identity, path, type) so
downstream code can read any one of them without calling
resolve again. Raises when ref resolves to no asset — or, with a
type, to no asset of that type — and when ref reaches more than one
asset, where it names the candidates for you to pick from instead of
picking one of them. A <scope>::-qualified identity reaches exactly one:
@root::name for the asset this world holds at its source root, the
library identity (@builtin::…) for a library's. For the same lookup
answering a miss with nil, use asset.tryResolve(ref, type).
A name written as a string LITERAL is recorded as this source's
dependency on that asset, so the asset travels with the content and
still resolves once someone installs it in another world. A COMPUTED
name cannot be written down, so nothing pins what it reaches: that is a
dynamic resolve — free in a tool, refused on the gameplay path (a
component or scene entrypoint). asset.tryResolve, asset.ref and
asset.source read the name they are given exactly this way too, so
which of the four you reach for changes neither answer. To ask whether a
computed name has files without reaching a handle, use
asset.exists(name, type).
Parameters
refRefArg— The asset to find — an identity, a guid, a VFS path, or a handle.type(C & string)?(optional) — Category to restrict the match to (optional). Separates a bare name that assets of different categories share (asset.resolve("cube", "mesh")); where several assets of the SAME category answer to it, the scope-qualified identity is what separates them. A reference naming a file an importer has since promoted (wall.pngafter the texture importer turned it intowall.texture) resolves to the promoted asset, and says so in the log once per reference.
local a = asset.resolve("@builtin::components.Camera")
modules/asset/rootKinds
rootKinds(): { string }
The kind of every asset folder that is a root of its contents (its category declares root: true; a package is
one too): a ~ written in a file inside such a folder names that folder. The same answer in every VM, the engine
thread's and each worker's.
local roots = asset.rootKinds() -- { "effect", ... }
modules/asset/schema
schema(ref: RefArg): any?
The typed settings schema governing this asset — the Field descriptors its type declares for every asset of that type, or the ones the asset declares for itself. Each descriptor carries its kind, default, constraint and description, so an editor renders it and an agent reads what a setting takes without guessing.
Parameters
refRefArg— The asset (ref, identity, guid or path).
local schema = asset.schema(texRef); print(schema.filter.constraint.values)
modules/asset/setSettings
setSettings(ref: RefArg, patch: { [string]: any })
Write a partial settings patch. The patch is merged over the asset's
current values, the type's cross-field constraints are applied — a field
the patch does not name moves to the only value the rest allows (a
texture given a high-precision compression stops generating mipmaps), and a
field the patch names that cannot hold refuses the write, saying why —
and the result is checked against its schema; a violation refuses the
whole write, naming every problem, and leaves the asset on its last
valid settings. A valid write re-runs the type's onChange, which is
where the type re-cooks whatever the settings describe. Older field
names are accepted and stored under the current ones, and a field whose
default follows another moves with it when the write does not name it.
Parameters
refRefArg— The asset (ref, identity, guid or path).patch{ [string]: any }— Any subset of the schema's fields.
asset.setSettings(texRef, { filter = "nearest" })
modules/asset/set_field
set_field(ref: RefArg, key: string, value: any)
Set one field in the asset's .metadata, creating the sidecar if missing.
Sibling fields are preserved. When the new value AND the existing value are
both maps (objects), the new value DEEP-MERGES into the existing one, so
writing one sub-key never drops the others — set_field(ref, "provenance", { bakedBy = "agent" }) keeps every other provenance key. Arrays and
scalars replace. Clear a whole field with asset.remove_field; replace
the entire sidecar with asset.set_metadata.
Parameters
refRefArg— Any name the asset has.keystring— Field name.valueany(optional) — Field value (any JSON-serialisable Lua value).
asset.set_field("brick", "author", "me")
asset.set_field("tree", "provenance", { bakedBy = "agent" }) -- merges; sibling keys kept
modules/asset/set_metadata
set_metadata(ref: RefArg, data: AssetMeta)
Replace the asset's .metadata sidecar with the given
table. Pass an empty table to clear all fields.
Parameters
refRefArg— Any name the asset has.dataAssetMeta— Full JSON-shaped contents for the sidecar.
asset.set_metadata("brick", { author = "me", tags = { "wip" } })
modules/asset/settings
settings(ref: RefArg): any?
This asset's settings values, with every declared default filled in.
Parameters
refRefArg— The asset (ref, identity, guid or path).
if asset.settings(texRef).filter == "nearest" then ... end
modules/asset/source
source(ref: RefArg, type: string?): string
Return the VFS source path for an asset.
It reaches the asset, so the name carries the same reference contract
asset.resolve's does: a literal is recorded as this source's
dependency, a computed name is a dynamic resolve — free in a tool,
refused on the gameplay path. asset.exists(name, type) is the probe a
computed name can ask.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local p = asset.source("brick") -- "/source/brick.material"
modules/asset/storeHoldsIdentity
storeHoldsIdentity(identity: string, typeName: string, reproduced: boolean): boolean
Whether an asset of type typeName that name reaches has files in
the store asset.create writes from this context — the authored /source
tree, plus the ephemeral /runtime/assets/ store when the caller is a
script component or a scene entrypoint, which is where a create there
files it. name is any name the registry answers to for that asset: its
canonical identity ("a.b.thing"), a registered alias, or the bare leaf
("thing") — the spelling asset.list publishes as an entry's name and
the spelling asset.create was given alongside opts.folder. So the
if not asset.exists(n, t) then asset.create(t, n, opts) end pairing is
satisfied by its own create, spelled the way the create was, in either
store and at any folder depth. A plain existence probe — it does NOT
resolve a handle or pin a content dependency, so it is safe to call with a
COMPUTED name (unlike asset.resolve, whose handle would become a
static-pinned dependency).
The name is read the way asset.resolve reads one; the ANSWER comes from
the store, so a registered asset whose files live outside the store this
context writes — every @builtin:: asset among them — is false.
asset.tryResolve(name, typeName) asks the registry the wider question
and hands back the handle — and because it reaches the asset, the name it
is given follows the reference rule every lookup follows: a literal is
pinned, a computed one is a dynamic resolve. So a name this source
computed is what asset.exists is for.
This call names the asset FIRST and its category second, as every
asset.* call taking both does except asset.create(category, name, opts). A call carrying a category where the asset goes and a non-category
where the category goes is refused, naming which way round the call reads,
rather than reporting the asset absent.
Parameters
identitystringtypeNamestring— The asset type (e.g. "mesh", "texture", "material") — one ofasset.categories().reproducedboolean
if not asset.exists(meshName, "mesh") then asset.create("mesh", meshName, geo) end
if not asset.exists(n, "mesh") then asset.create("mesh", n, { folder = "props", positions = p, indices = i }) end
modules/asset/tags
tags(ref: RefArg): { string }
Convenience read of the .metadata.tags array.
Parameters
refRefArg— Any name the asset has.
for _, t in asset.tags("brick") do print(t) end
modules/asset/tryResolve
tryResolve(ref: RefArg, type: string?, base: string?): AssetRef?
The same lookup asset.resolve performs, answering a miss with nil
instead of raising. Every name form, the same type narrowing, and the
same handle on success — so "use it if it is there" needs no pcall
around a call whose failure would otherwise be indistinguishable from a
real error.
This consults the asset REGISTRY, so it sees registered assets wherever
their files live, @builtin:: ones included. asset.exists(name, type)
answers the narrower question of whether an asset's files are present in
the current mode's store.
A name that reaches more than one asset of type (or more than one asset,
with no type) still raises: that is a question about the reference, and
a nil there would report absence for content that is present twice. A
name that only assets of other types answer to reaches no asset of type,
and answers nil.
It reaches the asset, so the name carries the same reference contract
asset.resolve's does: a literal is recorded as this source's
dependency, a computed name is a dynamic resolve — free in a tool,
refused on the gameplay path. asset.exists(name, type) is the probe a
computed name can ask.
Parameters
refRefArg— The asset to look up — an identity, a guid, a VFS path, or a handle.typestring?(optional) — Category to restrict the match to (optional). A reference naming a file an importer has since promoted resolves to the promoted asset, the same asasset.resolve.basestring?(optional) — Optional VFS path of the asset the reference is written in, or of its file: a data asset resolving the references it holds, such as a material resolving itsmat.yaml. A~/~.tailref expands against the root enclosing it, and a ref its.refsrecorded reaches the asset recorded there. Without it, both are read at the calling Luau source, asasset.resolvereads them.
local mat = asset.tryResolve(name, "material")
modules/asset/typeRef
typeRef(target: RefArg): string?
Return the pinned asset_type reference (the type's guid)
that the asset is an instance of. Resolve the full type with
asset.resolve(asset.typeRef(target)). Returns nil for loose
files / assets with no pinned type.
Parameters
targetRefArg— Asset handle / identity / guid / VFS path.
local t = asset.resolve(assert(asset.typeRef("brick")))
modules/asset/unusableReasons
unusableReasons(): { string }
Every reason asset.diagnose can report an asset unusable for, sorted.
for _, r in ipairs(asset.unusableReasons()) do print(r) end
modules/asset/validate
validate(ref: RefArg, type: string?): ValidateResult
Validate an asset folder against its type's type.yaml, plus
the type's own semantic validation. Structural problems come from
type.yaml — missing required files, unsatisfied one_of_group
alternatives, and (when allow_unlisted: false) unexpected
children. validated = false when no type.yaml is registered
— nothing structural to check. On top of that, when the asset's
type ships a behavior.luau exporting a top-level
validate(assetRef) -> { { code, message, severity? } }, its
reported problems (severity defaults to "error") are appended to
problems; error-severity problems flip ok to false, warnings
leave it untouched. A hook that raises or returns a non-table is
itself reported as a validate.hook_failed error problem — a
broken hook blocks. A type with no validate export behaves
exactly as the structural check alone.
world.push calls this per user asset, so a type's semantic
validation is enforced at publish time with no further wiring.
Parameters
refRefArg— Any name the asset has.typestring?(optional) — Category hint (optional).
local v = asset.validate("@builtin::components.Camera")
modules/asset/warmup
warmup(ref: RefArg, opts: WarmupOpts?): WarmupResult
Warm an asset's bytes into CPU memory and follow its declared
content dependencies to each referenced asset, deduped by
guid. Type-agnostic (reads the generic ref graph) and CPU-only —
never touches the GPU. Side-effect-free name resolution (uses
asset.guid/asset.deps, not asset.resolve).
Parameters
refRefArg— Any name the root asset has — handle, identity, guid, or path.optsWarmupOpts?(optional) — Optional{ vias, max }— restrict ref-edge kinds / cap closure size.
local w = asset.warmup("@builtin::scenes.test_arena")
modules/asset_tag/README
require("@builtin::modules.asset_tag") -- asset_tag
The assetTag field-constraint validator: a constrained value must be an asset carrying constraint.tag in its .metadata.tags. This is what lets a slot declare the KIND of asset it takes — a camera behavior, a player visual — without naming the assets themselves, so a new asset becomes assignable the moment it is tagged. Registers itself with the generic field_constraints registry on load. nil (no asset) passes — the field is optional.
Usage: local asset_tag = require("@builtin::modules.asset_tag")
modules/atmosphere/README
require("@builtin::systems.atmosphere.atmosphere") -- atmosphere
Physically-based atmospheric scattering — aerial perspective on distant geometry, and a sky whose colour follows from the sun's elevation rather than from an authored gradient.
Usage: local atmosphere = require("@builtin::systems.atmosphere.atmosphere")
modules/atmosphere/active
active(): boolean
Whether the atmosphere passes are currently running.
if atmosphere.active() then print("scattering") end
modules/atmosphere/clear
clear()
Turn the atmosphere off and release its passes. The other settings are
kept, so a later set({ aerial = ... }) brings back the same look.
atmosphere.clear()
modules/atmosphere/get
get(): AtmosphereState
The atmosphere settings currently in force.
local km = atmosphere.get().worldUnitsPerKm
modules/atmosphere/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = atmosphere.paramsBuffer()
modules/atmosphere/set
set(opts: AtmosphereOpts?): AtmosphereState
Set the scene's atmosphere. Any omitted field keeps its current value,
so a call can adjust one knob without restating the rest. With aerial at
0 and sky off nothing is wanted and the passes are released.
Parameters
optsAtmosphereOpts?(optional) — Atmosphere settings — seeAtmosphereOpts.
atmosphere.set({ aerial = 1, sky = true, worldUnitsPerKm = 1000 })
modules/audio/README
require("@builtin::modules.api.engine.audio") -- audio (also available as global 'audio')
Engine-native audio: encode audio (or raw PCM) into the ZAUD compressed payload, decode/inspect it, play PCM a script synthesizes while it sounds (audio.stream), set what the mix is heard at — a level per named channel, a master level and a mute — and observe what the mixer is making audible right now: live voices, why a source is silent, master levels, mixer voice accounting, listener state and subsystem cost.
Usage: local audio = require("@builtin::modules.api.engine.audio") Also available as global: audio
modules/audio/audiostream_close
audiostream_close(self: AudioStream): boolean
Close the stream: its voice falls silent and the entity's audio
source comes off. Despawning the entity, removing its audio source,
putting another audio source in its place or rewriting the source's
stream field closes the stream the same way.
Parameters
selfAudioStream— The streamaudio.streamreturned.
s:close()
modules/audio/audiostream_flush
audiostream_flush(self: AudioStream): boolean
Drop every frame queued on the stream, on the mixer's next buffer.
Parameters
selfAudioStream— The streamaudio.streamreturned.
s:flush()
modules/audio/audiostream_pause
audiostream_pause(self: AudioStream)
Pause the stream's voice. The queue holds what it has, and wanted()
stays at 0 while it is full.
Parameters
selfAudioStream— The streamaudio.streamreturned.
s:pause()
modules/audio/audiostream_play
audiostream_play(self: AudioStream)
Start or resume the stream's voice. A voice started after an earlier one ended reads a fresh, empty queue.
Parameters
selfAudioStream— The streamaudio.streamreturned.
s:play()
modules/audio/audiostream_push
audiostream_push(self: AudioStream, pcm: any, frames: number?): (number?, string?)
Queue interleaved samples on the stream. pcm is a buffer or a
string holding samples in the stream's format, or an array of numbers;
frames takes only that many frames from its start, so one buffer can be
reused frame after frame. Every sample must be finite and the samples a
whole number of frames.
Parameters
selfAudioStream— The streamaudio.streamreturned.pcmany(optional) — A buffer or string of samples, or an array of numbers.framesnumber?(optional) — How many frames from the start ofpcmto push; all of them when omitted.
local n = s:wanted(); fill(buf, n); s:push(buf, n)
modules/audio/audiostream_set
audiostream_set(self: AudioStream, settings: { [string]: any })
Change the stream's voice: any of volume, pitch, spatial,
maxDistance, rolloff, doppler, channel, sourceType, pitchValue and
volumeValue, as an Audio component carries them. A voice already
sounding takes the change on the next frame, except spatial, which a
voice takes as it starts: placed and attenuated, or played unplaced.
Parameters
selfAudioStream— The streamaudio.streamreturned.settings{ [string]: any }— The settings to change.
s:set({ pitch = 1.2, volume = 0.5 })
modules/audio/audiostream_status
audiostream_status(self: AudioStream): AudioStreamStatus?
Where the stream stands, nil once it is closed: sampleRate,
channels, format; queuedFrames and queuedMs (what is queued and
how far ahead of the mixer that is); capacityFrames; targetFrames
(the queue it asks for) and producerGapMs (the longest recent gap
between pushes behind it); wantedFrames; framesPushed,
framesRefused (frames the full ring could not take) and
framesPlayed; underruns (times it ran dry while it played) and
starvedFrames (the silence played in their place); voice
("waiting", "playing", "paused" or "ended"); rate (the rate the mixer
reads it at, pitch times Doppler).
Parameters
selfAudioStream— The streamaudio.streamreturned.
local st = s:status(); print(st.queuedMs, st.underruns)
modules/audio/audiostream_wanted
audiostream_wanted(self: AudioStream): number
How many frames to push now to bring the queue up to its target: the stream's latency, or one and a half times the longest recent gap between pushes when that is longer. Push this many every frame and the stream stays fed through frames as long as the ones before them. 0 once the stream is closed.
Parameters
selfAudioStream— The streamaudio.streamreturned.
local n = s:wanted()
modules/audio/decode
decode(zaud: buffer | string): (string?, number?, number?)
Decode a ZAUD payload into interleaved f32 PCM. A PCM payload comes
back as the frames its header accounts for, held to the whole frames the
bytes behind it fill, so the sample count is always a whole number of
channels and a consumer walking it channels at a time ends on a frame.
Parameters
zaudbuffer | string— A ZAUD payload — a buffer or a binary string.
modules/audio/device
device(): AudioDeviceStatus
What the engine's audio output is doing: state is "open" while a
stream is running on an output device and "silent" while none is, and
device names the device an open stream runs on. The counters record
what the engine has been through keeping one open — faults a live
stream reported, changes of the host's default output, reopens the
engine made, failedOpens the platform refused, and the glitches a
listener heard as dropouts, with lastError carrying what the platform
said. A device that goes away leaves the mixer running and the engine
opening a stream again as soon as one is there. parked is true while
nothing plays: the output stream is paused and the mixer renders nothing,
so the device rests, and the first sound started resumes it, reading
false once its first period plays; parks counts the times it parked and
resumeLatencyMs is how long the last resume took to play its first
period.
local d = audio.device(); print(d.state, d.device, d.reopens)
modules/audio/encode
encode(sourceBytes: buffer | string, opts: { [string]: any }?): (string?, string?)
Encode container audio bytes (ogg / mp3 / wav / flac) into a ZAUD
payload. Every decoded sample must be finite; a source whose samples carry
a NaN or an infinity comes back as (nil, err) naming how many fail and
where the first one sits.
Parameters
sourceBytesbuffer | string— Encoded source audio bytes — a buffer or a binary string.opts{ [string]: any }?(optional) —{ codec: "opus"|"pcm"?, bitrateKbps: number?, vbr: boolean?, sampleRate: number?, forceMono: boolean?, loopStart: number?, loopEnd: number? }
local zaud = audio.encode(oggBytes, { bitrateKbps = 96 })
modules/audio/encodePcm
encodePcm(pcm: any, sampleRate: number, channels: number, opts: { [string]: any }?): (string?, string?)
Encode raw interleaved f32 PCM into a ZAUD payload. Every sample must
be finite; a buffer carrying a NaN or an infinity comes back as
(nil, err) naming how many fail and where the first one sits, so a
filter that diverged over part of a bake is caught before it is written.
The sample count is a whole number of channels: a buffer with a tail
over comes back as (nil, err) naming the whole frames it holds and the
samples past them.
Parameters
pcmany(optional) — Interleaved f32 samples — a buffer or a binary string of little-endian f32, the shapemicrophone.samplesandaudio.decodehand back, or a flat number array. A byte payload's samples are its 4-byte lanes, and a length that stops partway through one comes back as(nil, err)naming the whole samples it holds and the bytes past them.sampleRatenumber— Source sample rate in Hz.channelsnumber— 1 or 2, and a divisor of the sample count.opts{ [string]: any }?(optional) — Same shape asaudio.encode.
local s = microphone.status(); local zaud = audio.encodePcm(microphone.samples(), s.sampleRate, 1)
modules/audio/info
info(zaud: buffer | string): (AudioInfo?, string?)
Read a ZAUD payload's header. A PCM payload's samples are its bytes, and
the header is read against them: a sample count differing from
frames * channels comes back as (nil, err) naming both counts, and a
sample carrying a NaN or an infinity comes back as (nil, err) naming how
many fail and where the first one sits, so the header handed back describes
a clip that is as long as it says and can sound. The header describes the
clip's shape — rate, channels, frames, duration, codec, loop points. What
the samples do where a whole-clip loop wraps is a reading of its own,
audio.loopSeam, which is the call that answers whether a bed cycles
without a click.
Parameters
zaudbuffer | string— A ZAUD payload — a buffer or a binary string.
local info = audio.info(zaud); print(info.durationMs)
modules/audio/levels
levels(): AudioLevels
The master mix's peak and RMS over the meter's most recent closed window, measured without recording anything.
local l = audio.levels(); print(l.peak, l.rms, l.windowMs)
modules/audio/listener
listener(): AudioListenerState
Where the scene is heard from, how many active listeners exist, and which entity's listener drives the ears.
local l = audio.listener(); print(l.present, l.count, l.entity)
modules/audio/loopSeam
loopSeam(zaud: buffer | string): (AudioLoopSeam?, string?)
Measure what a clip's samples do where a whole-clip loop wraps, so a bed
can be judged before anyone hears it tick. The wrap's own step
(|x[1] - x[frames]|) is reported against the step the signal ordinarily
makes between neighbouring samples, as ratio = step / meanStep — a figure
in the units the signal itself moves in, so a quiet ambience and a loud
drone are read the same way. A bed whose partials wrap reads near 1; one
carrying a strike at its head and silence at its tail reads in the tens.
ratio and the step / meanStep / maxStep beside it belong to the
worst channel, channel names it, and channels carries every channel's
own reading. seamless is ratio <= threshold, the same threshold
asset.create("soundClip", ...) warns past. The reading is taken on the
DECODED samples, so it answers for what the codec left behind and for a
clip that arrived already encoded and whose source buffer nobody holds.
Costs a decode of the whole payload; audio.info reads a header without
one.
Parameters
zaudbuffer | string— A ZAUD payload — a buffer or a binary string.
local seam = audio.loopSeam(clipRef:getBytes()); print(seam.ratio, seam.seamless)
modules/audio/mixer
mixer(): AudioMixerLevels
The levels the mixer is applying to the mix right now: the master
level, whether the mix is muted, and the level of every channel one has
been set on. A channel absent from channels plays at unity, so a
source naming it is heard at the volume it asks for.
local m = audio.mixer(); print(m.master, m.muted, m.channels.music)
modules/audio/observe
observe(): AudioObservation
Report what the mixer is making audible right now, and why a source is not. One read covering every live voice with the mixer's own playback state and effective gain, the master mix's level, the mixer's voice accounting, the listener, the output device the mix is reaching, and what the subsystem costs. Answers in edit mode as well as play mode.
local a = audio.observe(); print(a.audibleCount, a.levels.rms)
for _, v in audio.observe().voices do print(v.entity, v.mixerState, v.silence) end
modules/audio/peakSince
peakSince(window: number): number?
The loudest peak the master mix reached across the meter's windows
that closed after its windows count stood at window. audio.levels()
carries the window that closed last, so a reader sees the windows its own
frames happen to land on; this spans all of them, which is what measuring
a sound shorter than the gap between two reads takes. Take the mark from
audio.levels().windows before the sound starts, wait until windows has
advanced past the sound's length, then read the span.
Parameters
windownumber— Awindowscount taken fromaudio.levels()earlier.
local mark = audio.levels().windows
local peak = audio.peakSince(mark)
modules/audio/peaks
peaks(zaud: buffer | string, buckets: number): ({ number }?, string?)
The loudest sample in each of buckets equal spans of a clip, across
its channels, as an absolute value held to 1: the shape a waveform is
drawn from. A span is frames // buckets frames (at least one), and the
frames past buckets * span fall in no bucket; a clip shorter than
buckets frames fills one bucket per frame and leaves the rest at 0. The
payload is decoded a block at a time, so the work never holds the clip's
whole PCM, however long it runs.
Parameters
zaudbuffer | string— A ZAUD payload — a buffer or a binary string.bucketsnumber— How many spans to divide the clip into: an integer from 1 to 4096.
local bars = audio.peaks(clipRef:getBytes(), 96)
modules/audio/profile
profile(): AudioProfile
What the audio subsystem has cost since the profiling window opened —
the streaming pump, clip decode, clip encode, voice starts, and building
the observation itself. Every total is a SUM across that window rather
than a per-frame figure, and the window runs from the last
audio.resetProfile() or from engine start. For what a frame costs now,
reset, let frames pass, then divide by the frames the window reports.
audio.resetProfile(); task.wait(1); local p = audio.profile()
print("per frame:", (p.pump.totalMs + p.observe.totalMs) / p.frames)
modules/audio/resetProfile
resetProfile()
Open a new audio profiling window, discarding what the previous one
measured. Call this before timing a stretch of frames: without it
audio.profile() reports totals reaching back to engine start.
audio.resetProfile()
modules/audio/setChannelVolume
setChannelVolume(channel: string, volume: number)
Set the level of one mixer channel — the channel an Audio
component names, such as "sfx", "music" or "ambient", or any name the
scene invents. It scales every voice on that channel and nothing else,
reaches voices that are already playing, and comes back per voice as
gain.channel. A channel no level has been set on plays at unity.
Parameters
channelstring— The channel name, matchingAudio.channel.volumenumber— Channel level, 0..1.
audio.setChannelVolume("music", 0.3)
for _, v in audio.voices() do print(v.channel, v.gain.channel) end
modules/audio/setMasterVolume
setMasterVolume(volume: number)
Set the master level of the mix, on the engine's 0..1 amplitude
scale. It scales every voice whatever channel it plays on, reaches
voices that are already playing, and comes back per voice as
gain.master.
Parameters
volumenumber— Master level, 0..1.
audio.setMasterVolume(0.5)
modules/audio/setMuted
setMuted(muted: boolean)
Silence or unsilence the whole mix. A muted mix sounds nothing
whatever its master and channel levels read, every voice reports
masterSilent, and unmuting hands the levels back untouched.
Parameters
mutedboolean— Whether the mix is silenced.
audio.setMuted(true)
modules/audio/stream
stream(entity: any, options: AudioStreamOptions?): (AudioStream?, string?)
Play PCM a script produces while it sounds — synthesis, an emulator's
sound chip, procedural engine or wind noise, decoded voice — through the
voice of entity. Opens a stream at the options' sample rate and
channels and puts an audio source on the entity that plays it, so the
voice is placed, attenuated and Doppler shifted when spatial, follows
pitchValue / volumeValue, and is levelled by its channel and the
master mix like every other source. Push samples each frame with
stream:push, as many as stream:wanted() asks for, and the stream
stays latencyMs ahead of the mixer, further on a host whose frames run
long; a frame longer than the audio queued runs it dry, which
stream:status().underruns counts. Frames pushed before the voice starts
are the first it plays, and a stream not yet fed counts no underrun. Any sample
rate from 4000 to 192000 Hz plays at its own pitch. The entity carries
one voice: one already carrying an audio source is refused. The stream
lives while the entity's audio source names it: removing the source,
despawning the entity, putting another source in its place or rewriting
the source's stream field closes it.
Parameters
entityany(optional) — The entity whose voice plays the stream: a proxy or its id.optionsAudioStreamOptions?(optional) — AnAudioStreamOptions, every field optional. The PCM:sampleRate(4000 to 192000 Hz, default the mixer's rate),channels(1, the default, or 2 interleaved left then right),format("f32", the default, or "i16": how a pushed buffer or string is read),latencyMs(the least audio kept queued ahead of the mixer, default 100),bufferMs(the most the ring holds, default four timeslatencyMsand at least 500). The voice, as anAudiocomponent carries it:volume,pitch,spatial,maxDistance,rolloff,doppler,channel,sourceType,pitchValue,volumeValue, andautoplay(default true).
local synth = audio.stream(e, { sampleRate = 22050, channels = 2, latencyMs = 80, spatial = true })
local n = s:wanted(); for i = 0, n - 1 do buffer.writef32(buf, i * 4, math.sin(phase)); phase += step end; s:push(buf, n)
modules/audio/voice
voice(entityId: string): AudioVoice?
The voice on one entity, or nil when that entity carries no audio
source. An entity despawned since the frame the observation describes
answers with its report from that frame, so an onDestroyed handler reads
how the entity's voice stood as it went.
Parameters
entityIdstring— The entity's stable id.
local v = audio.voice(e.id); print(v and v.mixerState)
modules/audio/voiceAccounting
voiceAccounting(): AudioVoiceAccounting
How many voices the mixer can hold, how many are in use, how many
are free — read off the mixer's own tracks, so the free count is the one
a play call is granted or refused against. The two pools are reported
apart: capacity / inUse / free are the main track, which carries
the NON-spatial voices, while a spatial voice plays through its own
sub-track and is counted by spatialInUse instead. sourcesHolding
counts both pools from the sources that own them, so it equals
inUse + spatialInUse while every voice answers to a source.
local v = audio.voiceAccounting(); print(v.inUse .. "/" .. v.capacity)
local v = audio.voiceAccounting(); print(v.sourcesHolding - (v.inUse + v.spatialInUse))
modules/audio/voices
voices(): { AudioVoice }
Every live audio source with the mixer's opinion of it.
for _, v in audio.voices() do print(v.clip, v.gain.effective) end
modules/audio/whySilent
whySilent(entityId: string): (string?, string?)
Why the source on an entity is making no sound. Returns nil when it
IS sounding, and one of noBackend, noDevice, notResident, neverStarted,
refused, paused, ended, gainZero, channelSilent,
masterSilent, outOfRange when it is not — the nearest cause, so the
answer names the thing to change. A second
return carries the mixer's own words when it refused the source, and
"no audio source on this entity" when nothing there plays at all.
Parameters
entityIdstring— The entity's stable id.
local why = audio.whySilent(e.id); if why then print(why) end
modules/av/README
require("@builtin::modules.api.engine.av") -- av (also available as global 'av')
Audio/video encode + mux control — live streaming, recording, encoder/muxer primitives. Public Luau surface over the __av Internal FFI namespace.
Usage: local av = require("@builtin::modules.api.engine.av") Also available as global: av
modules/av/is_live
is_live(): boolean
True if a live-stream session is currently active.
if av.is_live() then av.stop_live() end
modules/av/is_recording
is_recording(): boolean
True if a recording session is currently active.
print("recording:", av.is_recording())
modules/av/live
live(opts: LiveOpts?): (string?, string?)
Start the live-stream encoder. The stream is served at
/engine/live.stream and reverse-proxied at
/stream/<instance>/live.stream as a binary length-prefixed
protocol consumed by the multiviewer UI's WebCodecs decoder. A
browser engine encodes it with the browser's WebCodecs encoder, and
the proxy reads it over the ZeroMind bridge and serves it at the
same /stream/<instance>/live.stream. When texture_handle is set,
the encoder reads from that GPU texture's guid (a Camera pointed at
it via setTargetTexture) instead of the scene's viewport: that's
how spectator cameras work. A stream runs beside an av.record
take. Returns the stream URL once the encoder is open and
streaming, or nil and the reason it is not: no encoder on this
engine that streams H.264, a stream already running, an odd
dimension, a session the encoder refuses (a size it will not
encode, a spectator texture with no size to stream at). The engine
opens the encoder, so the call waits for it: run it where it can
yield, wrapping it in task.spawn from a callback that cannot. The
reason also stands on av.status().liveError, which is where a
stream that ends on a failure later says why.
Parameters
optsLiveOpts?(optional) — Encoder options.
local url, why = av.live({ width = 1280, height = 720, fps = 60 })
modules/av/record
record(path: string, opts: RecordOpts?): (string?, string?, Durability?)
Start recording the engine output to a VFS path. Default dir
is /zero/runtime/recordings/ when path is not absolute: that
directory is writable in every mode and stays out of the world's
sync, so a take named relative to it is kept for the session and
read back with vfs.read. A destination under /zero/source/ is
world content, which the world's sync uploads when the take is
filed. The
take runs until av.stop_recording() unless opts bounds it
with max_duration_sec (seconds of the take's own clock) or
frames (captured frames); max_duration_sec wins when both are
given, and the bound in force reads back as
av.status().recordingBound. With
no chroma/range opts the format defaults to full-range 4:4:4
HEVC where the GPU supports it, else 4:2:0. In the browser the
browser's WebCodecs encoder converts the picture itself, so the take
is 4:2:0 in the code range that encoder chooses, which an H.264 or
AV1 file states, and grain above 0, chroma = "444" and any stated range
are refused by name, and the master mix is encoded by the
browser's WebCodecs AudioEncoder. On the "software"
backend the take is H.264 encoded on the CPU, which costs the run
it records: read av.status().recordingAchievedFps against
recordingRequestedFps to see the rate it reached. What the take
did with the master mix reads back as
av.status().recordingAudio. cadence picks the clock the take
stamps its frames from. "realtime" (the default) stamps each
frame with the wall-clock slot it was captured in, so a recorded
session is watched back at the speed it happened and an engine
ticking under fps leaves slots empty. "frame" stamps every
rendered frame one fixed slot after the last, so a timeline whose
own clock advances a step per rendered frame — a cutscene, a
scripted demo, anything on a fixed timestep — is delivered at the
length that timeline runs to, however slowly the engine drew it: a
take of frames = n at fps is n / fps seconds of film, and a
max_duration_sec bound counts that film's seconds. A "frame"
take records silent, because the master mix plays in wall-clock
seconds and cannot share a file with a fixed-step picture;
recordingAudio says so, and an explicit audio = true beside it
is refused. Record the sound as a second "realtime" take.
camera names the camera the take draws its film from — an entity
proxy, an entity id, or an entity name. That camera holds the viewport
for as long as the take runs, above the priority contest and above
camera.setEditorOverride, so the film is its view and the frames
carry everything the presented frame carries. Only frames that camera
drew go into the film, and a camera that never draws the viewport ends
the take with the reason on av.status().recordingError — so a take is
the view it named or it is no take. The camera belongs to the take:
nothing is written to it, and the viewport is back under its own
contest the moment the take ends. It reads back as
av.status().recordingCamera while the take runs. Omitted, the take
records whichever camera holds the viewport, which in an engine on the
editor profile is the editor's own fly camera rather than the scene's.
renderLayers is the render-layer include spec the viewport is
drawn under for as long as the take runs — the same token string a
capture takes: all seeds every layer, name adds one and !name
drops one, so "all !EditorUI !debug" films the scene without the
editor's chrome or the authoring overlays (gizmos, light and probe
icons, frustums, collider wireframes) over it, and
"all !ui !EditorUI !debug" drops the authored HUD as well. The
viewport admits geometry and screens by that one spec, so it states
the whole picture. It belongs to the take: nothing is written to the
camera it is stated against, and the moment the take ends — its
bound reached, stopped, or refused — the viewport is back under the
camera's own spec. While a take states layers, the window shows what
the film holds, and av.status().recordingLayers reads the spec
back. Omitted, the take records the engine output as presented.
width / height are the film's size: the whole of the presented
frame (in an editor layout, the rect the scene is drawn into) is
resampled to it, and a side left out takes the presented frame's.
Returns the destination path of a session that is open and
recording, or nil
and the reason it is not: an adapter that cannot encode, a take
already running, an option the encoder rejects, a resolution the
device refuses, a destination the VFS cannot write (a read-only
path, a directory, a host filesystem path). The engine opens the
session, so the call waits for it: run it where it can yield,
wrapping it in task.spawn from a callback that cannot. How a
take finished reads back as
av.status().recordingEnd; a refused request puts its reason
there and on recordingError and leaves no take report behind,
while a request refused because a take is already running leaves
that take's report as it is.
Parameters
pathstring— VFS destination path, returned in its/zeroform; a relative name records under/zero/runtime/recordings/.optsRecordOpts?(optional) — Encoder options (optional).
local clip = av.record("intro.mp4", { fps = 60 })
local film = av.record("cut.mp4", { fps = 24, frames = 24 * 181, cadence = "frame" })
local clean = av.record("take.mp4", { fps = 24, renderLayers = "all !EditorUI !debug" })
local shot = av.record("film.mp4", { fps = 24, frames = 240, camera = "FilmCamera" })
local take, why, d = av.record("take.mp4", { fps = 24 })
if d and d.playShadow then log.warn(d.warning .. " " .. d.playShadow) end
modules/av/save
save(path: string, opts: SaveOpts?): (boolean, string, SaveReport?)
Save a finished take to the device of the person at the screen, so
the recording outlives the session: /zero/runtime/recordings/ is gone
when the engine stops (and, in the browser, when the tab closes). path
names the take the way av.record did: a relative name is the take of
that name under /zero/runtime/recordings/, and any VFS path works too.
The person decides where it lands. In the browser the take downloads at
once when the save rides a click or key press of the person at the
screen, so call it from a button's click handler; a save with no such
gesture behind it (an agent, a timer, the end of a take) makes the page
show the person an offer they save with a click of their own, because a
browser starts a download only for a person who just acted. A native
engine opens the host's save dialog in their downloads folder, with the
take's name filled in, and writes it where they choose; an engine with
no window has no person at its screen and refuses. The call waits for
the first answer, so run it where it can yield (task.spawn from a
callback). Returns true, a sentence saying where the take went, and the
report { state, detail, name, size, path } with state
"saved" (on the device) or "offered" (in front of the person, as the
page's offer or the save dialog); or false and why it was refused: a
take still recording (it is filed when it ends), no file at the path, a
host path, a name with a folder in it, no window, or a take too large
for the browser to hold, which the page shows the person as well. The
saved file is the take byte for byte. userfile.save saves any other
file the engine holds.
Parameters
pathstring— The take: its name under/zero/runtime/recordings/, or a VFS path.optsSaveOpts?(optional) —{ name }, the file name the device gets (the take's own when omitted).
local ok, where = av.save("take.mp4")
local ok, where, report = av.save("take.mp4", { name = "boss-fight.mp4" })
modules/av/status
status(): AvStatus
Report the encoder subsystem's state. Always available
regardless of GPU support. backend is the encode backend in use:
"vulkan" or "vaapi" on an adapter with a media engine,
"software" where a native engine encodes on the CPU, and
"webcodecs" in the browser, where the browser's own WebCodecs
encoder takes the frames. hardware is true for the first two, and
in the browser when the browser reports a hardware encoder for the
default codec, so a caller that pays for the take in engine time
knows which it is getting. codecs lists what the backend encodes
with the recording default first (h264 in the browser, which every
engine plays back with video.create). reason is "supported",
"not_probed" before the engine has asked its encoder,
"unsupported_adapter" for a native adapter with no encoder, or
"unsupported_browser" for a browser whose WebCodecs encodes none
of the codecs the engine offers. live is true while the
av.live stream is running, and liveError is why the most recent
stream was refused or ended on a failure: nil while one runs and
after av.stop_live() ended one that had opened, and the reason
that names av.stop_live() after it ended one still opening. A take of its own reads back on the
recording fields: recording is the destination of the take in
flight, recordingBound what will end it, recordingEnd how the
most recent one ended, and recordingError why one produced no
file. recordingAudio is the codec the take is writing the master
mix with ("opus"), or the reason the file carries no audio track
— read it to tell a film with a soundtrack from a silent one.
recordingLayers is the render-layer include spec the armed take is
drawing the viewport under, in the words its caller wrote, and nil for
a take that stated none — the reading that answers what is in the
picture rather than how much of it there is. recordingCamera is the
entity id of the camera the take's most recent captured frame was drawn
from, and stands as the source of the most recent take once that take
has ended — it is read off the frame the engine drew, so it answers
which view a film holds whether or not the take named a camera.
recordingCadence is the clock the take stamps its frames from,
"realtime" or "frame", and so what the tally below is a reading
against. What the take produced reads off recordingFrames,
recordingBytes (every byte the take has produced so far, climbing
while it runs and ending equal to the size of the file),
recordingSeconds (the timeline those frames cover),
recordingAchievedFps (the rate they arrived at) and
recordingRequestedFps (the rate asked for) — live while a take
runs, and its final tally once it ends. On "realtime" the
requested rate is a ceiling and an engine ticking under it reaches
less; on "frame" every rendered frame is a slot of the recorded
timeline, so recordingSeconds is that timeline's length and
recordingAchievedFps is the rate it plays back at.
recordingDurability is where the film in flight lands on the terms
standing now — the report av.record returns as its third value, asked
again for the take still running, so a caller polling status learns the
play shadow is taking the film in time to keep it, a take that entered
play after it opened included. It is present while a take names a
destination.
local s = av.status(); print(s.backend, s.hardware, s.recordingAudio)
modules/av/stop_live
stop_live(): boolean
Stop any active live-stream session.
av.stop_live()
modules/av/stop_recording
stop_recording(handle: string?): (boolean, string?)
Stop the active recording (or the one for the given promise
handle). Returns true when a recording was armed at call time. A
false return carries a second value naming how the most recent
recording already ended (the bound it reached, or the failure
that cut it short), and nil when no recording has run at all. The
engine finalizes the take once the call returns. A take stopped
before its first frame is captured runs on until that frame lands
and ends holding it, and one whose first frame has not landed 120
frames after the stop ends with none. Wait for
av.is_recording() to go false, then read what it produced off
av.status().
Parameters
handlestring?(optional) — Promise handle of a specific recording (optional).
local stopped, ended = av.stop_recording()
modules/base64/README
require("@builtin::modules.api.engine.base64") -- base64 (also available as global 'base64')
Base64 encode / decode between binary and text Luau strings (standard RFC 4648 alphabet, padded). Public Luau surface over the __base64 Internal FFI namespace.
Usage: local base64 = require("@builtin::modules.api.engine.base64") Also available as global: base64
modules/base64/decode
decode(text: string): (string?, string?)
Decode standard-alphabet base64 text back to the original binary string.
Parameters
textstring— Base64 text to decode.
local bytes = base64.decode(encoded)
modules/base64/encode
encode(bytes: buffer | string): string
Encode a binary string to standard-alphabet (padded) base64 text.
Parameters
bytesbuffer | string— Binary bytes to encode.
local text = base64.encode(jpegBytes)
modules/bitmask_bits/README
require("@builtin::modules.bitmask_bits") -- bitmask_bits
The bitmask field-constraint validator: a constrained value must be a whole number that fits the declared width, so what the field reads back is a mask the system consuming it can actually address. A rejection names the width and why the value is not a mask of it. Registers itself with the generic field_constraints registry on load. nil passes, so a mask field may be left unset.
Usage: local bitmask_bits = require("@builtin::modules.bitmask_bits")
modules/blend/README
require("@builtin::modules.api.engine.blend") -- blend (also available as global 'blend')
Record-stride blend primitives over Buffer slices — layout registry + weighted/lerp combiners. Public Luau surface over the __blend Internal FFI namespace.
Usage: local blend = require("@builtin::modules.api.engine.blend") Also available as global: blend
modules/blend/destroyLayout
destroyLayout(handle: number): boolean
Drop the layout from the registry.
Parameters
handlenumber— Layout handle.
modules/blend/layout
layout(slots: { BlendSlot }, totalStride: number?): number?
Register a record-stride layout. Each slot is
{ offset, stride, op } where op is "lerp" / "slerp" /
"sum" / "step". Slerp slots must have stride 4.
totalStride defaults to max(offset + stride) across slots;
pass an explicit value when records contain padding past the
last slot.
Parameters
slots{ BlendSlot }— Array of slot tables.totalStridenumber?(optional) — Optional explicit record stride.
local l = blend.layout({ { offset = 0, stride = 3, op = "lerp" } })
modules/blend/lerpInto
lerpInto(outBuffer: Substrate.TypedBuffer, layout: number, aBuffer: Substrate.TypedBuffer, bBuffer: Substrate.TypedBuffer, t: number): boolean
Two-input crossfade shortcut. Equivalent to
blend.weightedInto(out, layout, { {a, 1-t}, {b, t} }).
Faster for the common A/B fade case because it skips the
inputs-table walk.
Parameters
outBufferSubstrate.TypedBuffer— The buffer written into.layoutnumber— Layout handle.aBufferSubstrate.TypedBuffer— The A side of the fade.bBufferSubstrate.TypedBuffer— The B side of the fade.tnumber— Crossfade weight on B (0..1).
modules/blend/weightedInto
weightedInto(outBuffer: Substrate.TypedBuffer, layout: number, inputs: { BlendInput }): boolean
Combine N weighted input buffers into the output buffer
using the layout's slot ops. The output buffer's length must
be a whole multiple of layout.totalStride; every input
buffer must be at least as long as the output. Returns false
on any handle / size mismatch.
Parameters
outBufferSubstrate.TypedBuffer— The buffer written into.layoutnumber— Layout handle.inputs{ BlendInput }— Array of{ buffer, weight }.
modules/buoyancy/README
require("@builtin::systems.oceans.modules.buoyancy") -- buoyancy
Floats a rigid body on the water Physics.water answers for (a sea, a lake, a river, a pool) — displacement, damping and the righting moment that keeps a hull upright.
Usage: local buoyancy = require("@builtin::systems.oceans.modules.buoyancy")
modules/buoyancy/apply
apply(self, dt: number): boolean
Step the body once. The Buoyancy component calls this every frame;
call it yourself only when driving a body without that component.
Parameters
selfany(optional)dtnumber— Seconds since the last step.
float:apply(1 / 60)
modules/buoyancy/attach
attach(target: any, options: any?): (any?, string?)
Float a rigid body on the water. The entity needs a dynamic Physics
body; the hull is measured from what it draws unless sizeX/Y/Z say
otherwise.
Parameters
targetany(optional) — The entity id or proxy to float.optionsany?(optional) —{ density, damping, angularDamping, columns, sizeX, sizeY, sizeZ, mass, gravityScale, ocean }.densityis relative to water, and the lower it is the higher the hull rides.
local float = buoyancy.attach(barrel, { density = 0.4 })
modules/buoyancy/clear
clear()
Stop floating every body. Each one is released, so a body driven by a
Buoyancy component stops being pushed as well.
buoyancy.clear()
modules/buoyancy/columns
columns(size: any, columns: number): { { x: number, z: number } }
The local-space footprint of a hull's columns: an evenly spaced grid over its X/Z extent, each column standing for an equal share of the hull.
Parameters
sizeany(optional) —{ x, y, z }full extents of the hull in its own space.columnsnumber— Grid resolution per horizontal axis. 1 gives a single central column, which floats but cannot right itself; 2 is the smallest grid that produces a righting moment.
local cols = buoyancy.columns({ x = 4, y = 1, z = 2 }, 2)
modules/buoyancy/configure
configure(self, options: any)
Reconfigure a floating body. Any field may be passed; anything omitted is left as it was.
Parameters
selfany(optional)optionsany(optional) —{ density, damping, angularDamping, columns, sizeX, sizeY, sizeZ, mass, gravityScale, ocean }.massandgravityScalestand in for the rigid body's own, which is what they are read from otherwise.
float:configure({ density = 0.8 })
modules/buoyancy/destroy
destroy(self)
Stop floating this body. The rigid body keeps everything else about it.
Parameters
selfany(optional)
float:destroy()
modules/buoyancy/forEntity
forEntity(entityId: string): any
The floating body on an entity, if it has one.
Parameters
entityIdstring— The entity's id.
local float = buoyancy.forEntity(barrelId)
modules/buoyancy/list
list(): { any }
Every body currently floating.
print(#buoyancy.list())
modules/buoyancy/restingY
restingY(waterY: number, height: number, density: number): number
The height a hull of this density displaces its own weight at on flat water — the waterline its lift balances at, with no wave motion in it.
Parameters
waterYnumber— World Y of the undisturbed surface.heightnumber— The hull's full height.densitynumber— The hull's density relative to water.
local y = buoyancy.restingY(0, 1, 0.45)
modules/buoyancy/submergedFraction
submergedFraction(centreY: number, waterY: number, height: number): number
How much of a column stands under water: 0 clear of it, 1 fully under.
Parameters
centreYnumber— World Y of the column's mid-height.waterYnumber— World Y of the surface above it.heightnumber— The column's full height.
local f = buoyancy.submergedFraction(0.2, 0.0, 1.0)
modules/buoyancy/submersion
submersion(self): number
The share of the hull that was under water on the last step, averaged over its columns. 0 is clear of the sea, 1 is fully submerged.
Parameters
selfany(optional)
print(float:submersion())
modules/buoyancy/waterline
waterline(self): number?
The world Y of the water surface under the hull's centre on the last step — where the waterline stood, wave motion included.
Parameters
selfany(optional)
print(float:waterline())
modules/cachedIndirect/README
require("@builtin::systems.radianceCache.cachedIndirect") -- cachedIndirect
Indirect diffuse light that is gathered once per patch of world and reused, rather than re-gathered for every pixel of every frame. It is the scene-wide user of @builtin::systems.radianceCache.radianceCache and the worked example of what a cache buys a lighting technique: the same bounce, converged over frames instead of within one, at a fraction of the gathering per frame.
Usage: local cachedIndirect = require("@builtin::systems.radianceCache.cachedIndirect")
modules/cachedIndirect/active
active(): boolean
Whether the cached-indirect passes are running this frame.
if cachedIndirect.active() then ... end
modules/cachedIndirect/cache
cache(): any
The cache this effect drives. The render feature takes its passes from here, and a script can read its counters or invalidate it through the same handle.
cachedIndirect.cache():stats()
modules/cachedIndirect/clear
clear()
Turn the cached bounce off and release the passes, the cache table and
the resolve target. The other settings are kept, so a later
set({ intensity = ... }) brings the effect back at the same settings and
refills the table over history * stride frames.
cachedIndirect.clear()
modules/cachedIndirect/get
get(): { [string]: number }
The cached-indirect settings currently in force.
local s = cachedIndirect.get().stride
modules/cachedIndirect/invalidate
invalidate()
Declare that the lighting changed, so every patch takes its next gather
whole instead of averaging it into light that is gone. The cache is rebuilt
within stride frames.
cachedIndirect.invalidate()
modules/cachedIndirect/set
set(opts: CachedIndirectOpts?): { [string]: number }
Set the scene's cached indirect light. Any omitted field keeps its
current value. An intensity of 0 turns it off and releases the passes.
Parameters
optsCachedIndirectOpts?(optional) — Cached-indirect settings — seeCachedIndirectOpts.
cachedIndirect.set({ intensity = 1.0, stride = 8 })
modules/camera/README
require("@builtin::modules.api.engine.camera") -- camera (also available as global 'camera')
Script-facing camera queries: the main scene camera, the on-screen render camera, the editor fly-camera, per-frame view data, and the camera observation — which cameras drew this frame, with what projection, into what, and at what cost. Public Luau surface over the __camera Internal FFI namespace. A physical camera on the machine (a webcam, a phone's front or back camera) is cameraInput, which shows its live picture as a texture.
Usage: local camera = require("@builtin::modules.api.engine.camera") Also available as global: camera
modules/camera/active
active(): string?
Entity id of the on-screen render camera this frame — whichever camera wins the viewport by priority (the editor fly-camera in edit mode, the gameplay camera in play). Render features, billboards, and input bases that must follow the human's on-screen view read this.
local camId = camera.active()
modules/camera/cut
cut()
Declare that the camera on screen cuts: the next frame it draws stands somewhere it did not travel to. Motion vectors are the difference between where a surface projects now and where it projected on the camera's previous frame, and everything temporal reads that difference — the shutter reconstructs the frame by walking it, a temporal resolve reprojects its history along it. Across a cut that difference describes a displacement no surface made, so the frame is reconstructed from taps a whole screen away and belongs to neither shot. A declared cut leaves the camera with no previous frame for exactly one frame, which is the state its very first frame is already in, so every consumer reads zero motion across the cut. Declare it in the same step that places the camera at the new station; declaring it again before that frame draws still costs the one frame. Handing the viewport from one camera to another is already a cut without being declared one: the incoming camera stands where it always stood, and the engine performs the handover, so it is what states it.
camera.cut(); entity(camId).position = { 40, 6, -12 }
modules/camera/editor
editor(): string?
Entity id of the editor fly-camera (the EditorOnly authoring camera), or
nil if the scene has none. This is the camera the editor viewport renders
through, so it is the one a capture of the screen sees. Its pose is its
entity transform: assign entity(id).position to move it and aim it with
the camera toolbox's lookAt, which makes a screen capture repeatable
instead of whatever pose the instance booted with.
local camId = camera.editor()
local id = camera.editor(); entity(id).position = { 12, 8, 12 }; tools.use("camera", "lookAt", id, { 0, 0, 0 })
modules/camera/editorOverride
editorOverride(): string?
Entity id currently overriding viewport selection, or nil when the viewport is decided by highest-priority-wins.
local owner = camera.editorOverride()
modules/camera/get
get(target: (string | EntityRef)): CameraReport?
One camera's report from the observation — the same record
camera.list yields, for the camera the caller names. Takes an entity id,
an entity name, or an entity proxy, the same way the camera tools do.
Parameters
target(string | EntityRef)— Entity id, entity name, or entity proxy of the camera to report on.
local c = camera.get(camera.active()); print(c.frame.far, c.authored.far)
local c = camera.get("minimapCam"); print(c.rendering, c.reason)
modules/camera/list
list(): { CameraReport }
Every camera in the world as a compact row each, ordered the way the
renderer resolves the on-screen camera: highest priority first. Reads the
same observation camera.observe does, so a row can never disagree with
the full report about whether a camera is enabled or which one drew.
for _, c in ipairs(camera.list()) do print(c.name, c.enabled, c.rendering) end
modules/camera/main
main(): string?
Entity id of the main scene camera — the scene camera the viewport is
drawn from, and while the editor fly-camera holds the screen, the scene
camera that would take it. The gameplay/PlayerPrototype camera, an
agent-placed scene camera, or a cutscene camera. Never the editor camera;
nil if the scene has only the editor camera. It comes off the same
selection the frame does, so writing a pose to it moves what is drawn
whenever a scene camera is on screen. The scene camera with the highest
authored priority takes it; cameras tied on priority settle on the order
the frame visits them, so a scene that needs a specific camera — a
prototype and the clone play makes of it both stand at 0 — states a
distinct priority rather than resting on that order. For the camera drawn
on screen whichever partition owns it, use camera.active().
local camId = camera.main(); local cam = camId and entity(camId)
modules/camera/motionTally
motionTally(): { frames: number, withoutHistory: number }
Frames the camera on screen has drawn, and how many of them had no previous frame to difference their motion vectors against — its first frame, every declared cut, and every frame the viewport changes hands on. Both counts are monotonic across the session, so two readings either side of a run say what happened in between.
local before = camera.motionTally().withoutHistory
modules/camera/observe
observe(): CameraObservation?
Every camera in the world, for the frame that has just been drawn.
lastRender retains the latest submitted frame, target and pending build
count while the camera exists, including frames when it is disabled.
engineFrame identifies the script frame (time.frameCount()) that drew.
Answers "why is this camera not showing what I expect" in one call:
rendering says whether each camera drew and reason names the single
cause when it did not — "disabled", "entityInactive", "targetMissing",
"noLayers", "outranked", "notDrawn", "paced" for a texture camera
whose per-frame render waits for the next frame the frame pacer admits, or
"awaitingPipelines" for a deferrable render queued behind pipeline
builds. Explicit camera renders draw the requested frame and report its
pending builds in lastRender.
pipelinesPending counts the builds a camera is waiting on: what a held
render is queued behind, and — for a camera that DID draw — what the frame
it drew was drawn WITHOUT. It is absent once a camera's frame was drawn
with everything the scene asked for. Each camera carries both
projections: authored is what the Camera component holds and frame is
what the renderer actually built, with mismatch naming every field the
two disagree on — so a clip range or a lens the frame did not use is one
field read. frame, viewProj, frustum and the cost numbers describe
a camera that drew; every cost is for that one frame.
One snapshot is published per drawn frame, from after the frame is drawn,
so a read describes the last frame rather than the world at the instant of
the call — a write and a read in one script step return the frame that ran
before the write. Put a task.wait() between them to compare a camera
either side of a change; frame counts the frames observed, so a poll can
wait for it to advance.
local obs = camera.observe(); for _, c in ipairs(obs.cameras) do print(c.name, c.rendering, c.reason) end
local dark = {}; for _, c in ipairs(camera.observe().cameras) do if not c.rendering then table.insert(dark, c.name .. ": " .. tostring(c.reason)) end end
modules/camera/setEditorOverride
setEditorOverride(entityId: string?)
Give one camera the viewport outright, or pass nil to clear it. While
set, that camera IS the on-screen camera and priority is never consulted,
so no authored priority can take the viewport from it — which is what makes
an authoring camera safe to fly over a scene holding a camera at any
priority. An override naming a camera that is despawned or disabled falls
back to highest-priority-wins rather than blanking the screen.
The override holds across a change of engine.mode: the flip rebuilds
the scene and materialises its cameras again, and an override whose
camera the rebuilt scene holds under the same entity id names it again
once the rebuild has ended. One whose camera the rebuilt scene does not
hold (a temporary camera, or one play replaces with a clone of its own)
ends there: a warning notice and the engine log name the camera it held,
and the wld.play / wld.edit result reports it under viewportOverride.
An override on a camera that draws nothing in the new mode (an EditorOnly
camera sits out play) stands, and the highest-priority camera holds the
viewport until its camera draws again; viewportOverride.onScreen names
the camera holding it.
Parameters
entityIdstring?(optional) — Entity id of the camera to route the viewport to, or nil to clear.
camera.setEditorOverride(camera.editor())
camera.setEditorOverride(nil)
modules/camera/viewData
viewData(target: ((string | EntityRef)?)): CameraView?
Camera render data. Called with no argument it is the active viewport
camera's data for this frame: world position, which projection it drew and
the field describing that frame, viewport pixel size, the 6 world-space
frustum planes (the same inward-pointing, normalized planes the renderer
culls with), and the view-projection matrix. The camera state a render
feature needs for camera-relative work — LOD selection, frustum culling,
billboards. Render features also get it as ctx.camera.
Called with an entity id it is that camera's data, read from the frame's
camera observation, and carries the identity the bare form has no room for:
which camera it describes, which frame it was built for, what it rendered
into, and the render layers it resolved to.
Parameters
target((string | EntityRef)?)(optional) — Entity id, name, or proxy of the camera to read, or nil for the viewport camera.
local c = camera.viewData(); if c then print(c.position.x, c.fovY) end
local minimap = camera.viewData("minimapCam"); print(minimap.output.target, minimap.viewport.w)
modules/cameraInput/README
require("@builtin::modules.api.engine.cameraInput") -- cameraInput (also available as global 'cameraInput')
Physical cameras as live textures and pixel sources: list the capture devices (a webcam, a phone's front and back cameras), open one as a feed, show its live picture anywhere a texture goes (a material, a UI image, a recording), and read its pixels. Public Luau surface over the __cameraInput Internal FFI namespace.
Usage: local cameraInput = require("@builtin::modules.api.engine.cameraInput") Also available as global: cameraInput
modules/cameraInput/awaitRunning
awaitRunning(self: CameraFeed, timeoutSeconds: number?): (boolean, string?)
Wait until the feed is running, and report whether it got there. Returns
as soon as the feed leaves starting and permissionPending, or when
timeoutSeconds have passed, whichever comes first: a permission prompt
nobody answers never settles, so the wait is always bounded.
Parameters
selfCameraFeedtimeoutSecondsnumber?(optional) — Seconds to wait at most. Defaults to 10.
local ok, why = feed:awaitRunning(15); if not ok then print(why) end
modules/cameraInput/devices
devices(): { CameraDevice }
Every capture device the platform offers: id is what
cameraInput.open takes as device, name the label a person
recognises, facing which way it points. Until camera access has been
granted, id and name read as empty strings and facing as
"unknown": the list is part of what the permission protects, so a
first open takes the default camera or a facing, and the list names the
devices after that.
for _, d in ipairs(cameraInput.devices()) do print(d.name, d.facing) end
modules/cameraInput/feeds
feeds(): { CameraFeedEntry }
Every open feed, with the owning context that opened it (scope,
the same tag scopes.list() shows), whose end stops the feed.
for _, f in ipairs(cameraInput.feeds()) do print(f.id, f.state, f.scope) end
modules/cameraInput/onDeviceChange
onDeviceChange(callback: (devices: { CameraDevice }) -> ()): () -> ()
Call callback with the new device list every time a camera is
added or removed, or the platform names its devices after access is
granted. Each listener is watched by a task of the context that
registered it, so a listener a component registered ends when that
component is removed, and every other listener goes on hearing changes.
Parameters
callback(devices: { CameraDevice }) -> ()— Receives the device list, ascameraInput.devices()returns it.
Returns () — A function that removes this listener.
local off = cameraInput.onDeviceChange(function(devices) print(#devices) end)
modules/cameraInput/open
open(opts: CameraOpenOpts?): (CameraFeed?, string?)
Open a camera as a feed. Returns the feed at once; it reads
permissionPending while the platform asks for access, then running
(or denied / failed with a reason). Wait with feed:awaitRunning().
feed.texture is a texture handle that shows the camera's current frame:
put it on a surface as a session material's base_color_texture
(renderer.material.create, worn with Model:applySessionMaterial) or in
a slot of a material that exists (renderer.material.setTexture(key, "base_color_texture", feed.texture)), in UI as
{ type = "image", props = { src = feed.texture } },
and av.record films it like any other scene content.
device names a camera by the id or name cameraInput.devices() lists;
facing asks for the "front" or "back" camera instead; with neither,
the platform's default camera opens. width, height and fps are hints:
the device delivers the nearest it can, and feed:status() reports what it
delivers. A second feed on a camera already open shares it.
Returns nil and the reason for a request refused before any camera is touched: a hint outside its range, a facing other than front or back, a device the platform does not offer.
Parameters
optsCameraOpenOpts?(optional) —{ device, facing, width, height, fps }, every field optional.
local feed = cameraInput.open({ facing = "front", width = 1280, height = 720 })
local screen = feed and renderer.material.create({ shader = "unlit", textures = { base_color_texture = feed.texture } }, "tv_screen")
modules/cameraInput/readPixels
readPixels(self: CameraFeed, rect: CameraRect?): (any, string?)
Read the pixels of the frame the feed is showing now, without stopping
it: the whole frame, or the rectangle { x, y, w, h } of it in pixels from
the top-left corner. The answer is a TextureCpuHandle holding RGBA8
pixels (:readPixel(x, y), :rgba(), :encodePng()); :unload() it once
done. Returns nil and the reason while no frame has arrived, after the feed
stopped, or for a rectangle outside the frame.
Parameters
selfCameraFeedrectCameraRect?(optional) — Optional{ x, y, w, h }.
local cpu = feed:readPixels(); if cpu then print(cpu:readPixel(0, 0)); cpu:unload() end
modules/cameraInput/status
status(self: CameraFeed): CameraStatus
Where the feed stands. width, height and fps are what the device
delivers, whatever the open asked for. frames advances once per new
frame, so two reads that show the same count saw the same picture.
rotation is the degrees clockwise the picture turns to stand upright on
the display, and follows a phone's screen as it turns; mirrored says the
picture, once turned, reads as the person expects only when shown
mirrored, which is how a front camera is shown. reason carries the
platform's own message for denied and failed, and what is being waited
on for permissionPending.
Parameters
selfCameraFeed
local s = feed:status(); print(s.state, s.width, s.height, s.frames)
modules/cameraInput/stop
stop(self: CameraFeed): boolean
Stop the feed. The camera is released once no other feed is reading it, which is what turns the platform's camera indicator off. True when the feed was open.
Parameters
selfCameraFeed
feed:stop()
modules/cameraInput/stopAll
stopAll(): number
Stop every open feed and release every camera, whatever opened them.
cameraInput.stopAll()
modules/camera_spawner/README
require("@builtin::modules.api.engine.camera_spawner") -- camera_spawner
DEPRECATED: v7 scenes author their own Camera entity. This procedural primary-camera spawner serves legacy v6 scenes only; M.ensure stands down (returns early) for any scene carrying a string playerIntent.
Spawns the scene's primary Camera entity on non-additive layers.onLoad, for legacy v6 scenes. The per-mode world default (world.camera_default_<mode>) is the fallback; scene-level overrides via sceneProxy.settings.camera win when present. Missing refs → log.error + skip (no hardcoded fallback).
Usage: local camera_spawner = require("@builtin::modules.api.engine.camera_spawner")
modules/carried/README
require("@builtin::modules.api.engine.carried") -- carried (also available as global 'carried')
Carried mounts: content of another world, mounted read-only for this session at /zero/runtime/carried/<key>/ without installing it. A closure is named by the address of its manifest (closureSha, the sha-256 ZeroMind serves the manifest at); the engine reads the manifest and every file it names through the device's content cache, lays the files out the way their world places them, and states where the mount stands in <key>/status. Nothing a mount holds is content of the open world: it is in no listing of its assets, no dependency table, no push and no zm status, and the open world's code cannot require from it. A mount lives while some caller holds it and the session lasts.
carried.mount(closureSha, { key = "ada.avatar" }) holds a mount and
starts filling it; carried.wait(key) yields until it settles;
carried.status(key) reads where it stands; carried.release(key)
lets go of it. carried.mountDraft(assetPath) mounts the closure of an
asset of the open world's working tree the same way, for a preview on
this engine. carried.resolve(key, reference) answers what a reference
written inside the closure names. guides { path: "core/carried" }
covers the whole surface.
Usage: local carried = require("@builtin::modules.api.engine.carried") Also available as global: carried
modules/carried/heldBytes
heldBytes(): number
The bytes every carried mount holds in this engine's memory.
print(carried.heldBytes())
modules/carried/list
list(): { Status }
The status of every carried mount of this session.
for _, m in carried.list() do print(m.key, m.state) end
modules/carried/manifest
manifest(key: string): string?
The manifest of the ready mount at key: the JSON bytes the
content store served ($schema zero/closure/v1, root, and entries,
one per file and folder with its world path, asset_guid, checksum,
size_bytes, kind and origin, plus one engine entry per builtin it
was built against). Their sha-256 is the mount's closureSha. Nil until
the mount is ready.
Parameters
keystring— The mount's key.
local entries = require("@builtin::modules.json").decode(carried.manifest("ada.avatar")).entries
modules/carried/mount
mount(closureSha: string, options: MountOptions?): Status
Hold the carried mount of the closure whose manifest address is
closureSha and start filling it, unless it is already held. The mount
stands at /zero/runtime/carried/<key>/; a key holds one closure for as
long as anyone uses it, and every mount of the same closure at the same
key holds it once more. Answers at once with the mount's status (state
resolving while it fills); carried.wait yields until it settles.
Raises when the key is malformed, closureSha is no sha-256, or the key
holds another closure.
Parameters
closureShastring— The sha-256 hex digest of the closure's manifest.optionsMountOptions?(optional) —key: the mount's folder name (one path segment of letters, digits,.,_,-), defaultclosure-<first 16 hex digits>;commit: the commit the closure was published at, stated in the status.
local m = carried.mount(sha, { key = "ada.avatar" }); local s = carried.wait(m.key)
modules/carried/mountDraft
mountDraft(assetPath: string, options: MountOptions?): Status
Hold a draft carried mount of the asset at assetPath, an asset of
the open world's working tree (or of your home folder): the engine walks
the asset and every asset its files reference, writes that closure and
its manifest into the device's content cache, and mounts it from there
the way a published closure mounts, labelled draft = true. It is this
engine's alone. Mounting it again rebuilds it from the tree as it stands.
A draft holding a home folder's content is that folder's: it is made for
code that reaches the folder, and its files, listing, status and
manifest answer that code alone. Raises, naming the folder, when the
asset or anything it reaches is in a home folder the calling code does
not reach.
Parameters
assetPathstring— The asset, e.g./zero/source/chars/ada.avatar.optionsMountOptions?(optional) —key: the mount's folder name, defaultdraft-<asset name>.
local d = carried.mountDraft("/zero/source/props/lamp.model"); carried.wait(d.key)
modules/carried/release
release(key: string): number
Let one holder of the mount at key go. The last one takes it
down: its folder leaves /zero/runtime/carried/ and its bytes leave this
engine's memory, while the device's content cache keeps them for the
next mount. Raises when no mount is held at key.
Parameters
keystring— The mount's key.
carried.release("ada.avatar")
modules/carried/resolve
resolve(key: string, reference: string): string?
What reference, written by content of the closure at key,
names: a guid the closure carries, a path of its world
(props/lamp.model, /zero/source/props/lamp.model) or an identity of
its world (props.lamp) answers the file inside the mount; a reference
to the engine library answers the library asset, taken to the version of
an engine builtin the closure was built against when the mount holds that
version. The open world's own content answers none of it. Nil when
nothing answers.
Parameters
keystring— The mount's key.referencestring— A guid, path, identity or library reference.
local tex = carried.resolve("ada.avatar", "chars.ada_albedo")
modules/carried/status
status(key: string): Status?
Where the mount at key stands, as <key>/status states it:
state is resolving, fetching, measuring, ready, refused or
none; reason is a word saying why nothing is mounted (unreachable,
notFound, incomplete) or why the closure was refused, with detail
the sentence; bytesFetched / bytesTotal count the files read;
measured counts files, folders and bytes per kind once ready;
builtin names how each engine builtin the closure was built against
resolves (host, mount, or hostOtherVersion with why). Nil when
no mount is held at key, and when the mount holds a home folder's
content the calling code does not reach.
Parameters
keystring— The mount's key.
print(carried.status("ada.avatar").state)
modules/carried/wait
wait(key: string, seconds: number?): Status
Yield until the mount at key settles (ready, refused or
none) or seconds pass, and answer its status then. Raises when no
mount is held at key, or when it holds a home folder's content the
calling code does not reach.
Parameters
keystring— The mount's key.secondsnumber?(optional) — How long to wait, default 120.
local s = carried.wait("ada.avatar", 30); assert(s.state == "ready", s.detail)
modules/channel/README
require("@builtin::modules.api.engine.channel") -- channel (also available as global 'channel')
Keyframe-channel sampling primitives — registry + sampleInto variants. Public Luau surface over the __channel Internal FFI namespace.
Usage: local channel = require("@builtin::modules.api.engine.channel") Also available as global: channel
modules/channel/create
create(opts: ChannelOpts): number?
Register a keyframe channel. times is the sorted keyframe
time array; values is the packed value array (layout depends
on interp); stride is the floats-per-sample width; interp
is "step" | "linear" | "slerp" | "cubicHermite". Returns
the channel handle, or nil on malformed input.
Parameters
optsChannelOpts—{ times, values, stride, interp }.
local h = channel.create({ times = ts, values = vs, stride = 3, interp = "linear" })
modules/channel/destroy
destroy(handle: number): boolean
Drop the channel from the registry.
Parameters
handlenumber— Channel handle.
modules/channel/sampleInto
sampleInto(ch: number, time: number, buf: Substrate.TypedBuffer, offset: number): boolean
Sample the channel at time and write stride floats into
the buffer starting at f32 index offset. Returns false
on unknown handle, layout mismatch, or out-of-bounds; the
buffer is unchanged on failure.
Parameters
chnumber— Channel handle.timenumber— Sample time in seconds.bufSubstrate.TypedBuffer— The buffer written into.offsetnumber— Starting f32 index in the buffer.
modules/channel/sampleManyInto
sampleManyInto(ch: number, time: number, buf: Substrate.TypedBuffer, offsets: { number }): boolean
Sample once, blit the result into every position in
offsets. Saves the per-offset binary search when one channel
feeds many bones / particles / parameters.
Parameters
chnumber— Channel handle.timenumber— Sample time in seconds.bufSubstrate.TypedBuffer— The buffer written into.offsets{ number }— Array of f32 indices.
modules/channel/sampleQuat
sampleQuat(ch: number, time: number): (number?, number?, number?, number?)
Convenience accessor for stride-4 quaternion channels.
Parameters
chnumber— Channel handle.timenumber— Sample time.
modules/channel/sampleVec3
sampleVec3(ch: number, time: number): (number?, number?, number?)
Convenience accessor for stride-3 channels. Returns the three components as multiret, or nil if the channel is unknown / has a different stride.
Parameters
chnumber— Channel handle.timenumber— Sample time.
local x, y, z = channel.sampleVec3(h, t)
modules/color/README
require("@builtin::modules.api.engine.color") -- color (also available as global 'color')
Color construction, conversion, and perceptual ops (RGB / HSL / HSV / Oklch / hex). Public Luau surface over the __color Internal FFI namespace.
Usage: local color = require("@builtin::modules.api.engine.color") Also available as global: color
modules/color/coerce
coerce(value: any): Color?
Read a value written in any of the shapes a colour is authored
in — a hex string, an {r=,g=,b=,a=} map, or an {r,g,b,a} array
— as an sRGB color table. Returns nil when the value does not
describe a colour, so a caller can name the value it was handed
instead of substituting one. Channels absent from a map or array
read as 0; alpha absent reads as 1.
Parameters
valueany(optional) — Value to read as a colour.
local c = color.coerce("#5a5a62") or color.coerce({ 0.2, 0.7, 0.2 })
modules/color/complementary
complementary(c: Color): Color
Complementary color — rotate hue 180° in Oklch space.
Parameters
cColor— Input color.
local accent = color.complementary(primary)
modules/color/darken
darken(c: Color, amount: number): Color
Decrease the lightness of a color in Oklch perceptual space.
Parameters
cColor— Input color.amountnumber— Lightness decrease 0-1.
local pressed = color.darken(base, 0.1)
modules/color/desaturate
desaturate(c: Color, amount: number): Color
Decrease the chroma (saturation) of a color in Oklch space.
Parameters
cColor— Input color.amountnumber— Chroma decrease (typically 0-0.2).
local muted = color.desaturate(base, 0.05)
modules/color/hex
hex(hexString: string): Color?
Parse a hex color string into an sRGB color table. Accepts 3,
4, 6, or 8 hex digits with or without a leading # (e.g. "#f00",
"f00f", "#ff0000", "ff000080"). Returns nil on parse failure.
Parameters
hexStringstring— Hex color string.
local fromCss = color.hex("#ff8800")
modules/color/hsl
hsl(h: number, s: number, l: number): Color
Build a color from HSL (h: 0-360, s: 0-1, l: 0-1).
Returned as sRGB.
Parameters
hnumber— Hue (degrees, 0-360).snumber— Saturation (0-1).lnumber— Lightness (0-1).
local teal = color.hsl(180, 0.5, 0.5)
modules/color/hsla
hsla(h: number, s: number, l: number, a: number): Color
Build a color from HSLA, returned as sRGB.
Parameters
hnumber— Hue (0-360).snumber— Saturation (0-1).lnumber— Lightness (0-1).anumber— Alpha (0-1).
local fadedTeal = color.hsla(180, 0.5, 0.5, 0.3)
modules/color/hsv
hsv(h: number, s: number, v: number): Color
Build a color from HSV (h: 0-360, s: 0-1, v: 0-1).
Parameters
hnumber— Hue (0-360).snumber— Saturation (0-1).vnumber— Value / brightness (0-1).
local primary = color.hsv(220, 0.7, 0.9)
modules/color/lighten
lighten(c: Color, amount: number): Color
Increase the lightness of a color in Oklch perceptual space.
Parameters
cColor— Input color.amountnumber— Lightness increase 0-1.
local hover = color.lighten(base, 0.1)
modules/color/linear
linear(r: number, g: number, b: number, a: number?): Color
Build a color from linear RGB values (not gamma-corrected), output converted to sRGB. Useful for GPU-correct blending. Alpha defaults to 1.
Parameters
rnumber— Linear red (0-1).gnumber— Linear green (0-1).bnumber— Linear blue (0-1).anumber?(optional) — Alpha (0-1, default 1).
local gpuBlue = color.linear(0.0, 0.0, 1.0)
modules/color/mix
mix(c1: Color, c2: Color, t: number): Color
Perceptually blend two colors in Oklch space — better than RGB mixing for gradients.
Parameters
c1Color— First color.c2Color— Second color.tnumber— Blend factor 0-1 (0 = c1, 1 = c2).
local mid = color.mix(color.rgb(255, 0, 0), color.rgb(0, 0, 255), 0.5)
modules/color/mixRgb
mixRgb(c1: Color, c2: Color, t: number): Color
Linearly blend two colors in sRGB space — simple, but not
perceptually uniform. Prefer color.mix for natural gradients.
Parameters
c1Color— First color.c2Color— Second color.tnumber— Blend factor 0-1.
local plain = color.mixRgb(a, b, 0.5)
modules/color/oklch
oklch(l: number, c: number, h: number): Color
Build a color from Oklch perceptual color space (l: 0-1,
c: 0-0.4, h: 0-360). Ideal for perceptually uniform gradients
and color manipulation.
Parameters
lnumber— Lightness (0-1).cnumber— Chroma / saturation (0-0.4).hnumber— Hue (0-360).
local accent = color.oklch(0.7, 0.15, 30)
modules/color/rgb
rgb(r: number, g: number, b: number): Color
Build an sRGB color from CSS-style 0-255 RGB channels. Alpha defaults to 1. Channels are normalised to 0-1 on the way out so the result composes with every other color helper.
Parameters
rnumber— Red channel (0-255).gnumber— Green channel (0-255).bnumber— Blue channel (0-255).
local red = color.rgb(255, 0, 0)
modules/color/rgba
rgba(r: number, g: number, b: number, a: number): Color
Build an sRGB color from CSS-style 0-255 RGB channels with explicit alpha. RGB are normalised to 0-1; alpha is taken as-is in the 0-1 range.
Parameters
rnumber— Red channel (0-255).gnumber— Green channel (0-255).bnumber— Blue channel (0-255).anumber— Alpha (0-1).
local halfRed = color.rgba(255, 0, 0, 0.5)
modules/color/rotateHue
rotateHue(c: Color, degrees: number): Color
Rotate the hue of a color by a given number of degrees in Oklch space.
Parameters
cColor— Input color.degreesnumber— Hue rotation (positive or negative).
local triadic = color.rotateHue(base, 120)
modules/color/saturate
saturate(c: Color, amount: number): Color
Increase the chroma (saturation) of a color in Oklch space.
Parameters
cColor— Input color.amountnumber— Chroma increase (typically 0-0.2).
local pop = color.saturate(base, 0.05)
modules/color/toHex
toHex(c: Color): string
Convert a color to a hex string. Returns "#rrggbb" or
"#rrggbbaa" if alpha is not 1.
Parameters
cColor— Input color.
print(color.toHex(color.rgb(255, 136, 0))) -- "#ff8800"
modules/color/toHsl
toHsl(c: Color): HslColor
Convert a color to HSL.
Parameters
cColor— Input color.
local hsl = color.toHsl(base)
modules/color/toLinear
toLinear(c: Color): Color
Convert a color from sRGB to linear RGB space — useful for GPU calculations that need linear-space values.
Parameters
cColor— Input sRGB color.
local gpu = color.toLinear(base)
modules/color/toOklch
toOklch(c: Color): OklchColor
Convert a color to Oklch perceptual color space.
Parameters
cColor— Input color.
local okl = color.toOklch(base)
modules/color/withAlpha
withAlpha(c: Color, a: number): Color
Return a copy of a color with a different alpha value.
Parameters
cColor— Input color.anumber— New alpha (0-1).
local ghost = color.withAlpha(base, 0.3)
modules/compute/README
require("@builtin::modules.api.engine.compute") -- compute (also available as global 'compute')
GPU compute pipelines — compile shaders, dispatch workgroups, read back results. Public Luau surface over the __compute Internal FFI namespace. A buffer belongs to the shader that owns it (shaderRef:createBuffer) or to the substrate (substrate.createBuffer), and reaches a dispatch as a handle.
Usage: local compute = require("@builtin::modules.api.engine.compute") Also available as global: compute
modules/compute/absentReasons
absentReasons(): { string }
Every reason compute.diagnose reports, sorted. resident is the one
that means the resource is there.
for _, r in ipairs(compute.absentReasons()) do print(r) end
modules/compute/beginBvh
beginBvh(instances: { any }, opts: { [string]: any }?): (number?, string?)
Start the build compute.buildBvh runs, without running any of it.
Takes the same instances and options and reports the same non-resident
guids, and returns an id compute.stepBvh advances a bounded slice at a
time and compute.finishBvh collects. Each mesh the instances name is
copied as this is called — once per guid however many instances share it
— so the CPU mesh may be unloaded on the next line and the build still
finishes on the copy it holds. compute.buildBvhSliced is the whole loop
as one call.
Parameters
instances{ any }— Array of{ guid, transform, attributes? }mesh instances.opts{ [string]: any }?(optional) — Optional{ maxLeaf? }— max triangles per leaf.
local id = compute.beginBvh(gather.instances)
modules/compute/buildBvh
buildBvh(instances: { any }, opts: { [string]: any }?): (any, string?)
Build a bounding-volume hierarchy over the world-space triangles of a
set of mesh instances and upload it as two named compute buffers —
geometry never passes through the scripting heap. Each instance is
{ guid, transform, attributes? }: guid names a mesh resident in the
meshcpu store (materialise with ref:load() / meshcpu.load),
transform is 16 numbers, row-major, translation in slots 4/8/12, and
attributes is up to 40 floats stamped onto every triangle of that
instance (surface colors, material ids, physics tags — whatever the
consuming shader wants per-surface). Triangles pack 18 vec4 each
(v0/v1/v2, n0/n1/n2, uvs, then 10 attribute vec4s — float slots 32..
carry the instance attributes, zero when absent) in BVH leaf order;
nodes 2 vec4 each (min + first-or-left, max + leaf-tagged
count-or-right). Consumers: GI baking, ray-traced passes, GPU picking,
navmesh and SDF generation.
Parameters
instances{ any }— Array of{ guid, transform, attributes? }mesh instances.opts{ [string]: any }?(optional) — Optional{ maxLeaf? }— max triangles per leaf.
local bvh = compute.buildBvh(instances)
asset.resolve("raytrace", "computeShader"):dispatch({ buffers = { bvh.nodes, bvh.tris }, workgroups = { 64, 1, 1 } })
modules/compute/buildBvhSliced
buildBvhSliced(instances: { any }, opts: { [string]: any }?): (any, string?)
The hierarchy compute.buildBvh builds, spread over as many frames as
it takes: a slice of the build per frame, so a scene's triangle count
costs the frame loop budgetMs at a time instead of the whole build at
once. Yields, so it is called from a task. The result is the same pair of
buffers and the same counts compute.buildBvh returns.
Parameters
instances{ any }— Array of{ guid, transform, attributes? }mesh instances.opts{ [string]: any }?(optional) — Optional{ maxLeaf?, budgetMs? }— max triangles per leaf, and the wall time one frame may spend on the build (default 4 ms).
local built, err = compute.buildBvhSliced(gather.instances, { budgetMs = 4 })
modules/compute/bvhBuilds
bvhBuilds(): { any }
What the builds started by compute.beginBvh and not yet finished are
costing, oldest id first. Each row is { id, phase, triangles, units, slices, cpuMs, uploadedBytes }: phase is "gather", "build",
"serialize", "upload" or "ready", triangles how many have been
gathered, units the work units run, slices the compute.stepBvh
calls they ran in, cpuMs the wall time spent inside those calls, and
uploadedBytes how much of the hierarchy has reached the GPU.
print(#compute.bvhBuilds(), "hierarchies in flight")
modules/compute/cancelBvh
cancelBvh(id: number): boolean
Drop a build along with the triangles it has gathered.
Parameters
idnumber— Build id fromcompute.beginBvh.
compute.cancelBvh(id)
modules/compute/compile
compile(nameOrHandle: string | { [string]: any } | AssetRef, opts: { [string]: any }?): (boolean, string?)
Compile a compute shader from inline WGSL + a declarative binding
schema — the same codegen a .computeShader asset uses. The engine
generates the @group/@binding declarations from bindings/params,
so the source writes only @compute fn main. Symmetric with
registerShader, but with zero-scaffolding bindings (incl. textures,
samplers, storage textures and a params uniform). For asset-backed
shaders prefer authoring a .computeShader (compiled automatically);
use this for dynamic/generated compute shaders.
Parameters
nameOrHandlestring | { [string]: any } | AssetRef— Shader identity to register under (string or asset handle).opts{ [string]: any }?(optional) —{ source, entryPoint?, bindings, params? }—bindingsis an ordered list of{ name, kind, access?, element?, format?, array?, sample? }.
compute.compile("my_sim", { source = WGSL, bindings = { { name = "data", kind = "buffer", access = "read_write", element = "f32" } } })
modules/compute/compileByName
compileByName(ref: string | { [string]: any } | AssetRef)
Optional explicit pre-warm for a .computeShader asset (idempotent —
fingerprint-guarded). NORMALLY UNNECESSARY: compute.dispatch / dispatchEx
auto-compile a .computeShader on first use. Reach for this only to avoid
the one-frame first-dispatch warm-up in a latency-critical spot. Accepts an
identity/guid string or a resolved asset handle (its .identity is used).
Parameters
refstring | { [string]: any } | AssetRef— A.computeShaderidentity/guid string, or a resolved asset handle.
compute.compileByName("@builtin::shaders.compute_double")
modules/compute/copyBufferToTexture
copyBufferToTexture(bufferName: string, textureKey: string, width: number, height: number, format: string?, rowBytes: number?): boolean
Copy a compute buffer into a cached GPU texture under
textureKey, staying on the GPU. The path for an image a compute
pass produced: the buffer holds tightly-packed rows in the format's
texel layout, and the result is an ordinary cached texture — sample
it from a material, or pack it into the shared feature-texture array.
The copy reads rows 256-byte aligned: rows packed tight must be a
multiple of 256 bytes (at rgba16f, any width that is a multiple of 32),
and any other width is laid out with its rows padded to that alignment
and rowBytes saying how far apart they are.
Parameters
bufferNamestring— Source compute buffer.textureKeystring— Cache key to register the texture under.widthnumber— Texture width in texels.heightnumber— Texture height in texels.formatstring?(optional) — Texel format:"rgba16f"(default),"rgba32f","rgba8".rowBytesnumber?(optional) — Bytes from one row's start to the next when rows are padded pastwidthtexels — a multiple of 256 at least a row's texels long.
compute.copyBufferToTexture("gi_resolved", "lm_wall", 128, 128)
compute.copyBufferToTexture("heights_packed", "heights", 300, 300, "rgba16f", 2560)
modules/compute/createBuffer
createBuffer(name: string, opts: { [string]: any }): boolean
Allocate a buffer under name, sized in bytes.
Parameters
namestring— The name a dispatch binds it by.opts{ [string]: any }—{ size, readback? }—sizein bytes.
modules/compute/createSampler
createSampler(name: string, opts: { [string]: any }?): boolean
Create a named GPU sampler. opts: filter/wrap settings.
Parameters
namestringopts{ [string]: any }?(optional)
modules/compute/createStorageTexture2D
createStorageTexture2D(name: string, opts: { [string]: any }): boolean
Create a 2D storage texture (compute-writable render target). opts: { width, height, format? }.
Parameters
namestringopts{ [string]: any }
modules/compute/createTexture3D
createTexture3D(name: string, opts: { [string]: any }): boolean
Create a 3D texture volume. opts: { width, height, depth, format?, storage? }.
Parameters
namestring— Unique volume name.opts{ [string]: any }— Dimensions + format (r8/r16f/r32f/rgba8/rgba16f/rgba32f).
modules/compute/createTextureHistory
createTextureHistory(name: string, opts: { [string]: any }): boolean
Create a temporal history buffer (ping-pong textures) for a target. opts: { width, height, format? }.
Parameters
namestringopts{ [string]: any }
modules/compute/destroyBuffer
destroyBuffer(name: string): boolean
Release the buffer allocated under name.
Parameters
namestring— The name it was created under.
modules/compute/destroySampler
destroySampler(name: string): boolean
Release a named sampler created by compute.createSampler and free
it. The counterpart to that call, alongside destroyBuffer,
destroyTexture, destroyTexture3D, destroyStorageTexture2D and
destroyTextureHistory. The manager's own defaults (linear_clamp,
linear_repeat, nearest_clamp) are kept for the session, since a
compute pass binds them by name.
Parameters
namestring— Sampler name.
compute.createSampler("soft", { filter = true }); compute.destroySampler("soft")
modules/compute/destroyShader
destroyShader(name: string): boolean
Destroy a named compute shader pipeline.
Parameters
namestring— Shader name.
modules/compute/destroyShaderEx
destroyShaderEx(name: string): boolean
Destroy a shader registered via registerShaderEx.
Parameters
namestring
modules/compute/destroyStorageTexture2D
destroyStorageTexture2D(name: string): boolean
Destroy a named 2D storage texture.
Parameters
namestring
modules/compute/destroyTexture
destroyTexture(textureKey: string): boolean
Release the cached GPU texture copyBufferToTexture registered
under textureKey, freeing its memory. Call it once the image is no
longer sampled. Writing the same key again replaces the texture, so a
key you keep re-using holds one allocation.
Parameters
textureKeystring— Cache key the texture was registered under.
compute.destroyTexture("lm_wall")
modules/compute/destroyTexture3D
destroyTexture3D(name: string): boolean
Destroy a named 3D volume and free its GPU memory.
Parameters
namestring
modules/compute/destroyTextureHistory
destroyTextureHistory(name: string): boolean
Destroy a named texture-history buffer.
Parameters
namestring
modules/compute/diagnose
diagnose(key: string): { [string]: any }
Whether a resource is filed under key right now, and when none is,
which state the inventory says the key is in. A key out of a dispatch
failure resolves here; a mistyped one reports why it does not.
Parameters
keystring— The resource key, verbatim.
local d = compute.diagnose(key)
if not d.exists then print(d.reason, d.current) end
modules/compute/dispatch
dispatch(shaderNameOrHandle: string | { [string]: any } | AssetRef, opts: DispatchOpts): boolean
Dispatch a compute shader with bound buffers. Accepts a
shader name string or an asset handle from asset.load().
Parameters
shaderNameOrHandlestring | { [string]: any } | AssetRef— Shader name or asset handle.optsDispatchOpts—{ buffers, workgroups }. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
compute.dispatch("blur", { buffers = { "src", "dst" }, workgroups = { 8, 8 } })
modules/compute/dispatchEx
dispatchEx(shaderNameOrHandle: string | { [string]: any } | AssetRef, opts: { [string]: any }): boolean
Dispatch a compute shader with extended texture/storage/sampler bindings.
Asset-backed .computeShaders resolve to their stable guid (collision-safe,
lazily compiled on first dispatch); raw registerShaderEx names pass through.
resources covers the bindings the shader DECLARES. A params: block's
uniform is engine-owned — the compile creates and packs it, setParam
writes it, and the dispatch binds it — so it takes no entry here.
Parameters
shaderNameOrHandlestring | { [string]: any } | AssetRef— Shader name or asset handle.opts{ [string]: any }—{ resources, workgroups }— each resource is{ kind, name }. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
modules/compute/dispatchOnVertices
dispatchOnVertices(shaderNameOrHandle: string | { [string]: any } | AssetRef, opts: DispatchOnVerticesOpts): boolean
Dispatch a compute shader with a model's vertex buffer bound
at binding 0 (read_write). Use to mutate vertex positions
directly. Asset-backed .computeShaders resolve to their stable guid
(collision-safe, lazily compiled on first dispatch); raw
registerShader names pass through.
Parameters
shaderNameOrHandlestring | { [string]: any } | AssetRef— Shader name or asset handle.optsDispatchOnVerticesOpts—{ model, buffers?, workgroups }. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
compute.dispatchOnVertices("flatten", { model = "@user/mesh", workgroups = { 64 } })
modules/compute/failing
failing(): { { [string]: any } }
Every compute dispatch whose most recent run FAILED, one record per
(shader, target) pair. A dispatch is recorded into a command encoder
frames after the call that asked for it returned, so a pass that stops
running reports here rather than through that call's return value: each
record carries the shader key, the target it writes (a mesh guid for a
dispatch over vertices, the buffers it bound for one that writes only
those), how
many dispatches and failures it has had, and lastError. An empty result
means every dispatch the engine has been given is running.
for _, d in ipairs(compute.failing()) do print(d.shader, d.lastError) end
modules/compute/finishBvh
finishBvh(id: number): (any, string?)
Hand over a finished build's hierarchy as the same two buffers
compute.buildBvh returns, and release the build. The slices put every
byte of it on the GPU as they ran, so this costs the frame it is called
in the handover and nothing of the scene.
Parameters
idnumber— Build id fromcompute.beginBvh, stepped until"ready".
local built = compute.finishBvh(id)
modules/compute/getReadbackResult
getReadbackResult(resultKey: string): { number }?
Poll for a completed read-back and return its bytes as a
1-indexed array of f32 values, nil if pending. The f32
reinterpretation applies to whatever the buffer holds: bytes
written as u32 1, 2, 3, 4 read back here as 1.4e-45, 2.8e-45, 4.2e-45, 5.6e-45 — use getReadbackResultU32() for those, or
getReadbackResultBytes() for a buffer the rest of the buffer
surface accepts. Result is consumed on retrieval, and polling a key
that was never issued raises rather than reading as forever-pending.
Parameters
resultKeystring— Key returned byreadBuffer().
local floats = compute.getReadbackResult(key)
modules/compute/getReadbackResultBytes
getReadbackResultBytes(resultKey: string): buffer?
Poll for a completed read-back and get its raw bytes as a
buffer, copied once. The read counterpart of writeBufferBytes:
read values out with buffer.readf32 / buffer.readu32, or hand the
buffer straight to writeBuffer — a payload that stays packed never
becomes a table. Result is consumed on retrieval.
Parameters
resultKeystring— Key returned byreadBuffer().
local bytes = compute.getReadbackResultBytes(key)
local firstTexel = buffer.readf32(bytes, 0)
modules/compute/getReadbackResultU32
getReadbackResultU32(resultKey: string): { number }?
Poll for a completed read-back interpreting bytes as u32. Returns array of integer values if ready, nil if pending.
Parameters
resultKeystring— Key returned byreadBuffer().
modules/compute/isReadbackReady
isReadbackReady(resultKey: string): boolean
Check if a readback result is available without consuming it.
Raises for a key this engine never issued, or whose result was already
drained — nil/false already means "still in flight", so a mistyped
key reports itself instead of polling forever. Use readbackState()
to test that case without raising.
Parameters
resultKeystring— Key returned byreadBuffer().
modules/compute/markBaseline
markBaseline(): number
Record which compute resources are resident right now, and make that the
point compute.resetToBaseline returns to.
A caller that runs work in someone else's engine — a sweep of test suites sharing one, an editor tool driving a session — allocates as it goes: a pass builds the grid its quality asks for and keeps it, a shader files the uniform it was compiled with. Kept is right for a frame that draws again and wrong for the next caller, which then reads an inventory it did not make. This is how a caller says where its own allocations start.
local mark = compute.markBaseline() -- then run, then compute.resetToBaseline(mark)
modules/compute/observe
observe(): { [string]: any }
Every GPU resource the compute subsystem is holding right now — its storage and uniform buffers, its 3D textures, its 2D storage targets, its history pairs and its samplers — with what each one costs and which shader asked for it. This is the call to reach for when compute is holding memory and you do not know what, or when a key out of a dispatch failure needs matching against what exists.
local r = compute.observe()
print(r.totals.count, r.totals.bytes)
for _, res in ipairs(r.resources) do print(res.key, res.kind, res.bytes) end
modules/compute/program.compile
program.compile(key: string, spec: { [string]: any }): (boolean, string?)
Register a compiled program under key from WGSL plus a declared
binding schema. The engine generates the @group/@binding declarations
from the schema, expands #includes, naga-validates, and registers the
result.
Parameters
keystring— The key to register under.spec{ [string]: any }—{ source, entryPoint?, bindings, params, ranges? }— the parsed schema. A buffer binding statingrange = true(or every array buffer binding, withranges = true) takes a range of a buffer: a dispatch binds it withzero_base_NAME/zero_len_NAMEin its params, and the body'sNAME[i]andarrayLength(&NAME)address that range. One that states no range binds the whole buffer.
modules/compute/program.destroy
program.destroy(key: string): boolean
Release the program registered under key.
Parameters
keystring— The program's key.
modules/compute/program.dispatch
program.dispatch(key: string, opts: { [string]: any }): boolean
Dispatch the program under key with one buffer per declared storage
binding, in declaration order.
Parameters
keystring— The program's key.opts{ [string]: any }—{ buffers, workgroups, params? }.paramsgives values of the program'sparams:uniform, by name, to this dispatch alone: two dispatches of one program in a frame each read their own, and a value left out reads what the program holds. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
modules/compute/program.dispatchEx
program.dispatchEx(key: string, opts: { [string]: any }): boolean
Dispatch the program under key with explicit resources — one
{ kind, name } per declared binding, in declaration order.
Parameters
keystring— The program's key.opts{ [string]: any }—{ resources, workgroups }. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
modules/compute/program.dispatchOnVertices
program.dispatchOnVertices(key: string, opts: { [string]: any }): boolean
Dispatch the program under key over a mesh's vertices. The mesh
opts.model names fills the shader's vertices binding, and opts.buffers
fills the remaining storage bindings.
Parameters
keystring— The program's key.opts{ [string]: any }—{ model, buffers?, workgroups, params? }.paramsgives values of the program'sparams:uniform to this dispatch alone. A zero in any workgroup dimension is refused and recorded as a dispatch failure — clamp a computed count withmath.max(1, math.ceil(n / 64)).
modules/compute/program.dispatches
program.dispatches(): number
How many dispatches the running thread has queued since it began, a run of a compute list counting each dispatch the list holds. Two readings taken around a piece of work give what that work dispatched.
modules/compute/program.dropList
program.dropList(key: string): boolean
Forget the compute list under key.
Parameters
keystring— The list's key.
modules/compute/program.forPlugin
program.forPlugin(key: string, bindings: number | { string }): any
The program under key as a handle a script passes a plugin in a call,
for it to dispatch over the GPU buffers and textures it was handed.
bindings is how many storage buffers the shader binds, or the kind of
each binding in declaration order as bindings.yaml spells them
(buffer, texture3d, storage3d, storage2d).
Parameters
keystring— The program's key.bindingsnumber | { string }— A count of buffers, or each binding's kind.
modules/compute/program.list
program.list(key: string, entries: { { [string]: any } }): boolean
Register the compute list under key, replacing one already there: an
ordered run of dispatches and buffer writes that runList queues in one
call, each value a run supplies named as a slot.
Parameters
keystring— The key to register the list under.entries{ { [string]: any } }— The dispatches and writes, in the order they run. A dispatch is{ program, buffers, workgroups, params?, slots?, runs?, writes?, when? },slotsmapping a param name to the slot that gives it its value.runsnames the runs the dispatch reaches through a page it binds andwritesthe ones of those it writes: the list holds them standing (a replay over a run that was let go of is refused, not run) and moves the write revision of the ones it writes. A write is{ write = bufferName, offset?, values, unsigned?, slots?, when? }:offsetin 32-bit words,valueswritten as f32 (u32 whenunsigned),slotsmapping a value's place, from 1, to the slot that gives it.whennames a slot: a run giving it 0 leaves the entry out.
modules/compute/program.listCost
program.listCost(key: string): (number?, number?)
What recording the runs of the compute list under key has cost the
render side so far. A run is recorded on a frame after the one that queued
it, so a cost read just after runList holds the runs before that one.
Parameters
keystring— The list's key.
modules/compute/program.record
program.record(fn: ({ { [string]: any } }) -> ()): { { [string]: any } }
Run fn and answer every compute.program.dispatch it made, in order,
as the entries of a compute list: { program, buffers, workgroups, params }
each. The dispatches are queued as they always are; the answer is what
compute.program.list takes to replay them. fn is handed the entries as
they are made, so it can add slots to one it just dispatched.
Parameters
fn({ { [string]: any } }) -> ()— The work to run, given the entries recorded so far.
modules/compute/program.runList
program.runList(key: string, slots: { [string]: number }?, label: string?): boolean
Queue the compute list under key: every entry in order, each value an
entry names a slot for taken from slots, every other value as the list
holds it. While the GPU profiler is read the run is recorded as a compute
pass of its own, and its GPU time is the compute.list:<label> row of the
gpu report.
Parameters
keystring— The list's key.slots{ [string]: number }?(optional) — The value of each slot for this run, by name.labelstring?(optional) — The name the run's GPU time is reported under; the list's key when absent.
modules/compute/program.setParam
program.setParam(key: string, prop: string, value: number): boolean
Write one scalar of the program's params: uniform. A value set before
the program's first compile is the value it starts with.
Parameters
keystring— The program's key.propstring— Parameter name as declared.valuenumber— New scalar value.
modules/compute/program.status
program.status(key: string): { { [string]: any } }
What the engine did with the dispatches of the program under key,
one record per target.
Parameters
keystring— The program's key.
modules/compute/programState
programState(ref: string | { [string]: any } | AssetRef): (string, string?)
Where a shader's compiled program stands. A registration is queued
from script and the pipeline is built on the render side frames later,
so the call that asked for the compile cannot say whether it produced a
program: "absent" (the engine holds nothing under this key and nothing
is in flight — never asked for, or released), "pending" (asked for, not
on the device yet — a recompile of a resident program reads pending too,
because what it produces is a different program from the one bound now),
"ready" (compiled and resident, so a dispatch binds it), or "failed"
(the most recent registration produced no program), returned with the
reason as a second value. A .computeShader whose bindings.yaml its
compile refuses reads "failed", with the reason naming the file and the
line, because no program is compiled from the file as it stands. Wait for
"ready" before a dispatch whose result is read back, rather than for a
count of frames.
Parameters
refstring | { [string]: any } | AssetRef— A.computeShaderidentity/guid string, a resolved asset handle, or the name a raw registration chose.
if compute.programState(carve) == "ready" then carve:dispatch(opts) end
modules/compute/readBuffer
readBuffer(name: string): string
Start a GPU→CPU read of the buffer under name.
Parameters
namestring— The name it was created under.
modules/compute/readTexture3D
readTexture3D(name: string): string
Start a GPU→CPU readback of a named 3D volume. Returns a result key to poll.
Parameters
namestring
modules/compute/readbackPromise
readbackPromise(resultKey: string): any
The promise that settles when a read-back reaches a terminal state,
delivered or given up on. task.await it to wait for the read without
polling: where the engine can wait on the device the coroutine resumes in
the frame the device answered, so a task that reads, uses the answer and
reads again does all of it in one frame; elsewhere it resumes on the next
frame the answer reaches the engine. Answers nil when the read-back is
not in flight (already delivered, failed, drained or never issued), and
readbackState() then says which.
Parameters
resultKeystring— Key returned byreadBuffer().
local promise = compute.readbackPromise(key); if promise then task.await(promise) end
modules/compute/readbackState
readbackState(resultKey: string): string
Where a readback key stands, without consuming it and without
raising: "pending" (issued, GPU has not delivered), "ready"
(delivered, waiting to be drained), "failed" (given up on, with the
reason as a second return), or "unknown" (never issued by
readBuffer(), or already drained — a result is delivered once).
Every read leaves "pending": one the GPU does not answer inside the
bound the engine holds it to reaches "failed" naming the buffer. A
wait on readbackState(key) ~= "pending" therefore ends on what the
read did, which a count of engine frames cannot say.
Parameters
resultKeystring— Key returned byreadBuffer().
if compute.readbackState(key) == "ready" then ... end
modules/compute/registerShader
registerShader(nameOrHandle: string | { [string]: any } | AssetRef, opts: ShaderOpts?): boolean
Register a compute shader. Accepts an asset handle from
asset.load(), or (name, opts) with inline WGSL source.
Parameters
nameOrHandlestring | { [string]: any } | AssetRef— Shader name or asset handle.optsShaderOpts?(optional) — Shader options.bindingscomes from the source's own@group(0) @binding(n)declarations when omitted; supplying a count that disagrees with them raises. EveryreadOnlyBindingsentry names one of those declared bindings, as a whole number from 0 tobindings - 1; an entry outside that run raises.
compute.registerShader("blur", { source = WGSL, entryPoint = "main" })
modules/compute/registerShaderEx
registerShaderEx(nameOrHandle: string | { [string]: any } | AssetRef, opts: { [string]: any }?): boolean
Register a compute shader with extended texture/sampler bindings. Accepts a name + opts or an asset handle.
Parameters
nameOrHandlestring | { [string]: any } | AssetRefopts{ [string]: any }?(optional)
modules/compute/releaseBaseline
releaseBaseline(generation: number): boolean
Drop the mark generation names, and every mark taken after it, once
the caller that took it is done resetting to it. It touches the
marks alone.
Parameters
generationnumber— The mark to drop, ascompute.markBaselinereturned it.
compute.releaseBaseline(mark) -- the run is over
modules/compute/resetToBaseline
resetToBaseline(generation: number?): number
Release every compute resource allocated since compute.markBaseline,
leaving the ones it recorded where they are.
Each kind this closes is one a caller allocated under a name it chose, so
the next caller finds that name free. A storage buffer is such a resource
and is not closed here: every one a caller can make is a substrate buffer,
and substrate.resetToBaseline is what puts those back. A compiled
shader's params uniform is not, and is left where it is: it is filed under
its shader's guid, which no other caller can ask for, and it belongs to
the .computeShader asset that compiled it, released when that is.
mark is closed; nothing the mark recorded is touched.
Parameters
generationnumber?(optional) — The mark to restore to, ascompute.markBaselinereturned it; the newest mark when omitted. The marks taken after it go with the reset.
local released = compute.resetToBaseline(mark)
modules/compute/resources
resources(owner: any?): { any }
The resource rows on their own, optionally narrowed to what one shader owns.
Parameters
ownerany?(optional) — A.computeShaderref, its guid, or its asset identity. Omit for every resource compute holds. A value carrying no shader raises, so a narrowing that cannot be done reads as an error rather than as the whole inventory. A guid stands for itself, so resources outlive the asset that made them and stay reachable by their owner.
for _, r in ipairs(compute.resources(shaderRef)) do print(r.key, r.bytes) end
modules/compute/setParam
setParam(nameOrHandle: string | { [string]: any } | AssetRef, prop: string, value: number): boolean
Set a named scalar parameter on a .computeShader (a params:
entry in its bindings.yaml). Updates the shader's params uniform
in place; the next dispatch sees the new value. No effect on raw
registerShader shaders, which have no params block.
Parameters
nameOrHandlestring | { [string]: any } | AssetRef— Shader identity (the.computeShaderasset name), or the handleasset.load/asset.resolvereturns — the same formsdispatchtakes.propstring— Parameter name as declared inbindings.yaml.valuenumber— New scalar value (numbers only).
compute.setParam("my_sim", "scale", 4.0)
modules/compute/stepBvh
stepBvh(id: number, budgetMs: number?): (string?, string?)
Advance a build by as many work units as budgetMs buys, and report
whether it has finished: "pending" means there is work left,
"ready" means compute.finishBvh will hand over the buffers. The
slices carry the hierarchy onto the GPU as well as building it, so a
build that reads "ready" has already uploaded every byte of itself. A
slice always runs at least one unit, so a budget of 0 advances the build
by exactly one and the largest single unit sets the floor under a slice.
Parameters
idnumber— Build id fromcompute.beginBvh.budgetMsnumber?(optional) — Wall time this slice may spend, in milliseconds (default 4).
while compute.stepBvh(id, 4) == "pending" do task.wait() end
modules/compute/textureForPlugin
textureForPlugin(name: string): any
The texture this script created under name as a handle a script
passes a plugin in a call. The handle holds the texture by an id of its
own, never by the name: once the texture is destroyed the handle refuses,
even when the name is made again. Only a texture made by
compute.createTexture3D or compute.createStorageTexture2D can be
handed over.
Parameters
namestring— The texture's name.
modules/compute/textureFormatBytes
textureFormatBytes(format: string): number
Bytes-per-voxel for a texture format string (rgba16f, r8, ...).
Parameters
formatstring
modules/compute/writeBuffer
writeBuffer(name: string, values: { number } | buffer | string, offset: number?): boolean
Write words into the buffer under name.
Parameters
namestring— The name it was created under.values{ number } | buffer | string— The floats to write, or abuffer/ binary string already holding them.offsetnumber?(optional) — 32-bit word offset to write at.
modules/compute/writeBufferBytes
writeBufferBytes(name: string, bytes: buffer | string, offsetBytes: number?): boolean
Write packed bytes into the buffer under name.
Parameters
namestring— The name it was created under.bytesbuffer | string— The payload.offsetBytesnumber?(optional) — Byte offset to write at.
modules/compute/writeBufferU32
writeBufferU32(name: string, values: { number } | buffer | string, offsetBytes: number?): boolean
Write 32-bit words into the buffer under name.
Parameters
namestring— The name it was created under.values{ number } | buffer | string— The words to write.offsetBytesnumber?(optional) — Byte offset to write at.
modules/compute/writeFloatsTexture3D
writeFloatsTexture3D(name: string, floats: { number }, formatOrOpts: (string | { [string]: any })?): boolean
Upload float values into a named 3D volume, packed via the given format (default rgba16f).
Parameters
namestringfloats{ number }formatOrOpts(string | { [string]: any })?(optional)
modules/compute/writeTexture3D
writeTexture3D(name: string, data: buffer | string | { number }): boolean
Upload raw bytes (u8) into a named 3D volume. A buffer or a binary
string holds the volume's byte layout verbatim and crosses in one copy —
the shape a file's voxel payload arrives in; an array carries one byte
value (0..255) per entry.
Parameters
namestring— Volume name.databuffer | string | { number }— Voxel bytes as abuffer, a binary string, or an array of bytes.
modules/compute_abi/README
require("@builtin::modules.compute_abi") -- compute_abi
The kernel ABI of a .computeShader: the bindings.yaml extensions (columns bindings, output count / capacity / append with a live counter, specialize compile-time parameters, determinism), lowered to the plain bindings and WGSL the engine compiles, and the host side that allocates outputs, packs column tables and dispatches a variant.
Usage: local compute_abi = require("@builtin::modules.compute_abi")
modules/compute_abi/accessorLines
accessorLines(name: string, element: string, lanes: number?, writable: boolean): { string }?
The lines lower generates for one buffer binding: its length, its read and, when it is written, its write.
Parameters
namestring— The binding's name.elementstring— The element type as the schema states it after specialization (vec3<f32>).lanesnumber?(optional) — How many scalars the element holds.writableboolean— Whether the binding is written.
local lines = abi.accessorLines("src", "vec3<f32>", 3, false)
modules/compute_abi/allocationCount
allocationCount(): number
How many device buffers this module has made (a table of columns, an output, a live counter) since the module state began; the buffers a kernel dispatch allocates are in it.
local before = abi.allocationCount()
modules/compute_abi/buffer
buffer(self: any): any
The GPU buffer holding the table.
Parameters
selfany(optional)
modules/compute_abi/compile
compile(baseKey: string, lowered: { [string]: any }, label: string?): string
Compile a lowered variant under <baseKey>#<hash of what it lowered to>;
one variant compiles once.
Parameters
baseKeystring— The shader's registration key.lowered{ [string]: any }— A value fromlower.labelstring?(optional) — The name profiling rows carry.
local key = abi.compile(guid, lowered, "kernels.map")
modules/compute_abi/compileCount
compileCount(): number
How many variants compile has registered since the module state began: a count that grows while the same
work repeats says the work asks for a program of its own each time.
local before = abi.compileCount()
modules/compute_abi/compiledSince
compiledSince(since: number): { { label: string, key: string } }
What compile registered after the count stood at since (compileCount), oldest first, for the latest 4096
compiles: each variant's label and the key it is dispatched under (loweredOf(key) reads what it lowered to).
Parameters
sincenumber— A countcompileCountanswered.
local before = abi.compileCount(); work(); for _, c in ipairs(abi.compiledSince(before)) do print(c.label) end
modules/compute_abi/copyWords
copyWords(src: string, dst: string, words: number, first: number?): boolean
Queue a word-for-word copy of the first words words of the buffer src into the buffer dst, from word
first on.
Parameters
srcstring— The source buffer's name.dststring— The destination buffer's name.wordsnumber— How many words.firstnumber?(optional) — The word ofdstthe first one lands at. Default 0.
abi.copyWords(a:bufferName(), b:bufferName(), 64)
modules/compute_abi/directLimit
directLimit(schema: { [string]: any }, binding: string): number
How many columns of the columns binding binding a variant can bind directly, each as a binding of
its own run: the storage buffers a shader stage holds on every device, less the buffers the schema's other
bindings take and the binding's own table.
Parameters
schema{ [string]: any }— A parsed schema.bindingstring— The name of acolumnsbinding that reads.
local limit = abi.directLimit(schema, "cols")
modules/compute_abi/directLimitOf
directLimitOf(program: any, binding: string): number
Program.directLimit for a program made by an earlier load of this module.
Parameters
programany(optional) — A program fromabi.program.bindingstring— The name of acolumnsbinding that reads.
local limit = abi.directLimitOf(program, "cols")
modules/compute_abi/directPlan
directPlan(columns: { { [string]: any } }, limit: number): { number }
The column slots, in increasing order, that a table of columns takes as direct columns: the first limit
columns that name a device buffer and hold no values of their own. A dispatch binds each buffer at one slot, so
a column whose buffer an earlier direct column holds stays in the table.
Parameters
columns{ { [string]: any } }— The arrayabi.tableis given.limitnumber— How many direct columns the variant can bind (abi.directLimit).
local direct = abi.directPlan(columns, abi.directLimit(schema, "cols"))
modules/compute_abi/directs
directs(self: any): { slots: { number }, buffers: { string } }
The column slots the table binds as direct columns, and the names of the buffers they are read from, in the order a variant binds them.
Parameters
selfany(optional)
modules/compute_abi/evaluate
evaluate(text: string, vars: { [string]: number }, lengths: (string) -> number): number
Evaluate a count / capacity expression.
Parameters
textstring— The expression.vars{ [string]: number }— The names it may use, with their values.lengths(string) -> number—len(binding): the element count of a bound run.
abi.evaluate("n * 4", { n = 10 }, function() return 0 end) --> 40
modules/compute_abi/fingerprint
fingerprint(text: string): string
A fingerprint of a text, the one lowered variants and fused kernels are keyed by.
Parameters
textstring— Any text.
local tag = abi.fingerprint(source)
modules/compute_abi/forget
forget()
Forget every compiled variant, so the next compile of each registers it again; for a device that was rebuilt.
modules/compute_abi/isExtended
isExtended(schema: { [string]: any }): boolean
Whether a schema uses any extension, which is what makes a shader lowered rather than compiled as written.
Parameters
schema{ [string]: any }— A parsed schema.
if abi.isExtended(schema) then ... end
modules/compute_abi/lower
lower(schema: { [string]: any }, wgsl: string, spec: { [string]: any }?): { [string]: any }
Lower a shader's extensions to the bindings and WGSL the engine compiles.
Parameters
schema{ [string]: any }— A parsed schema.wgslstring— The shader body, with its#includeliterals already canonicalized.spec{ [string]: any }?(optional) —{ specialize = { NAME = value }, columns = { [binding] = { names } }, direct = { [binding] = { slot } } }.directnames, per readcolumnsbinding, the column slots read from a binding of their own run (NAME_d0,NAME_d1, ... after the table), so those columns are not copied into the table.
local lowered = abi.lower(schema, wgsl, { specialize = { T = "vec3<f32>" } })
modules/compute_abi/loweredOf
loweredOf(key: string): { [string]: any }?
What compile lowered the program under key from: { lowered, label, base }, the lowered value lower
answered (its source, bindings, params, slots, workgroup and fusion). Nil for a key this module did not
compile, or one compiled before the device was rebuilt.
Parameters
keystring— A keycompileanswered.
local made = abi.loweredOf(entry.program)
modules/compute_abi/names
names(self: any): { string }
The names of the table's columns, in slot order.
Parameters
selfany(optional)
modules/compute_abi/noteWrite
noteWrite(name: string, method: string, payload: any, offset: number?)
Tell whoever is recording that the host wrote payload into the device buffer name.
Parameters
namestring— The buffer's name.methodstring—write(words as f32,offsetin words),writeU32orwriteBytes(offsetin bytes).payloadany(optional) — What was handed to the buffer's method.offsetnumber?(optional) — The method's offset argument.
abi.noteWrite(handle.name, "writeU32", { 0 })
modules/compute_abi/observeWrites
observeWrites(fn: (any) -> ()): () -> ()
Hear the writes the host makes into device buffers: fn(entry) is called with each write as a compute list
entry. Every call returns a function that stops listening.
Parameters
fn(any) -> ()— Called with{ write = bufferName, offset = words?, values, unsigned? }.
Returns () — The function that stops listening.
local stop = abi.observeWrites(function(entry) entries[#entries + 1] = entry end)
modules/compute_abi/pageBinding
pageBinding(lowered: { [string]: any }, runs: { [string]: any }): { [string]: any }
What a dispatch of a lowered kernel with page and column bindings binds: the arena page each page
binding names and the base and length of each column's run in it.
runs maps each column name to a buffer handle or name. A column's run stands in one arena page
(substrate.placement); every column the kernel declares in one page binding must stand in one page, and a
column outside an arena page (a buffer of its own) is a page of one column. A column in another page than the
rest of its binding, or a page two bindings name, raises naming both: the kernel is lowered for the partition of
columns it was given, and a partition that differs is a different kernel.
Parameters
lowered{ [string]: any }— A value fromlower.runs{ [string]: any }—{ [column] = handle | name }.
local bound = abi.pageBinding(lowered, { pos = positions, vel = velocities })
modules/compute_abi/pageEntry
pageEntry(key: string, lowered: { [string]: any }, runs: { [string]: any }, opts: { [string]: any }): { [string]: any }
The entry of a compute list (compute.program.list) that dispatches a page-bound kernel over runs: the
program, the pages it binds, the base and length of each column, and the runs it reaches through those pages,
with the ones its column declarations write. A list holding the entry keeps those runs standing and moves the
write revision of the ones the kernel writes, so a replay never runs over a run that was let go of, and what
reads a written run sees it changed.
Parameters
keystring— The keycompileanswered for the kernel.lowered{ [string]: any }— A value fromlower.runs{ [string]: any }—{ [column] = handle | name }.opts{ [string]: any }—{ workgroups, params?, buffers?, slots?, when? }—paramsare the kernel's own,buffersnames the buffer of each non-page binding,slotsandwhenare a list entry's.
compute.program.list("step", { abi.pageEntry(key, lowered, runs, { workgroups = { 1, 1, 1 } }) })
modules/compute_abi/parse
parse(content: string, file: string?): { [string]: any }
Parse bindings.yaml into { bindings, params, specialize, determinism, workgroup }. A binding without a kind is a buffer. Every YAML list
form reads: flow mappings, block mappings and flow lists. Raises, naming
file, on text the YAML decoder refuses (with the line) and on a list key
holding anything but a list of mappings (with the key).
Parameters
contentstring— The text ofbindings.yaml.filestring?(optional) — The file named in an error;bindings.yamlwhen omitted.
local schema = abi.parse(vfs.read(path .. "/bindings.yaml"), path .. "/bindings.yaml")
modules/compute_abi/program
program(def: { [string]: any }): any
A shader's ABI, ready to specialize and dispatch.
Parameters
def{ [string]: any }—{ key, label?, schema, wgsl, canonicalize? }: the registration key, the parsed schema, the shader body, and a function that resolves the#includeliterals of the lowered source.
local program = abi.program({ key = guid, schema = schema, wgsl = wgsl })
modules/compute_abi/read
read(handle: any, asU32: boolean?): { number }?
Read a buffer's words back, waiting for the frames the read takes.
Parameters
handleany(optional) — A buffer handle created withusage = { "readback" }.asU32boolean?(optional) — Answer the words as u32 (default f32).
local values = abi.read(out.buffer)
modules/compute_abi/release
release(baseKey: string): number
Release every variant compile registered under baseKey, and the program program made for it: each
variant's compiled program and params uniform are destroyed, and the next compile of one registers it again.
The teardown of a shader whose asset is gone.
Parameters
baseKeystring— The shader's registration key.
local released = abi.release(guid)
modules/compute_abi/repack
repack(self: any)
Copy the device buffers the table was packed from into it again, where they stand now: what a rewrite of those buffers in place leaves the table to read. The numbers it was given on the CPU stay as written.
Parameters
selfany(optional)
cols:repack()
modules/compute_abi/run
run(self: any, env: { [string]: any }): { [string]: any }
Dispatch the variant over env.n elements.
Parameters
selfany(optional)env{ [string]: any }—{ n, inputs = { [binding] = buffer | name | table }, outputs?, params?, values?, class?, owner? }:nis the element count;paramssets the shader's own params;valuesadds names to count expressions;class("effect"or"persistent") makes every buffer the run allocates a run of the device arenas, held forowner(substrate.createBuffer). Outputs withcountorcapacityare allocated here, except thoseoutputsnames:outputs[binding]is a buffer (or{ buffer, count?, capacity?, counter? }) the dispatch writes in place, and an appended output given one needs itscounter, whose count the dispatch keeps appending to. The first run of a variant waits for its program to be built, so a read of an output asked for after the run sees what the dispatch wrote.
local r = variant:run({ n = 10, inputs = { src = src } })
modules/compute_abi/slot
slot(self: any, name: string): number
The slot a named column holds.
Parameters
selfany(optional)namestring
modules/compute_abi/specKey
specKey(spec: { [string]: any }?): string
The variant for a specialization: lowered and compiled once.
Parameters
spec{ [string]: any }?(optional) —{ specialize = { NAME = value }, columns = { [binding] = { names } }, direct = { [binding] = { slot } } }.
local v = program:variant({ specialize = { T = "vec3<f32>" } })
modules/compute_abi/table
table(columns: { { [string]: any } }, opts: { [string]: any }?): any
Pack columns into one buffer a columns binding reads.
Parameters
columns{ { [string]: any } }— An array of{ name, kind = "f32" | "i32" | "u32", lanes?, count, values? | buffer? }.valuesare numbers a column holds, element after element (lanes contiguous);bufferis a GPU buffer whose words are copied in on the device.opts{ [string]: any }?(optional) —{ name = string, direct = { slot }, class?, owner? }: the name the buffer is created under, and the 0-based slots of the columns a variant binds as direct columns (abi.directPlan). A direct column is not copied: itsbufferis bound beside the table, and the table holds its header alone.class("effect"or"persistent") makes the table a run of the device arenas, held forowner(substrate.createBuffer), which the substrate names in place ofname.
local t = abi.table({ { name = "a", kind = "f32", count = 4, values = { 1, 2, 3, 4 } } }, { name = "cols" })
modules/compute_abi/wordCopyOf
wordCopyOf(entry: any): (string?, string?)
The source and destination of a recorded dispatch that is a copyWords from word 0: the copy of the first
words words of src into the same words of dst. Nil for any other entry.
Parameters
entryany(optional) — An entry of a recorded list.
local src, dst = abi.wordCopyOf(entry)
modules/connected_users/README
require("@builtin::modules.connected_users") -- connected_users
world.connectedUsers.* — server-replicated user registry. This module is user-scope and user-editable. The file you're reading is /zero/source/libs/@builtin/modules/connected_users.module/init.luau — anyone (any script, any agent, any user with VFS write) can rewrite it; hot-reload picks the change up and the engine uses the new version. There is no security boundary here. The read-only metatable below catches accidental writes loudly (API hygiene); it doesn't enforce anything. Trust boundaries that DO exist: - The Rust FFI (__connected_users.local_identity()) is registered into the VM state by the engine at boot and cannot be replaced from Luau. When it's called, it returns the real JWT sub. - The trusted VM (src/lua/trusted/**) is a separate Luau state, not on the user-writable VFS root, holds the auth.* namespace. User-scope Luau cannot reach it. - The server verifies the JWT on every RPC. Anything the server gates on flows through that check, not through whatever this module reports. What IS load-bearing: - __connected_users.local_identity() (Rust FFI) cannot be replaced. It always returns the real JWT sub of the engine's UserCredential, or nil for anonymous sessions. - The JWT bytes and session token NEVER cross any FFI exposed here; only the extracted identity string does. A malicious user-scope script can lie about identity but cannot exfiltrate the bearer token. - Authority on the server is established by the JWT the SDK presents on every request, not by anything this module reports. Multi-user replication plugs in on top of the same User metatable shape: the registry holds one record per person the published presence roster names (__presence.roster()), each carrying the engines they're connected through and the agents working for them (__presence.revision() gates the resync, so a re-send that changed nothing costs nothing). The local person always has a record — the roster view this engine reads folds it in even before any frame has arrived.
Usage: local connected_users = require("@builtin::modules.connected_users")
modules/contactShadows/README
require("@builtin::systems.contactShadows.contactShadows") -- contactShadows
Short screen-space shadow traces that supply the small-scale contact a shadow map cannot resolve — the grounding under a chair leg, a prop on a table, anything whose contact is finer than one shadow texel.
Usage: local contactShadows = require("@builtin::systems.contactShadows.contactShadows")
modules/contactShadows/active
active(): boolean
Whether the contact-shadow pass is running this frame.
if contactShadows.active() then ... end
modules/contactShadows/clear
clear()
Turn contact shadows off and release the pass. The other settings are
kept, so a later set({ strength = ... }) brings back the same look.
contactShadows.clear()
modules/contactShadows/get
get(): ContactState
The contact-shadow settings currently in force.
local l = contactShadows.get().length
modules/contactShadows/lights
lights(): { ContactLight }
The point, spot and distant lights the last refresh packed for the trace pass, ranked by what each is worth at the main camera.
local n = #contactShadows.lights()
modules/contactShadows/lightsBuffer
lightsBuffer(): any?
The light buffer the trace pass reads — one row per light the scene's contact traces reach toward, packed by the last refresh.
local l = contactShadows.lightsBuffer()
modules/contactShadows/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = contactShadows.paramsBuffer()
modules/contactShadows/refresh
refresh()
Re-read the scene's lights and re-push what the trace pass reads: the sun's direction and weight, and the lights supplying contact of their own. The render feature calls this every frame, so the traces follow lights that move, brighten or are spawned while the scene runs.
contactShadows.refresh()
modules/contactShadows/set
set(opts: ContactOpts?): ContactState
Set the scene's contact shadows. Any omitted field keeps its current
value. A strength of 0 turns them off and releases the pass.
Parameters
optsContactOpts?(optional) — Contact-shadow settings — seeContactOpts.
contactShadows.set({ strength = 0.9, length = 0.35, steps = 16 })
modules/data_contract/README
require("@builtin::modules.data_contract") -- data_contract
The dataContract field-constraint validator: a constrained value must be a .data instance whose dataType contract chain includes constraint.contract. Registers itself with the generic field_constraints registry on load.
Usage: local data_contract = require("@builtin::modules.data_contract")
modules/debanding/README
require("@builtin::systems.debanding.debanding") -- debanding
Gradient debanding. Rebuilds a shallow ramp that eight-bit storage flattened into shelves, so a sky or a light falloff reads as continuous instead of as a stack of contour lines.
Usage: local debanding = require("@builtin::systems.debanding.debanding")
modules/debanding/active
active(): boolean
Whether the debanding pass is running this frame.
if debanding.active() then ... end
modules/debanding/disable
disable()
Turn debanding off and release the pass.
debanding.disable()
modules/debanding/enable
enable(strength: number?): State
Turn debanding on at a given strength.
Parameters
strengthnumber?(optional) — Strength in [0, 1]. Omit to keep the current value.
debanding.enable()
modules/debanding/get
get(): State
The debanding settings currently in force.
local s = debanding.get().threshold
modules/debanding/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = debanding.paramsBuffer()
modules/debanding/set
set(opts: DebandOpts?): State
Set the debanding settings. Any omitted field keeps its current value.
Parameters
optsDebandOpts?(optional) — Debanding settings — seeDebandOpts.
debanding.set({ threshold = 3, radius = 16 })
modules/debugger/README
require("@builtin::modules.api.engine.debugger") -- debugger (also available as global 'debugger')
Luau debugger — breakpoints, stepping, stack inspection, watches. Public Luau surface over the __debugger Internal FFI namespace.
Usage: local debugger = require("@builtin::modules.api.engine.debugger") Also available as global: debugger
modules/debugger/__diagnostics
__diagnostics(): DebuggerDiagnostics
Internal diagnostic counters for debugging the debugger
itself: { installs, debugbreakHits }.
modules/debugger/addWatch
addWatch(expr: string): number
Register an expression to re-evaluate on every pause.
Parameters
exprstring— Luau expression.
modules/debugger/continue_
continue_(): boolean
Resume the paused thread. The thread resumes on the next scheduler tick. A task's thread settles like any resumed task: a wait it reaches is armed, what it returns is its result, and an error it raises is the task's error, reported the way every task error is. A task cancelled while paused does not run on. A coroutine a task resumed itself runs on with nothing waiting for it, and an error it raises is logged.
modules/debugger/disableAll
disableAll()
Disable every registered breakpoint. Records persist; bytecode BREAK ops are cleared.
modules/debugger/disconnect
disconnect(handle: number): boolean
Disconnect an onBreak or onResume callback.
Parameters
handlenumber— Handle returned by onBreak/onResume.
modules/debugger/enableAll
enableAll()
Enable every registered breakpoint and re-install them in the VM bytecode.
modules/debugger/evaluate
evaluate(expr: string, frame: number?): (string?, string?)
Evaluate an expression against the paused frame's
environment. Returns (value, error).
Parameters
exprstring— Luau expression.framenumber?(optional) — 1-based frame index (default 1).
modules/debugger/getLocals
getLocals(frame: number?): { [string]: string }
Locals captured at the active pause for the given frame index (1 = top). Values are stringified for safe display.
Parameters
framenumber?(optional) — 1-based frame index (default 1).
modules/debugger/getPauseInfo
getPauseInfo(): PauseInfo?
Info about the active pause, or nil if nothing is paused.
modules/debugger/getStack
getStack(): { Frame }
Captured stack from the active pause, top frame first. Empty when nothing is paused.
modules/debugger/getUpvalues
getUpvalues(frame: number?): { [string]: string }
Upvalues captured at the active pause for the given frame.
Parameters
framenumber?(optional) — 1-based frame index.
modules/debugger/getWatchValue
getWatchValue(id: number): (string?, string?)
Re-evaluate the watch expression against the paused frame's
environment and return (value, error).
Parameters
idnumber— Watch id.
modules/debugger/getWatches
getWatches(): { Watch }
Snapshot of all watches with their last evaluated value and error, sorted by id.
modules/debugger/isPauseOnError
isPauseOnError(): boolean
Current pause-on-error toggle state for this VM.
modules/debugger/isPaused
isPaused(): boolean
Whether the debugger currently has a paused thread.
modules/debugger/listBreakpoints
listBreakpoints(): { Breakpoint }
Snapshot of every registered breakpoint, sorted by id
ascending. Each entry reports whether it is installed:
chunkNames lists the loaded chunks carrying it, and
pendingReason says why an empty list is empty.
modules/debugger/onBreak
onBreak(fn: (PauseInfo) -> ()): number
Register a callback invoked on every pause with
{ path, line, reason }. Returns a handle usable with
debugger.disconnect.
Parameters
fn(PauseInfo) -> ()— Callback.
modules/debugger/onResume
onResume(fn: () -> ()): number
Register a callback invoked when the paused thread is resumed.
Parameters
fn() -> ()— Callback.
modules/debugger/removeBreakpoint
removeBreakpoint(id: number): boolean
Remove the breakpoint with the given id.
Parameters
idnumber— Breakpoint id returned by setBreakpoint.
modules/debugger/removeWatch
removeWatch(id: number): boolean
Remove the watch with the given id.
Parameters
idnumber— Watch id.
modules/debugger/setBreakpoint
setBreakpoint(path: string, line: number, opts: BreakpointOpts?): Breakpoint
Set a breakpoint at line in the script path names — its
VFS path, its require identity, or the chunk name it loaded
under. An installed breakpoint carries resolvedLine and lists
the loaded chunks holding it in chunkNames; one whose script is
not loaded carries pendingReason, an empty chunkNames, and
installs itself when that script loads.
Parameters
pathstring— VFS path, require identity, or chunk name.linenumber— 1-based source line.optsBreakpointOpts?(optional) —{ condition?, logMessage?, hitCount?, notify?, enabled? }.notifymakes it a TRACEPOINT: the hit firesonBreakhandlers against the frame it stopped in —getStack,getLocals,getUpvaluesandevaluateall answer for that frame — and then runs on, instead of holding the thread until something resumes it. That is how code observes a moment without stopping it; halting is for a person at a keyboard. A breakpoint on any line drops the enclosing function out of native code until its chunk reloads, so one left armed on a per-frame function costs more than it reports.
local bp = debugger.setBreakpoint("/zero/source/main.luau", 42)
print(bp.pendingReason or ("installed in " .. bp.chunkNames[1]))
modules/debugger/setPauseOnError
setPauseOnError(enabled: boolean)
When true, uncaught Luau errors fire the onBreak callback (observation only — the error still propagates).
Parameters
enabledboolean— Toggle state.
modules/debugger/stepInto
stepInto(): boolean
Run until the next line, descending into any function call.
modules/debugger/stepOut
stepOut(): boolean
Run until the current frame returns; pauses in the caller.
modules/debugger/stepOver
stepOver(): boolean
Run until the next line in the current frame. Calls inside the current line are skipped.
modules/debugger/toggleBreakpoint
toggleBreakpoint(path: string, line: number): Breakpoint?
Toggle a breakpoint at the given line: removes if present, adds otherwise.
Parameters
pathstring— VFS path, require identity, or chunk name.linenumber— 1-based line.
modules/denoiser/README
require("@builtin::systems.denoising.denoiser") -- denoiser
Edge-aware denoising a render feature routes a noisy signal through. A feature that shades from a few stochastic samples per pixel writes a result carrying that sampling noise, and the only way to quieten it in the feature itself is to cast more rays. Filtering the result instead buys the same quality far more cheaply, and the filter is the same one for every such feature, so it lives here rather than being rewritten per effect. A filter smooths in two directions. Across the frame it is an à-trous wavelet: successive passes with a doubling tap stride, so a handful of 5x5 passes reach the radius a single wide blur would need hundreds of taps for. Each tap is weighted by how much the surface under it resembles the surface under the centre pixel — its world position from @scene.depth and its normal from @scene.normal — so the smoothing follows geometry and stops at depth and normal discontinuities instead of bleeding an object's occlusion onto the wall behind it. Across time — with temporal set — it first carries the previous frame's estimate forward through @scene.motion, so the standing average holds far more samples than any one frame casts and the feature feeding it can trace fewer rays for the same quietness. A reprojected estimate is admitted only where the surface it was written on is the surface being shaded now, and never for longer than historyFrames. Each filter owns its targets and its compiled passes, keyed by the name it was created with, so two features denoising in the same frame do not interfere.
Usage: local denoiser = require("@builtin::systems.denoising.denoiser")
modules/denoiser/create
create(name: string, opts: DenoiseOpts?): Filter
Create a filter that owns its own targets and passes. name keys those
resources, so two features denoising in the same frame each pass their own
name and never share state.
Parameters
namestring— Identifies this filter's resources. Unique per feature.optsDenoiseOpts?(optional) — Filtering settings — seeDenoiseOpts.
local d = denoiser.create("rt_ao", { iterations = 4, worldSigma = 0.5, temporal = true })
modules/denoiser/destroy
destroy(self: Filter)
Release the filter's targets. The filter rebuilds on its next run.
Parameters
selfFilter
filter:destroy()
modules/denoiser/passes
passes(self: Filter): number
Consecutive order slots run occupies, counted from the order it is
given, so a caller knows where its own next pass can sit.
Parameters
selfFilter
local apply = 51 + filter:passes()
modules/denoiser/reset
reset(self: Filter)
Drop what the accumulation holds, so the next frame starts from its own samples. Call it at a camera cut, where nothing on screen was on the last frame and no reprojection could find it.
Parameters
selfFilter
filter:reset()
modules/denoiser/run
run(self: Filter, ctx: any, source: string, opts: { phase: string?, order: number? }?): string
Enqueue this filter's passes over source, and answer the guid holding
the filtered result. Call it from a render feature's render, passing the
same ctx; the result is ready for the phase and order given.
Parameters
selfFilterctxany(optional) — The render context the calling feature received.sourcestring— Guid of the texture holding the noisy signal.opts{ phase: string?, order: number? }?(optional) —{ phase, order }— where the filter's passes run.orderis the first ofpasses()consecutive slots.
local clean = filter:run(ctx, noisy.guid, { phase = "afterLighting", order = 55 })
modules/denoiser/stats
stats(self: Filter): DenoiseStats
What the filter is doing right now — whether it accumulates, whether it holds an accumulation, how many times that has been dropped, and the size its targets are built for.
Parameters
selfFilter
if not filter:stats().warmed then print("first frame of the accumulation") end
modules/deprecatedParticles/README
require("@builtin::deprecated.deprecatedParticles.deprecatedParticles") -- deprecatedParticles
Particle emitters: create one, list the ones that are live — every emitter, or one creator's own — and read what each is simulating and drawing right now: whose it is, how many particles are alive, what it costs on the GPU, and when it is producing nothing, which reason explains it.
Usage: local deprecatedParticles = require("@builtin::deprecated.deprecatedParticles.deprecatedParticles")
modules/deprecatedParticles/create
create(spec: table?): any
Create a GPU particle system from a spec, allocating its buffers and
registering it with the auto-update driver. The handle it returns carries
:emit, :update, the setters, :observe, and :getCreator.
Parameters
spectable?(optional) —{ maxCount, rate, lifetime, speed, shape, ... }— every field optional, each falling back to the emitter's default.ownerandnamesay whose the emitter is:owneris the keylist(owner)matches, so a creator reaches exactly its own emitters after it has lost their handles, andnamesays which of them this one is. An emitter that states neither is still attributed to the module and line it was created from. optional, each falling back to the emitter's default. A field that names one of a closed set takes a name from it and raises with the whole set otherwise; a key the spec does not define is reported on its own, naming the key that writes what it was written for.man particles.createlists every key the spec defines.
local fire = particles.create({ maxCount = 2000, rate = 100 })
local star = particles.create({ owner = "starfield", name = "shell" })
modules/deprecatedParticles/list
list(filter: (string | ParticleCreatorFilter)?): { any }
Every particle system this VM has created and not destroyed, in creation order — or, given a filter, the ones whose creator matches it. Answered from the emitter registry, so finding an emitter costs nothing per entity in the scene.
Called with nothing it answers with every emitter in the VM, which is what
makes it the way to reach one whose creator has lost its handle, and
:getCreator() on an entry says whose that one is. A filter narrows it to
one creator's own, so a module clears what a previous load of it left
behind and leaves every other emitter in the world standing.
Parameters
filter(string | ParticleCreatorFilter)?(optional) — Optional. A string matches theownerkey a creator stated; a table matches every one ofowner,nameandsourcethat it names.
for _, sys in ipairs(particles.list()) do print(sys:getActiveCount()) end
for _, sys in ipairs(particles.list("starfield")) do sys:destroy() end
local mine = particles.list({ source = debug.info(1, "s") })
modules/deprecatedParticles/observe
observe(system: any?): { [string]: any }
What the engine is simulating and drawing for particles right now.
With no argument, every live emitter plus the totals they sum to; with an
emitter, that one's reading. An engine holding no emitters answers
count = 0 with an empty list, which reads differently from an engine
whose emitters are all silent (count > 0, silent = count).
Parameters
systemany?(optional) — Optional particle system handle to read on its own.
local o = particles.observe(); print(o.count, o.alive, o.silent)
local r = particles.observe(fire); print(r.alive, r.bytes.total)
modules/deprecatedParticles/silenceReasons
silenceReasons(): { { reason: string, means: string } }
The closed set of reasons an emitter can be producing nothing, in the
order a reading resolves them — nearest cause first — each with what it
means. Every observe().reason is one of these.
for _, r in ipairs(particles.silenceReasons()) do print(r.reason, r.means) end
modules/deprecatedParticles/whySilent
whySilent(system: any): (string?, string?)
Why one emitter is producing nothing, from the closed set
silenceReasons() enumerates — or nil when it is producing. The second
return is the detail line naming what the reason is about.
Parameters
systemany(optional) — The particle system handle to ask about.
local why, detail = particles.whySilent(fire)
modules/deprecation/README
require("@builtin::modules.deprecation") -- deprecation
Whether an asset is deprecated, why, and what replaces it. An asset is deprecated when its own .metadata carries a deprecated marker, when any container holding it at any depth does (a package, a toolbox, a folder asset), or when its asset type does (every instance of that type). The marker is "deprecated": { "reason": "<one line why>", "replacedBy": "<identity of what to use instead>" }. of is the one function that answers it; search surfaces ask indexed, and resolving an asset asks warnOnce, which warns on the next frame.
Usage: local deprecation = require("@builtin::modules.deprecation")
modules/deprecation/describe
describe(subject: string, found: Deprecation): string
The sentence that names a deprecated asset, its reason and what replaces it.
Parameters
subjectstring— What the deprecation is of: an identity or a name.foundDeprecation— The deprecationofanswered.
log.warn(deprecation.describe(identity, d))
modules/deprecation/forget
forget()
Forget which assets have warned, which were found clean and what each
folder's .metadata was read to state, so the next use of each is read
again.
deprecation.forget()
modules/deprecation/indexed
indexed(ref: any, memo: { [string]: any }?): boolean
Whether a search may index and offer an asset: true unless the asset is deprecated. Every search surface asks this before it reads an asset, so a deprecated asset is never read, ranked or listed.
Parameters
refany(optional) — An asset handle, identity, guid or path.memo{ [string]: any }?(optional) — The table shared across one pass, asoftakes it. Optional.
if deprecation.indexed(ref, memo) then print(deprecation.of(ref)) end
modules/deprecation/of
of(ref: any, memo: { [string]: any }?, site: string?): Deprecation?
The deprecation an asset stands under, from its own marker, a container's or its asset type's; nil when it is not deprecated. The nearest marker wins: the asset's own, then each enclosing folder outward, then its asset type's.
Parameters
refany(optional) — An asset handle, identity, guid or path.memo{ [string]: any }?(optional) — A table shared across the calls of one pass, so a folder's.metadatais read once for every asset beneath it. Optional.sitestring?(optional) — The source a name given asrefwas written in (__asset.callerSite(), read where the call came in): a~.tailname expands against the root enclosing it and a name its reference table recorded reaches the asset recorded there. Optional.
local d = deprecation.of("@builtin::deprecated.deprecatedParticles.DeprecatedParticleEmitter")
modules/deprecation/settled
settled(): boolean
Whether every use warnOnce queued has been asked about, so each
deprecated one among them has warned.
while not deprecation.settled() do task.wait() end
modules/deprecation/warnOnce
warnOnce(ref: any): boolean
Warn that an asset is deprecated, once per session per asset, naming
the asset, the reason and the replacement. The use is asked about on the
next frame, so the call that named the asset reads nothing beyond the
index: a .metadata is read then, once for as long as it stands as it is.
An asset found clean is not asked again for a few seconds, so a hot path
resolving it pays one lookup.
Parameters
refany(optional) — An asset handle.
deprecation.warnOnce(handle)
modules/depthOfField/README
require("@builtin::systems.depthOfField.depthOfField") -- depthOfField
Depth of field from a lens — focus distance, focal length and aperture, so the falloff behaves the way a camera's does.
Usage: local depthOfField = require("@builtin::systems.depthOfField.depthOfField")
modules/depthOfField/active
active(): boolean
Whether the defocus passes are currently running.
if depthOfField.active() then print("shallow") end
modules/depthOfField/clear
clear()
Turn defocus off and release the passes. The lens is kept, so a later
set({ fStop = ... }) brings back the same look.
depthOfField.clear()
modules/depthOfField/get
get(): DepthOfFieldState
The lens currently in force.
local f = depthOfField.get().focusDistance
modules/depthOfField/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = depthOfField.paramsBuffer()
modules/depthOfField/set
set(opts: DepthOfFieldOpts?): DepthOfFieldState
Set the lens. Any omitted field keeps its current value, so a call can
rack focus without restating the rest. An fStop of 0 turns defocus off
and releases the passes.
Parameters
optsDepthOfFieldOpts?(optional) — Lens settings — seeDepthOfFieldOpts.
depthOfField.set({ focusDistance = 8, fStop = 1.8, focalLength = 85 })
modules/discovery/README
require("@builtin::modules.discovery") -- discovery
Content search in this engine: keyword mode over the files each asset type's type.yaml names, semantic mode through ZeroMind over the scope this world can reach. One question, one answer shape, two modes.
search { q, assetType, match, mode, limit } is the question; match
applies to keyword mode only. q is a
phrase or a list of them and the answer carries one results entry per
query, in the order they were asked. searchGuides asks it the way a
guides query does: over the documentation types DOC_TYPES names when
it names no assetType, and an answer that found nothing names the
surface that searches every other kind.
Keyword mode reads the files each asset type declares under
indexing.data in its type.yaml, for the slot match selects:
identity is the identity role, capability is the capability,
interface and implementation roles together, any is either and
all is both. The query's words are matched against that text, each word
counting once for the asset that carries it, and an asset ranks by what
the words it carries as words of their own weigh, a word weighing more the
fewer of the assets read carry it, then by how many it carries side by
side in the query's order, then by how many it carries anywhere in its
text. It runs on the files this engine holds, so unpushed content and a
private world's own content are in it, and from code that can yield it
reads them across frames, giving the frame back every SLICE_MS.
Semantic mode is ZeroMind's ranking over what ZeroMind may embed. Say what
you need in q, in plain words. The search decides which asset types the
words are about and orders what it keeps by how relevant a judge read each
hit to be. match does not apply to it, and naming an assetType replaces
that decision: only the named types are searched, so a type guessed wrong
answers nothing. Name one only when the task fixes the type. The answer
names the worlds it covered.
Every answer states the scope it ran from — from, the bound world, and
the searched worlds — and every hit carries the local form of the asset
this engine holds: its path, the identity a call names a tool by, the
identity guides reads a guide or an assetType's README by.
Usage: local discovery = require("@builtin::modules.discovery")
modules/discovery/answer
answer(fields: {
Assemble an answer: the mode and match that ran, the scope it ran from,
the results by query position, and the status they hold. A refused request
ran no mode and names none. An answered semantic search from a private
world is promoted to private_world and carries the note saying what was
searched; every other status stands as given. An answered semantic search
whose narrowed is false ran naming no kind, and carries the note saying
the ranking covered every kind ZeroMind holds. An answered search whose
results hold no hit at all carries emptyNote, the sentence its surface
gives for having found nothing. The notes stand in one note, the
private-world sentence first: status names that promotion, so the
sentence it reads for opens what the answer carries. A keyword answer
states scanned, the most assets one of its queries read, and cut,
whether any query's walk stopped at KEYWORD_SCAN_MAX. A library
answer ranked over the published library and carries the note saying so,
and is not promoted to private_world, since it lists this world's own
matches itself; kinds names the kinds the search read, and the note then
says it read only those; librarySkipped is the reason a library search could not
ask ZeroMind, and adds the note saying the hits are this world's own.
local out = discovery.answer({ mode = "keyword", match = "any", status = "answered", results = results, scope = scope })
modules/discovery/awaitJob
awaitJob(poll: () -> any, budgetMs: number): (any, number)
Poll poll until it reports a terminal status, giving up after
budgetMs of wall clock. The budget is measured against the clock, so it
means the same span whatever the frame rate is.
Parameters
poll() -> any— Reads the job's current state.budgetMsnumber— How long to wait, in milliseconds.
local settled, ms = discovery.awaitJob(poll, 15000)
modules/discovery/boundGuid
boundGuid(): string?
The guid of the world this engine is bound to, or nil on an engine bound to none. Every read of the binding in this module goes through it.
local guid = discovery.boundGuid()
modules/discovery/boundWorld
boundWorld(): BoundWorld?
The world this engine is bound to, with whether it is private — which
is what decides whether its own content is anything ZeroMind may embed.
Reads the visibility through visibility, and holds a world whose
visibility cannot be read as private. Nil when no world is bound.
local here = discovery.boundWorld()
modules/discovery/defaultMode
defaultMode(): string
The mode a call runs when it names none: semantic on a live engine, keyword on an offline boot.
local mode = discovery.defaultMode()
modules/discovery/fetch
fetch(
One semantic fetch: the trusted job for one query over worlds, read
into { ok, hits, total?, types?, containers?, elapsedMs } or
{ ok = false, error, reason, elapsedMs }. semantic asks every query
through it, so the answer ZeroMind sent is read in one place.
local answer = discovery.fetch("outline", {}, nil, 10, 15000, false)
modules/discovery/forget
forget()
Drop every held text. The next query reads its files again.
discovery.forget()
modules/discovery/guideTypes
guideTypes(): { string }
The types a guides query searches: the ones types() lists that
DOC_TYPES names — the documentation this engine holds. In name order.
local names = discovery.guideTypes()
modules/discovery/identityOf
identityOf(hit: Hit): string
The name the surface acting on a tool-family hit takes: a tool's
<toolbox>.<tool> identity, which tools.use calls, and a toolbox's name,
which a search_tools { toolbox } drill-in lists. A tool the registry does
not hold is named by the toolbox its folder sits in and the name of its
own .tool folder; a hit this engine does not hold, by its name.
Parameters
hitHit— One hit of asearchanswer.
local identity = discovery.identityOf(hits[1])
modules/discovery/indexing
indexing(typeName: string): { IndexingEntry }?
The indexing recipe a type declares in its type.yaml, as
{ { role, extractor, files, order } } in declared order, or nil when the
type declares none, is deprecated, or does not exist. A deprecated type
is not indexed, so none of its instances is read. order is the entry's place in
indexing.data, which is what ranks two hits that matched the same number
of words.
Parameters
typeNamestring— The asset type's name, in any casing ("guide").
local recipe = discovery.indexing("guide")
modules/discovery/installedOrigin
installedOrigin(row: any): SearchedWorld?
One searched entry for an installed row's origin world, or nil when
the row names none. why is library for a package, import
otherwise. title is read from the row's own record of its origin
world's title; a row whose install carried none leaves it nil, so that
origin is named by guid alone.
Parameters
rowany(optional) — Oneworld.installedAssets()row.
local entry = discovery.installedOrigin({ origin_world_guid = "...", kind = "material" })
modules/discovery/installedPaths
installedPaths(): { [string]: boolean }
The paths of everything this world carries from ZeroMind, as
installedRows lists them: every library, imported asset and
dependency a pull wrote. Empty on an engine bound to no world.
local pulled = discovery.installedPaths()
modules/discovery/installedRows
installedRows(): { any }
What this world carries from ZeroMind, as world.installedAssets()
lists it: one row per library, imported asset and dependency a pull
wrote. Every read of the installed set in this module goes through it.
Empty on an engine bound to no world, or when the list cannot be read.
local rows = discovery.installedRows()
modules/discovery/keyword
keyword(
Keyword mode over the assets this engine holds: the assets of the
named types, read through each type's recipe for the slot match selects,
ranked by what the query's words the asset carried as words of their own
weigh together (hand in "hand it over", spawn in "spawns", and not off
in "offline"). A word weighs more the fewer of the assets the walk read
carry it, so in "roster who is here" the asset saying "roster" ranks above
the many saying "who is here". Then by the most of them it carried side by
side in the query's order, so a tool saying "hand off" ranks above one
saying "hand" and "off" apart, then by how many it carried anywhere in its
text, then by the order the type declares the role that matched, then by
name. The walk takes this world's own assets first and the library's after
them, each the types' assets in turn (the first of each type, then the
second of each), and reads at most KEYWORD_SCAN_MAX of them. Called from
code that can yield, it gives the frame back every SLICE_MS while it
reads.
local hits, corpus, walk = discovery.keyword("outline", { assetType = "guide", match = "any", limit = 5 })
modules/discovery/keywordScope
keywordScope(corpus: Corpus): Scope
The scope a keyword answer names: the bound world, and the worlds whose content the query actually read. It asks ZeroMind nothing.
Parameters
corpusCorpus— Where the assets a query read came from.
local scope = discovery.keywordScope({ builtin = true, world = false })
modules/discovery/kindParam
kindParam(assetType: string?): string?
The kind a semantic request names for a comma list of type names:
each registered type travels as the guid of its .assetType, the identity
ZeroMind files it under wherever it was declared, builtin types included.
A name no registered type answers to travels as written in lowercase, so
ZeroMind names the one it does not know.
Parameters
assetTypestring?(optional) — A comma list of type names, or nil.
local kind = discovery.kindParam("guide,module")
modules/discovery/libraryScope
libraryScope(): Scope
The scope a library search names: no world at all. Naming no world is what widens the ranking from the content this engine can see to everything published, because the request carries a world filter only when it has worlds to name. The bound world still travels, so an answer can say where the search was made from.
local scope = discovery.libraryScope()
modules/discovery/newSlice
newSlice(): () -> ()
A function to call between the pieces of a long walk: it yields one
frame once SLICE_MS has run since the slice began, and does nothing for
a caller that cannot yield. Each walk makes its own.
Returns () — The function to call between pieces.
local between = discovery.newSlice(); for _, ref in ipairs(asset.list("tool")) do between() end
modules/discovery/onlyKinds
onlyKinds<T>(hits: { T }, kinds: { [string]: boolean }, limit: number): { T }
The hits of hits whose kind kinds holds, in their order, at most
limit of them.
Parameters
hits{ T }— Hits, each carryingkind.kinds{ [string]: boolean }— Lowercase kind names to keep.limitnumber— How many to keep.
local kept = discovery.onlyKinds(hits, discovery.DOC_TYPES, 10)
modules/discovery/resolve
resolve(guid: string): LocalForm?
The local form of an asset this world holds, by guid: its path, the
identity a call names a tool by, the name a drill-in lists a toolbox by
(for a tool, its own toolbox's), whether the registry holds what a tool
or toolbox hit names, the identity guides reads a guide or an
assetType's README by, and the VFS path of the asset's README when it
holds one. Nil when this world holds no asset under that guid.
Parameters
guidstring— The published guid.
local here = discovery.resolve(hit.guid)
modules/discovery/resting
resting(): (number?, string?)
How long the semantic leg is still resting, in seconds, and the failure it is resting after. Nil when it is not resting; the window closes as soon as it has run out.
local seconds, why = discovery.resting()
modules/discovery/scope
scope(): Scope
The worlds a semantic search covers from this engine, and the bound world it runs from. The builtin library is always in reach; this world is in when it is public; the origin world of every installed library and imported asset is in through the public world that published it.
local scope = discovery.scope()
modules/discovery/search
search(req: { [string]: any }): { [string]: any }
Search this engine's content. req is
{ q, assetType?, match?, mode?, from?, limit?, budgetMs?, within? }: q is a phrase or
a list of them, assetType a comma list of type names as types()
lists them (a name types() does not list is refused, and the refusal
names every type it lists; in semantic mode leave it out unless the task
fixes the type, since naming one replaces the search's own choice of
types), match (keyword mode only) one of
identity / capability / any / all, mode one of keyword /
semantic, within a folder path or a list of them that the walk of this
engine's own files is held to (the library ranking is not), and from
where results may come from: all is everything published (what
library = true asks), bound the current world and its installed
libraries, with no published-library leg, in either mode. Naming no
from keeps a library the request states; stating neither searches
everything published in semantic mode and this engine's own files in
keyword mode. A name other than those two is refused, and from = "all" with
mode = "keyword" is refused, since keyword mode reads this engine's
own files. Every answer carries mode, from, status, the
bound world, the searched worlds, and one results entry per query;
a keyword answer also carries match.
Parameters
req{ [string]: any }— The request table.excerptsasks each hit to carry the passage it was ranked on, which costs the fuller hit payload; documentation searches ask for them already.libraryranks over the whole published library instead of the content this engine can see, for a caller looking for something to install rather than something already here, and lists this world's own matches by their words after the library's hits, each markedfrom = "world"; when ZeroMind cannot be asked, those own matches still answer and the note says why the library was not searched. It is off by default, andmode: keywordrefuses it, since keyword mode reads this engine's own files.
local out = discovery.search({ q = "outline", assetType = "guide", mode = "keyword" })
local out = discovery.search({ q = "outline", excerpts = true })
modules/discovery/searchGuides
searchGuides(req: { [string]: any }): { [string]: any }
Search as a guides query asks: search over the documentation types
DOC_TYPES names, or over exactly the ones of them req.assetType names.
Naming no type, keyword mode walks the types guideTypes() lists, and
semantic mode asks ZeroMind over them (semanticKinds) and keeps only
those kinds of its hits. An answered
search that found nothing carries NO_DOCS_NOTE, saying which kinds it
matched against. An assetType naming a type TOOL_TYPES
holds is refused with a sentence that points to search_tools, and one
naming any other type types() lists with a sentence that points to
discovery.search. The answer is search's, in rank order.
Parameters
req{ [string]: any }—{ q, assetType?, match?, mode?, from?, limit?, budgetMs?, excerpts? }, assearchtakes it. A semantic search here carriesexcerpton each hit unlessexcerpts = falsesays not to: a reader asking the documentation a question is answered by the passage that answered it, not only by what the guide is.
local out = discovery.searchGuides({ q = "outline", mode = "keyword" })
modules/discovery/searchTools
searchTools(req: { [string]: any }): { [string]: any }
Search as a search_tools query asks: search over the types
TOOL_TYPES names (tools, toolboxes and workflows), or over exactly the
ones of them req.assetType names. Naming no type, keyword mode walks the
types toolTypes() lists, and semantic mode asks ZeroMind over them
(semanticKinds) and keeps only those kinds of its hits. An assetType
naming any other type is refused with a sentence that points to the
surface that searches it. The answer is search's, in rank order.
Parameters
req{ [string]: any }—{ q, assetType?, match?, mode?, from?, limit?, budgetMs?, library?, within? }, assearchtakes it.
local out = discovery.searchTools({ q = "orbit the camera", mode = "keyword" })
modules/discovery/semantic
semantic(
Semantic mode: ZeroMind's ranking over scope for the types
opts.assetType names (none: the search decides which types the words are
about), spelled for the request through kindParam, each hit carrying the local form of the asset
when this engine holds it. opts.only names the kinds the answer keeps:
the request then names opts.kinds, asks for SEMANTIC_FETCH_MAX hits,
and keeps the first limit of those kinds in ZeroMind's order, so a
ranking that could not be narrowed on the request is narrowed here.
A failure that cost more than EXPENSIVE_FAILURE_MS reached ZeroMind, and
opens the rest window resting() reports.
local results, status, err = discovery.semantic({ "outline" }, opts, discovery.scope())
modules/discovery/semanticKinds
semanticKinds(names: { string }): string?
The kind a semantic request names to cover names: the guid of each
one's .assetType, as kindParam spells it. A name no registered type
answers to is left out. Nil when none of them resolves, which is the
request that names no kind and ranks over all of them.
Parameters
names{ string }— Type names, astypes()spells them.
local kind = discovery.semanticKinds(discovery.guideTypes())
modules/discovery/shape
shape(answer: { [string]: any }, form: string, query: string?): { [string]: any }
A search answer in the shape a surface hands it on, built where the
search ran so every way of collecting it reads the same value.
"answer" is the answer itself with each hit's local form named local.
"guides" is { kind = "search", query, match_count, matches }, a row
per hit: a guide's (assetType guide) or an asset type's (assetType assettype) names
the guides { path } identity as path and carries summary, and the
excerpt it was ranked on where the search asked for one; any other
type's names its assetType, a one-line purpose and the VFS path of its
README as vfs_path. Every row of either list form carries guid, installed (whether
this world holds it), skill on an agent skill and workflow on a
workflow this world holds, p when the search core judged it, and from = "world" on a match found in
this world's own content after a library ranking. Every row of every
form whose hit the search core ranked carries container_key and
system_key, keys into the answer's containers: the container the hit
ships in and the highest one above it (a tool's toolbox and the package
it ships in), or the world it belongs to; each container entry names the
one above it by parent_key. "answer" keeps containers on each
query's result; both list forms carry it once, beside the rows.
"tools" is { type = "functions", count, functions }, a row per hit
naming its assetType (tool, toolbox or workflow), its identity (discovery.identityOf:
the tools.use identity of a tool, the drill-in name of a toolbox), its
toolbox, a one-line purpose and whether the registry holds what the
identity names; a tool row carries tool, the tools.use identity while
the registry holds it and empty while it does not. Both list forms carry the
answer's mode, match, from, status, world, searched, note,
error, retry_in_s, scanned and cut beside the rows, and total,
how many the search matched of which the rows are the best, when it
answered one query and counted them.
Parameters
answer{ [string]: any }— Whatsearchanswered.formstring—"answer","guides"or"tools".querystring?(optional) — The query a"guides"answer echoes.
return discovery.shape(discovery.searchGuides({ q = "outline" }), "guides", "outline")
modules/discovery/stats
stats(): { reads: number, bytes: number, visibilityReads: number }
What this module has read and what it is holding. reads is the number
of vfs.read calls it has made — a query that reads content it already
holds against an unchanged checksum leaves it where it stood. bytes is
the asset text held right now, which stays under TEXT_BUDGET_BYTES.
visibilityReads is the number of times it has asked ZeroMind for a
world's visibility.
local before = discovery.stats().reads
modules/discovery/toolTypes
toolTypes(): { string }
The types a search_tools query searches: the ones types() lists
that TOOL_TYPES names, the things an agent runs. In name order.
local names = discovery.toolTypes()
modules/discovery/toolboxKey
toolboxKey(path: string): string?
The name the tool registry carries a toolbox under, for a .tool at
path. A toolbox under a library root other than the builtin one is
registered scope-qualified (@lib::ns); every other toolbox is registered
under its bare name.
Parameters
pathstring— The tool's VFS path.
discovery.toolboxKey("/zero/source/libs/@builtin/tools/zm.toolbox/status.tool")
modules/discovery/types
types(): { string }
Every asset type whose type.yaml declares an indexing recipe — the
types a search can read, in name order.
for _, name in ipairs(discovery.types()) do print(name) end
modules/discovery/visibility
visibility(guid: string): string?
A world's visibility as ZeroMind reports it, read through the trusted
world read and waiting up to VISIBILITY_BUDGET_MS. An answer is held for
the guid, so each world is asked once; nil when the engine cannot read it.
Parameters
guidstring— The world's guid.
local visibility = discovery.visibility(world.guid())
modules/discovery/withWorldMatches
withWorldMatches(results: { QueryResult }, own: { { Hit } }): { QueryResult }
A library ranking with this world's own matches listed after it, query
by query: own[i] are the hits keyword mode found for results[i] in
this world's own content. A hit the library already returned stays where
the library put it; every other one is appended in the order keyword mode
ranked it, marked from = "world". The library's hits keep the order the
search core gave them, and no score is changed or combined.
Parameters
results{ QueryResult }— The library ranking, by query position.own{ { Hit } }— This world's own matches, by the same positions.
local merged = discovery.withWorldMatches(results, { ownHits })
modules/discovery/worldHere
worldHere(): BoundWorld?
The world this engine is bound to, as the engine itself knows it: its
guid and title, and private when a semantic search has already read the
world's visibility. Nothing here waits on ZeroMind, which is what lets a
keyword answer and a refusal name the world at once. Nil when no world is
bound.
local here = discovery.worldHere()
modules/discovery/worldOwn
worldOwn(path: string, installed: { [string]: boolean }): boolean
Whether an asset at path is this world's own content: not the
builtin library, not an installed library root (libs/@<name>/), not a
dependency a pull brought (/source/deps/), and not at or inside a path
installed holds. Those are the content a library ranking already
covers; what is left is what this world's authors made here.
Parameters
pathstring— The asset's VFS path.installed{ [string]: boolean }— WhatinstalledPaths()answered.
local own = discovery.worldOwn("/source/tools/mine.toolbox/go.tool", discovery.installedPaths())
modules/diverged
modules.diverged() -> { { module: string, reason: string } }
The modules whose running code differs from their source: each one's hot reload failed (its new source did not compile, or its body raised while it ran), so the code it ran before that edit is still running. Each entry names the module by the key it is required under and gives the reason its reload failed. A module leaves the list once it loads cleanly, and each failure also posts an error notice that stands until then.
Returns { { module: string, reason: string } } — One entry per module whose running code differs from its source; empty when every module runs its source
modules/editor.asset_instance_inspector/README
require("@builtin::modules.editor.asset_instance_inspector") -- editor.asset_instance_inspector
The entity inspector's view of an Asset component — an instance of an asset placed in the scene. It says which asset the instance is linked to and how it stands against it: every part the asset composed, whether it is as the asset has it or was edited, removed or added in the scene, and what the edit changed. Each edited part can be reverted to the asset, selected, or the whole instance reverted or unpacked into plain scene entities.
Usage: local editor.asset_instance_inspector = require("@builtin::modules.editor.asset_instance_inspector")
modules/editor.asset_instance_inspector/build
build(ctx: any): { any }
The Asset component's card body on an entity (edui.inspector): the
summary badges, the source field as the component's typed, undoable
setting, the Overrides and Linked parts lists, and the revert / unpack
actions, built from M.sections with ctx.widgets.
Parameters
ctxany(optional) — The inspector Context of the Asset component on its entity.
modules/editor.asset_instance_inspector/sections
sections(entityId: string, proxy: any): any
The view's sections for one Asset component: a summary of how the
instance stands against its asset, its source field, the parts that
differ from the asset and the parts that match it, and the actions that
revert or unpack it.
Parameters
entityIdstring— The entity the component is on.proxyany(optional) — The live Asset component.
modules/edui.app/README
require("@builtin::editor.edui.app") -- edui.app
The edui reactive core: an App owns one ui.* screen, maps author closures to ui.* string callback ids, dispatches the broadcast that ui.registerCallbackEnv delivers, and rebuilds the widget tree on state change. This is the layer that lets editor chrome be written with closures (onClick = function() ... end) instead of hand-managed string ids — the footgun the deprecated zui grew three shapes for.
Usage: local edui.app = require("@builtin::editor.edui.app")
modules/edui.app/adoptHandlers
adoptHandlers(self: any, bucket: { [string]: (any) -> () })
Re-register a bucket of handlers collected by collectHandlers into
the current build, keeping a cached subtree's callbacks live.
Parameters
selfany(optional)bucket{ [string]: (any) -> () }— The handler bucket to adopt.
app:adoptHandlers(cached.bucket)
modules/edui.app/cb
cb(self: any, closure: (any) -> (), key: (string | number)?): string
Allocate (or reuse) a callback id bound to closure for this build.
Pass a stable key so the id is identical across rebuilds — required for
anything the renderer tracks by id (focus, drag, ui.widgetState).
Without a key the id is a per-build sequence number (fine for a
fire-and-forget button).
Parameters
selfany(optional)closure(any) -> ()— The handler(data) -> ()the id dispatches to.key(string | number)?(optional) — Optional stable key (unique within this screen).
props = { onClick = app:cb(function() doThing() end, "save") }
modules/edui.app/cbRaw
cbRaw(self: any, id: string, closure: (any) -> ()): string
Register closure under the EXACT id id, without the screen-name
prefix cb adds. For wiring engine-emitted interaction ids that a widget
publishes itself (e.g. a dockArea's <panelId>-close), which arrive
unprefixed. Re-issue it each build, like cb.
Parameters
selfany(optional)idstring— The exact callback id the engine will deliver.closure(any) -> ()— The handler(data) -> ().
app:cbRaw(panelId .. "-close", function() closePanel(panelId) end)
modules/edui.app/collectHandlers
collectHandlers(self: any, fn: () -> any): (any, { [string]: (any) -> () })
Collect every callback registered while fn runs into a named bucket,
returned alongside fn's result. A host that CACHES the subtree fn
built re-adopts the bucket on later builds (adoptHandlers), so the
cached tree's callback ids stay live across rebuilds that skipped it.
Parameters
selfany(optional)fn() -> any— The builder to run.
Returns () }) — fn's result, and the bucket of handlers it registered.
local tree, bucket = app:collectHandlers(function() return panel.build() end)
modules/edui.app/current
current(): any
The app whose builder is currently running, or nil outside a build.
The edui.* primitive builders read this to register their closures, so
authors don't thread the app through every call.
local app = edui.app.current()
modules/edui.app/dispatch
dispatch(self: any, id: string, data: any): boolean
Route a callback id to its closure and schedule a rebuild. This is
what the screen's onCallback broadcast calls. Returns true when the id
was handled by this app (an id from another surface returns false so a
host can keep routing).
Parameters
selfany(optional)idstring— The callback id the broadcast delivered.dataany(optional) — The engine event envelope{ value, eventType, widgetId, button, mouseX, mouseY }. The handler receives itsvalue: a scalar foronChange(checkbox bool, input string, select value), a{ dx, dy, shift, ctrl, alt }table for a canvasonDrag/onScroll,nilfor a bareonClick.
function onCallback(id, data) app:dispatch(id, data) end
modules/edui.app/markDirty
markDirty(self: any)
Mark the app dirty and rebuild its tree. Coalesces a rebuild requested WHILE a build is running into a single follow-up build (so a handler that mutates state and a builder that reads it never recurse), and one requested WHILE a dispatch's handler runs into the single rebuild that dispatch performs after the handler returns.
Parameters
selfany(optional)
modules/edui.app/mount
mount(self: any, builderFn: (any) -> any): any
Mount the app: register the broadcast callback env and do the first
build. builderFn(app) -> widgetTree is called now and on every rebuild;
inside it, app:cb(...) (or the edui.* primitives) wire closures.
Parameters
selfany(optional)builderFn(any) -> any—(app) -> widgetTree.
app:mount(function(a) return { type = "vertical", children = { ... } } end)
modules/edui.app/new
new(screenName: string, opts: { [string]: any }?): any
Create an editor app that owns the ui.* screen screenName.
Parameters
screenNamestring— Unique screen id (also the callback-id namespace prefix).opts{ [string]: any }?(optional) —{ layer? = <renderLayerMask>, order? = <number>, callbackKey? = <string> }.layeris a render-layer membership mask (e.g. the EditorUI bit) applied viaui.setScreenRenderLayeron first register; omit for the default.orderis the screen's Z-ORDER — higher paints on top; a floating surface (the command palette) states one to stand over the dock.
local app = edui.app.new("myPanel", { layer = editorMask })
modules/edui.app/rebuild
rebuild(self: any)
Run the builder and push the resulting tree to the screen. First call registers the screen (+ render layer); later calls update it. Builder errors are logged, never thrown, so one bad build never wedges the editor.
Parameters
selfany(optional)
modules/edui.app/unchanged
unchanged(self: any, sig: string): boolean
Whether the tree this build would produce is the one the app's screen
already shows. sig names every piece of state the build reads: an equal
signature means the published tree already says it, so the builder returns
nil and the App keeps what it published, at O(1) cost however large the
tree. The signature belongs to the App that published the tree, so an App
with nothing published reports a change and gets a tree to register.
Parameters
selfany(optional)sigstring— The signature of the state this build reads.
if app:unchanged(buildSignature()) then return nil end
modules/edui.app/unmount
unmount(self: any)
Tear the app down: release the callback env and unregister the screen.
Parameters
selfany(optional)
modules/edui.argForm/README
require("@builtin::editor.edui.widgets.argForm") -- edui.argForm
The typed argument form — a declared argument list becomes a form of REAL controls, and the filled form becomes the typed values a call takes. A person never types a Luau literal: strings get a text field, numbers a numeric field, booleans a checkbox, string-literal unions a chip row, colours a colour swatch, Vec3 three axis fields, and an options table expands one level into typed rows of its own. Only a type outside the model falls back to the literal field. The command palette renders every tool through this; the Inspector renders an asset type's operations through the same form, so any surface that knows a signature can offer it.
Usage: local edui.argForm = require("@builtin::editor.edui.widgets.argForm")
modules/edui.argForm/fieldRows
fieldRows(self: any, path: string, t: string, optional: boolean,
The label + control rows for one argument (or one expanded table
field). depth indents expanded option fields under their parent.
modules/edui.argForm/make
make(W: any): any
Bind the form builder to the widgets barrel W. The barrel calls this
once; consumers reach the result as edui.argForm.
Parameters
Wany(optional)
modules/edui.argForm/new
new(o: { [string]: any }): any
A new form instance. o.ns (REQUIRED — the id namespace every
control keys under), o.typeDefs (the schema's named definitions,
{ { name, definition } }), o.onSubmit (fired when Enter lands in
a text field — the run affordance), o.onChanged (fired after any
control writes a value, for hosts that gate rebuilds on an epoch).
Parameters
o{ [string]: any }
modules/edui.argForm/parseSignature
parseSignature(sig: string): { any }
Parse a method signature string — "(self, name: string, opts: T?)" —
into the argument list a form renders: { { name, type, optional } }.
A leading self is the receiver, not an argument, and is dropped. The
arguments are the balanced parenthesised run at the head of the text, so a
signature that goes on to declare what the call hands back —
"(self, name: string): boolean" — renders the same form as one that
stops at the arguments.
Parameters
sigstring— The signature text.
modules/edui.argForm/rows
rows(self: any, args: { any }): { any }
The rows for a whole argument list (each { name, type, optional, description? }), in order.
Parameters
selfany(optional)args{ any }
modules/edui.argForm/values
values(self: any, args: { any }): (boolean, any, number?)
Assemble the positional values for args from the filled form.
Returns (true, values, n) — n the last non-nil position for
table.unpack(values, 1, n) — or (false, message).
Parameters
selfany(optional)args{ any }
modules/edui.cmdPalette/README
require("@builtin::editor.edui.cmdPalette") -- edui.cmdPalette
The command palette — search everything under one keystroke. Ctrl+K (or the topbar's Tools button) opens a floating surface whose one query reaches the scene's entities (select + frame), the registered assets (select — the Inspector shows it), the editor's panels (focus), and the whole tool registry (pick one and its typed argument schema becomes a form, Run executing it in place). A t: / e: / a: / p: prefix narrows to one domain. Every domain reads its live registry, so what exists is findable with no UI work per addition.
Usage: local edui.cmdPalette = require("@builtin::editor.edui.cmdPalette")
modules/edui.cmdPalette/isOpen
isOpen(): boolean
Whether the palette is up. The screen's live visibility is the one answer every scope shares — the menu bar, the entrypoint, and a panel each hold their own copy of this module, and a module-local flag left them disagreeing about whether the palette was open, so a Close click handled by one copy re-showed what another copy had shown.
modules/edui.cmdPalette/mount
mount(layerMask: number?)
Mount the palette (idempotent): its own screen, hidden until toggled.
Parameters
layerMasknumber?(optional) — Optional EditorUI render-layer mask (the menu bar passes its own).
modules/edui.cmdPalette/openTool
openTool(name: string)
Open the palette directly at a tool's form — the deep link another
surface uses to hand a person a ready-to-fill tool ("run this operation"
from an inspector, a docs page, an agent suggestion). Opens the palette
if it is closed, then loads name's schema as the form.
Parameters
namestring— The tool's full name,toolbox.tool.
modules/edui.cmdPalette/screenName
screenName(): string
The palette's screen name (capture / element addressing).
modules/edui.cmdPalette/toggle
toggle()
Open / close the palette. Opening starts fresh at the search and puts the caret in it. The decision reads the screen's live visibility, never a module-local flag.
modules/edui.cmdPalette/unmount
unmount()
Tear the palette down.
modules/edui.confirmDialog/README
require("@builtin::editor.edui.confirmDialog") -- edui.confirmDialog
The editor's confirmation dialog: a question over the whole editor with a row of answers. One question shows at a time. Opening another while one is up puts the new one in front, and the earlier one comes back once the new one is answered. An answer's run decides whether its question closes: returning false, why keeps it up with why shown under it, anything else closes it.
Usage: local edui.confirmDialog = require("@builtin::editor.edui.confirmDialog")
modules/edui.confirmDialog/choose
choose(key: string): boolean
Answer the question on screen with the action keyed key — what
clicking its button does. The action's run returning false, why
keeps the question up showing why; otherwise it closes, and the
question it stood in front of comes back.
Parameters
keystring— An action key of the question on screen.
edui.confirmDialog.choose("cancel")
modules/edui.confirmDialog/close
close(key: string?)
Close a question without answering it and run its onClose once:
the one keyed key wherever it waits, or the one on screen when key
is omitted.
Parameters
keystring?(optional) — The key the question was opened with.
edui.confirmDialog.close("close:code")
modules/edui.confirmDialog/current
current(): string?
The key of the question on screen, or nil while closed or when it
was given none.
if edui.confirmDialog.current() == "close:code" then end
modules/edui.confirmDialog/errorText
errorText(): string?
Why the last answer to the question on screen kept it up, or nil.
modules/edui.confirmDialog/isAsking
isAsking(key: string): boolean
Whether a question with key is on screen or waiting behind one.
Parameters
keystring— The key the question was opened with.
modules/edui.confirmDialog/isOpen
isOpen(): boolean
Whether the dialog is on screen.
modules/edui.confirmDialog/mount
mount(layerMask: number?)
Create the dialog's screen (idempotent): hidden until a question is opened. Order 5100, over every dock panel, the bars and the other editor dialogs.
Parameters
layerMasknumber?(optional) — The EditorUI render-layer mask; computed when omitted.
modules/edui.confirmDialog/open
open(request: Request)
Ask a question. It goes in front of any question already up, which
comes back once this one is answered; a question opened with the key
of one already open takes that one's place. Each action is a button,
keyed edui_confirmdialog:cd:<action key> for ui.click; dismiss
names the action Escape or a click outside runs, and without it the
question can only be answered. onClose runs once when the question
closes.
Parameters
requestRequest—{ key?, title, message, actions = { { key, text, primary?, run? } }, dismiss?, onClose? }.
edui.confirmDialog.open{ title = "Delete?", message = "It goes for good.", dismiss = "no", actions = { { key = "yes", text = "Delete", run = del }, { key = "no", text = "Keep" } } }
modules/edui.confirmDialog/screenName
screenName(): string
The dialog's screen name, for captures and element addressing.
modules/edui.confirmDialog/unmount
unmount()
Tear the dialog's screen down, closing every open question.
modules/edui.framework/README
require("@builtin::editor.edui.framework") -- edui.framework
Editor UI framework on the CSS-parity ui.* surface. A small, editor-ONLY toolkit: a reactive app that maps author closures to ui.* callback ids, a dock shell over ui.* native docking, and editor-chrome primitives (panels, trees, toolbars, inspector rows, context menus, drag-and-drop). Gameplay / normal UI authors raw ui.* trees and needs none of this — edui earns its keep only for the editor.
Usage: local edui.framework = require("@builtin::editor.edui.framework")
modules/edui.framework/createApp
createApp(name: string, opts: { [string]: any }?): any
Create + return an editor app that owns the ui.* screen name.
Shorthand for edui.app.new. Call app:mount(builderFn) to bring it up.
Parameters
namestring— Unique screen id (also the callback-id namespace).opts{ [string]: any }?(optional) —{ layer? = <renderLayerMask> }.
local a = edui.createApp("myPanel"); a:mount(function(app) return tree end)
modules/edui.framework/current
current(): any
The app whose builder is currently running (nil outside a build). The
edui.* primitives read this to register their closures.
modules/edui.inspector.assetSections/README
require("@builtin::editor.edui.inspector.assetSections") -- edui.inspector.assetSections
The generic sections every asset's Inspector shows, in default order: identity (name, type, scope, guid, description), problems (what asset.validate reports, present only when it reports any), tags (removable chips and an add row), move (relocate the asset's folder), settings (the typed, editable settings), preview (the live or still picture) and operations (every ref method the type declares, each a typed argument form run against the asset in place).
Usage: local edui.inspector.assetSections = require("@builtin::editor.edui.inspector.assetSections")
modules/edui.inspector.assetSections/generic
generic(ctx: any, only: { [string]: boolean }?): { any }
The generic sections for the asset ctx inspects, in default order. A
section with nothing to show is left out: Move for an asset outside the
world's own source tree, Settings for an asset with neither values nor a
schema problem, Preview for an asset with no picture, Operations for a type
with no ref methods. Operations lists every method but setSettings, and
starts collapsed on a type that declares an inspector of its own.
Parameters
ctxany(optional) — The inspector Context (asset scope).only{ [string]: boolean }?(optional) — The ids of the sections to build; every one when nil. A section left out is not read at all, so an inline editor that shows Settings alone runs no validation, preview lookup or behavior load.
local sections = AssetSections.generic(ctx)
modules/edui.inspector.assetSections/releaseExcept
releaseExcept(keep: string)
Drop the interaction state (open operation rows, argument forms, the
last result, pending tag and move inputs) and the validation problems
read for every asset but keep.
Parameters
keepstring— The asset id whose state stays.
AssetSections.releaseExcept(guid)
modules/edui.inspector.parts/README
require("@builtin::editor.edui.inspector.parts") -- edui.inspector.parts
The building blocks a type's inspector.luau composes its sections from, reached as ctx.parts: fact rows, lists, tables, asset and entity links, actions, a file opener into the Code panel, problem lists, colour swatches, a cache keyed on content versions (and one for values read by running an asset's code), an lsp check, and typed controls over any values. Every function takes the section's Context first and returns edui nodes; every callback key starts with ctx.keyPrefix.
Usage: local edui.inspector.parts = require("@builtin::editor.edui.inspector.parts")
modules/edui.inspector.parts/action
action(ctx: any, id: string, label: string, run: () -> (), opts: any?): { any }
A button that runs run. A run that raises shows its message beneath
the button until the next run.
Parameters
ctxany(optional) — The Context.idstring— Action id within this subject.labelstring— Button text.run() -> ()— The action.optsany?(optional) —{ primary? }.
ctx.parts.action(ctx, "compile", "Compile", function() ctx.ref:compile() end)
modules/edui.inspector.parts/bytes
bytes(n: number): string
A byte count as text: B below 1 KiB, KiB to one decimal below 1 MiB, else MiB to two.
Parameters
nnumber— Bytes.
parts.bytes(1536) --> "1.5 KiB"
modules/edui.inspector.parts/cached
cached(key: string, paths: { string }, compute: () -> any): any
compute()'s value, computed again only when the content version of any
of paths moves. Read through a Context's ctx.parts, the value is held
while that Context, or another that read it, stays open; read through the
module itself, it is held until the next Inspector.release.
Parameters
keystring— Cache key (make it unique per asset and purpose).paths{ string }— The files the value is derived from.compute() -> any— Produces the value.
local geom = ctx.parts.cached("mesh:" .. guid, { path .. "/data.zmsh" }, decode)
modules/edui.inspector.parts/cachedCode
cachedCode(key: string, ref: any, compute: () -> any, opts: any?): any
compute()'s value where computing it runs ref's own code (a
graph built from its init.luau, a module's declared settings): held until
a file of ref's folder changes, it moves, a module its code requires
changes (one it required before that module was known is asked about
again at most every quarter second), a file opts.dependsOn(value)
names changes, or a name opts.awaits(value) lists — one the value was
read without because no asset answered to it — comes to answer (asked
again when an asset is made, removed or renamed). A compute that raises holds nothing and raises, and a value
opts.hold(value) answers false for is returned and not held, so either
is read again on the next build. Read through a Context's ctx.parts, the
value is held while that Context, or another that read it, stays open.
Fold codeSignature(key) into the declaration's signature so a change
to what the value came from rebuilds the section.
Parameters
keystring— Cache key (make it unique per asset and purpose).refany(optional) — The asset whose codecomputeruns.compute() -> any— Produces the value.optsany?(optional) —{ hold?, dependsOn?, awaits? }.
local graph = ctx.parts.cachedCode("graph:" .. guid, ctx.ref, function() return vfs.read(ctx.ref.path .. "/graph.json") end)
modules/edui.inspector.parts/check
check(ctx: any, path: string): { any }
A "Check" action running lsp.check(path), and the result of the last
check of the file's current content.
Parameters
ctxany(optional) — The Context.pathstring— The.luaufile.
ctx.parts.check(ctx, ctx.ref.path .. "/init.luau")
modules/edui.inspector.parts/codeSignature
codeSignature(key: string): string
Text that moves when what the value behind cachedCode(key, ...)
came from beyond its own folder changes: the modules its code requires,
one of them becoming known, the files dependsOn named, and a name
awaits listed coming to answer. Empty before
the first read.
Parameters
keystring— The keycachedCodewas read with.
signature = function(ref) return ctx.parts.codeSignature("graph:" .. guid) end
modules/edui.inspector.parts/entityLinks
entityLinks(ctx: any, ids: { string }, opts: any?): { any }
One button per entity — its name — that selects it. An id whose entity no longer exists is listed as text, marked despawned.
Parameters
ctxany(optional) — The Context.ids{ string }— Entity ids.optsany?(optional) —{ max?, empty? }.
ctx.parts.entityLinks(ctx, compRef:listInstances())
modules/edui.inspector.parts/facts
facts(ctx: any, rows: { any }, empty: string?): { any }
Label/value rows; the value takes the width its label leaves and wraps
within it. A row whose value is nil shows "—", so a value
that could not be read is seen to be missing; a row that does not apply to
the subject is left out of rows by the section. With no rows, empty
(or "Nothing recorded.") is shown.
Parameters
ctxany(optional) — The Context.rows{ any }—{ { label, value, mono? } }.emptystring?(optional) — Text for no rows.
ctx.parts.facts(ctx, { { label = "Vertices", value = 24 } })
modules/edui.inspector.parts/forContext
forContext(keyPrefix: string): any
The parts as the Context keyPrefix names reads them — what
ctx.parts holds. Its cached records that Context as one that read the
value, so the value goes when every Context that read it is released;
every other part is the module's own.
Parameters
keyPrefixstring— The Context'skeyPrefix.
ctx.parts = Parts.forContext(ctx.keyPrefix)
modules/edui.inspector.parts/format
format(v: any): string
A value as display text: integers plain, other numbers to 4 significant digits, booleans yes/no, a list as its length, a map as its entry count.
Parameters
vany(optional) — The value.
parts.format(3) --> "3"
modules/edui.inspector.parts/links
links(ctx: any, refs: { any }, opts: any?): { any }
One button per distinct asset — its name and type — that selects it; an
asset named twice is listed once. An item is an AssetRef, a
{ __ref = guid } envelope, or a guid or name; one that does not resolve
is listed as text.
Parameters
ctxany(optional) — The Context.refs{ any }— AssetRefs,{ __ref }envelopes, or guids.optsany?(optional) —{ max?, empty? }.
ctx.parts.links(ctx, { meshRef, materialRef })
modules/edui.inspector.parts/list
list(ctx: any, items: { string }, opts: any?): { any }
One text row per item, at most max (default 40), then "… and N more".
Parameters
ctxany(optional) — The Context.items{ string }— The texts.optsany?(optional) —{ max?, empty?, mono? }.
ctx.parts.list(ctx, boneNames, { max = 30 })
modules/edui.inspector.parts/openFile
openFile(ctx: any, path: string, label: string?): { any }
An action opening path in the Code panel. Nothing when the file is
absent. Its id names the file relative to the subject's folder, so two
files of one name in different folders keep separate actions.
Parameters
ctxany(optional) — The Context.pathstring— VFS path.labelstring?(optional) — Button text (default "Open").
ctx.parts.openFile(ctx, ctx.ref.path .. "/init.luau")
modules/edui.inspector.parts/problems
problems(ctx: any, problems: { any }, clean: string?): { any }
One notice per problem (error or warning tone), or clean when there are none.
Parameters
ctxany(optional) — The Context.problems{ any }—{ { message, code?, severity?, line? } }.cleanstring?(optional) — Text for no problems (default "No problems.").
ctx.parts.problems(ctx, asset.validate(ctx.ref).problems)
modules/edui.inspector.parts/release
release(keyPrefix: string)
Forget what the parts hold for the Context keyPrefix names and every
key nested beneath it: the last failure of each action, each file's last
check, its sections' state, and every cached value (a cached one or a
cachedCode one) no other open Context read. A value read through the module itself, by no Context, goes too.
Parameters
keyPrefixstring— A Context'skeyPrefix.
Parts.release(ctx.keyPrefix)
modules/edui.inspector.parts/state
state(ctx: any): { [string]: any }
The table a Context's sections keep state in between builds (a picked zoom, a chosen tab), forgotten when the Context is released.
Parameters
ctxany(optional) — The Context.
local s = ctx.parts.state(ctx); s.zoom = s.zoom or "1"
modules/edui.inspector.parts/swatch
swatch(ctx: any, color: any, label: string): any
A colour square beside a label.
Parameters
ctxany(optional) — The Context.colorany(optional) —{ r, g, b, a? }in 0..1.labelstring— The label.
ctx.parts.swatch(ctx, { r = 1, g = 0, b = 0 }, "accent")
modules/edui.inspector.parts/table
table(ctx: any, key: string, columns: { any }, rows: { any }, empty: string?): { any }
A table of records, each value shown through format.
Parameters
ctxany(optional) — The Context.keystring— Table id within this section.columns{ any }—{ { key, label?, align?, mono? } }.rows{ any }— Records keyed by column key.emptystring?(optional) — Text for no rows.
ctx.parts.table(ctx, "props", { { key = "name" }, { key = "type" } }, rows)
modules/edui.inspector.parts/values
values(ctx: any, opts: any): { any }
Typed controls over any values: one control per field of schema,
validated with Field.check and written through write inside one undoable
operation. undoable = false is for values that are session state, not
content — a running render feature's live settings: each write goes
through write with no undo operation, so undo and redo never reach it,
and what it changes lasts as long as the thing it changed. readOnly
shows the values with no control that writes. The controls' keys and
rejections live under ctx.keyPrefix and subject, so the same subject
shown by two Contexts keeps two states.
Parameters
ctxany(optional) — The section's Context.optsany(optional) —{ subject, schema?, values?, write?, undoable?, readOnly? }.
ctx.parts.values(ctx, { subject = guid .. ":live", schema = s, values = v, write = w })
modules/edui.inspector.presetActions/README
require("@builtin::editor.edui.inspector.presetActions") -- edui.inspector.presetActions
The Settings section's preset actions. "Save as preset" captures the values a Settings section shows as a typed preset targeting the declarer that governs them, named in a text field beneath the section, and selects the new preset. "Apply preset…" lists the presets whose target is that declarer and writes the one picked into the section's subject as one undoable operation. Both act on an asset's Settings section and on a component card's.
Usage: local edui.inspector.presetActions = require("@builtin::editor.edui.inspector.presetActions")
modules/edui.inspector.presetActions/applyInto
applyInto(p: any, name: string, targets: { any }): { text: string, tone: string }
Write preset p into each of targets (an asset ref, or { entity, component }) as one undoable operation — the operation already open, when
one is, else its own. A target the preset refuses is reported by name and
the rest are still written.
Parameters
pany(optional) — The preset.namestring— The preset's name as the outcome names it.targets{ any }— What to write into.
local outcome = PresetActions.applyInto(p, "pixel_art", { texRef })
modules/edui.inspector.presetActions/outcomeNotice
outcomeNotice(ctx: any): any?
The outcome of the last save or apply under ctx, as a notice, or nil.
Parameters
ctxany(optional) — The inspector Context.
local note = PresetActions.outcomeNotice(ctx)
modules/edui.inspector.presetActions/presetsFor
presetsFor(declarer: any): { Candidate }
Every preset whose target is declarer, by name.
Parameters
declarerany(optional) — The declarer.
for _, c in ipairs(PresetActions.presetsFor(texTypeRef)) do print(c.name) end
modules/edui.inspector.presetActions/recordOutcome
recordOutcome(keyPrefix: string, outcome: { text: string, tone: string })
Record outcome as the last save or apply under keyPrefix, which
outcomeNotice shows until the next one or a release.
Parameters
keyPrefixstring— A Context'skeyPrefix.outcome{ text: string, tone: string }—{ text, tone }, asapplyIntoanswers.
PresetActions.recordOutcome(ctx.keyPrefix, PresetActions.applyInto(p, name, { tex }))
modules/edui.inspector.presetActions/release
release(keyPrefix: string)
Forget the open action, typed name, listed presets and outcome kept
under keyPrefix and every prefix nested in it.
Parameters
keyPrefixstring— A Context'skeyPrefix.
PresetActions.release(ctx.keyPrefix)
modules/edui.inspector.presetActions/subjectOf
subjectOf(ctx: any): (any?, any?)
What a Settings section's preset actions write from and into, and the
declarer that governs it: an asset's own ref, or { entity, component }
for a component card. Nil for a Context whose values no preset targets —
a preset's own values, a subject with no declarer.
Parameters
ctxany(optional) — The inspector Context.
local subject, declarer = PresetActions.subjectOf(ctx)
modules/edui.inspector.settingsSection/README
require("@builtin::editor.edui.inspector.settingsSection") -- edui.inspector.settingsSection
The Settings section: every field of ctx.schema as its typed control, ctx.settings as the values, ctx.setSettings as the one write, each field's last rejection shown on it, and ACTIONS beneath.
Usage: local edui.inspector.settingsSection = require("@builtin::editor.edui.inspector.settingsSection")
modules/edui.inspector.settingsSection/actionRow
actionRow(ctx: any): any?
The row of ACTIONS that apply to ctx (only those ctx.actions
names, when it is set), each acting on the whole of
ctx.schema, with the panel of each open action and the outcome of the
last preset save or apply beneath it; nil when no action applies.
Parameters
ctxany(optional) — The inspector Context.
local row = SettingsSection.actionRow(ctx)
modules/edui.inspector.settingsSection/build
build(ctx: any): { any }
The section body for ctx. Reads only ctx.schema, ctx.schemaProblem,
ctx.settings, ctx.setSettings, ctx.rejected, ctx.nameOf,
ctx.widgets and ctx.keyPrefix, so any source of values (an asset, a
component, a preset) renders through it.
Fields show in the order the schema declares them.
Parameters
ctxany(optional) — The inspector Context.
local nodes = SettingsSection.build(Inspector.valuesContext{ subject = key, schema = s, values = v, write = w, selection = sel })
modules/edui.inspector.settingsSection/fieldRows
fieldRows(ctx: any, fields: { [string]: any }): { any }
One typed control per field of fields (a schema, or part of
ctx.schema), in declaration order, each writing through
ctx.setSettings. Aliases are skipped. ctx.admit narrows every asset
chip, asked with the chip's path from the field (presets[2].preset);
ctx.openFields shows structs and lists open.
Parameters
ctxany(optional) — The inspector Context.fields{ [string]: any }— The field descriptors to show.
local rows = SettingsSection.fieldRows(ctx, ctx.schema)
modules/edui.inspector.settingsSection/fields
fields(ctx: any): { any }
The field rows alone — one typed control per schema field — for a
caller that shows values without the actions beneath them. With no
ctx.schema, the one row naming the schema problem, or that none is
declared.
Parameters
ctxany(optional) — The inspector Context.
local rows = SettingsSection.fields(ctx)
modules/edui.inspector.settingsSection/release
release(keyPrefix: string)
Forget what the Settings actions keep under keyPrefix (an open
panel, a typed name, an outcome) and every prefix nested in it.
Parameters
keyPrefixstring— A Context'skeyPrefix.
SettingsSection.release(ctx.keyPrefix)
modules/edui.inspector/README
require("@builtin::editor.edui.inspector") -- edui.inspector
The Inspector as an ordered list of sections. A subject (an asset, or a component on an entity) gets generic sections, merged with the sections its declarer's inspector.luau adds or replaces and put in the order it names; each section's build(ctx) receives one Context: the ref, its schema, its values with a validating, undoable setSettings, the selection and the edui widget set.
A section is { id, title, icon?, open?, build(ctx) -> { node } }. A type
declares its own in the file its type.yaml names under inspector: (see
@builtin::assetTypes.assetType.shared.inspector); material.assetType/ inspector.luau is a worked example.
The Context every build receives:
| Field | What it is |
|---|---|
ref | the inspected asset (on an entity, the component asset) |
info | asset.inspect(ref) |
schema | asset.schema(ref), settingsOf resolved; nil when none is declared |
schemaProblem | why a declared schema did not resolve |
settings | the current values |
setSettings(patch) | Field.checkSchema, then one undoable operation named for the field; answers (ok, violations) |
rejected | field path -> the message of its last rejected edit |
selection | { scope = "asset" | "entity", id, component?, name? }; on an entity, component is the component's identity and name the name the entity lists it by |
component | the live component proxy (entity scope) |
nameOf(id) | the name an entity-reference field shows for an entity id (entity scope) |
widgets | the edui framework table (field, schemaField, section, button, text, ...) |
keyPrefix | the callback-key namespace for this subject |
refresh() | rebuild the Inspector after a write that moves no revision |
follow() | keep rebuilding while this section is shown: what it shows moves with nothing writing it (a clock that runs) |
actions | when set, the ids of the Settings actions offered; nil offers every one that applies |
parts | the building blocks a section composes (edui.inspector.parts) |
The generic asset sections, in default order: identity, problems | |
(present when asset.validate reports any), tags, move, settings, | |
preview, operations. A declared section is added before | |
operations. settingsSection is the Settings section's body and the | |
| actions offered beneath it. | |
A component on an entity (componentSections) has one generic section, | |
settings: its public fields as typed controls over the live component, | |
| each write one undoable operation. A component that ships the file its | |
type names as inspector: { instance } adds, replaces and orders | |
| sections the same way. |
Usage: local edui.inspector = require("@builtin::editor.edui.inspector")
modules/edui.inspector/assetSections
assetSections(ref: any, info: any, keyPrefix: string?): ({ any }, any)
Generic plus declared sections for an asset, and the Context they share.
Parameters
refany(optional) — The asset ref.infoany(optional) — Itsasset.inspectrecord.keyPrefixstring?(optional) — The Context's key prefix; one per asset when omitted.
local sections, ctx = Inspector.assetSections(ref, asset.inspect(ref))
modules/edui.inspector/buildSection
buildSection(section: any, ctx: any): ({ any }, string?)
Run one section's build for ctx. A build that raises, or returns
anything but a list, yields one error row and the problem text.
Parameters
sectionany(optional) — The section.ctxany(optional) — The Context.
local rows, problem = Inspector.buildSection(section, ctx)
modules/edui.inspector/componentSections
componentSections(entityId: string, componentName: string): ({ any }, any)
The sections of one component on one entity: the generic settings
section (its public fields as typed controls over the live component, each
write validated and one undoable operation) merged with what the file the
component ships as its inspector: { instance } declares.
Parameters
entityIdstring— The entity the component is on.componentNamestring— The component's name as the entity lists it.
local sections, ctx = Inspector.componentSections(id, "Camera")
modules/edui.inspector/componentSettingsRows
componentSettingsRows(ctx: any): { any }
The body of a component's generic Settings section: each three-number
alias (a colour or a vector written as three channels) as one grouped
control, then every other field through settingsSection.fieldRows,
then the Settings actions over every declared field. A component that
declares no fields reads "(no editable fields)".
Parameters
ctxany(optional) — The component's Context.
local rows = Inspector.componentSettingsRows(ctx)
modules/edui.inspector/componentValuesSignature
componentValuesSignature(entityId: string, componentName: string): string
Text that moves whenever a declared field of componentName on
entityId holds a different value — an edit, an undo, a redo, a script's
write. Fold it into a panel's build signature to rebuild a card whose
values moved without the entity revision moving.
Parameters
entityIdstring— The entity the component is on.componentNamestring— The component's name as the entity lists it.
parts[#parts + 1] = Inspector.componentValuesSignature(id, "Camera")
modules/edui.inspector/epoch
epoch(): number return epoch end
Moves on every interaction the inspector's own state records (a disclosure, a rejection, a write). Fold it into a panel's build signature.
parts[#parts + 1] = tostring(Inspector.epoch())
modules/edui.inspector/following
following(): boolean
Whether a section built since the last call asked, through its
Context's follow(), to be rebuilt while it is shown — what a panel reads
after rendering to keep a running clock moving on screen.
if Inspector.following() then live = true end
modules/edui.inspector/isGenericSection
isGenericSection(id: string): boolean
Whether id names a section the generic builder adds where it
applies (identity, problems, tags, move, settings, preview, operations),
as opposed to one a type's own inspector declares.
Parameters
idstring— A section id.
if not Inspector.isGenericSection(s.id) then print("declared", s.id) end
modules/edui.inspector/mergeSections
mergeSections(generic: { any }, decl: any?, problem: string?, file: string?): { any }
Merge generic sections with a declaration: replace swaps a generic
section by id, sections add (before operations when present, else at
the end), order puts the ids it names first (a generic id this asset
does not show is passed over). A problem becomes a first
section naming it; every other section still renders.
Parameters
generic{ any }— Sections in default order.declany?(optional) — The declaration, or nil.problemstring?(optional) — Why the declaration could not be read, or nil.filestring?(optional) — The declaring file, named in problems.
local sections = Inspector.mergeSections(generic, decl, problem, file)
modules/edui.inspector/release
release(keyPrefix: string)
Forget the rejections, section disclosures, Settings-action state and
parts state (action failures, file checks, cached values no other open
Context read) recorded under keyPrefix and every key nested beneath it —
what a closed inline editor, or a subject the Inspector no longer shows,
leaves behind.
Parameters
keyPrefixstring— A Context'skeyPrefix.
Inspector.release(ctx.keyPrefix)
modules/edui.inspector/render
render(sections: { any }, ctx: any, opts: any?): { any }
Render sections as cards (or, nested, as titled groups inside a card).
Each build runs through buildSection, so one that raises renders its
error inside its own section.
Parameters
sections{ any }— The ordered sections.ctxany(optional) — The Context every build receives.optsany?(optional) —{ nested? }.
local nodes = Inspector.render(sections, ctx, { nested = true })
modules/edui.inspector/renderAsset
renderAsset(assetId: string): { any }?
The rendered sections for the asset named by assetId, or nil when it
cannot be read. A different asset than the last one clears the last one's
rejections and its operation state.
Parameters
assetIdstring— The asset's guid or identity.
local nodes = Inspector.renderAsset(guid)
modules/edui.inspector/signature
signature(assetId: string): string
Text that moves whenever what the Inspector shows for assetId can
have moved: the asset folder's content version, which the change
dispatcher moves after any write inside the asset has reached its type's
hook — an edit, an undo or redo, a peer's synced write — and its settings
values file's. A type's declaration adds what its own sections show
beyond the asset's files (a render feature's running state) through a
signature(ref) member. Fold it into a panel's build signature.
Parameters
assetIdstring— The asset's guid or identity.
parts[#parts + 1] = Inspector.signature(guid)
modules/edui.inspector/typeSections
typeSections(ref: any, keyPrefix: string?): ({ any }?, any?)
The declared sections of ref's type, plus Settings when it has values —
what an asset reference's inline editor shows. Nil when the type declares
no type: inspector.
Parameters
refany(optional) — The asset ref.keyPrefixstring?(optional) — The Context's key prefix — the inline editor's own, so two editors of one asset keep their own state and callback keys.
local sections, ctx = Inspector.typeSections(matRef, chipKey .. ":ed")
modules/edui.inspector/valuesContext
valuesContext(opts: any): any
The one Context builder. write(patch) performs a validated patch; this
wraps it in Field.checkSchema, an undo operation named for the fields it
sets, and the rejection record the Settings section shows. undoable = false names values that are session state rather than content (a running
feature's live settings): their writes open no undo operation, so none
reaches the undo history. keyPrefix names the callback keys and the
state this Context keeps; it defaults to one per subject, and an inline
editor passes its chip's own.
Parameters
optsany(optional) —{ subject, keyPrefix?, schema?, schemaProblem?, values?, write, undoable?, ref?, info?, selection, component?, nameOf?, actions?, admit?, openFields? }.admit(record, at)narrows what every asset chip offers and accepts (at = { path, parent });openFieldsshows structs and lists open.
local ctx = Inspector.valuesContext{ subject = guid, schema = s, values = v, write = w, selection = sel }
modules/edui.query/README
require("@builtin::editor.edui.query") -- edui.query
Resolves the engine-provided query globals edui panels read — queryEntitiesTable, queryLogsTable, getProfilingDataTable, and the like. The engine installs these on _G at boot (before the global table is sealed read-only), so panels read them through this one indirection rather than each touching _G directly. override/restore swap a source for a stub or a mock feed without writing the sealed _G.
Usage: local edui.query = require("@builtin::editor.edui.query")
modules/edui.query/override
override(name: string, fn: any)
Shadow an engine query global with a function until restored.
Parameters
namestring— The global name.fnany(optional) — The function to resolve in its place.
modules/edui.query/resolve
resolve(name: string): any
Resolve a named engine query global, honouring any active override.
Parameters
namestring— The global name (e.g. "queryEntitiesTable").
modules/edui.query/restore
restore(name: string)
Clear an override so resolve falls back to the engine global again.
Parameters
namestring— The global name.
modules/edui.sceneInfo/README
require("@builtin::editor.edui.sceneInfo") -- edui.sceneInfo
Which scene asset each loaded layer came from, as the editor shows it. A layer is a loaded instance of a scene asset: its guid is the asset's guid, its name is the asset's display name, and its identity names the asset to open, save or reload (@builtin::scenes.test_arena, a world scene's name). The open scene is the one non-additive layer.
Usage: local edui.sceneInfo = require("@builtin::editor.edui.sceneInfo")
modules/edui.sceneInfo/describe
describe(guid: string): { name: string, identity: string?, path: string?, loaded: boolean }
The scene asset behind a layer guid — a loaded layer's info, or for a guid no layer is loaded under, the scene asset that guid names.
Parameters
guidstring— A layer guid (asentity.treegroups rows by).
modules/edui.sceneInfo/layers
layers(): { LayerInfo }
Every loaded layer with the scene asset it came from, in the order
layers.list() reports them.
modules/edui.sceneInfo/open
open(): LayerInfo?
The open scene: the root (non-additive) layer and the asset it was loaded from.
modules/edui.sceneInfo/shortName
shortName(identity: string?): string?
A scene identity's last segment: @builtin::scenes.test_arena reads
test_arena, /source/scenes/level01.scene reads level01.
Parameters
identitystring?(optional) — A scene identity or VFS path.
modules/edui.sceneInfo/signature
signature(): string
A one-line signature of the loaded layers — which are loaded, which is open, and what each is named — for a watcher to compare frame to frame.
modules/edui.shell/README
require("@builtin::editor.edui.shell") -- edui.shell
The editor dock shell on the CSS-parity ui.* surface. One edui app owns a ui.* native dockArea whose children are a dockPanel per registered edui panel — real egui_dock tabs, splits and drag. The shell keeps its OWN panel registry (separate from the deprecated zui editor registry) so the zui editor stays untouched while panels migrate one at a time; the two registries fold into one at cutover.
Usage: local edui.shell = require("@builtin::editor.edui.shell")
modules/edui.shell/activeLayout
activeLayout(): { name: string?, title: string, slot: string? }
The layout in force, as the layout switch shows it.
edui.shell.activeLayout().title
modules/edui.shell/addPanel
addPanel(spec: any): boolean
Register (or replace) an edui dock panel. A duplicate id replaces the prior registration; the live shell rebuilds so the change shows at once.
Parameters
specany(optional) —{ id (REQUIRED), build (REQUIRED, () -> widget), title?, order?, dock?, badge?, badgeColor?, menu?, menuHint?, startClosed?, transient?, close?, dirty?, save?, discard? }.buildis an edui builder: it may call theedui.*primitives, whose closures register on the shell app automatically.startClosed = trueregisters into the Window-menu catalog without opening a tab; the panel opens when someone opens it.titleis text or ani18n.textvalue, which the tab, the menus and the catalog read in the editor's language each time they build.menuHintis a short note the menu entry carries on the right — a string, or a function read each time the menu opens.transient = truemakes a panel that exists for this session alone: closing its tab forgets it, a layout or mode change keeps it open, and no saved arrangement records it.dirty: () -> booleansays whether the panel holds unsaved edits: its tab title ends in a dot while it does, and closing its tab asks first (Save & close / Discard / Cancel) — callrefreshChromewhen the answer changes.save: () -> (boolean, string?)writes the edits, returning false and why when it could not;discard: () -> ()drops them before a Discard closes the tab. A layout or mode change closes a non-transient panel without asking, so a panel declaringdirtykeeps its edits through itsclosehook and shows them again when it reopens.
edui.shell.addPanel{ id = "entities", title = "Entities", build = fn }
modules/edui.shell/app
app(): any
The mounted shell App, or nil when the shell is not up.
modules/edui.shell/applyLayout
applyLayout(name: string, opts: any?): (boolean, string?)
Apply the layout named: the world's .editorLayout of that name, else
the built-in one. A layout listing panels rebuilds the dock from its
panel set and region hints, so it comes out the same at any window size;
one holding a captured arrangement restores it. The name is recorded
under /source/local as the layout this world's editor comes up in.
Parameters
namestring— A namelayoutsreports.optsany?(optional) —{ persist? = false, arrangement? }—persist = falseapplies without recording it (a boot's--layout);arrangementis a captured arrangement to restore in place of the layout's own seed, which is how the layout switch brings a layout back as it was left.
edui.shell.applyLayout("recording")
modules/edui.shell/assignLayout
assignLayout(side: string, name: string): (boolean, string?)
Assign a layout to side A or side B of the layout switch. The assignment is kept per world on this machine. A layout already standing for the other side swaps places with the one this side gave up. When this side is the one in force, the layout takes the editor at once.
Parameters
sidestring— "a" | "b".namestring— A namelayoutsreports.
edui.shell.assignLayout("a", "recording")
modules/edui.shell/catalog
catalog(): { any }
Every catalogued panel (open or closed), sorted by (order, id), each
{ id, title, order, dock, open } — the Window menu's source.
modules/edui.shell/catalogRevision
catalogRevision(): number
How many times the catalog's membership has changed — a registration, a re-registration or a removal each count once. A surface built from the catalog (the menu bar) compares this between frames and rebuilds when it moves, rather than walking the catalog every frame.
if edui.shell.catalogRevision() ~= seen then print("the panel catalog changed") end
modules/edui.shell/confirmClose
confirmClose(id: string): boolean
Ask the user whether to save a panel's unsaved edits before its tab
closes: a dialog titled "Unsaved changes" offering Save & close (when
the spec declares save), Discard and Cancel. While the dialog asks
about another panel this one waits its turn.
Parameters
idstring— The panel id passed to addPanel.
edui.shell.confirmClose("code")
modules/edui.shell/confirmDiscard
confirmDiscard(request: any)
Ask whether to keep unsaved edits before something drops or replaces them: a dialog titled "Unsaved changes" saying "
save is given), Discard and Cancel.
A save that succeeds, or a discard, runs andThen; a save that fails
keeps the dialog up with its reason; Cancel runs nothing. Closing a
dirty tab asks through this, and a panel asks through it before it
replaces or drops a document of its own.
Parameters
requestany(optional) —{ key, title, save?: () -> (boolean, string?), discard?: () -> (), saveText? = "Save & continue", andThen: () -> (), onClose?: () -> () }—keynames the question (edui.confirmDialog.current()), andonCloseruns once when it closes by any answer.
edui.shell.confirmDiscard{ key = "code:open", title = "notes.md", save = save, andThen = open }
modules/edui.shell/exportLayout
exportLayout(): string?
The live dock arrangement, serialized without its transient tabs — what saveLayout writes, what the next boot restores, and what loadLayout applies. Nil before the dock's first render.
modules/edui.shell/focusPanel
focusPanel(id: string): boolean
Bring a panel's tab to the front of its dock leaf, opening it from
the catalog first if its tab is closed — what a menu entry naming a
panel does. Unlike openPanel, this acts visibly when the tab is
already open behind another.
Parameters
idstring— The panel id.
modules/edui.shell/isPanelDirty
isPanelDirty(id: string): boolean
Whether a catalogued panel reports unsaved edits through its spec's
dirty.
Parameters
idstring— The panel id passed to addPanel.
if edui.shell.isPanelDirty("code") then end
modules/edui.shell/isPanelOpen
isPanelOpen(id: string): boolean
Whether the shell is holding a panel's tab open right now. A panel that arms something while it is on screen reads this to find out whether it still is: the shell can rebuild a panel whose tab has just gone, and the answer here has already moved.
Parameters
idstring— The panel id passed to addPanel.
if edui.shell.isPanelOpen("capture") then end
modules/edui.shell/layoutMode
layoutMode(): string
The mode of the layout in force: "full" (a panel that registers later opens as a tab) or "simple" (the layout's panel set is fixed: a panel that registers later waits in the Window menu).
modules/edui.shell/layoutRevision
layoutRevision(): number
How many times the registered layouts, the slots or the layout in force have changed. The bar compares this between frames to rebuild its layout switch.
modules/edui.shell/layoutSlots
layoutSlots(): { a: string?, b: string? }
The layout each side of the layout switch stands for: the one a person assigned while it is registered, else the one the library ships for that side.
edui.shell.layoutSlots().a
modules/edui.shell/layouts
layouts(): { any }
Every layout that can be applied: the built-in library's standard ones
(kind = "standard") in registration order, then the world's own
(kind = "saved"), each with the title the layout switch shows (the
layout's name when its layout.yaml gives none), the sentence its
layout.yaml describes it with, its mode and whether it shows the
toolstrip, the side of the switch it declares (defaultSlot), the panel ids it opens in the order it names them, where
it places each (placements) and the share each side region takes
(fractions). A world layout with a standard layout's name stands in for
it and is listed once. A layout holding a captured arrangement rather
than a panel list reports an empty panels and the arrangement decides
its tabs.
modules/edui.shell/listLayouts
listLayouts(): { string }
Every layout name that can be applied, in menu order: the standard layouts first, then the world's own.
modules/edui.shell/loadLayout
loadLayout(name: string): (boolean, string?)
applyLayout, under the name the Window menu has always used.
Parameters
namestring— A namelayoutsreports.
modules/edui.shell/mount
mount(opts: any?): any
Mount the shell (idempotent — returns the existing app if already up).
Registers the ui.* screen on the EditorUI layer and does the first build.
Parameters
optsany?(optional) —{ refresh? = <seconds between liveness rebuilds, default 0.5> }.
edui.shell.mount()
modules/edui.shell/openPanel
openPanel(id: string): boolean
Re-open a catalogued panel by id — restores its tab in its preferred dock region. A no-op (returns false) if the id was never registered or is already open.
Parameters
idstring— The panel id.
modules/edui.shell/panel
panel(id: string): any?
The catalogued panel record for id — the spec table its
registration passed to addPanel, extra keys included. This is how one
panel reaches another's exported surface: the Files panel opens a file
in the Code panel through the openFile its record carries.
Parameters
idstring— The panel id passed to addPanel.
local rec = edui.shell.panel("code"); if rec then rec.openFile(path) end
modules/edui.shell/panelsSorted
panelsSorted(): { any }
The registered panels sorted by (order, id) — the dock/tab order.
modules/edui.shell/refresh
refresh()
Rebuild every active panel now — each re-queries live data. Call after
a change the shell can't observe (a scene edit made outside its own
handlers). For a change that concerns ONE panel, refreshPanel rebuilds
just that panel.
modules/edui.shell/refreshChrome
refreshChrome()
Rebuild the dock chrome — the tab titles and what each tab's close
does. A panel with a dirty spec calls this when its answer changes.
edui.shell.refreshChrome()
modules/edui.shell/refreshPanel
refreshPanel(id: string)
Rebuild one panel — its own screen republishes; every other panel and the dock itself are untouched. The scoped path for a data event with a known audience (a selection change concerns the entity tree and the inspector, not the console).
Parameters
idstring— The panel id to rebuild.
edui.shell.refreshPanel("inspector")
modules/edui.shell/registerLayout
registerLayout(record: any): boolean
Register a layout with the shell, the way an .editorLayout asset's
onRegister does. record is { name, title?, description?, mode, panels, fractions?, dock?, origin }; title and description are text
or i18n.text values, read in the editor's language each time the
layouts are listed; origin is "builtin" for the library's or "world" for
one authored into the world, and a world layout stands in for a built-in
one of the same name. A layout the boot asked for applies as soon as it
is registered.
Parameters
recordany(optional) — The layout record.
modules/edui.shell/reloadLayoutSlots
reloadLayoutSlots()
Read the layout assignment this world kept, replacing what the editor holds: what a boot does before it applies anything.
modules/edui.shell/removePanel
removePanel(id: string): boolean
Remove a registered panel by id — closes its tab. The panel stays in
the catalog, so the Window menu can re-open it later; a transient
panel is forgotten with its tab. A spec that declares close is told:
the hook runs as the tab goes, so a panel holding live resources (a
render session, a watcher) releases them.
Parameters
idstring— The panel id passed to addPanel.
modules/edui.shell/requestClose
requestClose(id: string): boolean
Close a panel's tab the way its close button does: a panel without
unsaved edits closes at once, one with them asks first (confirmClose).
Parameters
idstring— The panel id passed to addPanel.
edui.shell.requestClose("code")
modules/edui.shell/resetLayout
resetLayout()
Restore the arrangement a fresh editor starts from, the escape hatch
for a layout dragged into an unusable state: the layout side A of the
layout switch stands for when it is registered, else the mode's own panel
set (every catalogued panel in full mode, the viewport alone in simple)
rebuilt from each panel's dock region hint.
edui.shell.resetLayout()
modules/edui.shell/resetLayoutSlots
resetLayoutSlots()
Forget the layouts assigned to the two sides, so each stands for the layout the library ships for it, and forget the file this world kept them in.
modules/edui.shell/resolveBootLayout
resolveBootLayout(boot: string?, dock: string?, startLayout: string?): any
What the editor comes up in, from the three things that can name it. A layout named at boot is an instruction for this boot, so it applies without being recorded and the arrangement the editor was left in does not stand over it. With none named, that saved arrangement comes back; with none saved, the layout this world's editor last applied; and with none of those, side A of the layout switch, whichever layout it stands for.
Parameters
bootstring?(optional) — The layout--layoutnamed for this boot, or nil.dockstring?(optional) — The arrangement saved for this world, or nil.startLayoutstring?(optional) — The layout this world's editor last applied, or nil.
edui.shell.resolveBootLayout(nil, nil, nil).slot
modules/edui.shell/restoreLayout
restoreLayout(json: string): (boolean, string?)
Put the dock back into an arrangement exportLayout read: the open
set becomes exactly the tabs it names, and the dock restores its tabs and
splits on its next render. The counterpart of exportLayout for a caller
that read the arrangement, moved it, and hands it back. A string that does
not decode to a dock arrangement is refused, and the dock stays as it is.
Parameters
jsonstring— An arrangementexportLayoutreturned.
local held = edui.shell.exportLayout(); edui.shell.applyLayout("watch"); edui.shell.restoreLayout(held)
modules/edui.shell/sameArrangement
sameArrangement(a: string?, b: string?): boolean
Whether two arrangements exportLayout read hold the same tabs in the
same splits at the same fractions, whatever size the window drew them at
and whichever tab had focus. Two nils are the same arrangement; a nil and
an arrangement are not.
Parameters
astring?(optional) — An arrangementexportLayoutreturned, or nil.bstring?(optional) — Another, or nil.
if not edui.shell.sameArrangement(held, edui.shell.exportLayout()) then edui.shell.restoreLayout(held) end
modules/edui.shell/saveLayout
saveLayout(name: string, opts: any?): (boolean, string?)
Save the live dock arrangement as the world's .editorLayout asset
named name, at <folder>/<name>.editorLayout/ (the folder defaults to
/zero/source/editor/layouts): layout.yaml points at the dock.json
the live dock wrote. The asset registers itself, so the layout is in the
Window menu at once, and it is renameable and removable through the
Files panel like any other asset.
Parameters
namestring— The layout's name; non-identifier characters fold to_.optsany?(optional) —{ folder?, title?, description? }— the folder under/zero/sourceto create the asset in, the name the layout switch shows (the layout's name by default), and the sentence the menu shows beside it.
edui.shell.saveLayout("modeling")
modules/edui.shell/screenName
screenName(): string
The shell's screen name (for ui.showScreen / capture screen).
modules/edui.shell/setLayoutMode
setLayoutMode(mode: string, opts: any?): boolean
Put the editor in a layout mode without applying a layout: the mode
every layout declares, and applying a layout does this for you. "simple"
closes the authoring panels — every open panel that opens by default; the
Scene viewport and every panel opened on purpose
(one registered startClosed, an agent's tab among them) stay open.
"full" restores the arrangement the editor held when simple was entered,
tabs and splits as they were, or on a boot into simple opens every default
panel at its region. The mode in force persists across sessions
alongside the saved dock arrangement.
Parameters
modestring— "full" | "simple".optsany?(optional) —{ persist? = false }skips the write (the boot restore path).
edui.shell.setLayoutMode("simple")
modules/edui.shell/switchLayout
switchLayout(): (boolean, string?)
Take the editor to the other side of the layout switch: from A to B, from B to A, and from a layout standing for neither to A. The layout it leaves is remembered as it was left, tabs and splits included, and comes back that way.
edui.shell.switchLayout()
modules/edui.shell/togglePanel
togglePanel(id: string): boolean
Toggle a catalogued panel open/closed — the Window-menu action.
Closing goes through requestClose, so a panel holding unsaved edits
asks first and stays open while it asks.
Parameters
idstring— The panel id.
modules/edui.shell/unmount
unmount()
Tear the shell down (unregisters the screen + callback env). Panel
registrations are kept, so a later mount brings the same set back up.
modules/edui.shell/unregisterLayout
unregisterLayout(name: string, origin: string?)
Remove a registered layout, the way an .editorLayout asset's
onUnregister does. With a built-in one of the same name still
registered, that one stands again.
Parameters
namestring— The layout's name.originstring?(optional) — "builtin" | "world"; omitted removes both.
modules/edui.shell/unregisterPanel
unregisterPanel(id: string): boolean
Drop a panel from the shell altogether: its tab closes the way
removePanel closes it, and the catalog forgets it, so the Window menu
stops listing it — what an .editorPanel asset's removal does.
Parameters
idstring— The panel id passed to addPanel.
modules/edui.shell/update
update(dt: number)
Drive the shell's liveness refresh. Call each frame from the editor
update loop; every ACTIVE panel rebuilds every refresh seconds so it
reflects live scene state without arming its own timer. A tab switch is
also caught here: the newly shown panel refreshes on the tick after the
switch. The tool strip rebuilds on the frame after a message or chat post
is written.
Parameters
dtnumber— Seconds since the last call.
modules/edui.shown/README
require("@builtin::editor.edui.shown") -- edui.shown
Panels opened to put a file in front of the user: each open is its own closable dock tab around an edui.document, beside whatever the user has open. The panels are transient — closing one releases its document, and no saved arrangement records them. A panel holding unsaved edits marks its tab and asks the user before it closes. The show toolbox is the agent surface over this module.
Usage: local edui.shown = require("@builtin::editor.edui.shown")
modules/edui.shown/available
available(): boolean
Whether this engine has an editor dock to show into — false in a headless engine and under the runtime profile.
modules/edui.shown/close
close(id: string): (boolean, string?)
Close a shown panel — the same as its tab's close button. A panel holding unsaved edits stays open and the user is asked to save or discard them.
Parameters
idstring
local closed, pending = edui.shown.close("show:3")
modules/edui.shown/get
get(id: string): ShownRow?
The row for one shown panel, or nil when id is not open.
Parameters
idstring
modules/edui.shown/list
list(): { ShownRow }
Every open shown panel, in the order opened. dirty marks unsaved
edits the user made in it.
modules/edui.shown/open
open(path: string, opts: { line: number?, title: string? }?): string?
Open path in a new dock tab and bring it to the front. Every call
makes its own tab, including for a path already shown.
Parameters
pathstring— A VFS path (edui.shown.resolveturns an asset reference into one).opts{ line: number?, title: string? }?(optional) —{ line?, title? }— the line code opens at, and the tab title (the file name when omitted).
local id = edui.shown.open("/zero/source/notes.md", { title = "Notes" })
modules/edui.shown/resolve
resolve(target: string): string
The VFS path target names: itself when something is there, else
the source of the asset it names (name, identity or guid). Raises when
it names nothing, and raises with the candidates when it names more
than one.
Parameters
targetstring— A VFS path or an asset reference.
edui.shown.resolve("hero.bundle")
modules/edui.shown/scratchPath
scratchPath(title: string?, ext: string): string
An unused scratch path for text with no file behind it, under
/zero/source/tmp/show/ (never saved, never synced), named from title.
Parameters
titlestring?(optional) — What the text is; slugged into the file name.extstring— The file extension, which picks the viewer.
edui.shown.scratchPath("Plan", "md") -- /zero/source/tmp/show/plan-1.md
modules/edui.shown/unavailableReason
unavailableReason(): string?
Why this engine has no editor dock to show into right now, or nil
when available() is true. Each cause has its own message: a headless
boot mounts no editor shell, the runtime profile mounts none either, and
a windowed editor still coming up mounts its shell a moment after this
module is reachable, so that message tells the caller to call again.
if not edui.shown.available() then error(edui.shown.unavailableReason()) end
modules/edui.topbar/README
require("@builtin::editor.edui.topbar") -- edui.topbar
The editor menu bar on edui — a ui.* ctx-level topPanel above the dock: domain dropdown menus on the left (Scene / Content / Debug), the Window menu that opens/closes edui panels, and the play/pause transport on the right. On a window too narrow for that row (a phone's) the bar folds its menus and view toggles into one overflow menu, and unfolds once the window is wide enough again. Every menu entry names a panel this editor ships and focuses it. It owns one edui app on its own screen, so it composes above the shell's dock and toolstrip.
Usage: local edui.topbar = require("@builtin::editor.edui.topbar")
modules/edui.topbar/layoutSwitch
layoutSwitch(): { label: string, slot: string?, tooltip: string }
What the bar's layout switch shows: label is the title of the layout in
force, slot the side it stands for ("a", "b", or nil for a layout in
neither), and tooltip says what a press does.
edui.topbar.layoutSwitch().label
modules/edui.topbar/mount
mount(layerMask: number?): any
Mount the menu bar (idempotent). Registers its ui.* screen on the
EditorUI layer and does the first build.
Parameters
layerMasknumber?(optional) — Optional EditorUI render-layer mask; computed when omitted.
edui.topbar.mount()
modules/edui.topbar/openBranchMenu
openBranchMenu()
Open the branch menu under the top bar's breadcrumb, reading the world's branches afresh — the route another panel takes to switch branch.
modules/edui.topbar/screenName
screenName(): string
The bar's screen name (for ui.showScreen / capture screen).
modules/edui.topbar/unmount
unmount()
Tear the menu bar down.
modules/edui.widgets.assetBrowser/README
require("@builtin::editor.edui.widgets.assetBrowser") -- edui.widgets.assetBrowser
The generic asset browser — one surface for browsing and for picking. Search (name and type), a scope filter (project / builtin), a type filter built from the live registry, list and grid presentation with adjustable tile size and image previews where the asset is one, over the world's asset registry. Browse mode is the Assets panel's body; picker mode is what a REF field or an Add Component flow opens, filtered to the kinds the target accepts, firing onPick with the chosen record.
Usage: local edui.widgets.assetBrowser = require("@builtin::editor.edui.widgets.assetBrowser")
modules/edui.widgets.assetBrowser/data
data(): { rows: { AssetRecord }, kinds: { { id: string, count: number } } }
The shared registry reading — { rows, kinds }, fetched on first
use and held until invalidate. The capability queries above resolve
their per-kind probes against it.
modules/edui.widgets.assetBrowser/epoch
epoch(): number
The browser's view epoch — fold into the host panel's build signature.
modules/edui.widgets.assetBrowser/instantiableKinds
instantiableKinds(): { string }
The placeable kind ids in the live registry, sorted — each answered
by its type's canInstantiate capability. For an accepts list or a
label.
modules/edui.widgets.assetBrowser/invalidate
invalidate()
Drop the shared registry cache; the next build re-reads the registry. Call after authoring/installing content so every open browser sees it.
modules/edui.widgets.assetBrowser/isInstantiable
isInstantiable(kind: any): boolean
Whether assets of kind can be placed into a scene — the asset
type's canInstantiate capability, answered once per kind. Drop
targets and filters that accept "a placeable asset" resolve the
question here, so every surface answers it the same way.
Parameters
kindany(optional)
modules/edui.widgets.assetBrowser/make
make(W: any): (any) -> any
Bind the browser builder to the widgets barrel W. The barrel calls
this once and exposes the result as edui.assetBrowser.
Parameters
Wany(optional) — Theedui.widgetstable.
Returns any — assetBrowser(o) -> widget.
modules/edui.widgets.assetBrowser/noteMutation
noteMutation(path: string, kind: string)
What the browser does with one change under /zero/source/: the
callback its vfs.watch runs, for a caller that reports a change itself.
Parameters
pathstring— The changed path.kindstring—"write"or"remove".
modules/edui.widgets.assetBrowser/previewSrc
previewSrc(path: any): string?
The image source that pictures an asset — its own file when the path
is an image, else the preview/source file inside its folder. Nil when
nothing drawable is found. Cached per path; M.invalidate() clears it.
Parameters
pathany(optional)
modules/edui.widgets.assetBrowser/showSubassets
showSubassets(shown: boolean)
Show or hide private subassets in every open browser; the registry is re-read the next time a browser builds.
Parameters
shownboolean— True to list private subassets as well.
modules/edui.widgets.assetBrowser/subassetsShown
subassetsShown(): boolean
Whether the listing includes private subassets — the interiors of composite assets such as a bundle's meshes and materials.
modules/edui.widgets.controls/README
require("@builtin::editor.edui.widgets.controls") -- edui.widgets.controls
edui's OWN interactive controls, drawn on the ui.* canvas substrate (paint commands + pointer/key/scroll events) rather than the generic ui.* widgets — so an editor control looks and behaves like an editor control, independent of general UI, and enforces its type. A number is a drag-scrub field that only ever holds a number (drag to scrub, scroll to nudge, double-click to type digits — letters can't enter); a bool is a toggle switch. Controls.make(W) binds them to the widgets barrel.
Usage: local edui.widgets.controls = require("@builtin::editor.edui.widgets.controls")
modules/edui.widgets.controls/make
make(W: any): any
Bind the canvas controls to the widgets barrel W. Returns
{ numberField, boolToggle }.
Parameters
Wany(optional)
modules/edui.widgets.document/README
require("@builtin::editor.edui.widgets.document") -- edui.widgets.document
One open document in an editor panel: a VFS file or asset shown in the viewer its kind calls for, editable where it is text, and following the file as it changes on disk. The Code panel holds one document; every panel edui.shown opens holds another. A document owns its state and prefixes every element id with its own id, so any number coexist. Viewers are modes: registerMode adds one, and a document opens a path in the highest-priority mode whose match claims it.
Usage: local edui.widgets.document = require("@builtin::editor.edui.widgets.document")
modules/edui.widgets.document/_conflictBar
_conflictBar(self: any, P: any): any?
The bar over the body while the open file moved on disk under unsaved edits or was removed, or nil.
Parameters
selfany(optional)Pany(optional) — The palette.
modules/edui.widgets.document/_watch
_watch(self: any)
Watch the open path for writes and removals.
Parameters
selfany(optional)
modules/edui.widgets.document/build
build(self: any, P: any): any
The panel content: a toolbar (name, path, status, the mode's items, the owner's extras) over the mode's body; an empty panel while nothing is open.
Parameters
selfany(optional)Pany(optional) — The palette (edui.palette()).
modules/edui.widgets.document/close
close(self: any)
Close the open path: stop watching it, release the mode's resources, and empty the document.
Parameters
selfany(optional)
modules/edui.widgets.document/codeBody
codeBody(doc: any, P: any): { any }
The code editor with its diagnostics strip and context menu, for a mode's body: line numbers, highlighting for the document's language, folding and hover inspection for Luau, and a context menu with Go to Definition and Inspect, every element keyed under the document.
Parameters
docany(optional) — The document the mode is building.Pany(optional) — The palette (edui.palette()).
return { edui.document.saveButton(doc) }, edui.document.codeBody(doc, P)
modules/edui.widgets.document/conflictState
conflictState(self: any): string? return self.conflict end
"changed" while the file moved under unsaved edits, "removed" while it is gone from disk, nil otherwise.
Parameters
selfany(optional)
modules/edui.widgets.document/dirty
dirty(self: any): boolean return self.buf ~= self.savedText end
Whether the buffer holds edits the file does not.
Parameters
selfany(optional)
modules/edui.widgets.document/dispose
dispose(self: any)
Release everything the document holds — what a closing panel calls.
Parameters
selfany(optional)
modules/edui.widgets.document/healthEpoch
healthEpoch(): number
Moves whenever any path's recorded health changes — fold into a build signature that renders health badges.
modules/edui.widgets.document/isTextBytes
isTextBytes(bytes: string): boolean
Whether bytes are text a document can edit: valid UTF-8 holding no
NUL byte. What a file holds decides it, whatever its name.
Parameters
bytesstring— A file's contents.
edui.document.isTextBytes(vfs.read("/zero/source/.zmignore") or "")
modules/edui.widgets.document/isTextFile
isTextFile(path: string): boolean
Whether the file at path opens as editable text, read from what it
holds (isTextBytes). A directory, or a path holding no file, is not.
Parameters
pathstring— A VFS path.
edui.document.isTextFile("/zero/source/a/init.luau") -- true
modules/edui.widgets.document/keepMine
keepMine(self: any)
Keep the unsaved edits over the file's new contents; Save writes them.
Parameters
selfany(optional)
modules/edui.widgets.document/key
key(self: any, suffix: string): string
The element id / callback key suffix under this document.
Parameters
selfany(optional)suffixstring— What the id names within the document.
modules/edui.widgets.document/modeName
modeName(self: any): string? return if self.mode ~= nil then self.mode.name else nil end
The name of the mode showing the open path, or nil when nothing is open.
Parameters
selfany(optional)
modules/edui.widgets.document/new
new(opts: DocOpts): any
A new, empty document. id prefixes every element id and callback
key it builds; panelId is the dock panel it draws in (defaults to id);
onChange runs whenever its state moves outside an interaction (a disk
change, a preview coming live, a setText that moves dirty()) so the
panel can rebuild and mark its tab; startInSource
opens markdown as source rather than rendered; toolbarExtras returns
items appended to its toolbar.
Parameters
optsDocOpts—{ id, panelId?, onChange?, startInSource?, toolbarExtras? }.
local doc = edui.document.new{ id = "notes" }
modules/edui.widgets.document/open
open(self: any, path: string, line: number?): boolean
Open path: text is read into the buffer, the mode is picked, a
.luau file is LSP-checked, and the file is watched. With line, code
lands on that line.
Parameters
selfany(optional)pathstring— A VFS path — a file, or an asset folder.linenumber?(optional) — The source line to reveal.
modules/edui.widgets.document/path
path(self: any): string? return self.filePath end
The open path, or nil when nothing is open.
Parameters
selfany(optional)
modules/edui.widgets.document/pathHealth
pathHealth(path: string): number?
The error count from path's last LSP check in any document, or nil
when no document has checked it.
Parameters
pathstring— A VFS path.
modules/edui.widgets.document/registerMode
registerMode(mode: Mode)
Register a viewer mode, or replace the one of the same name. match
returns a priority for a path it claims (nil otherwise); a document opens
a path in the highest. build(doc, P) returns the toolbar items and the
body children. open / dispose bracket the mode's own resources, kept in
doc.modeState; a suspended document releases them through dispose and
takes them again through open as it resumes. onDisk(doc, path, kind)
replaces the text reaction to a watched write or removal.
Parameters
modeMode—{ name, match, build, open?, dispose?, onDisk? }.
edui.document.registerMode{ name = "csv", match = function(_, i) return i.ext == "csv" and 25 or nil end, build = function(doc, P) return {}, {} end }
modules/edui.widgets.document/reload
reload(self: any)
Drop the unsaved edits and take the file as it is on disk; with the file gone, the buffer goes back to the text last loaded or saved.
Parameters
selfany(optional)
modules/edui.widgets.document/resume
resume(self: any)
Pick a suspended document back up: the mode takes its resources again, the file is watched again, and the file is read as it is now — a clean buffer adopts what changed on disk meanwhile, one with unsaved edits keeps them and raises the "changed" conflict, and a file removed meanwhile raises "removed".
Parameters
selfany(optional)
modules/edui.widgets.document/save
save(self: any): (boolean, string?)
Write the buffer to the file and re-check it.
Parameters
selfany(optional)
modules/edui.widgets.document/saveButton
saveButton(doc: any): any
The Save button text modes share, for a mode's toolbar items:
writes the document's buffer, keyed <id>:save.
Parameters
docany(optional) — The document the mode is building.
return { edui.document.saveButton(doc) }, edui.document.codeBody(doc, P)
modules/edui.widgets.document/setText
setText(self: any, text: string)
Replace the buffer — what the editor's onChange does as the user types.
A change that moves dirty() tells the owner through onChange.
Parameters
selfany(optional)textstring
modules/edui.widgets.document/showDiff
showDiff(self: any)
Show how the unsaved edits differ from the file on disk, in the Code panel's diff view.
Parameters
selfany(optional)
modules/edui.widgets.document/signature
signature(self: any): string
What a panel folds into its no-change gate: moves on every state change and every keystroke.
Parameters
selfany(optional)
modules/edui.widgets.document/suspend
suspend(self: any)
Set the document aside while its panel is closed: stop watching the
file and release the mode's resources (a live preview), keeping the path,
the buffer and the text last loaded or saved. resume picks it back up.
Parameters
selfany(optional)
modules/edui.widgets.document/text
text(self: any): string return self.buf end
The buffer: the open text with the user's edits.
Parameters
selfany(optional)
modules/edui.widgets.document/touch
touch(self: any)
Record a state change and tell the owner, which rebuilds the panel.
Parameters
selfany(optional)
modules/edui.widgets.entityPicker/README
require("@builtin::editor.edui.widgets.entityPicker") -- edui.widgets.entityPicker
The entity picker — the Hierarchy's tree shape wherever an entity is chosen. A search field over a windowed, expandable entity tree (collapsed by default, so skeleton bones and other deep noise stay behind their roots until unfolded or matched), firing onPick with the chosen entity's id. What a REF field opens instead of a flat dump of every entity in the world.
Usage: local edui.widgets.entityPicker = require("@builtin::editor.edui.widgets.entityPicker")
modules/edui.widgets.entityPicker/epoch
epoch(): number
The picker's view epoch — fold into the host panel's build signature.
modules/edui.widgets.entityPicker/make
make(W: any): (any) -> any
Bind the picker builder to the widgets barrel W. The barrel calls
this once and exposes the result as edui.entityPicker.
Parameters
Wany(optional) — Theedui.widgetstable.
Returns any — entityPicker(o) -> widget.
modules/edui.widgets.fields/README
require("@builtin::editor.edui.widgets.fields") -- edui.widgets.fields
Inspector field rows for edui — a two-column (label + control) row whose control is chosen by the field's declared TYPE (from the component's backing schema), falling back to the value's shape when no type is given. The registry maps: number → numeric field, bool → checkbox, string → text field, enum → a dropdown of its members, color → a colour picker, {x,y,z} → a vec3 triple, a quaternion → an editable euler (X/Y/Z degrees), an asset slot → a live-asset chip, a nested table → a recursing disclosure. Each control wraps the matching ui.* widget and carries the author's onChange closure, so a field writes straight back to the live component. schemaField builds the row from a Field descriptor instead: its kind and constraint pick the control, a struct or list edits in place, and a vec2 is an axis pair. Fields.make(W) binds these to the widgets barrel; the barrel exposes edui.field / edui.schemaField / edui.section.
Usage: local edui.widgets.fields = require("@builtin::editor.edui.widgets.fields")
modules/edui.widgets.fields/epoch
epoch(): number
The field layer's interaction epoch — moves on every dropdown / nested-table / picker open or close, and on every view mutation inside an open asset or entity picker. Fold it into a panel's build signature so those interactions repaint through a no-change gate.
modules/edui.widgets.fields/field
field(o: any): any
An inspector field row. o = { label, value, kind?, options?, optionLabels?, accepts?, onChange?, readOnly?, key }. kind (from the
component schema) selects the control; without it the control is
inferred from the value's shape. An enum shows each of its options as
its entry in optionLabels (text or an i18n.text value) when it has
one, and onChange receives the option itself.
An editable leaf fires onChange(newValue) (vec3/quat fire the full new
table).
Parameters
oany(optional)
edui.field{ label = "kind", value = c.kind, kind = "enum", options = {"a","b"}, onChange = set, key = "k" }
modules/edui.widgets.fields/make
make(W: any): any
Bind the field builders to the widgets barrel W. Returns
{ field, section, schemaField, subErrors }.
Parameters
Wany(optional) — The edui widgets barrel.
modules/edui.widgets.fields/openEditorsSignature
openEditorsSignature(): string
Text that moves whenever the asset shown in any open inline editor
moves (edui.inspector.signature of each). Fold it into a panel's build
signature so an editor follows an undo or a peer's write.
parts[#parts + 1] = Fields.openEditorsSignature()
modules/edui.widgets.fields/releaseEditors
releaseEditors(prefix: string)
Close every inline editor whose field key is prefix or nested under
it, and forget what was open or refused inside them — what a panel does
for the subject it stops showing.
Parameters
prefixstring— A field key prefix, e.g. a component card'sinsp:e:<id>.
Fields.releaseEditors("insp:e:" .. previousId)
modules/edui.widgets.fields/section
section(o: any): any
A collapsible inspector section, drawn as a CARD — a bordered, rounded
container whose clickable header (chevron + optional icon + uppercase
title, with an optional trailing widget) sits over a body shown while
open. o = { title, open, onToggle, children, key, headerRight?, icon?, muted? }. headerRight is a SIBLING of the clickable header region, so
its click isn't swallowed by the header toggle.
Parameters
oany(optional)
edui.section{ title = "Transform", icon = tfIcon, open = st, onToggle = t, children = rows }
modules/edui.widgets.inlineMarkdown/README
require("@builtin::editor.edui.widgets.inlineMarkdown") -- edui.widgets.inlineMarkdown
Inline markdown of one run of text as styled segments — the { text, color, monospace?, italic?, background? } list a richText, a tooltip and a code editor's hoverText draw. Reads code, bold, italic and text; everything else, newlines included, passes through as plain text.
Usage: local edui.widgets.inlineMarkdown = require("@builtin::editor.edui.widgets.inlineMarkdown")
modules/edui.widgets.inlineMarkdown/segments
segments(text: string, colors: Colors): { any }
The segments text reads as. Bold draws in colors.strong (a
segment carries no weight), inline code in colors.code on
colors.codeBackground in the monospace face, a link's label in
colors.link.
Parameters
textstring— One run of markdown text.colorsColors— The colours each kind of run draws in.
local segs = InlineMarkdown.segments("Returns the `Playback`.", colors)
modules/edui.widgets.livePreview/README
require("@builtin::editor.edui.widgets.livePreview") -- edui.widgets.livePreview
The ONE live preview session, following the asset selection. Every surface that shows the selected asset live — the Preview panel, the Inspector's Preview section — reads this module instead of holding its own rig, so one camera and one subject serve them all. The session starts when the asset selection lands, swaps with it, and tears down when it clears. subscribe tells a consumer the session's state moved (started, came live, failed) so it can rebuild; epoch folds that state into a build signature. play replaces the still session with a stage play of the selected effect or graph (proc.stage, effects.stage): a session with a transport (transport, pause, resume, stop, seek), inputs given while it plays (set), and a profile. setMeasure has the graph editor show that play's cost on each node (numbers); a selection that moves disposes the session, and the numbers of a node opened from the graph editor (openInside) stay with the asset it opened.
Usage: local edui.widgets.livePreview = require("@builtin::editor.edui.widgets.livePreview")
modules/edui.widgets.livePreview/assetId
assetId(): string? return sessionFor end
The guid the session (or attempt) is for, or nil.
modules/edui.widgets.livePreview/dragOrbit
dragOrbit(d: any)
Apply a pointer-drag delta as an orbit — the shared handler every
live-preview surface hands its onDrag.
Parameters
dany(optional)
modules/edui.widgets.livePreview/ensure
ensure()
Bring the session in line with the asset selection: a new primary disposes the old rig and assembles one for it, a cleared selection tears down. Idempotent — consumers call it from their builds; the selection subscription below calls it on every change.
modules/edui.widgets.livePreview/epoch
epoch(): number return epoch end
The monotonic state counter — fold into a build signature so the session coming live is a change the panel's no-change gate can see.
modules/edui.widgets.livePreview/isStarting
isStarting(): boolean return starting end
True while a session is assembling.
modules/edui.widgets.livePreview/kind
kind(): string return sessionKind end
The kind of the selected asset once known, else "".
modules/edui.widgets.livePreview/measuring
measuring(): boolean return measuring end
Whether the graph editor shows the stage play's cost on each node.
modules/edui.widgets.livePreview/name
name(): string return sessionName end
The selected asset's display name once known, else "".
modules/edui.widgets.livePreview/numbers
numbers(guid: string, path: string): any
The cost of the graph asset guid (at path) as the measurement stands: the branch of its cost tree, whose
children hold each node by id with ms, firstMs, againMs, checkMs, dispatches, uploads, readbacks.
The played graph is read from the stage play; a graph opened from a node (openInside) from the snapshot taken
then, at the node's place in the tree. Nil while nothing is measured for it.
Parameters
guidstring— The asset's guid.pathstring— The asset's VFS path.
modules/edui.widgets.livePreview/openInside
openInside(viewedGuid: string, viewedPath: string, nodeId: string, innerGuid: string)
Open the graph asset innerGuid, which node nodeId of the graph being viewed (viewedGuid, at viewedPath)
stands for, keeping that node's cost: the numbers the inner graph then shows are that instance's.
Parameters
viewedGuidstring— The guid of the graph the node is in.viewedPathstring— Its VFS path.nodeIdstring— The node's id.innerGuidstring— The guid of the asset the node is.
modules/edui.widgets.livePreview/orbitSession
orbitSession(s: any, d: any)
Apply a pointer-drag delta as an orbit of s, a live preview
session.
Parameters
sany(optional)dany(optional)
modules/edui.widgets.livePreview/pause
pause() stagedCall("pause") end
Stop the stage play's clock where it is.
modules/edui.widgets.livePreview/play
play(opts: { [string]: any }?)
Replace the still session with a stage play of the selected effect or graph, from its first frame. The play loops and its picture is the session's render target.
Parameters
opts{ [string]: any }?(optional) —{ entry?, inputs? }: the entry of an effect, and values for the inputs by name.
livePreview.play({ entry = "burst", inputs = { size = 2 } })
modules/edui.widgets.livePreview/playable
playable(): boolean
Whether the selected asset is one a stage play can be started for: an effect or a graph.
modules/edui.widgets.livePreview/reason
reason(): string? return failReason end
Why the last attempt produced no live session, or nil.
modules/edui.widgets.livePreview/resetView
resetView()
Back to the framed opening view.
modules/edui.widgets.livePreview/restart
restart() stagedCall("play") end
Play the stage play again from its first frame.
modules/edui.widgets.livePreview/resume
resume() stagedCall("resume") end
Run the stage play from where it stands.
modules/edui.widgets.livePreview/scrollZoom
scrollZoom(d: any)
Apply a wheel delta as a zoom — the shared handler every
live-preview surface hands its onScroll. Wheel-up moves in.
Parameters
dany(optional)
modules/edui.widgets.livePreview/seek
seek(seconds: number)
Move the stage play to seconds and hold it there.
Parameters
secondsnumber
modules/edui.widgets.livePreview/session
session(): any return session end
The live session for the selected asset, or nil while there is none (nothing selected, still starting, or the type has no live path).
modules/edui.widgets.livePreview/set
set(name: string, value: any)
Give the stage play an input's value while it plays.
Parameters
namestring— The input's name.valueany(optional) — A value, or a path over time{ { t, value }, ... }.
modules/edui.widgets.livePreview/setEntry
setEntry(entry: string)
Start the stage play again on another entry of the effect, keeping the inputs given.
Parameters
entrystring
modules/edui.widgets.livePreview/setMeasure
setMeasure(on: boolean)
Turn the cost shown on the graph editor's nodes on or off.
Parameters
onboolean
modules/edui.widgets.livePreview/staged
staged(): boolean return staged ~= nil end
Whether the session is a stage play.
modules/edui.widgets.livePreview/stop
stop() stagedCall("stop") end
Stop the stage play and show nothing; restart plays it again from its first frame.
modules/edui.widgets.livePreview/subscribe
subscribe(fn: () -> ())
Register a consumer's rebuild closure, called whenever the session's state moves. Registration is for the VM lifetime.
Parameters
fn() -> ()
livePreview.subscribe(function() edui.shell.refreshPanel("preview") end)
modules/edui.widgets.livePreview/transport
transport(): any
What the stage play stands at: { playing, stopped, time, frame, frames, fps, ends, entry, inputs }, or nil
while there is no stage play. frames is the length of the longest graph that ends, or 1.
modules/edui.widgets.livePreview/verdicts
verdicts(guid: string, path: string): { [string]: { string } }?
What the measurement found wrong at the nodes of the graph asset guid (at path): for each node of it that has
a verdict, its id and the verdict lines (time paid again with the cause, waits by site). A call node carries the
verdicts of the nodes inside it. Nil while nothing is measured for it.
Parameters
guidstring— The asset's guid.pathstring— The asset's VFS path.
modules/edui.widgets.livePreview/zoomBy
zoomBy(factor: number)
Zoom by a plain factor (toolbar buttons).
Parameters
factornumber
modules/edui.widgets.livePreview/zoomSession
zoomSession(s: any, d: any)
Apply a wheel delta as a zoom of s, a live preview session.
Wheel-up moves in.
Parameters
sany(optional)dany(optional)
modules/edui.widgets.newAsset/README
require("@builtin::editor.edui.widgets.newAsset") -- edui.widgets.newAsset
What the Files panel's "New asset" flow offers and how it creates it. An asset kind that cannot be created bare, because asset.create needs it bound to another asset (a data asset is a set of values for one dataType), is offered once per asset it can be bound to, so the choice that creation needs is made in the same menu that names the kind. A kind that creates bare is offered as it is.
Usage: local edui.widgets.newAsset = require("@builtin::editor.edui.widgets.newAsset")
modules/edui.widgets.newAsset/binding
binding(kind: string): { param: string, from: string }?
The binding a kind needs, or nil when it creates bare.
Parameters
kindstring— An asset kind name.
local b = NewAsset.binding("data")
modules/edui.widgets.newAsset/candidates
candidates(kind: string): { string }
The identities of every asset a kind can be bound to, sorted.
Parameters
kindstring— A kind that has a binding.
for _, id in ipairs(NewAsset.candidates("data")) do print(id) end
modules/edui.widgets.newAsset/choices
choices(kinds: { { key: string, label: string } }): { Choice }
The menu rows for a list of creatable kinds: one row for each kind that creates bare, and for a kind needing a binding one row per asset it can be bound to, or a single disabled row saying what is missing.
Parameters
kinds{ { key: string, label: string } }— Array of{ key, label }kind rows.
local rows = NewAsset.choices({ { key = "data", label = "data" } })
modules/edui.widgets.newAsset/create
create(kind: string, name: string, folder: string?, bound: string?): any
Create an asset of a kind through asset.create, with the field that
binds it to another asset when the kind needs one.
Parameters
kindstring— The asset kind.namestring— The new asset's name.folderstring?(optional) — The subfolder of the world's source to create it in, or nil for the root.boundstring?(optional) — The identity of the asset it is bound to (required when the kind has a binding).
NewAsset.create("data", "goblin", nil, "enemy")
modules/edui.widgets.newAsset/kindsBoundTo
kindsBoundTo(assetType: string): { string }
The kinds that are created from an asset of the given type.
Parameters
assetTypestring— The type of the asset the kinds are bound to.
NewAsset.kindsBoundTo("dataType") -- { "data" }
modules/edui.widgets.nodeGraph/README
require("@builtin::editor.edui.widgets.nodeGraph") -- edui.widgets.nodeGraph
A node graph: titled nodes with output ports and input ports, a value on every input port that has no wire into it, wires between the ports, and everything done with a pointer. The whole graph is one canvas, painted from the palette's own tokens, so a graph of hundreds of nodes is one widget; it reports where inside itself a pointer is, which is what hit-testing a port, a value, a node or a wire needs. Drag the background to pan, scroll to zoom about the pointer, drag a node to move it, drag from a port to another port to connect, drag a connected input port away to pick its wire up, click a node or a wire to select it, press Delete to remove the selection. Click a value to edit it where it stands: a number or a string takes typing, a number also scrubs when dragged, a switch flips, a choice opens its options. A node given no position is placed by a layered layout over the wires. The widget draws and reports; the owner holds the graph and applies each change it is told of. NodeGraph.make(W) binds it to the widgets barrel; the barrel exposes edui.nodeGraph.
Usage: local edui.widgets.nodeGraph = require("@builtin::editor.edui.widgets.nodeGraph")
modules/edui.widgets.nodeGraph/layout
layout(nodes: { any }, edges: { any }): { [string]: { x: number, y: number } }
A layered layout over the wires: each node sits one column right of the
furthest of its producers, and the rows of a column follow the average row
of the nodes feeding it, so wires run left to right with few crossings. A
wire that closes a cycle is ignored. nodes is { { id, ... } } and edges
is { { from, to } }.
Parameters
nodes{ any }edges{ any }
modules/edui.widgets.nodeGraph/make
make(W: any): any
Bind the node graph to the widgets barrel W. Returns { nodeGraph, layout, nodeSize, view }.
Parameters
Wany(optional)
modules/edui.widgets.nodeGraph/nodeGraph
nodeGraph(o: any): any
A node graph.
o = { key, nodes, edges, selected?, height?, onSelect?, onMove?, onConnect?, onDisconnect?, onDelete?, onOpen?, onDropOnEmpty?, onField?, redraw?, toolbar? }.
nodes:{ { id, title?, sub?, heat?, flag?, tone?, outputs = { { name, type? } }, inputs = { { name, type?, field?, extra? } }, fields? = { field }, x?, y?, open? } }.toneis"input","output","graph","asset"or nil;openmarks a node a double-click opens.subis the small text on the right of the header, andheat(0 to 1) is a bar along the foot of the header, longer for a costlier node and green, amber or red as it grows. A node with aflag(a short text such as"!") carries it in a red mark at the right end of the header.- a
fieldis{ name, label?, kind, value, options?, min?, max?, int? };kindis"number","string","bool","enum","vec3","color"or"asset". On an input port it is the value that drives the port while nothing is wired into it; infieldsit is a row of the node's own. A port flaggedextrais one of the node's unset values, which fold under "more" past the first few. edges:{ { from, fromPort, to, toPort } }; an input takes one wire.onField(id, name, value)is told of each value a person sets;valueis a whole vec3 for a vec3.onSelect(id?),onMove(id, x, y)(once, when a drag ends),onConnect(from, fromPort, to, toPort),onDisconnect(to, toPort, from, fromPort),onDelete(id),onOpen(id),onDropOnEmpty(from, fromPort, x, y).redraw()is called after a change to the view alone (pan, zoom, a drag in flight), so the owner can rebuild its panel.toolbaris extra widgets placed after the built-in view controls.
Parameters
oany(optional) — The graph's state and handlers.
edui.nodeGraph{ key = "g:graph", nodes = nodes, edges = edges, selected = id, onSelect = select }
modules/edui.widgets.nodeGraph/nodeSize
nodeSize(n: any, wired: { [string]: boolean }?, expanded: boolean?): (number, number)
The size of a node in graph units. n is { id, title, sub?, outputs, inputs, fields? }; wired names the input ports that have a wire in
("<id>\1<port>"), and expanded whether the node shows every input.
Parameters
nany(optional)wired{ [string]: boolean }?(optional)expandedboolean?(optional)
modules/edui.widgets.nodeGraph/view
view(key: string): any
Where the view stands for the widget keyed key: { panX, panY, zoom, positions }. Positions are in graph units.
Parameters
keystring
modules/edui.widgets.timeline/README
require("@builtin::editor.edui.widgets.timeline") -- edui.widgets.timeline
A timeline: a transport, a ruler ticked frame by frame, and a track a playhead runs along, with the played range as a region whose ends are dragged and the frames already cooked filled in behind it. The track is one canvas — the only widget that reports where inside itself a pointer is, which is what click-to-seek and dragging a handle need — painted from the palette's own tokens. Timeline.make(W) binds it to the widgets barrel; the barrel exposes edui.timeline.
Usage: local edui.widgets.timeline = require("@builtin::editor.edui.widgets.timeline")
modules/edui.widgets.timeline/make
make(W: any): any
Bind the timeline to the widgets barrel W. Returns { timeline }.
Parameters
Wany(optional)
modules/edui.widgets.timeline/timeline
timeline(o: any): any
A timeline for a clock something else owns: a transport, a ruler and a track carrying the played range, what is cooked, and a playhead.
o = { frame, first, last, frames, fps, cookedThrough?, playing?, held?, loop?, realTime?, wallTime?, time?, key, onSeek?, onRange?, onPlay?, onPause?, onLoop?, onWallTime?, onFps? }. Frames count from
zero; first/last are the played range inside frames, and
cookedThrough is the last frame already cooked. A handler left out
takes its control away.
Parameters
oany(optional) — The timeline's state and handlers.
edui.timeline{ frame = 42, first = 0, last = 149, frames = 150, fps = 30, key = "gen:tl", onSeek = seek }
modules/edui.widgets.tree/README
require("@builtin::editor.edui.widgets.tree") -- edui.widgets.tree
The editor hierarchy tree primitive — flattens a nested node graph into the rows that are actually visible under the current expand state, and renders them as indented, selectable ui.* rows inside a virtualized scroll area. The flatten pass is pure and separately exported, so row order is testable without a rendered frame.
Usage: local edui.widgets.tree = require("@builtin::editor.edui.widgets.tree")
modules/edui.widgets.tree/flatten
flatten(o: { [string]: any }): { Row }
Flatten o.roots into the ordered list of rows visible under the
current expand state — a node's children are included only while that node
is expanded. Pure: no ui.* calls, no app required.
Parameters
o{ [string]: any }—{ roots, childrenOf?, idOf?, expanded?, isExpanded? }.expandedis an{ [id] = true }set;isExpanded(node, id) -> booleanoverrides it.
local rows = edui.widgets.flattenTree{ roots = roots, expanded = { root = true } }
modules/edui.widgets.tree/make
make(W: any): (any) -> any
Bind the tree builder to a widgets barrel W. The barrel calls this
once and exposes the result as edui.tree.
Parameters
Wany(optional) — Theedui.widgetstable (supplies palette/text/svgIcon/cbId/merge).
Returns any — tree(o) -> widget.
modules/edui.widgets.tree/windowBounds
windowBounds(total: number, offset: number, viewport: number, rowH: number,
The band of a total-row list that exists as widgets: the rows in
view plus an overscan on each side, its start snapped to a multiple of the
quantum so a small scroll inside the overscan moves nothing.
edui.widgets.windowBounds(4000, 0, 440, 22) --> 0, 48
modules/edui.widgets/README
require("@builtin::editor.edui.widgets") -- edui.widgets
Editor-chrome primitives for edui — styled ui.* subtree builders (box/text/icon/iconButton/button/toolbar/panel/divider/spacer). Each reads the active theme's editor tokens so chrome looks like the editor by default, and interactive builders register their closures with the currently-building edui app (edui.current()), so an author passes a closure, not a callback id.
Usage: local edui.widgets = require("@builtin::editor.edui.widgets")
modules/edui.widgets/button
button(o: { [string]: any }): any
A text button. o.text, o.onClick, o.key, o.primary, o.icon
(SVG path), o.tooltip.
Parameters
o{ [string]: any }
edui.button{ text = "Add", primary = true, onClick = onAdd, key = "add" }
modules/edui.widgets/divider
divider(o: { [string]: any }?): any
A 1px divider line (horizontal by default).
Parameters
o{ [string]: any }?(optional)
modules/edui.widgets/group
group(o: { [string]: any }): any
A FLAT collapsible group (chevron + uppercase title + optional count),
with none of the section card's border/shadow — for grouping a list inside
a panel. o.title, o.count?, o.open, o.onToggle, o.children, o.key.
Parameters
o{ [string]: any }
edui.group{ title = "@builtin", count = 12, open = o, onToggle = t, children = rows }
modules/edui.widgets/hbox
hbox(o: { [string]: any }): any
A horizontal flex container. Forwards onClick, onDoubleClick,
onContextMenu, onDrag, dragPayload (with dragLabel), onDrop and
tooltip (a string, or styled segments).
Parameters
o{ [string]: any }
edui.hbox{ gap = 6, align = "center", children = { ... } }
modules/edui.widgets/iconButton
iconButton(o: { [string]: any }): any
A compact icon button — a hoverable, optionally-active square holding
an SVG icon. o.d (icon path), o.tooltip, o.active, o.onClick,
o.key, o.size, o.color, o.id (widget id, e.g. a popup anchor).
Parameters
o{ [string]: any }
edui.iconButton{ d = eyeIcon, tooltip = "Visible", active = vis, onClick = toggle, key = "vis:"..id }
modules/edui.widgets/input
input(o: { [string]: any }): any
A flat text-entry field — a styled container holding an optional leading
icon and a borderless input, so it reads as one clean field instead of the
raw widget's heavy frame. o.text, o.placeholder, o.onChange (live
per-keystroke), o.onSubmit (command-line mode: the full line on Enter,
buffer cleared, caret kept), o.key, o.icon (SVG path), o.style,
o.bare (no container frame at all — the input alone, for a surface like
a terminal prompt that draws its own ground).
Parameters
o{ [string]: any }
edui.input{ placeholder = "Search…", icon = searchPath, onChange = fn, key = "search" }
modules/edui.widgets/menu
menu(o: { [string]: any }): any?
A context/action menu — a ui.* popup pinned below an anchor widget
or at a window point, holding clickable action items. o.anchorTo (widget
id of the anchor, which must render before this in tree order) or o.at
({ x, y } in the window's points — the value an onContextMenu delivers,
so a right-click menu opens at the pointer), o.open (bool), o.items (list of
{ label, icon?, onClick, danger?, disabled?, hint?, separator?, key? } —
a disabled item dims and takes no click; hint renders right-aligned dim
text, where a shortcut goes), o.onDismiss (closure, fired on
click-outside / Escape, and after an item's onClick runs — a menu closes
once it has acted), o.key (id namespace), o.pivot. Returns nil when
closed.
Parameters
o{ [string]: any }
edui.menu{ anchorTo = "rowmenu:"..id, open = open, items = {...}, onDismiss = close }
edui.menu{ at = clickPoint, open = clickPoint ~= nil, items = {...}, onDismiss = close }
modules/edui.widgets/notice
notice(o: { [string]: any }): any
An inline status banner. o.text, o.tone ("info" | "ok" | "error").
edui has no timer, so a transient toast is the caller gating this on/off;
this draws the styled line.
Parameters
o{ [string]: any }
edui.notice{ text = "Saved", tone = "ok" }
modules/edui.widgets/panel
panel(o: { [string]: any }): any
A panel frame — an optional title/toolbar header over a body that
fills the remaining height. This is the standard dockable-panel shell.
o.title (string) OR o.toolbar (a prebuilt toolbar widget); o.body
(widget); o.style.
Parameters
o{ [string]: any }
edui.panel{ title = "Entities", body = tree }
modules/edui.widgets/scroll
scroll(o: { [string]: any }): any
A first-class vertical scroll container filling its parent. o.children,
o.height?, o.maxHeight?, o.style?.
Parameters
o{ [string]: any }
edui.scroll{ children = rows }
modules/edui.widgets/spacer
spacer(): any
A flexible spacer that eats remaining space in a flex row/column.
modules/edui.widgets/stat
stat(o: { [string]: any }): any
A dense read-only telemetry row: label on the left, value on the
right (mono by default). good/warn numeric thresholds tint the value
(higher = worse: ≥warn is danger, ≥good is warn-hue, else ok); an explicit
color overrides. For readouts too light to warrant an editable field.
Parameters
o{ [string]: any }
edui.stat{ label = "RSS", value = "412 MB", good = 400, warn = 800, mono = true }
modules/edui.widgets/svgIcon
svgIcon(o: { [string]: any }): any
An inline SVG icon. o.d is an SVG path (or full <svg>); o.size,
o.color.
Parameters
o{ [string]: any }
edui.svgIcon{ d = "<path d='M6 9l6 6 6-6'/>", size = 14 }
modules/edui.widgets/switch
switch(o: { [string]: any }): any
A bare toggle switch (pill track + sliding knob) — the switch control on
its own, distinct from a checkbox or a power button. o.value (bool),
o.onChange, o.key, o.readOnly.
Parameters
o{ [string]: any }
edui.switch{ value = enabled, onChange = function(v) ... end, key = "comp:en" }
modules/edui.widgets/table
table(o: { [string]: any }): any
A multi-column table with a header row, on the real CSS grid. o.columns
is { { key, label?, width?, align?, mono? } } (width defaults to 1fr);
o.rows is { [colKey] = value } records. o.key (widget id).
Parameters
o{ [string]: any }
edui.table{ columns = {{key="name",label="Script"},{key="ms",label="ms",align="right",mono=true}}, rows = rows, key = "vm" }
modules/edui.widgets/text
text(o: { [string]: any } | string): any
A text label. o.text, o.color, o.dim (muted), o.weight,
o.size, o.style.
Parameters
o{ [string]: any } | string
edui.text{ text = "Entities", weight = "600" }
modules/edui.widgets/toolbar
toolbar(o: { [string]: any }): any
A header row — items laid out horizontally with comfortable padding
and a hairline rule beneath, on the panel's own surface (no competing
fill). o.items (widget list), o.style.
Parameters
o{ [string]: any }
edui.toolbar{ items = { edui.text{text="Entities"}, edui.spacer(), addBtn } }
modules/edui.widgets/typeBadge
typeBadge(kind: string?): any?
A tiny type badge — a mono uppercase pill that names a field's kind in
its own hue (num/str/bool/enum/rgb/vec3/rot/ref/obj), so a row's type reads
at a glance. kind is a field kind (number/string/enum/…).
Parameters
kindstring?(optional)
edui.typeBadge("enum")
modules/edui.widgets/vbox
vbox(o: { [string]: any }): any
A vertical flex container. o.style overrides; o.children (or the
positional 1st arg) are the children. Forwards onClick, onDoubleClick,
onContextMenu (the right button, with the pointer's { x, y } — open an
edui.menu{ at = ... } there), onDrag, dragPayload (with dragLabel,
what the ghost under the pointer reads while it is dragged), onDrop and
tooltip (a string, or styled segments).
Parameters
o{ [string]: any }
edui.vbox{ gap = 4, children = { ... } }
modules/egress/README
require("@builtin::modules.api.engine.egress") -- egress (also available as global 'egress')
Credential-injecting HTTP for BYO-key world egress (Mechanism B). Public Luau surface over the __egress Internal FFI namespace.
Usage: local egress = require("@builtin::modules.api.engine.egress") Also available as global: egress
modules/egress/clearCredential
clearCredential(name: string): boolean
TRUSTED ONLY. Remove a named credential.
Parameters
namestring— Credential name.
egress.clearCredential("meshy")
modules/egress/configureForward
configureForward(baseUrl: string, worldGuid: string): boolean
TRUSTED ONLY. Route named-secret requests through the bound world's ZeroMind forwarding endpoint.
Parameters
baseUrlstring— ZeroMind service origin.worldGuidstring— Bound world identity.
modules/egress/credentialNames
credentialNames(): { string }
List the names in the local credential store. Names only — secret values are never exposed to Luau.
for _, n in ipairs(egress.credentialNames()) do print(n) end
modules/egress/fetch
fetch(name: string, method: string, url: string,
Perform an HTTP request using a named credential. A bound world
forwards the request to ZeroMind, which resolves its world secret and
enforces the allowed destination. Await the returned handle; a refused
forwarded request returns the HTTP error JSON with __http_error = true.
With a local credential store, an unknown name or a URL outside its
allowed prefix returns nil immediately. Credential values stay with
the store or forwarding server and never enter world code.
local h = egress.fetch("meshy", "POST", url, nil, { prompt = p })
modules/egress/hasCredential
hasCredential(name: string): boolean
Whether the local credential store holds a name. Returns only a boolean. World secrets are resolved by ZeroMind when a forwarded request runs; this probe answers for the local store.
Parameters
namestring— Credential name.
if not egress.hasCredential("meshy") then error("set MESHY_API_KEY") end
modules/egress/setCredential
setCredential(name: string, base_url: string,
TRUSTED ONLY. Register a named credential whose header is
injected into matching egress.fetch calls. The value is held
in Rust and never returned to Luau.
egress.setCredential("meshy", "https://api.meshy.ai/", "Authorization", "Bearer " .. key)
modules/engine.dirty_hot_reload/README
require("@builtin::modules.api.engine.dirty_hot_reload") -- engine.dirty_hot_reload
Per-entity hot reload on <scene>.dirty/entities/. Subscribes to the layer's dirty entities directory via the generic vfs.watch(folder, callback) primitive and reapplies changed bodies to live entities — the consumer side of the collaborative-via-VFS-sync edit model. Local edits write a dirty file; VFS sync replicates the bytes to every peer's local VFS; the subscription fires for both Local and Remote writes; the callback reads the replicated file and applies it to the peer's live entity. No polling. Writes made through vfs.* fire watchers synchronously inside the FFI call. Shell writes and peer-driven writes are queued in zero_vfs::write_events and drained by the engine schedule's apply_vfs_mutations system, which fires watchers within a frame of the bytes landing. Cost is O(0) when nothing changes. Mark-suppression contract: Body application happens inside __scene_load.begin() / __scene_load.finish() so the Rust mark sites (mark_entity_dirty, mark_manifest_dirty) early-return — without the gate, applying a peer's edit would re-mark the entity dirty locally, the saver would re-write the same body to disk, VFS sync would re-broadcast back, and the feedback loop would saturate the relay. The same gate the scene loader uses on full-scene loads. Echo-loop suppression: Local writes round-trip through the watcher too (lua_vfs_write fires synchronously). The known per-eid content cache short- circuits re-apply when the file content matches the last-seen string — we just wrote it, no need to re-apply our own write. Lifecycle: layers.M.fireLoad(proxy) calls M.install(proxy) for every scene (additive or not) that just loaded — the install seeds known from current dir contents and registers one vfs.watch on <entitiesDir> (folder subscription). M.fireUnload(proxy) calls M.uninstall(proxy) which calls vfs.unwatch(id) and drops the per-layer state. Authored content lives in additive overlays too (editor side-panels, side games, custom HUD overlays) — they get the same hot-reload treatment. Scenes that genuinely don't resolve to a dirty subtree (e.g. an engine-internal scaffolding overlay) early-return inside entitiesDirFor.
Usage: local engine.dirty_hot_reload = require("@builtin::modules.api.engine.dirty_hot_reload")
modules/engine.dirty_hot_reload/canonicalChanged
canonicalChanged(sceneGuid: string, origin: string?): number
Take each entity whose record changed in the layer's canonical
scene.json to what that record now says, and the loaded scene to the
scene-level fields the write changed (player, the setting blocks), and
report what that reached. The entry point for a write this module's own
subscription does not see: vfs.watch fires for a write made inside the
vm and for one replicated
from a peer, and NOT for one made through the host (write_file /
edit_file), which is the route an author reaches for first. The scene
assetType's onChange sees that one and calls this.
Guarded by the same content cache the subscription uses, so whichever of the two arrives first applies the write and the other reads an echo. A record whose entity already matches costs nothing either way, and so does a scene-level field the scene already holds as the file states it.
Parameters
sceneGuidstring— The layer's guid.originstring?(optional) — Who wrote the file:"local"(the default) for this session,"remote"for a peer, whose records are applied as a peer's.
DirtyHotReload.canonicalChanged(layers.active.guid)
modules/engine.dirty_hot_reload/debugFire
debugFire(guid, path, kind, origin)
Diagnostic: synchronously dispatch a synthetic write event for the
given guid + path, as a write origin made ("local" by default,
"remote" for a peer's). Used by tests and debugging; production reads
come from vfs.watch callbacks.
Parameters
guidany(optional)pathany(optional)kindany(optional)originany(optional)
modules/engine.dirty_hot_reload/debugState
debugState(guid)
Diagnostic: return a shallow copy of the per-layer state for inspection.
Returns { entitiesDir, knownKeys, waiting, active, watcherId, eventCount, peerSettles, peerSettlePending }. peerSettles counts the times the layer was respawned from its
files because another session took overlay records out of them and those files then
held something other than the live layer; peerSettlePending is true while such a
removal waits for its run of removals to end before the files are read.
waiting maps the id of each record whose parent no entity provides to
the parent reference it states; that record's entity is built when an
entity providing the parent is built from the scene's records.
Parameters
guidany(optional)
modules/engine.dirty_hot_reload/install
install(sceneProxy)
Subscribe to the layer's dirty/entities/ directory via
vfs.watch (folder subscription — fires for any descendant
write/remove, both Local and Remote origins). Called automatically
from layers.M.fireLoad
for EVERY loaded scene (additive or root) — scenes don't need to
install it manually. Scenes that don't resolve to a dirty subtree
(engine-internal scaffolding overlays, persistent UI layers with
no on-disk authoring path) early-return inside entitiesDirFor.
Parameters
sceneProxyany(optional) — SceneProxy for the just-loaded layer.
modules/engine.dirty_hot_reload/installed
installed()
Return the set of currently-installed layer guids. Observability hook for tests / debugging.
modules/engine.dirty_hot_reload/uninstall
uninstall(sceneProxy)
Stop the watcher for the given layer. Called from layers.M.fireUnload.
Idempotent — safe to call when no install ran or after a prior uninstall.
Parameters
sceneProxyany(optional) — SceneProxy for the layer being unloaded.
modules/entity/README
require("@builtin::modules.api.engine.entity") -- entity (also available as global 'entity')
Entity spawn / despawn / query / hierarchy surface. Calling the table itself — entity(idOrProxy) — resolves an id or proxy to its live entityRef proxy, and iterating it (for name, member in entity do) lists its members. Public Luau surface over the __entity Internal FFI namespace, composed with the entityRef proxy metatable, the hierarchy swap helper, id/proxy coercion, and the polymorphic batch read/write dispatch.
Usage: local entity = require("@builtin::modules.api.engine.entity") Also available as global: entity
modules/entity/batchAddComponent
batchAddComponent(targets: { string | entityRef }, type_name: string, data: table?): number
Add the same component type to many entities in one call. Returns the count of entities the component was added to — an entity already carrying an unnamed instance of the same type is skipped rather than double-added.
Parameters
targets{ string | entityRef }— Array of entity ids or entity proxies (e.g. the return ofentity.batchSpawnorentity.findAll).type_namestring— Component type to add to every entity.datatable?(optional) — Init data: one table applied identically to every entity — the same shape the second arg toentity(id).component.add(type, data)takes — or an array holding one such table per target, in the targets' order, so each entity is added with its own values.
local n = entity.batchAddComponent(ids, "Debris", { lifetime = 5 })
entity.batchAddComponent({ a, b }, "Debris", { { lifetime = 2 }, { lifetime = 7 } })
modules/entity/batchDespawn
batchDespawn(targets: { string | entityRef }): number
Despawn many entities in one call. Locked or unresolvable entities are skipped. Returns the count queued for despawn.
Parameters
targets{ string | entityRef }— Array of entity ids, entity proxies, or display names (e.g. the return ofentity.batchSpawn/entity.findAll).
local n = entity.batchDespawn(ids)
modules/entity/batchProxy
batchProxy(targets: { string | entityRef }): { entityRef? }
Resolve an array of entity ids to proxies in one call. Each output
slot is the standard entity(id) proxy; ids missing from the frame
cache surface as nil at that index. Use when iterating over a snapshot
of entities so per-id lookups don't dominate the hot path.
Parameters
targets{ string | entityRef }— Array of entity ids or entity proxies.
local proxies = entity.batchProxy(ids)
modules/entity/batchRead
batchRead(target: { string | entityRef } | binding, component: string?, field: string?, sink: TypedBuffer?): { any? } | number
Read a component-field across many entities in one call.
Polymorphic on the shape of target and sink:
entity.batchRead(ids)/(ids, comp)/(ids, comp, field)— returns one value per entity (a whole snapshot, one component table, or one field value). Missing entities/components/fields surface as nil at that slot.entity.batchRead(binding, comp, field, buffer)— reads each entity's field directly into a typed CPU substrate buffer (substrate.createBuffer({type="vec3"}), etc.) with no per-entity Lua table allocation. Returns the count of successful reads.Transform.worldMatrixreads each entity's world matrix — its own transform folded with its ancestors', the oneentity(id).worldMatrix()answers — as 16 column-major numbers: into amat4buffer, or as an array of 16 per entity. It is read, never written.targetaccepts an entity-id array or aecs.bindEntities(ids)handle. Buffer sinks require a binding — the typed kernel is binding-only.
Parameters
target{ string | entityRef } | binding— Array of entity ids or entity proxies, or a binding handle fromecs.bindEntities(ids).componentstring?(optional) — Component type name (e.g. "Transform").fieldstring?(optional) — Field name (e.g. "position").sinkTypedBuffer?(optional) — Typed CPU buffer fromsubstrate.createBuffer({...})to memcpy field values into. Required whentargetis a binding.
local snapshot = entity.batchRead(ids)
local positions = entity.batchRead(ids, "Transform", "position")
entity.batchRead(ecs.bindEntities(ids), "Transform", "worldMatrix", matrices)
modules/entity/batchReadToBuffer
batchReadToBuffer(binding: number, component: string, field: string, buffer: number): number
FFI primitive backing entity.batchRead(binding, ..., buffer).
Prefer the unified entity.batchRead, which auto-dispatches by
argument shape. Reads each entity's component field directly into a
typed CPU substrate buffer, with no per-entity Lua table allocation.
After the call, read the buffer via buf:read(0, count*stride).
Parameters
bindingnumber— Binding id fromecs.bindEntities(ids).id, live while its handle is held.componentstring— Component type name.fieldstring— Field name to read.buffernumber— Destination buffer id (must be the matching type).
entity.batchReadToBuffer(binding.id, "Transform", "position", buf.id)
modules/entity/batchSpawn
batchSpawn(count: number, name_prefix: string?, opts: { temporary: boolean?, parent: (string | entityRef)? }?): { string }
Spawn count entities in one call. Returns an array of the new
entity ids in spawn order. Each entity is given a display name of
<name_prefix><i> (or entity<i> if the prefix is omitted). Prefer this
over looping entity.spawn when creating large entity counts.
Parameters
countnumber— How many entities to spawn (capped at 1,000,000).name_prefixstring?(optional) — Display-name prefix appended with the 1-based index. Defaults to "entity".opts{ temporary: boolean?, parent: (string | entityRef)? }?(optional) —{ temporary?, parent? }— a temporary batch is one the scene does not save, the same thingentity.spawn({ temporary = true })asks for. The component goes on in one crossing, so a batch of a hundred thousand costs what one does. A batch spawned inside an entrypoint that is itself temporary is temporary whatever this says.parent— an id or an entity — makes every entity in the batch its child as it is made, so the batch stands, moves and goes with it.
local ids = entity.batchSpawn(100, "grass_")
local particles = entity.batchSpawn(5000, "spark_", { temporary = true })
local parts = entity.batchSpawn(8, "part_", { temporary = true, parent = owner })
modules/entity/batchWrite
batchWrite(target: { string | entityRef } | binding, component: string, field: string, source: { any? } | TypedBuffer): number
Write a single component-field across many entities in one call.
Polymorphic on the shape of target and source:
entity.batchWrite(ids, comp, field, values)— per-call entity-id resolution;valuesis an array the same length asids(nil slots are skipped). Use for one-shot writes.entity.batchWrite(binding, comp, field, values)— binding handle fromecs.bindEntities(ids); skips per-call id resolution. Use for per-frame writes against a stable entity set.entity.batchWrite(binding, comp, field, buffer)— typed CPU buffer source (substrate.createBuffer({type="vec3"}), etc.), with no per-entity table allocation. Returns the count of successful writes. Buffer sources require a binding — the typed kernel is binding-only.
Parameters
target{ string | entityRef } | binding— Array of entity ids or entity proxies, or a binding handle fromecs.bindEntities(ids).componentstring— Component type name.fieldstring— Field name to write.source{ any? } | TypedBuffer— Per-entity values array (nil entries are skipped), or a typed CPU buffer fromsubstrate.createBuffer({...}). A buffer source requires a bindingtarget.
entity.batchWrite(ids, "Transform", "position", positions)
modules/entity/batchWriteBound
batchWriteBound(binding: number, component: string, field: string, values: { any? }): number
FFI primitive backing entity.batchWrite(binding, ...) with a
per-entity values table. Prefer the unified entity.batchWrite, which
auto-dispatches by argument shape; this entry stays for power users /
debug code that wants to skip dispatch overhead.
Parameters
bindingnumber— Binding id fromecs.bindEntities(ids).id, live while its handle is held.componentstring— Component type name.fieldstring— Field name to write.values{ any? }— Per-entity source values (nil = skip). Length must match the binding's entity count.
entity.batchWriteBound(binding.id, "Transform", "position", values)
modules/entity/batchWriteFromBuffer
batchWriteFromBuffer(binding: number, component: string, field: string, buffer: number): number
FFI primitive backing entity.batchWrite(binding, ..., buffer).
Prefer the unified entity.batchWrite, which auto-dispatches by
argument shape. Caller fills a typed substrate buffer
(substrate.createBuffer({type="vec3"})) once via buf:write(...),
then this memcpys 12 (vec3) or 16 (quat) bytes per entity into the
component field. Buffer count and binding count should match — a
mismatch processes the smaller of the two.
Parameters
bindingnumber— Binding id fromecs.bindEntities(ids).id, live while its handle is held.componentstring— Component type name.fieldstring— Field name to write.buffernumber— Buffer id fromsubstrate.createBuffer({type="vec3", len=N}).id.
entity.batchWriteFromBuffer(binding.id, "Transform", "position", buf.id)
modules/entity/capture
capture(builder: () -> ()): ({ string }, any?, { string }, { any })
Run builder inside an entity capture scope and return the entity ids
it minted, in creation order, the error it raised (if any), and the ids
among them that a component the builder attached minted in its own
lifecycle. Every id minted while the builder runs is recorded — through
entity.spawn, entity.spawnSynced, entity.batchSpawn, and
entity.instantiate alike. Scopes nest: an id minted inside an inner
capture is recorded by that capture AND every enclosing one — the
innermost capture answers, so a nested build shapes its own entities,
not the ones around it. A builder that raises still returns its ids, so
the caller can despawn what a failed build left behind; the scope closes
either way and never outlives this call. While the builder runs, an
operation whose result cannot be composed into a record is refused
rather than applied, and so is any operation aimed at an entity the
builder did not mint — a builder that returned while something it did
was refused comes back with an error naming every refusal.
Parameters
builder() -> ()— Function run inside the scope; the entities it creates are what comes back.
local ids, err, reproduced, refusals = entity.capture(function() entity.spawn("chair") end)
modules/entity/capturing
capturing(): boolean
Whether an entity.capture builder (a scene build) is running on the
calling thread. A component a build adds takes the world's Preset Manager
rows in every mode, so a scene built in a play session holds what the
same build holds in edit mode.
if entity.capturing() then return end
modules/entity/despawn
despawn(target: string | entityRef)
Despawn an entity and all its components. Pass an id string or an entity proxy to despawn that ONE entity. Pass a name to despawn EVERY entity with that name — names are not unique, so a name argument despawns all matches, not one arbitrary match. A despawned id becomes invalid after this call. Raises if no entity matches; for a bulk name despawn, locked entities are skipped with a logged summary and only raise if every match is locked.
Parameters
targetstring | entityRef— Entity id, name, or entity proxy. A name despawns all entities sharing that name.
entity.despawn(id)
entity.despawn("Enemy") -- despawns every entity named "Enemy"
modules/entity/duplicate
duplicate(sourceId: string | entityRef, name: string?, opts: table?): string?
Duplicate an entity with all its components (transform, script
components, attributes, visuals, material) and its descendants. Returns
the new entity's id, or nil when sourceId names no live entity.
Descendants marked temporary are left out of the copy: they are
scaffolding whatever spawned them re-creates, so a component that
regenerates its own children rebuilds them on the copy rather than the
copy carrying a second set. includeTemporary copies them too, for the
hierarchy that IS the temporary thing.
Parameters
sourceIdstring | entityRef— Entity id or entity proxy of the source entity to clone.namestring?(optional) — Display name for the copy (defaults to source name + " (copy)").optstable?(optional) —{ includeTemporary?: boolean, descendants?: boolean, components?: table, name?: string }:descendants = falsecopies the source entity alone, leaving its children to it;componentslays fields over the copy's script components by type ({ SoftBody = { mass = 2 } }), merged over the state copied from the source;nameis the same field thenameargument sets, and wins when both are given.
local copyId = entity.duplicate(id); if copyId then entity(copyId).position = { 1, 0, 0 } end
local copyId = entity.duplicate(id, "Turret", { includeTemporary = true })
local lone = entity.duplicate(id, nil, { descendants = false, components = { SoftBody = { mass = 2 } } })
modules/entity/exists
exists(idOrProxy: string | entityRef): boolean
Check whether an entity currently exists in the scene. Accepts an
entity-id string or an entity proxy, matched by entity id — so it agrees
exactly with entity(id). A name is a different kind of identifier: a
string that misses as an id but names a live entity raises rather than
answering false, since false there is indistinguishable from absence.
Check by name with entity.find(name) ~= nil.
Parameters
idOrProxystring | entityRef— Entity id or an entity proxy.
if entity.exists(id) then ... end
modules/entity/find
find(nameOrGlob: string): entityRef?
Find the first entity matching nameOrGlob. A plain string matches
an exact id or Name component; a string containing * (any run of
characters) or ? (any single character) matches Names as a glob, so
entity.find("enemy_*") is the first entity whose name starts with
enemy_. A glob addresses Names only, never ids. Same-frame pending
spawns are searched too, and anything queued for despawn in the same
frame is skipped. Names are NOT unique — use entity.findAll when every
match matters; find is the first entity findAll lists. Inside a build
(a scene's content(), a module's builder), a name the build's own
entities carry resolves to those first, so entity.spawn("door")
followed by entity.find("door") is the door the build just made even
when the world around it holds another door.
Parameters
nameOrGlobstring— Exact entity Name or id, or a*/?glob over Names.
local e = entity.find("enemy_*")
modules/entity/findAll
findAll(nameOrGlob: string?): { entityRef }
Enumerate entity proxies. With a nameOrGlob argument, returns every
entity whose Name component or id matches (names are not unique): a
plain string matches exactly, while a * / ? glob matches Names. With
no argument, returns every entity in the current snapshot —
findAll("") is the exact-match filter for the empty name, which
normally matches nothing. Same-frame pending spawns are included and
same-frame despawns filtered out. Elements are entity proxies, not id
strings — for ids, wrap the result: entity.ids(entity.findAll(...)).
Inside a build (a scene's content(), a module's builder), the entities
the build made come first and the world's same-named entities follow.
Parameters
nameOrGlobstring?(optional) — Exact entity Name or id to filter by, or a*/?glob over Names. Omit to enumerate every entity.
for _, e in entity.findAll("enemy_*") do e:despawn() end
modules/entity/getChildren
getChildren(id: string | entityRef): { entityRef }
Get an array of the direct children as entity proxies. Each element
carries .name, .id, .position, .component, and the rest of the
per-entity surface, the same shape entity.findAll returns. A string
that names a live entity rather than identifying it raises, naming
entity.find(name), the lookup that takes a name.
Parameters
idstring | entityRef— Entity id or entity proxy.
for _, c in entity.getChildren(id) do c.internal = true end
modules/entity/getDescendants
getDescendants(id: string | entityRef): { entityRef }
Get every descendant (children, grandchildren, and deeper) of the
given entity as entity proxies in breadth-first order, excluding the
entity itself. Resolves the whole subtree in one linear pass over the
entity set, so a large subtree costs proportionally to the entity count
rather than to the subtree size times the entity count. A string that
names a live entity rather than identifying it raises, naming
entity.find(name), the lookup that takes a name.
Parameters
idstring | entityRef— Entity id or entity proxy.
local all = entity.getDescendants(id)
modules/entity/getParent
getParent(id: string | entityRef): entityRef?
Get the parent entity proxy, or nil if the entity is a root entity.
The returned proxy carries .name, .id, .position, .component,
and the rest of the per-entity surface — the same shape entity.find
returns. A string that names a live entity rather than identifying it
raises, naming entity.find(name), the lookup that takes a name:
answering it as an id would read the same as a root entity.
Parameters
idstring | entityRef— Entity id or entity proxy.
local p = entity.getParent(id)
modules/entity/instantiate
instantiate(handle: EntityTemplate, count: number, fn: ((number) -> EntityInstantiateOverrides?)?): { string }
Spawn count instances of a template registered with
entity.template. Each instance gets a fresh entity id; the optional
fn(i) callback runs per instance (i in 1..=count) and may return an
overrides table. Override keys: name, position, rotation, scale,
parent, temporary / active / internal, attributes, components
(script components, merged over the template body's data for that type
— a type the template lacks is added fresh), and ecs (native
components, merged the same way). Each override supersedes the
template's shared config for that instance. The whole batch crosses in
one call and lands as a single deferred mutation the engine expands
into bulk work — per-instance cost drops from a full round trip to one
callback plus one mutation. Inside queue() the batch is deferred onto
the cross-frame ring; outside, it lands in the next frame's drain.
Returns the array of newly-minted entity ids in spawn order.
Parameters
handleEntityTemplate— Template handle fromentity.template.countnumber— Number of instances to spawn (capped at 1,000,000).fn((number) -> EntityInstantiateOverrides?)?(optional) — Per-instance override callback(i) -> table?.
local ids = entity.instantiate(h, 50, function(i) return { position = { i, 0, 0 } } end)
modules/entity/sceneWalks
sceneWalks(): number
How many whole-scene walks entity.findAll has made since the module
loaded. A walk is priced by the number of entities the scene holds, so a
caller that must not scale with the scene — a per-frame push, a write
that reaches its target through a record — is read either side of its
work against this count, which a walk raises by one.
local before = entity.sceneWalks(); entity(id):rename("door"); assert(entity.sceneWalks() == before)
modules/entity/spawn
spawn(nameOrOpts: (string | SpawnOpts)?, opts: SpawnOpts?): entityRef
Spawn a new entity and return its PROXY (the same value entity(id)
yields) — act on it immediately (entity.spawn(name).component.add(...),
.localPosition = ...) with no second entity(id) round trip. The proxy
still exposes .id for the rare site that needs the raw string. An
entity with no components carries only a Transform and is invisible;
pass components to give it the components that make it visible in the
same call — entity.spawn { name = "crate", components = { Model = { model = "cube" } } } — or add them afterwards through the returned
proxy. Mirrors entity.find / entity.findAll, which also return
proxies. The options table can be passed on its own with the name inside
it — entity.spawn { name = "turret", position = { 1, 2, 3 } } is the
same call as entity.spawn("turret", { position = { 1, 2, 3 } }).
Parameters
nameOrOpts(string | SpawnOpts)?(optional) — Display name for the entity, or the options table itself.optsSpawnOpts?(optional) — Options:components= component types to attach to the new entity, keyed by type name with each value the component's init table (attached in sorted type order; a failing add raises),internal= take the entity out of the default entity listings (it still renders —entity(id):hide()stops the draw),parent= parent entity id or proxy,temporary= skip this entity (and descendants) from scene/world saves,position/rotation/scale= place the entity's Transform at spawn,attributes= per-entity attribute values keyed by name ({ role = "guard" }, the same valuesentity(id).attribute.set(key, value)writes andentity.template/entity.instantiatetake),synced= flag the entity multiplayer-synced (whatentity.spawnSyncedimplies),active= false spawns it inactive,scene_owner= the scene layer guid the entity is attributed to (inherited from the spawning scene when unset),id= restore a previously-assigned entity id (scene_loader use; leave unset for a normal spawn). An unrecognised key is rejected loudly.
local e = entity.spawn("crate", { components = { Model = { model = "cube" } } })
local e = entity.spawn { name = "turret", position = { 1, 2, 3 } }
local guard = entity.spawn("guard", { attributes = { role = "guard", hp = 3 } })
modules/entity/spawnSynced
spawnSynced(nameOrOpts: (string | SpawnOpts)?, opts: SpawnOpts?): entityRef
Spawn an entity already flagged multiplayer-synced at the root — the
explicit form of entity.spawn for SHARED, host-authoritative content.
The entity's existence broadcasts to every peer; joiners receive it from
the relay snapshot instead of spawning their own copy. Use this (NOT
entity.spawn) for anything that must be the SAME object on all
clients: enemies, pickups, projectiles, dynamic world props. Call it
ONLY where exactly one client runs the code — a scene's onHostLoad
(host-only) phase, or behind multiplayer.isHost(). Calling it in
all-client code makes every client spawn+sync its own copy — the
double-spawn "explosion". Equivalent to
entity.spawn(name, { synced = true }); identical in every other
respect.
Parameters
nameOrOpts(string | SpawnOpts)?(optional) — Display name for the entity, or the options table itself.optsSpawnOpts?(optional) — Same options asentity.spawn(syncedis already implied).
if multiplayer.isHost() then entity.spawnSynced("Goblin") end
modules/entity/template
template(def: EntityTemplateDef): EntityTemplate
Construct a reusable spawn template. Captures a shared entity config
ONCE and returns an EntityTemplate handle for entity.instantiate(handle, count, fn?) — one call per batch instead of one per entity. The template
lives as long as a script holds the handle: once nothing reaches it, the
collector releases the template, and the entities already instantiated
from it stay as they are. Keep the handle (a module-level local, a field)
for as long as more instances may follow. def keys:
components (script components, { [type] = init-data }), ecs
(array of native ecs.X{...} components), temporary (instances skip
scene/world saves), active (spawn state), internal (instances are
taken out of the default entity listings; they still render),
attributes ({ key = value } applied to every instance). Every value
is a shared default; a per-instance entity.instantiate override
supersedes it. The template body is captured by value — later edits to
the source table do not affect templates already created.
Parameters
defEntityTemplateDef— Template definition:components/ecs/temporary/active/internal/attributes. Per-instancename/position/rotation/scale/parentand any override go through theinstantiatecallback.
local h = entity.template({ components = { Model = { model = "cube" } } })
modules/entity/tree
tree(opts: { [string]: any }?): { [string]: any }
A windowed, lean view over the scene's entity tree, in one crossing.
Rows carry id, name, parentId, depth, childCount, active, sceneLayer and
componentNames — names only, never component values — so the call costs
the rows it answers with rather than the size of the scene. Entities group
under scene layers, per-layer roots and children name-sorted; internal
entities and their subtrees stay out. expanded names the ids whose
children unfold, and a collapsed node still reports its childCount;
filter keeps the rows whose name or id contains the needle plus every
ancestor on a path to one, auto-unfolded, with the actual matches flagged
matched. offset / limit window the flattened rows, layer scopes the
window and its total to one layer while layers still reports every
layer's row count, and revision echoes
getEntitiesRevision("structure"), which moves only on structural change.
Parameters
opts{ [string]: any }?(optional) —{ layer?, expanded?, filter?, offset?, limit? }.
local view = entity.tree({ filter = "crate", limit = 50 })
modules/entityMembers/README
require("@builtin::modules.api.engine.entity.members") -- entityMembers
The declarative description of every entityRef member. The runtime dispatch, the accepted-member set, the miss diagnostics and the LSP tree all derive from this table, so they cannot disagree.
Usage: local entityMembers = require("@builtin::modules.api.engine.entity.members")
modules/enum_values/README
require("@builtin::modules.enum_values") -- enum_values
The enum field-constraint validator: a constrained value must be one of the strings the field declared. A rejection names every member, so the error carries the whole set the caller may choose from. Registers itself with the generic field_constraints registry on load. nil passes, so an enum field may be left unset.
Usage: local enum_values = require("@builtin::modules.enum_values")
modules/environment/README
require("@builtin::modules.api.engine.environment") -- environment (also available as global 'environment')
Environment / reflection capture — bake the scene into reflection-probe cube slots from world positions, persist them as faces6 .texture assets, and set per-probe blend data so surfaces reflect the nearest probe(s). Public Luau surface over the __environment Internal FFI namespace. The generic "render the scene into a cubemap from a point" capability the reflection probe system is built on.
Usage: local environment = require("@builtin::modules.api.engine.environment") Also available as global: environment
modules/environment/capture
capture(x: number, y: number, z: number): boolean
Bake the scene into the environment from (x, y, z) as the single global
reflection (slot 0 + one full-coverage probe). Every PBR surface reflects it.
Queued — takes effect on the next frame. For multiple proximity-blended
probes use the reflectionProbe system instead.
Parameters
xnumber— World X of the capture position.ynumber— World Y of the capture position.znumber— World Z of the capture position.
environment.capture(0, 2, 0)
modules/environment/captureSky
captureSky(x: number?, y: number?, z: number?): boolean
Render the SKY alone into the environment's sky slot from (x, y, z) and
arm the sky fallback. A reflective surface no probe covers then reflects the
sky rather than black, and a partially covered one blends the shortfall
against it. The capture holds whatever the scene's sky draws — a gradient, a
physical atmosphere, a skybox material — with no geometry in it, so it stays
correct wherever the camera goes. Once captured, the slot follows the sky
the scene draws: a sky that changes is recaptured from the same position.
Queued — takes effect on the next frame.
Parameters
xnumber?(optional) — World X of the capture position. Defaults to 0.ynumber?(optional) — World Y of the capture position — the altitude a height-dependent atmosphere is sampled at. Defaults to 0.znumber?(optional) — World Z of the capture position. Defaults to 0.
environment.captureSky()
modules/environment/captureSlot
captureSlot(slot: number, x: number, y: number, z: number): boolean
Bake the scene into reflection-probe slot from (x, y, z).
Renders the FULL scene (geometry + sky) six times from that
point into that slot. Register the probe's position+radius via setProbes
so surfaces blend it by proximity. Queued — takes effect next frame.
Parameters
slotnumber— Reflection-probe slot (0-based).xnumber— World X of the capture position.ynumber— World Y of the capture position.znumber— World Z of the capture position.
environment.captureSlot(0, 0, 2, 0)
modules/environment/captureSlotToAsset
captureSlotToAsset(name: string, slot: number, x: number, y: number, z: number, timeoutFrames: number?): (string?, string?)
Bake the scene into reflection-probe slot from (x, y, z) AND persist
the 6 rendered faces into a faces6 .texture cubemap asset at
/source/<name>.texture/ (px/nx/py/ny/pz/nz PNGs + a cube.yaml sidecar).
Survives an engine restart and syncs like any other texture. Yields a few
frames while the bake + GPU readback complete; must be called from a
task/coroutine context (component hook, task.spawn, or execute).
Parameters
namestring— Destination asset identity (writes/source/<name>.texture/).slotnumber— Reflection-probe slot (0-based).xnumber— World X of the capture position.ynumber— World Y of the capture position.znumber— World Z of the capture position.timeoutFramesnumber?(optional) — Optional max frames to wait for the readback (default 900, past the frames the engine gives a readback before it gives up on one, so what ends the wait is the readback's own answer).
environment.captureSlotToAsset("probe_lobby", 0, 0, 2, 0)
modules/environment/captureToAsset
captureToAsset(name: string, x: number, y: number, z: number): (string?, string?)
Bake the single global reflection AND persist it to a faces6 .texture
asset (slot 0). Yields a few frames; call from a task/coroutine context.
Parameters
namestring— Destination asset identity (writes/source/<name>.texture/).xnumber— World X of the capture position.ynumber— World Y of the capture position.znumber— World Z of the capture position.
environment.captureToAsset("env_main", 0, 2, 0)
modules/environment/ensureSkyFallback
ensureSkyFallback(): boolean
Ensure the scene's sky is in the environment's sky slot: a reflective surface no probe covers then reflects the sky rather than black, and a partially covered one blends the shortfall against it. Queues a capture when the sky slot holds none, and re-arms the fallback when a capture is there but switched off. The engine's own state answers both questions, so everything that stands a sky up can call this and one capture is shared between them. Once captured, the slot follows the sky the scene draws on its own.
environment.ensureSkyFallback()
modules/environment/loadFromAsset
loadFromAsset(name: string): (boolean, string?)
Load a persisted global reflection asset into slot 0 and make it the active single reflection (one full-coverage probe).
Parameters
namestring— Source asset identity (reads/source/<name>.texture/).
environment.loadFromAsset("env_main")
modules/environment/loadSlotFromAsset
loadSlotFromAsset(name: string, slot: number): (boolean, string?)
Load a persisted faces6 .texture cubemap (written by
captureSlotToAsset) into reflection-probe slot WITHOUT re-rendering the
scene. Reads the 6 face PNGs from /source/<name>.texture/ and uploads them
into the slot's cube layers. How a persisted probe restores its baked
environment on reload.
Parameters
namestring— Source asset identity (reads/source/<name>.texture/).slotnumber— Reflection-probe slot (0-based).
environment.loadSlotFromAsset("probe_lobby", 0)
modules/environment/setProbes
setProbes(probes: { any }): boolean
Set the active reflection probes' blend data. probes is an array of
{ x, y, z, radius } (or { position = {x,y,z}, radius = r }); index i is
probe slot i. Surfaces blend the probe slots by proximity to these
positions, gathering the highest priority first — each rank takes the
coverage the ranks above it left, so a small interior probe ranked above a
large exterior one wins outright wherever it reaches full weight. Coverage
left over reflects the sky once captureSky has run. Queued for next frame.
Parameters
probes{ any }— Array of{ x, y, z, radius, priority? }, one per active probe slot.prioritydefaults to 0.
environment.setProbes({ { x = 0, y = 2, z = 0, radius = 12 } })
modules/environment/setSkyFallback
setSkyFallback(active: boolean): boolean
Arm or disarm the sky fallback against the sky already captured, with no
recapture. Disarmed, reflections come from the probes alone. Arming is
refused while the sky slot holds no capture (captureSky fills it), since
an uncaptured slot reflects black; renderer.reflectionEnvironment()
reports whether the fallback ended up armed.
Parameters
activeboolean— Whether reflections fall back to the captured sky.
environment.setSkyFallback(false)
modules/environment/stateFromAsset
stateFromAsset(identity: string): (boolean, string?)
Make a faces6 .texture cubemap the environment that cameras stating
it reflect. A camera rendering an isolated environment reflects only what
it states — never the world's sky or reflection probes — so this is what a
mirror or a pane of glass in its frame shows. The cube is stated under
identity, which is the name a camera's environmentMap gives it; stating
one already stated, from the same bytes, reads nothing. Called from a task,
it waits for faces whose bytes are still being fetched (the web build
fetches builtin images); called outside one, a face not yet fetched is
answered as missing.
Parameters
identitystring— The cube texture, by the identityasset.resolvetakes.
task.spawn(environment.stateFromAsset, "@builtin::textures.studio_environment")
modules/exposure/README
require("@builtin::systems.exposure.exposure") -- exposure
Exposure in stops, and eye adaptation — the image settles when the scene gets brighter or darker instead of clipping or going black.
Usage: local exposure = require("@builtin::systems.exposure.exposure")
modules/exposure/active
active(): boolean
Whether the exposure passes are currently running.
if exposure.active() then print("metering") end
modules/exposure/buffers
buffers(): { [string]: any }?
The buffers the exposure passes read: params carries the settings this
module packs, state is the adaptation value the GPU owns between frames.
The render feature binds what this hands it.
local b = exposure.buffers()
modules/exposure/clear
clear()
Turn exposure off and release the passes. The display goes back to the
exposure that stood before the metering started. The other settings are
kept, so a later set brings back the same behaviour.
exposure.clear()
modules/exposure/get
get(): ExposureState
The exposure settings currently in force.
local ev = exposure.get().compensation
modules/exposure/set
set(opts: ExposureOpts?): ExposureState
Set the scene's exposure. Any omitted field keeps its current value, so
a call can adjust one knob without restating the rest. With auto off and
compensation at 0 nothing is being asked for and the passes are released.
Each setting names the interval it means something in, and a value outside
that interval is refused naming the field, the value and the interval —
the whole call, so the scene stays on the exposure it already had. The
settings this returns are therefore the settings the frame is rendered
with.
Parameters
optsExposureOpts?(optional) — Exposure settings — seeExposureOpts.
exposure.set({ auto = true, targetGrey = 0.18, meter = "centre" })
modules/exposure/tick
tick(dt: number)
Advance adaptation by dt seconds. Adaptation is a rate, so the passes
need the frame's own delta to move at the same speed whatever the frame
rate. The AutoExposure component calls this; code driving the module
directly calls it once a frame.
Parameters
dtnumber— Seconds since the last frame.
exposure.tick(dt)
modules/field_constraints/README
require("@builtin::modules.field_constraints") -- field_constraints
Generic field-constraint dispatch. A Field descriptor may carry an opaque constraint table with a kind; the engine calls _G.__zero_check_field_constraint(value, constraint) on every write to (and default of) a constrained field. This module owns that hook and the validator registry — the engine core carries the constraint verbatim and never interprets it.
Usage: local field_constraints = require("@builtin::modules.field_constraints")
modules/field_constraints/register
register(kind: string, fn: Validator)
Register the validator for a constraint kind. A kind belongs to the chunk its validator is defined in. Registering it again from that chunk (its module running again, on a hot reload or after its require cache entry was dropped) replaces the validator; registering it with a validator defined in another chunk is an error naming both.
Parameters
kindstring— The constraint kind string (matchesconstraint.kind).fnValidator—(value, constraint) -> ok, reason?.
FieldConstraints.register("dataContract", checkDataContract)
modules/fluid/README
require("@builtin::systems.fluidSim.fluid") -- fluid
Grid-based GPU fluid simulation — smoke, fire and gas that curls, rolls and is deflected by forces, rather than translating rigidly the way billboard particles do.
Usage: local fluid = require("@builtin::systems.fluidSim.fluid")
modules/fluid/addForce
addForce(self: any, opts: ForceOpts)
Place a directional force. Same one-step lifetime as a source, so a sustained wind is re-applied each frame.
Parameters
selfany(optional)optsForceOpts— Force placement and direction — seeForceOpts.
sim:addForce({ position = { 2, 1, 0 }, direction = { -1, 0, 0 }, strength = 5 })
modules/fluid/addSource
addSource(self: any, opts: SourceOpts)
Place a density/heat source. It emits for one step, so a continuous plume calls this each frame — which is also what lets emission follow a moving object without any separate binding.
Parameters
selfany(optional)optsSourceOpts— Source placement and emission — seeSourceOpts.
sim:addSource({ position = { 0, 1, 0 }, density = 1.0, temperature = 400 })
modules/fluid/create
create(opts: FluidOpts?): any
Create a fluid simulation over a world-space box.
Parameters
optsFluidOpts?(optional) — Grid and solver settings — seeFluidOpts.
local sim = fluid.create({ resolution = { 64, 64, 64 } })
modules/fluid/destroy
destroy(self: any)
Release every GPU resource the simulation owns. The handle is unusable afterwards.
Parameters
selfany(optional)
sim:destroy()
modules/fluid/step
step(self: any, dt: number)
Advance the simulation one step. Emitters added since the last step are consumed here, so they act exactly once.
Parameters
selfany(optional)dtnumber— Step length in seconds.
sim:step(1 / 60)
modules/fluid/velocityTexture
velocityTexture(self: any): string
The 3D texture currently holding the velocity field. Velocity changes texture each step, so read this when you need it rather than caching it.
Parameters
selfany(optional)
local vel = sim:velocityTexture()
modules/fog/README
require("@builtin::systems.atmosphere.fog") -- fog
Scene-wide exponential height fog with directional in-scattering. Density falls off with altitude, so valleys pool fog while hilltops clear, and the medium brightens toward the sun so looking into it is not the same as looking away from it.
Usage: local fog = require("@builtin::systems.atmosphere.fog")
modules/fog/active
active(): boolean
Whether the fog pass is running this frame.
if fog.active() then ... end
modules/fog/clear
clear()
Turn fog off and release the pass. The other settings are kept, so a
later set({ density = ... }) brings back the same look.
fog.clear()
modules/fog/get
get(): FogState
The fog settings currently in force.
local d = fog.get().density
modules/fog/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = fog.paramsBuffer()
modules/fog/set
set(opts: FogOpts?): FogState
Set the scene's fog. Any omitted field keeps its current value, so a
call can adjust one knob without restating the rest. A density of 0
turns fog off and releases the pass.
Parameters
optsFogOpts?(optional) — Fog settings — seeFogOpts.
fog.set({ density = 0.03, heightFalloff = 0.12, heightRef = 0, inscatter = 0.85 })
modules/font/README
require("@builtin::modules.api.engine.font") -- font (also available as global 'font')
Font primitive — parse a font file ONCE into a baked, vectorized glyph format (ZFNT), then drive every text surface from it. A font is a general CPU resource addressed by name (the CPU counterpart of a renderer GPU resource), so a single registration is usable from UI text, 2D text, and true 3D glyph geometry. Public Luau surface over the __font Internal FFI namespace. Authored fonts are .font assets whose onRegister hook calls font.register.
Usage: local font = require("@builtin::modules.api.engine.font") Also available as global: font
modules/font/coverage
coverage(bytes: buffer | string): string?
The codepoints a font file maps to a glyph, as the coverage text
font.declare reads: comma-separated inclusive hexadecimal ranges.
Parameters
bytesbuffer | string— Raw font-file bytes (TTF / OTF).
local cov = font.coverage(assert(vfs.read("/zero/source/fonts/MyCJK.otf")))
modules/font/declare
declare(name: string, coverage: string, opts: table): number
Declare an on-demand face: a face known by the codepoints it covers,
whose bytes are read only when a text surface first meets one of those
codepoints with no installed face that draws it. Until then the face costs
its coverage and nothing else, so a session that never shows its script
never reads its file. When a label, a text.* object, or font.prefetch
reaches a covered character, the engine requests the face: its file is read
and registered with font.register(name, bytes, opts), and every text
surface draws the character from it from then on. A .font asset whose
face.json lists onDemand chunks declares each of them through this call.
Parameters
namestring— The name the face is declared and registered under.coveragestring— The codepoints it covers: comma-separated inclusive hexadecimal ranges ("3040-30ff,4e00"), the textfont.coverage(bytes)writes.optstable—{ file: string, family: string?, role: string?, aliases: {string}? }naming the VFS path of the font file (TTF / OTF, or a baked ZFNT) and thefont.registeroptions it installs with.
font.declare("MyCJK", assert(font.coverage(assert(vfs.read("/zero/source/fonts/MyCJK.otf")))), { file = "/zero/source/fonts/MyCJK.otf" })
modules/font/glyph
glyph(name: string, codepoint: number): any
Read one glyph's vectorized outline from a registered font, in font
units (resolution-independent — scale by fontSize / unitsPerEm).
Parameters
namestring— Registered family name.codepointnumber— Unicode codepoint (e.g.string.byte("A")).
local g = font.glyph("Inter", string.byte("A"))
modules/font/list
list(): { string }
List every registered font family name.
for _, fam in font.list() do print(fam) end
modules/font/observe
observe(): { any }
What the text system is holding for fonts: one row per family the
shaper can resolve, with its face count, the numeric weights those faces
carry, whether any of them is slanted, and whether the family arrived
through a registration rather than from the platform. weights is what a
style's weight can name for that family. The same rows are fonts in
text.observe().
for _, f in ipairs(font.observe()) do print(f.family, #f.weights) end
modules/font/onDemand
onDemand(): { any }
Every on-demand face font.declare declared, in declaration order, and
where each stands: declared (its file never read), requested (a
character it covers reached a text surface that could not draw it, and its
file is being read), installed (registered on every text surface; bytes
is the size of the file it installed from) or failed (error says why).
requestedBy is the character whose miss requested it, and family the
family group it installs into (opts.family of its font.declare, else
its own name); ui.listFonts() lists each face under that family's row.
for _, f in ipairs(font.onDemand()) do print(f.name, f.state, f.requestedBy) end
modules/font/parse
parse(bytes: buffer | string): string?
Parse a font file (TTF / OTF raw bytes) ONCE into the baked, vectorized
glyph format (ZFNT): per-glyph vector outlines + metrics + character map,
plus the original bytes. Heavy — run at import time (the .font assetType's
onCreate / the font importer), then store the result as the asset payload.
font.register loads it cheaply.
Parameters
bytesbuffer | string— Raw font-file bytes (binary-safe) — TTF / OTF.
local zfnt = font.parse(assert(vfs.read("/zero/source/Inter.ttf")))
modules/font/prefetch
prefetch(text: string): number
Request, ahead of drawing it, every on-demand face covering a character
of text that no requested or installed face covers: a screen about to
show a script starts reading its faces before its first frame.
Parameters
textstring— Text whose characters the faces must cover.
font.prefetch("日本語")
modules/font/ready
ready(text: string): boolean
Whether text draws without waiting on an on-demand face: no
character of it is covered by a face still declared or requested.
Call font.prefetch(text) first, then open the screen once this answers
true, and its first frame draws every glyph. True as well for a character
no declared face covers (ui.missingGlyphs() names it once drawn) and for
a face that failed (font.onDemand() says why).
Parameters
textstring— Text to be drawn.
font.prefetch(title); task.spawn(function() while not font.ready(title) do task.wait() end; ui.showScreen("title") end)
modules/font/reconcile
reconcile(): { any }
Every family the text shaper can resolve, held against what the shaper
does with it. family is the name, faces how many faces of it the font
database holds, weights the numeric weights those faces carry, loaded
whether it arrived through a registration rather than from the platform,
registered whether content registered the name, selectable whether some
style naming the family reaches it, matched whether fontFamily = family
on its own reaches it — the family name at the default weight over Latin
text — weight the weight it needs when the default is not it, shapedWith
the family the name selects, spelled the way the font file spells it, which
for a registration name is the family declared inside the file rather than
the name the asset carries, and reason why when the face that answered is
not that family. A
family is probed at its own weights and over content from several scripts,
so a family reachable only at one weight or covering only one script is
reported selectable, with matched false and weight naming what the style
must carry. Every probe object is destroyed again, so the live text-object
count is where it was.
for _, f in ipairs(font.reconcile()) do if f.selectable and not f.matched then print(f.family, f.weight) end end
modules/font/register
register(name: string, zfnt: string, opts: table?): any
Register a baked font (ZFNT from font.parse) under name, making it
usable on every text surface via fontFamily = "<name>". Loads the
vectorized glyph data into the runtime store (for font.glyph /
font.textMesh) and feeds the embedded face to the 2D text and egui UI
systems. Raw font bytes (TTF / OTF) register too: their tables are read
and the glyph outlines are baked the first time font.glyph /
font.textMesh reads one. A name declared with font.declare is installed
by this call. Registering a name again replaces what the earlier call
installed under it: a name, group or slot the earlier call gave the face
and this one does not stops selecting it, and text laid out under a name
whose face changed is laid out again.
opts groups several weight/style faces under one CSS family and maps
web-font names onto it: opts.family is the shared group key, opts.role
is "regular" | "bold" | "italic" | "bolditalic", and opts.aliases is a
list of extra selectable names (web fonts + CSS generics like "Arial",
"sans-serif") that resolve to this group, matched case-insensitively.
With a group set, font-weight / font-style on a font-family pick the
real metric-compatible face instead of a synthesized one.
Parameters
namestring— Family name to register under.zfntstring— BakedZFNTpayload fromfont.parse(binary-safe string).optstable?(optional) —{ family: string?, role: string?, aliases: {string}? }— group key, weight/style role, and case-insensitive selectable aliases.
local info = font.register("Inter", assert(font.parse(assert(vfs.read("/zero/source/Inter.ttf")))))
modules/font/textMesh
textMesh(name: string, text: string, opts: table?): any
Tessellate a string into renderable mesh geometry from a registered
font's glyph outlines — true 3D text, laid out left-to-right by advance
(newlines drop a line). Hand the result to renderer.mesh.create() (GPU)
or asset.create("mesh") (persistable).
Parameters
namestring— Registered family name.textstring— String to lay out.optstable?(optional) —{ size?=1, depth?=0 (extrude, EM units), tolerance?=0.0015, letterSpacing?=0, lineHeight?=0 }.
local geom = font.textMesh("Inter", "Hello", { size = 1, depth = 0.1 })
modules/frameStream/README
require("@builtin::modules.api.engine.frameStream") -- frameStream (also available as global 'frameStream')
Carries an image the GPU drew out to another program — the view a camera renders, read back off its render target and written into a byte stream frame after frame, so pixels that sit in GPU memory reach a process outside the engine while the world runs. Public Luau surface over the __framestream Internal FFI namespace.
Usage: local frameStream = require("@builtin::modules.api.engine.frameStream") Also available as global: frameStream
modules/frameStream/attach
attach(texture: string, stream: string, opts: AttachOpts?): (string?, string?)
Carry an image the GPU drew out to an open byte stream, frame
after frame. texture is the guid of the render target it was
drawn into — renderer.texture.create({ width = W, height = H })
makes one, and a Camera component draws into it as its
textureHandle; the session reads that target back when a frame
comes due, so what the camera drew last reaches the far end.
stream is a handle from stream.open. What reaches the stream
is one frame's pixels then the next frame's, with nothing between
them: a frame is width * height * bytesPerPixel bytes of tight
rows, written in a single call so a consumer reads a whole frame
or none of it. Each frame is read back off the render thread, so
the stream never holds the renderer up. fps caps how often a
frame is taken and defaults to one per rendered frame; format
accepts "rgb24" (3 bytes per pixel, the default) or "rgba8"
(4) — a call with a format outside those two raises, naming both;
flipY writes the last texture row first. Returns the session
handle, or nil and the reason an empty texture, a handle naming no
open stream, a stream another session already carries, or a
non-positive fps was refused with.
Parameters
texturestring— Guid of the render target the image was drawn into (a Camera's textureHandle).streamstring— Stream handle from stream.open.optsAttachOpts?(optional) — Rate, pixel layout and row order (optional).
local session = frameStream.attach(rt.guid, handle, { fps = 30 })
modules/frameStream/detach
detach(handle: string): boolean
End the session and free the staging buffers it read frames back through. The stream stays open — whoever opened it closes it.
Parameters
handlestring— Session handle from frameStream.attach.
frameStream.detach(session)
modules/frameStream/list
list(): { string }
Every live session handle, in a stable order.
for _, h in frameStream.list() do frameStream.detach(h) end
modules/frameStream/status
status(handle: string): FrameStreamStatus?
Report what the session has carried and lost. frames counts
the frames the stream accepted and bytes the bytes they
carried. dropped counts the frames it refused, of which
droppedBackpressure is the part refused because the consumer was
behind; stalledReadbacks counts the frames that came due while
every staging buffer still held a copy on its way from the GPU.
achievedFps is the rate the accepted frames arrived at, across
the span from the first to the most recent, and reads 0 until two
have been accepted — compare it against requestedFps to see a
display running slower than it was asked to. lastCopyFrame is
the engine frame, in time.frameCount() numbering, the copy of the
most recent accepted frame was taken on, and is nil until one is
accepted: every copy one engine frame takes of a texture holds the
same image, so two sessions on one texture whose lastCopyFrame
agree hold the same image as the newest frame of their streams.
lastOutcome names what became of the most recent frame offered.
nil when handle names no live session.
Parameters
handlestring— Session handle from frameStream.attach.
local s = frameStream.status(session); print(s.frames, s.dropped, s.achievedFps)
modules/future/README
require("@builtin::modules.future") -- future
Futures: a promise as a value you hold, pass around, combine and await later. Every promise-returning call (http.get_json, delay, scene.save, ...) already hands back a future, a PromiseHandle; this module makes new ones, runs work as one, chains them (f:andThen, f:catch, f:finally), waits for several at once (all, race, any, allSettled), bounds one in time (f:timeout) and cancels them (f:cancel).
A future is a PromiseHandle. Store it in a table, return it from a
function, hand it to another task, and await it whenever the value is
needed:
local future = require("@builtin::modules.future")
local pending: { Futureawait(f) and task.await(f))
f:state() "pending", "resolved", "rejected" or "cancelled", read
without taking the value
f:rejection() why it was rejected, { message, origin?, stack? }:
the reason as text, the chunk:line the rejection came
from, and the stack there when Luau rejected it; nil
while it is pending or once it resolved
f:source() the chunk:line whose call created the promise
f.handle the promise's id string; tostring(f) reads the same
f:andThen(onResolve, onReject?) a future of what the handler returns
f:catch(onReject) a future that recovers from a rejection
f:finally(fn) a future settled as f was, once fn has run
f:tap(fn) a future of f's value, once fn has seen it
f:timeout(seconds, reason?) a future of f's value that rejects
when seconds of real time pass first
f:cancel() end it as cancelled, and the work producing it with it
A rejection is kept apart from any value: a future resolved with a
table of any shape delivers that table. Catch one with pcall, and
read where it came from on the future:
local ok, err = pcall(f.await, f)
if not ok then
local why = f:rejection()
log.warn({why.message} (from {why.origin}))
end
Every task that awaits a future receives its value: the ones waiting
when it settles and any that await it later, while the future is held.
Cancellation. f:cancel() ends a pending future as cancelled: awaiting
it raises the cancellation task.isCancellation(err) recognises, and
f:state() reads "cancelled". The work producing it ends with it: the
task future.spawn or a handler runs in is cancelled and unwinds (the
cleanup around its wait runs), and so is everything that work started.
Cancelling reaches both ways along a chain:
- downstream: a future chained from a cancelled one (
andThen,catch,tap,timeout,all,race, ...) is cancelled too;finallyruns its function first; - upstream: a future counts the chains and combinators waiting on it,
and one whose last such consumer is cancelled or has settled without
it (a
raceanother input won, atimeoutthat ran out) is cancelled, so work nobody waits for any more stops. A directawaitis not a consumer. A future an engine call handed back (http.get_json,delay) runs to its end whatever waits on it, andf:cancel()answers false and the reason for one. Where the work lives: the task running a handler orfuture.spawnbelongs to what started it (the component instance whose code called it, the scene load, an enclosingscopes.run), so the end of that cancels the future too. A handler's work runs in ascopes.run: the future settles once everything the handler started is over, and an error any of it raises rejects the future. Identity: a VM holds one future object per promise. Every call that hands a promise to the VM while its future is alive,future.wrapincluded, hands back that same object, sofuture.wrap(f) == f,rawequal(future.wrap(f.handle), f), and a future is one table key. In type annotations,Future<T>is a future whose await delivers aT, andPromiseHandleis a future whose value has no stated type; the two are the same value.
Usage: local future = require("@builtin::modules.future")
modules/future/after
after(seconds: number): Future<boolean>
A future that resolves with true after seconds of real time, the
engine's own clock that engine.timeScale does not reach. The same
promise delay(seconds) hands back.
Parameters
secondsnumber— Seconds of real time until it resolves.
local timeout = future.after(5)
modules/future/all
all<T>(futures: { Future<T> }): Future<{ T }>
A future of every value futures resolve with, in the order given,
once all have resolved. The first one to reject rejects it with that
error, and the first one cancelled cancels it; either way the ones still
pending are let go of, and each nothing else waits on is cancelled. An
empty array resolves with an empty table.
Parameters
futures{ Future<T> }— An array of futures.
local maps = future.all({ http.get_json(a), http.get_json(b) }):await()
modules/future/allSettled
allSettled(futures: { Future<any> }): Future<{ Settlement }>
A future of how each of futures settled, in the order given, once
all have: { status = "resolved", value = v }, { status = "rejected", error = e } or { status = "cancelled" }. It never rejects.
Parameters
futures{ Future<any> }— An array of futures.
for _, s in future.allSettled(loads):await() do print(s.status) end
modules/future/andThen
andThen(self: any, onResolve: ((any) -> any)?, onReject: ((any) -> any)?): any
A future of what onResolve returns once this future resolves; a
future it returns is awaited and its value delivered. With onReject, a
rejection is handed to it and the future is what it returns; without,
the rejection passes through. A handler that raises rejects the future
with its error. The handler runs in a task (so it may wait) inside a
scopes.run. A cancellation passes through without calling either.
Parameters
selfany(optional)onResolve((any) -> any)?(optional) — Optional: called with the value.onReject((any) -> any)?(optional) — Optional: called with the error.
http.get_json(url):andThen(function(doc) return doc.levels end)
modules/future/any
any<T>(futures: { Future<T> }): Future<T>
A future of the first value any of futures resolves with; the rest
are let go of, and each nothing else waits on is cancelled. When none
resolves it rejects with an AnyRejected, { message, errors }, holding
each one's error in the order given; when every one was cancelled it is
cancelled. An empty array raises.
Parameters
futures{ Future<T> }— A non-empty array of futures.
local mirror = future.any({ http.get_json(primary), http.get_json(backup) }):await()
modules/future/cancel
cancel(self: any): (boolean, string?)
End this future as cancelled, when it is still pending: every await of
it raises the cancellation task.isCancellation recognises, the work
producing it is cancelled and unwinds, the futures chained from it are
cancelled, and each future it waited on that nothing else waits on is
cancelled. Answers true when this call cancelled it, or false and the
reason: it had already settled, or an engine call or another VM
settles it.
Parameters
selfany(optional)
local ok = load:cancel()
modules/future/catch
catch(self: any, onReject: (any) -> any): any
A future that recovers from this one's rejection: resolved with this
future's value, or with what onReject returns given the error. A
cancellation passes through.
Parameters
selfany(optional)onReject(any) -> any— Called with the error.
local doc = http.get_json(url):catch(function() return defaults end):await()
modules/future/finally
finally(self: any, fn: () -> ()): any
A future that settles the way this one did, once fn() has run after
it settled, whichever way, cancelled included. fn raising rejects it
with that error instead.
Parameters
selfany(optional)fn() -> ()— Called with no arguments once this future settles.
load:finally(function() hud.hideLoading() end)
modules/future/fromEvent
fromEvent(event: any, predicate: ((...any) -> boolean)?): Future<any>
A future of the next fire of event that predicate accepts: it
resolves with the first value that fire carried. event is a Signal, a
component event (comp.events.onHit), or anything offering
:Connect(fn) / :connect(fn). Its handler is disconnected once the
future settles or is cancelled. The listener belongs to what started the
call (a component instance, a scene load, a task scope), so the end of
that cancels the future. A predicate that raises rejects the future with
its error.
Parameters
eventany(optional) — The event to listen to.predicate((...any) -> boolean)?(optional) — Optional: called with the fire's values; the future resolves on the first fire it answers true for.
local damage = future.fromEvent(hit, function(amount) return amount > 10 end):await()
modules/future/new
new(onCancel: (() -> ())?): (Future<any>, Resolve, Reject)
Make a pending future and the two functions that settle it. resolve(value)
delivers value to every task awaiting the future, the value itself in this
VM; reject(error) raises error at each of their awaits: a string at the
await's line, any other value (an error table) as itself. The future's
rejection() reads the message, the line that called reject and the stack
there. A future settles once: each function answers true when its call
settled it, or false and the reason (it had already settled). Only this VM
settles it. onCancel runs when the future is cancelled, by f:cancel()
or because the last chain or combinator waiting on it let it go: release
what producing its value holds there.
Parameters
onCancel(() -> ())?(optional) — Optional: called with no arguments when the future is cancelled.
local f, resolve = future.new(); task.delay(2, function() resolve(true) end); f:await()
modules/future/race
race<T>(futures: { Future<T> }): Future<T>
A future that settles the way the first of futures to settle does:
resolved with its value, rejected with its error, or cancelled. The rest
are let go of, and each nothing else waits on is cancelled. An empty
array never settles, so it raises.
Parameters
futures{ Future<T> }— A non-empty array of futures.
local winner = future.race({ future.spawn(pathA), future.spawn(pathB) }):await()
modules/future/rejected
rejected(err: any): Future<any>
A future already rejected with err, any value but nil: awaiting it
raises err.
Parameters
errany(optional) — The error an await of it raises.
return future.rejected("no such level")
modules/future/resolved
resolved<T>(value: T): Future<T>
A future already resolved with value: awaiting it returns value at
once. For a function whose callers await its result when the answer is
already known.
Parameters
valueT— The value an await of it returns.
local cached = future.resolved(cache[key]); return cached
modules/future/retry
retry<T>(fn: () -> T, attempts: number, delaySeconds: number?): Future<T>
Call fn() until it succeeds, at most attempts times, and hand
back the future of the value it succeeded with. fn may wait, and may
return a future, which is awaited. After the last failed attempt the
future rejects with that attempt's error. delaySeconds of real time
pass between attempts. Cancelling the future cancels the attempt in
progress.
Parameters
fn() -> T— The function to call; each call is one attempt.attemptsnumber— The most attempts to make, at least 1.delaySecondsnumber?(optional) — Optional: real seconds to wait between attempts.
local config = future.retry(function() return http.get_json(url) end, 3, 1):await()
modules/future/spawn
spawn<T>(fn: (...any) -> T, ...: any): Future<T>
Run fn(...) as a task and hand back the future of its result: it
resolves with what fn returns (a future fn returns is awaited, and
its value delivered) and rejects with what fn raises. fn may wait
(task.wait, await, ...). Its work runs in a scopes.run: the future
settles once everything fn started is over, and an error any of it
raises rejects the future. Cancelling the future cancels that task and
everything it started, which unwind.
Parameters
fn(...any) -> T— The function to run.argsany(optional)
local loaded = future.spawn(loadLevel, "forest")
modules/future/tap
tap(self: any, fn: (any) -> ()): any
A future of this one's value, once fn(value) has seen it; a
rejection or cancellation passes through without calling fn. fn
raising rejects it with that error.
Parameters
selfany(optional)fn(any) -> ()— Called with the value.
load:tap(function(level) print("loaded", level.name) end)
modules/future/timeout
timeout(self: any, seconds: number, reason: any?): any
A future of this one's value that rejects with reason when
seconds of real time pass before this one settles; this one is then let
go of, and cancelled when nothing else waits on it.
Parameters
selfany(optional)secondsnumber— Seconds of real time to wait.reasonany?(optional) — Optional: the error to reject with; a message naming the time by default.
local level = future.spawn(loadLevel):timeout(5):await()
modules/future/wrap
wrap(promise: PromiseHandle | string): Future<any>
Adopt a promise: the future naming it, from its future or from its id string. A future passed in answers itself, and an id answers the future this VM already holds for that promise, when it holds one. An id naming no promise the engine keeps raises, saying whether it was released or never existed.
Parameters
promisePromiseHandle | string— A future (PromiseHandle) or a promise's id string.
local f = future.wrap(savedId); local value = f:await()
modules/gaussianSplats/README
require("@builtin::systems.gaussianSplats.gaussianSplats") -- gaussianSplats
Registry of live Gaussian splat clouds — the entity-id-keyed table the gaussianSplats render feature reads each frame. GaussianSplat.component writes the declaration into it; the feature owns every GPU buffer and reports back one thing, its verdict on whether it could build the cloud.
Usage: local gaussianSplats = require("@builtin::systems.gaussianSplats.gaussianSplats")
modules/gaussianSplats/clear
clear(id: string)
Drop an entity's cloud, along with the placement recorded for it. The render feature frees its GPU buffers on the next frame that finds the entry gone.
Parameters
idstring— Entity id.
gaussianSplats.clear(id)
modules/gaussianSplats/clearFailure
clearFailure(id: string)
Drop the failure standing against an entity's cloud. The feature calls this on the frame it builds the cloud.
Parameters
idstring— Entity id.
gaussianSplats.clearFailure(id)
modules/gaussianSplats/entries
entries(): { [string]: SplatEntry }
The live registry, keyed by entity id. Read-only for callers other than
GaussianSplat.component.
for id, entry in pairs(gaussianSplats.entries()) do ... end
modules/gaussianSplats/failure
failure(id: string): string?
Why the feature could not build an entity's cloud, or nil while it has nothing against it.
Parameters
idstring— Entity id.
local why = gaussianSplats.failure(id)
modules/gaussianSplats/get
get(id: string): SplatEntry?
The entry registered for one entity, or nil.
Parameters
idstring— Entity id.
local e = gaussianSplats.get(id)
modules/gaussianSplats/placement
placement(id: string): { number }?
The placement an entity's cloud was last culled and drawn at — 16 column-major numbers, translation in elements 13, 14, 15. The cull transforms every splat position by this matrix and the draw conjugates each covariance by its upper-left 3x3, so it is where the cloud was cut as well as where it was drawn. A fresh table each call, so writing to it leaves the record alone. Nil before the feature has drawn the cloud, on any frame it does not draw it, and once the cloud has left the registry.
Parameters
idstring— Entity id.
local m = gaussianSplats.placement(id)
modules/gaussianSplats/recordPlacement
recordPlacement(id: string, matrix: { number }?)
Record the placement an entity's splats were culled and drawn at, as 16 column-major numbers. The render feature calls this each frame it draws the cloud, with the matrix it hands the cull pass; nil drops the record. The numbers are copied in, so the caller keeps its own matrix to itself.
Parameters
idstring— Entity id.matrix{ number }?(optional) — The 16 column-major numbers the cloud was placed by.
gaussianSplats.recordPlacement(id, entity(id).worldMatrix())
modules/gaussianSplats/reportFailure
reportFailure(id: string, message: string)
Report that the feature could not build an entity's cloud. The message reaches the entry's status listener, which is how it lands on the component's error surface.
Parameters
idstring— Entity id.messagestring— What the feature refused the cloud for.
gaussianSplats.reportFailure(id, "no capture at 'captures/room.gaussianSplat'")
modules/gaussianSplats/set
set(id: string, entry: SplatEntry, onStatus: StatusListener?)
Register or update the cloud an entity renders. Changing source or
convention bumps the entry's generation, which makes the render feature
re-decode and re-upload on its next frame, and drops any verdict the
feature reached about the capture asked for before.
Parameters
idstring— Entity id.entrySplatEntry— The cloud's declaration.onStatusStatusListener?(optional) — Called with the feature's message when it cannot build the cloud, and with nil once it can.GaussianSplat.componentpasses the call that puts the message on its own error surface.
gaussianSplats.set(id, { source = "captures/ceramic.spz", opacity = 1 })
modules/gaussianSplats/setVelocity
setVelocity(enabled: boolean): boolean
Whether a moving cloud writes its screen-space displacement into the frame's velocity buffer, which is what makes motion blur, temporal antialiasing, temporal upsampling and a denoiser's history term treat it as moving. On costs two screen-sized targets and two full-screen passes while any cloud is on screen. On by default.
Parameters
enabledboolean— Whether the clouds report their motion.
gaussianSplats.setVelocity(false)
modules/gaussianSplats/velocity
velocity(): boolean
Whether the clouds report their motion into the frame's velocity buffer.
if gaussianSplats.velocity() then ... end
modules/home/README
require("@builtin::modules.api.engine.home") -- home (also available as global 'home')
The person's home folder, /zero/home/<username>: their own files, carried from world to world in the editor. It is the content of the account's home world, an ordinary private world the account owns, mounted in every world the person opens in their own editor sessions. A write under the folder is saved to the home world as it is made, with no commit or push. World content cannot depend on it: a world script that requires a home module is refused, and a world file that references a home path is refused at push, naming the file. The person's own execute and a home module requiring another in the same folder work.
Read and write the folder with vfs like any other path; home.status()
says whether it is mounted and, when it is not, why. home.get() answers
the guid of the account's home world, or nil when the account has none,
and home.ensure() answers it and creates it the first time it is
needed. guides { path: "core/home" } covers what to keep there and the
rule that keeps it out of worlds.
Usage: local home = require("@builtin::modules.api.engine.home") Also available as global: home
modules/home/ensure
ensure(): (string, boolean)
The guid of the account's home world, created the first time it is
needed: an account with no home world gets a new private world, owned
by the person the account acts for (an agent account's is its person's),
and every later call answers that same world. It is the world whose
content home.folder() mounts; a launch with --home-world-guid names
it for the session. Yields while ZeroMind answers. Raises, naming the
reason, on an engine that booted offline, one signed in to no account,
or when ZeroMind cannot be read.
local guid, created = home.ensure(); print(guid, created)
modules/home/folder
folder(): (string?, string?)
The home folder mounted in this session, /zero/home/<username>,
or nil and the reason no home folder is mounted.
local folder, why = home.folder()
modules/home/get
get(): string?
The guid of the account's home world, or nil when the account has
none; it never creates one (home.ensure() does). The same world
home.ensure() answers, whose content home.folder() mounts. Yields while
ZeroMind answers. Raises, naming the reason, on an engine that booted
offline, one signed in to no account, or when ZeroMind cannot be read.
local guid = home.get(); if guid == nil then print("no home world yet") end
modules/home/status
status(): Status
Where the home folder stands in this session. state is
"mounted" (with folder, the path to read and write, owner, the
account it belongs to, world, the guid of the home world that holds it,
files, how many files the home world held when it was mounted, and
from, "launch" or "zeromind", saying where that world was named),
"mounting" while a world load is mounting it, or "unmounted" with
reason saying why no home folder is mounted.
local s = home.status(); if s.state == "mounted" then vfs.write(s.folder .. "/notes.md", "hi") end
modules/http/README
require("@builtin::modules.api.engine.http") -- http (also available as global 'http')
Async HTTP — GET/POST returning JSON or raw bytes. Public Luau surface over the __http Internal FFI namespace.
Usage: local http = require("@builtin::modules.api.engine.http") Also available as global: http
modules/http/get_bytes
get_bytes(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP GET returning raw bytes (binary-safe string).
Suitable for piping into vfs.write to download a file.
Parameters
urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local bytes = task.await(http.get_bytes("https://example.com/sound.ogg"))
modules/http/get_json
get_json(url: string, headers: Headers?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP GET returning JSON. Returns a future (a
PromiseHandle) at once, with the request in flight: keep it,
f:await() (or task.await(f)) when the response is needed, and
f:state() to see whether it has arrived without waiting.
Parameters
urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local data = task.await(http.get_json("https://api.example.com/info"))
local record = task.await(http.get_json(recordUrl, nil, nil, { 404 })) -- a missing record is an answer
modules/http/post_bytes
post_bytes(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP POST returning raw bytes — use for APIs that accept JSON input but return binary output (audio, images).
Parameters
urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).bodyJsonBody?(optional) — JSON body (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local audio = task.await(http.post_bytes(ttsUrl, nil, { text = "hello" }))
modules/http/post_json
post_json(url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP POST returning JSON. Body is a Luau table; the FFI layer JSON-encodes it before the request goes out.
Parameters
urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).bodyJsonBody?(optional) — JSON body (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local r = task.await(http.post_json(url, nil, { name = "Alice" }))
modules/http/request
request(method: string, url: string, headers: Headers?, body: JsonBody?, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP request with an arbitrary verb (GET/POST/PUT/PATCH/ DELETE/…) returning JSON. Body is a Luau table; an empty 2xx response resolves to an empty table.
Parameters
methodstring— HTTP verb (case-insensitive).urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).bodyJsonBody?(optional) — JSON body (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local w = task.await(http.request("PATCH", url, hdrs, { description = "hi" }))
modules/http/request_raw
request_raw(method: string, url: string, headers: Headers?, body: buffer | string | nil, timeoutMs: TimeoutMs?, expectedStatuses: ExpectedStatuses?): PromiseId
Async HTTP request with an arbitrary verb and a RAW binary request body (a binary-safe string), for content-addressed blob uploads. The resolved value is the response body text.
Parameters
methodstring— HTTP verb (case-insensitive).urlstring— Request URL.headersHeaders?(optional) — Header key-value pairs (optional).bodybuffer | string | nil(optional) — Raw binary request body (optional).timeoutMsTimeoutMs?(optional) — How long the request is given to be answered, in milliseconds; the engine's own bound when left out, none when 0 (optional).expectedStatusesExpectedStatuses?(optional) — HTTP statuses this caller handles as an answer it expected, e.g.{ 404 }: a response with one settles the future as any other non-2xx does and is logged as information rather than an error (optional).
local r = task.await(http.request_raw("POST", blobsUrl, hdrs, pngBytes))
modules/httpServer/README
require("@builtin::modules.api.engine.httpServer") -- httpServer (also available as global 'httpServer')
Serve HTTP from this engine. A world registers a handler for a method and a path, and the engine's own HTTP server routes matching requests to it — so a browser tab, a curl call or another process on this machine reaches the running world over plain HTTP, with the world deciding what every address answers. The engine's own HTTP server listens on the loopback interface, so a world that asks for nothing is reachable from this machine, and through a forward another program opens to it (adb forward, an SSH tunnel, a reverse proxy). httpServer.listen(target) holds a second address of this world's own choosing: the host in the target is the interface bound and the whole of what decides who can reach it, so "0.0.0.0:8080" answers a phone on the same wifi and "127.0.0.1:8080" answers this machine. httpServer.address(path) is the URL to call, and httpServer.status() reports the host, the port and the reach those routes answer under. Content routes are served under the /app mount: httpServer.route("GET", "/status", h) answers http://<host>:<port>/app/status. The engine's own /engine/* routes are matched first, and every registration lands under /app, so the two trees stay disjoint. A route belongs to the chunk that registered it, and so does an address that chunk opened. When that chunk runs again — a module hot-reload, a cleared require cache — both are released and the new run makes its own, so an edited handler is the one that answers. httpServer.routes() names the owner of every address. A handler runs on the script thread, inside the frame, like any other world code — it may read and write the world, and it holds the tick for as long as it runs. The request waits at most timeoutMs (5 s by default) for its answer; past that the caller is told 504 and the connection closes, while the handler itself carries on to completion.
Usage: local httpServer = require("@builtin::modules.api.engine.httpServer") Also available as global: httpServer
modules/httpServer/address
address(path: string): (string?, string?)
The URL a path answers on — scheme, host, port and the /app mount,
ready to be fetched or printed for someone to open. Takes the same path
spelling route does, and reads the interface and port from the socket
routes answer on: the address listen opened while one is open, and the
engine's own server otherwise.
Parameters
pathstring— Path under the/appmount, e.g. "/status".
print(httpServer.address("/status")) --> http://127.0.0.1:7607/app/status
modules/httpServer/listen
listen(target: string): (HttpListener?, string?)
Hold an interface and port of this world's own, and answer content routes on it.
The host in target is the interface bound, and the whole of what decides
who can reach those routes: "127.0.0.1:8080" answers programs on this
machine, "0.0.0.0:8080" answers any host that routes to this machine on
that port — a phone on the same wifi, and whatever else the network lets
through. Bind loopback unless you want that. A port of 0 asks the
operating system for a free one, which the returned record reports, and
http:// may be spelled out in front.
This address serves the routes registered under the /app mount. The
engine's own /engine/* tree answers on the loopback server it booted
with, whose interface stays what the boot bound.
The address belongs to the chunk that opened it and is released when that chunk runs again, so an edited module holds the address its current source names. Asking for the address already held is the same address back.
Parameters
targetstring— Interface and port to hold, e.g. "0.0.0.0:8080".
local l = assert(httpServer.listen("0.0.0.0:8080"))
modules/httpServer/route
route(
Serve one method and path from this engine, answering each matching
request with handler.
The path is relative to the /app mount, and a trailing /* segment
matches the rest of the path — "/files/*" answers /app/files/a/b, with
"a/b" in request.wildcard. An exact path answers ahead of a wildcard,
and among wildcards the longest one wins.
One method and path is served by one handler. Registering an address
another chunk serves returns nil and a reason naming the handle and the
chunk holding it; httpServer.routes() finds that handle and
httpServer.unroute frees the address. Registering an address this same
chunk already serves takes it back and releases the handler it replaces,
so a chunk that runs twice serves the handler it just built.
The handler runs on the script thread; a route registered from a worker job keeps its handler in that worker's VM, which runs it once per request as the job that registered it while the request waits for its value and the engine thread waits for nothing. The route lasts until it is unregistered or the world changes or the scripting state resets, whatever became of the job that made it. Raising inside the handler answers 500 and writes the error to the engine log; returning something that is not a response table or a string answers 500 saying what arrived.
local h = httpServer.route("GET", "/status", function(req)
modules/httpServer/routes
routes(): { HttpRoute }
Every route this engine currently serves, in registration order — handle, method, registered path, the address it answers on, its full URL, the chunk that registered it, and how long a request for it waits.
for _, r in ipairs(httpServer.routes()) do print(r.method, r.url, r.owner) end
modules/httpServer/status
status(): HttpServerStatus
Whether this engine serves content routes, on which interface, port
and mount, who can reach them, and how many routes and waiting requests it
holds. host, port, url and reach are read from the socket routes
answer on — the one listen opened while one is open, and the engine's
own server otherwise — and listeners carries every address, each with
its own reach. When supported is false, reason says why: a browser tab
answers HTTP requests and holds no address of its own.
local s = httpServer.status(); print(s.url, s.reach)
modules/httpServer/unlisten
unlisten(): boolean
Release the address listen opened. Returns once the socket is free,
so the same port binds again straight after.
httpServer.unlisten()
modules/httpServer/unroute
unroute(handle: number): boolean
Stop serving a route and release its handler. The address is free for another registration once this returns true.
Parameters
handlenumber— The handlehttpServer.routereturned.
httpServer.unroute(h)
modules/humanoid/README
require("@builtin::avatarTypes.humanoid") -- humanoid
The humanoid avatar type: a two-legged body with a spine, a head and one or two arms. qualify(structure) maps a skeleton onto the humanoid roles and chains from its shape, for any bone naming and in any pose the skeleton rests in; names only raise confidence and are checked against the geometry.
Usage: local humanoid = require("@builtin::avatarTypes.humanoid")
modules/humanoid/frames
frames(s: any, roles: { [string]: string }): { [string]: any }
Each mapped body role's anatomical frame, from the rig's rest joint positions: X toward the next bone of the role's chain, Y the role's anatomical secondary (the hip line for hips, spine and chest; the shoulder line for upper chest, neck and head; the palm normal for shoulder, arm, forearm, hand and fingers; the toe direction for thigh and shin), Z = X x Y. A foot and its toes take the ground they stand on at rest: X their direction along the ground, Y the stand axis, so a heel's pitch is the rig's own and a standing foot of one rig is a standing foot of another. Bone rolls do not change a frame, and a pose turns it with the bones it turns. The root takes the hips' frame.
Parameters
sany(optional) — A rig structure (rigStructure.fromDoc).roles{ [string]: string }— The role -> bone name map (qualify(s).mapping.roles, or an effective mapping).
modules/i18n/README
require("@builtin::modules.api.engine.i18n") -- i18n (also available as global 'i18n')
The player's language, and your world's text in it. i18n.t(key, values) reads a string from the world's catalogs (/zero/source/locales/<tag>/<namespace>.json, the format origozero.ai uses: {{ name }} parameters, _one / _other plural forms), falling back through the locale's chain to English; i18n.text(key) is the same text as a value widgets take, which follows the language on screen; i18n.formatNumber / formatBytes / formatDate / formatAgo / formatMoney write values the way the player's locale does; i18n.pseudo(true) shows every catalog string bracketed so text left in code stands out; i18n.check() runs the catalog checks. i18n.pick({"en", "pt", "es"}) answers which of the languages your content has text for this player reads; i18n.preferred() is the languages their platform says they read (OS, browser or Android settings), most preferred first; i18n.onChange reports every change while they play; i18n.emulate(tags) stands a visitor's language list in to try content under it. i18n.locale() is the locale the engine's own text is in, one of i18n.offered(); i18n.choose(tag) is the player's own choice, kept for their account. The same surface in every VM. The engine picks the locale from one chain: the player's choice, then the language ZeroMind shows them, then the platform's list, then en, each matched against the offered locales (same tag, then the tag truncated, then the same language). i18n.sources() shows every link and which one decided.
Usage: local i18n = require("@builtin::modules.api.engine.i18n") Also available as global: i18n
modules/i18n/check
check(root: string?): CheckResult
Run the catalog checks origozero.ai runs over every catalog of a
root (<root>/locales/<tag>/*.json, en the source): files that do not
parse, keys a translation has that English lacks, placeholders or markup
that differ from English, plural forms the locale does not use, a
translation with no current review record (<namespace>.review.json;
the finding prints the record to write), and the rest of the shared
checks. A translated locale's terms are held to its glossary,
<root>/glossary/<tag>.json ({ "terms": [ { "source": ["coin", "coins"], "target": ["moeda*"] } ], "exceptions": [], "same_as_english": [] }); without one the check warns.
Parameters
rootstring?(optional) — The folder holdinglocales/; the world's/zero/sourceby default.
local r = i18n.check(); for _, e in r.errors do print(e) end
modules/i18n/choice
choice(): string?
The locale the player chose for themselves, or nil when they chose none and the chain decides.
modules/i18n/choose
choose(tag: string?): ChooseResult
Choose tag as the player's locale, kept on this device for their
ZeroMind account (or for the signed-out player), so it wins the chain
from now on and on every later boot. nil clears the choice and the
chain decides again. A tag no offered locale matches is refused, naming
the offered tags.
Parameters
tagstring?(optional) — A tag fromi18n.offered(), or nil to clear the choice.
local r = i18n.choose("pt-BR")
if not r.ok then log.warn(r.reason) end
modules/i18n/emulate
emulate(tags: { string }?): { ok: boolean, locale: string?, platform: { string }?, reason: string? }
Stand tags in for the platform's preferred languages, the way a
visitor whose device or browser reads them would arrive, and negotiate
again: i18n.preferred(), i18n.pick, i18n.locale() and
i18n.onChange all answer as they would for that visitor. nil reads
the platform's own list again. A report the platform makes afterwards
(a language change, a desktop window regaining focus) replaces it. The
player's own choice (i18n.choose) still comes first in the chain, so
clear it with i18n.choose(nil) to see the list decide.
Parameters
tags{ string }?(optional) — BCP 47 tags, most preferred first, or nil for the platform's own list.
i18n.emulate({ "pt-BR", "en" }) -- try the world as a Brazilian visitor
i18n.emulate(nil) -- back to this machine's own languages
modules/i18n/explain
explain(key: string, values: { [string]: any }?): Explanation
Where the text of key comes from for the caller: the text, the
locale and file it was found in, and every file searched in order
(locale by locale, layer by layer). The first thing to read when a
screen shows a key, English in a translated screen, or another layer's
wording.
Parameters
keystring—<namespace>.<key>.values{ [string]: any }?(optional) — Parameter values, asi18n.ttakes them.
local e = i18n.explain("hud.score"); print(e.found, e.path, e.locale)
modules/i18n/fallback
fallback(): { string }
The chosen locale's fallback chain: the locales a string missing from its catalog is looked up in, in order.
modules/i18n/formatAgo
formatAgo(amount: number, unit: string?, locale: string?): string
How long ago something happened, as the caller's text locale writes
it in CLDR's narrow style: seconds before now in the largest unit that
fits (45s ago, 3h ago), or with unit (second, minute, hour,
day, month, year) that many of that unit (há 5 min.).
Parameters
amountnumber— Seconds before now, or a count ofunit.unitstring?(optional) — The unitamountcounts, or nil for seconds in the unit that fits.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/formatBytes
formatBytes(bytes: number, locale: string?): string
A size in decimal units as the caller's text locale or locale
writes it: 228 B, 16.2 KB, 1.5 MB (16,2 KB in Brazilian
Portuguese).
Parameters
bytesnumber— The size in bytes.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/formatCompact
formatCompact(n: number, locale: string?): string
A count in the short compact form of the caller's text locale or
locale: 1.2K, 1,2 mil. Below a thousand the number is written whole.
Parameters
nnumber— A whole number.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/formatDate
formatDate(date: { year: number, month: number, day: number }, style: string?, locale: string?): string
A calendar date as the caller's text locale (i18n.textLocale())
or locale writes it. style is long (October 1, 2026, 1 de outubro de 2026; the default), medium (Oct 1, 2026), monthYear
(October 2026) or monthDay (Oct 1). Pass the result into a
message as text: i18n.t("hud.last_played", { date = i18n.formatDate(d) }).
Parameters
date{ year: number, month: number, day: number }—{ year, month, day }(the shapeos.date("*t")returns).stylestring?(optional) — The date style.localestring?(optional) — A locale tag, in place of the caller's text locale.
print(i18n.formatDate(os.date("*t")))
modules/i18n/formatMoney
formatMoney(amountMinor: number, currency: string, locale: string?): string
An amount of money as the caller's text locale or locale writes
it, given in the currency's minor unit (cents for USD): $12.50,
R$ 12,50.
Parameters
amountMinornumber— The amount in minor units.currencystring— An ISO 4217 code such asBRL.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/formatNumber
formatNumber(n: number, locale: string?): string
A whole number as the caller's text locale (i18n.textLocale()) or
locale writes it: 1,234,567 in English, 1.234.567 in Brazilian
Portuguese.
Parameters
nnumber— A whole number.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/has
has(key: string): boolean
Whether a catalog the caller reads holds key, in the player's
locale, its fallback chain or en.
Parameters
keystring—<namespace>.<key>.
modules/i18n/isText
isText(value: any): boolean
Whether value is an i18n.text value.
Parameters
valueany(optional) — Any value.
modules/i18n/locale
locale(): string
The locale the engine chose for the player for its own text, a BCP
47 tag such as en or pt-BR. It is always one of i18n.offered();
en, the engine's source language, until a negotiation states another.
To choose among your own content's languages, use i18n.pick.
if i18n.locale() == "pt-BR" then label.text = "Olá" end
modules/i18n/offChange
offChange(id: number): boolean
Remove an i18n.onChange subscriber by its watcher id. Returns true
when a live watcher carried that id (false for one already removed, or
ended with the component that made it).
Parameters
idnumber— Watcher id returned byi18n.onChange.
modules/i18n/offered
offered(): { Locale }
The locales the engine offers for its own text, sorted by tag. Only
an offered locale can be chosen or negotiated. Content picks among its
own languages with i18n.pick.
modules/i18n/onChange
onChange(callback: (string, { string }) -> ()): number
Run callback each time the player's language changes: the
platform's preferred list changes (the player changed their OS, browser
or device language while the engine runs, or i18n.emulate stood a list
in), the player chooses or clears a choice, the ZeroMind language moves,
the offered locales change, the pseudo-locale is switched, or a catalog
file this VM read text from is edited. Called as (locale, preferred),
after every screen built from i18n.text values redrew, and after the
engine renegotiated, so i18n.pick inside it answers for the new state.
A change i18n.emulate or i18n.choose makes reaches this VM's
subscribers before that call returns; one the platform reports reaches
them within a tenth of a second.
A subscription made from a component ends with that component. Returns
a watcher id for i18n.offChange.
Parameters
callback(string, { string }) -> ()— Function invoked as(locale: string, preferred: {string}).
local id = i18n.onChange(function(locale, preferred)
log.info(("locale %s, platform %s"):format(locale, table.concat(preferred, ",")))
end)
modules/i18n/pick
pick(available: { string }): string
Which of available, the languages your content has text for,
this player reads: the tag the engine's chain picks from the player's
own choice, the language ZeroMind shows them and their platform's list,
matched by the same rules (same tag, the tag truncated, the same
language). The first of available when none of them matches, so list
your fallback first. Call it again (or from i18n.onChange) to follow a
change while they play.
Parameters
available{ string }— BCP 47 tags your content has text for, fallback first.
local lang = i18n.pick({ "en", "pt", "es" })
label.text = ({ en = "Welcome!", pt = "Bem-vindo!", es = "¡Bienvenido!" })[lang]
modules/i18n/plural
plural(count: number, locale: string?): string
The CLDR plural category count takes in the caller's text locale
(i18n.textLocale()), or locale: zero, one, two, few, many
or other. A catalog's plural message picks its form this way; use it
for a choice that is not text.
Parameters
countnumber— The number.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/i18n/preferred
preferred(): { string }
The languages the player's platform says they read, as BCP 47 tags,
most preferred first: the OS language list on Linux, Windows and macOS,
navigator.languages in a browser, the device (or per-app) language list
on Android. Empty when the platform states none.
local first = i18n.preferred()[1]
modules/i18n/pseudo
pseudo(on: boolean?): boolean
Show (true) or stop showing (false) the pseudo-locale qps in
every VM: every catalog text renders as accented, bracketed English
(⟦Ŝçöŕé⟧), padded by about a third, so text that did not come from a
catalog reads as plain English and a label too narrow for a longer
language overflows. Screens built from i18n.text values redraw. With
no argument it changes nothing.
Parameters
onboolean?(optional) — Whether to show it; nil reads the current state.
i18n.pseudo(true) -- every English string left on screen is one no catalog holds
i18n.pseudo(false)
modules/i18n/revision
revision(): number
A number that moves whenever a catalog text may read differently: the locale changed, the pseudo-locale was switched, or a catalog file this VM read was written. A build that caches text compares it.
modules/i18n/sources
sources(): Sources
Every link of the chain the locale was chosen from: the player's
choice, the zeromind language, the platform list, and which link
decided (decidedBy: choice, zeromind, platform or default)
with the tag it matched; and where a choice is kept (choiceKept:
device, or run in an offline engine, which keeps it for that run alone).
modules/i18n/t
t(key: string, values: { [string]: any }?): string
The text of key in the player's language, from the catalogs: the
world's /zero/source/locales/<tag>/<namespace>.json, then (for code of
a package) the package's own locales/, then the built-in library's.
A key is <namespace>.<key>: hud.score_label is score_label in
hud.json. A world's (or an installed package's) catalogs are read in
whichever of their languages the player reads (the chain i18n.pick
runs), then en; the library's in the engine's locale, its fallback
chain, then en. The first layer holding the key gives it. values
fills the message's {{ name }} parameters: text as written, whole
numbers grouped the way the message's language groups them, an
i18n.text value as its text, a function as what it returns when the
text renders; count also picks the plural
form (items_one / items_other in the file). A key no catalog holds
reads as the key, said once in the log. While the pseudo-locale is shown
(i18n.pseudo(true)) the text is accented, bracketed English.
Parameters
keystring—<namespace>.<key>, lowercase words joined by.and_.values{ [string]: any }?(optional) — Parameter values by name;countpicks the plural form.
-- /zero/source/locales/en/hud.json: { "score": "Score: {{ points }}", "lives_one": "{{ count }} life", "lives_other": "{{ count }} lives" }
label.text = i18n.t("hud.score", { points = 1250 }) -- "Score: 1,250"; "Pontos: 1.250" in pt-BR
print(i18n.t("hud.lives", { count = 3 })) -- "3 lives"
modules/i18n/text
text(key: string, values: { [string]: any }?): Text
A value that reads as the text of key (see i18n.t): tostring
renders it in the player's language at that moment. Pass it wherever a
widget takes text (text, title, header, placeholder, tooltip,
a dropdown's options; every edui widget's label), and the screen
follows the player's language, the pseudo-locale and edits to the
catalog without being built again (ui.refreshLiveText). A value of
values may itself be an i18n.text value, or a function called each
time the text renders, so a value written in the player's language
follows it too: { date = function() return i18n.formatDate(d) end }.
Parameters
keystring—<namespace>.<key>.values{ [string]: any }?(optional) — Parameter values by name;countpicks the plural form.
ui.registerScreen("hud", { type = "label", props = { text = i18n.text("hud.title") } })
edui.button({ label = i18n.text("editor.save"), onClick = save })
i18n.text("hud.last_played", { date = function() return i18n.formatDate(lastPlayed) end })
modules/i18n/textLocale
textLocale(): string
The locale the caller's text is shown in: for a world's code, the
one of the world's catalog languages the player reads (pt-BR for a
Brazilian player of a world with a locales/pt-BR, even while the
engine shows its own text in English); for a package's code, its
package's; for the engine's own code, i18n.locale(). The formatting
helpers write in it by default, so a date or a count reads in the same
language as the sentence around it.
local lang = i18n.textLocale() -- "pt-BR" for a Brazilian player of a world with pt-BR catalogs
modules/i18n/upper
upper(text: string, locale: string?): string
text in capitals by the case rules of the caller's text locale or
locale (CONEXÃO, Turkish İ). string.upper changes ASCII letters
only.
Parameters
textstring— The text.localestring?(optional) — A locale tag, in place of the caller's text locale.
modules/ibl/README
require("@builtin::systems.imageBasedLighting.ibl") -- ibl
Image-based lighting from the scene's own sky — metal reflects what is actually above it, and matte surfaces pick up the sky's colour.
Usage: local ibl = require("@builtin::systems.imageBasedLighting.ibl")
modules/ibl/active
active(): boolean
Whether the environment-lighting passes are currently running.
if ibl.active() then print("lit by the sky") end
modules/ibl/clear
clear()
Turn environment lighting off and release the passes. The other settings
are kept, so a later set brings back the same look.
ibl.clear()
modules/ibl/follow
follow()
Go back to reading the sky and sun from the scene, after a call pinned them.
ibl.follow()
modules/ibl/get
get(): IblState
The environment-lighting settings currently in force.
local s = ibl.get().specular
modules/ibl/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = ibl.paramsBuffer()
modules/ibl/refresh
refresh()
Carry the scene's current sky and sun into the running passes. The
scales — diffuse, specular, skyIntensity, horizonSharpness and
sunSize — stay as they stand, so a caller ticking this every frame keeps
a day/night cycle reaching the reflections without restating them. It
reads while the passes are running and the scene is on automatic tracking;
a colour or direction pinned through set holds it off until follow.
ibl.refresh()
modules/ibl/set
set(opts: IblOpts?): IblState
Set the scene's environment lighting. Any omitted field keeps its
current value. With both diffuse and specular at 0 nothing is being
asked for and the passes are released.
Parameters
optsIblOpts?(optional) — Settings — seeIblOpts.
ibl.set({ diffuse = 1, specular = 1 })
modules/ies/README
require("@builtin::systems.photometrics.ies") -- ies
Photometric light distributions in the IESNA LM-63 format, turned into a texture a spot light projects through its cone.
Usage: local ies = require("@builtin::systems.photometrics.ies")
modules/ies/parse
parse(src: string): (Profile?, string?)
Read an IESNA LM-63 photometric file.
Parameters
srcstring— The file's text.
local p = ies.parse(vfs.read("/source/lights/downlight.ies"))
modules/ies/toLayer
toLayer(profile: Profile, layer: number, coneHalfAngleDeg: number, resolution: number?): (number?, string?)
Rasterize a profile into one layer of the shared feature-texture array,
ready for a spot light's cookieLayer to project it.
Parameters
profileProfile— A profile fromies.parse.layernumber— Which feature-texture layer to fill.coneHalfAngleDegnumber— The spot's outer half-angle, so the profile's angles land where the cone actually reaches.resolutionnumber?(optional) — Layer size in pixels, a multiple of 32. Defaults to 256.
ies.toLayer(profile, 0, spot.angle)
modules/launcher/README
require("@builtin::modules.api.engine.launcher") -- launcher
The world chooser: the screen a launch that names no world opens where the platform asks for one (the Android app started from its launcher). It lists the public worlds on ZeroMind, each to play or to edit, the world the person chose last, and a local session, and starts the app again on the one the person picks. Where the platform shows the app's open source license notices, the screen opens them. Installed by the prelude; on a boot that did not open the chooser it draws nothing.
Every word the screen draws is read from the library catalog
locales/<tag>/world_chooser.json as an i18n.text value, so the screen
follows the player's language. The world list, the credential it is read with and the relaunch live in
the trusted VM (trusted.call("launcher.*")), which answers only on a
chooser boot. Playing a world boots the runtime profile in play mode;
editing it boots the editor profile in edit mode.
Usage: local launcher = require("@builtin::modules.api.engine.launcher")
modules/launcher/buildScreen
buildScreen(model: Model): { [string]: any }
The chooser's widget tree for model: the account line, the world
chosen last, the world list (or why it could not be read), a local
session, and the app's open source licenses. Buttons call back
launcher:play:<guid>, launcher:edit:<guid>, launcher:continue,
launcher:retry, launcher:local and launcher:licenses.
Parameters
modelModel—{ last?, signedIn, licenses?, status = "loading"|"ready"|"unreachable", worlds?, reason?, opening?, refusal?, scale?, height? };licensesoffers the platform's screen of the app's license notices;scalemultiplies every size, 1 when omitted;heightis the height the list scrolls within, the screen's.
modules/launcher/install
install()
Start the chooser on a system task, so it opens on a boot that opened it. Called once by the prelude.
modules/launcher/show
show(): boolean
Open the chooser when this boot opened it: ask the trusted VM, then show the screen and read the world list. Draws nothing on any other boot.
modules/layeredMaterial/README
require("@builtin::systems.layeredMaterial.layeredMaterial") -- layeredMaterial
A surface written as a stack of materials that already exist, compiled to one WGSL surface shader. Rust over painted metal, snow over rock, mud over a vehicle, lacquer over paint: each is one material laid over another. The two materials are already authored; what is missing is a way to say "this one, over that one, where the mask says". Written by hand, that means a new fn surface() for every pair, and the pair is what the shader is about — neither half is reusable. A stack names the materials instead, and material() compiles it, writes the shader out as an ordinary .shader asset and hands back a material wearing it. Each layer is read off the material it names — its shading values and the textures it binds — and the emitted shader carries every layer's inputs under its own name, blends them by coverage, and shades once. Shading each layer and adding the results would put more energy back out than arrived; interpolating the inputs and shading the result cannot, which is what keeps a half-covered surface from reading brighter than either layer alone. A layer past the first is revealed by the product of three terms, each of which can be left neutral: a mask texture read through one channel and a contrast, a per-material amount, and one lane of the entity's own shader data. All three are ordinary material properties, so the blend is drivable at runtime, and the instance term is what lets two entities wearing one material carry different amounts of wear in the same frame. property(i, name) spells the naming convention out for a caller driving them, inputs() lists what a layer carries, and limits() reports the bounds a stack is compiled against.
Usage: local layeredMaterial = require("@builtin::systems.layeredMaterial.layeredMaterial")
modules/layeredMaterial/check
check(stack: Stack): (boolean, any)
Compile a stack without raising. The same work compile does, with the
error handed back rather than thrown — what an editor wants while the author
is still choosing materials.
Parameters
stackStack— The stack to check.
local ok, result = layeredMaterial.check(stack)
modules/layeredMaterial/compile
compile(stack: Stack, name: string?): Compiled
Compile a stack of materials into the two files a .shader asset holds.
The layers are read off the materials they name, so this reaches the asset
graph; it touches no renderer and no GPU, and a layer written as plain
values and textures instead of a material reference needs no asset at
all. Every reference a layer holds (its material, its textures, its
mask) is read where the call was written, so ~.textures.x in a
package's code names that package's texture.
Parameters
stackStack—{ name, layers = { { material, blend, mask, ... }, ... } }, the bottom layer first.namestring?(optional) — Overridesstack.namefor the shader this compiles to.
local out = layeredMaterial.compile({ name = "worn", layers = { { material = "@builtin::materials.default" }, { material = "@builtin::materials.gold", blend = 0.5 } } })
print(out.wgsl)
modules/layeredMaterial/inputs
inputs(): {
What a layer carries: the shading inputs the stack blends, the texture slots a layer may bind, the coverage controls a layer past the first declares, and the properties that belong to the whole surface.
for _, decl in ipairs(layeredMaterial.inputs().values) do print(decl.name) end
modules/layeredMaterial/install
install(stack: Stack, opts: { name: string?, into: any? }?): Installed
Compile a stack and write it out as a real .shader asset. The result is
an ordinary shader asset — it can be read, hand-edited and shipped like any
other. Installing the same stack again rewrites the same asset. The shader
is compiled at the next frame boundary, the way any shader edit is;
asset.ref(name, "shader"):compileStatus() is what reports the outcome.
Parameters
stackStack— The stack to install.opts{ name: string?, into: any? }?(optional) —{ name = <shader name>, into = { path = <folder> } }.intoplaces the asset as it is created; installing again writes wherever it already is.
local shader = layeredMaterial.install(stack, { name = "worn_barrel" })
local status = asset.ref(shader.name, "shader"):compileStatus()
modules/layeredMaterial/limits
limits(): { maxLayers: number, textureSlots: number }
The bounds a stack is compiled against: how many layers one holds, and how many texture slots the layers may spend between them.
print(layeredMaterial.limits().textureSlots)
modules/layeredMaterial/material
material(
Install a stack and make a material wearing the shader it compiled to,
carrying every layer's values and every texture the layers bind. The result
is an ordinary material asset: hand it to a Model's material field, or
drive its properties afterwards like any other. Calling it again with the
same material name is how a stack is iterated on — the shader is rewritten,
the material is brought onto it, and the layers are applied over it, so what
the call says is what the material holds when it returns.
local mat = layeredMaterial.material(stack, { name = "worn_barrel" })
entity.spawn("barrel").component.add("Model", { model = "cube", material = mat })
modules/layeredMaterial/property
property(index: number, input: string): string
The name the generated shader declares one of a layer's inputs under.
The convention is l<index>_<input>, and this is what says so — a caller
driving a blend at runtime asks for the name rather than spelling it.
Parameters
indexnumber— Which layer, counting the bottom one as 1.inputstring— The input's name — one ofinputs(), or a coverage control. The coverage controls belong to a layer laid over another, so asking for one on the bottom layer raises rather than naming a property no stack declares.
matRef:setProperty(layeredMaterial.property(2, "coverage"), 0.7)
modules/layeredMaterial/read
read(materialRef: any): Read
Read a layer's inputs off a material that already exists — the values it
carries for everything a stack blends, and the textures it binds for them.
This is what compile does with a layer written as { material = ... },
exposed on its own so a caller can see what a material would contribute
before stacking it. A slot the material leaves on a built-in fallback
(default:white, default:normal) is read as bound to nothing, since that
fallback is what a slot left undeclared samples anyway. The material's name
is read where the call was written, so ~.materials.x in a package's code
names that package's material. A texture the material writes relative to
its own file (~.textures.x) is given as the guid it names there, since
that is the texture the material binds.
Parameters
materialRefany(optional) — The material — a name, an identity, or anAssetRef<material>.
local layer = layeredMaterial.read("@builtin::materials.gold")
print(layer.values.metallic, layer.textures.base_color_texture)
modules/layers/README
require("@builtin::modules.api.engine.layers") -- layers (also available as global 'layers')
Top-level scene-management namespace + Scene proxy. Owns the public layer-management API surface exposed on _G.layers. Pure Luau composition over internal __layers.* ECS-glue primitives; the LSP discovers the public shape via this --!global layers directive.
Usage: local layers = require("@builtin::modules.api.engine.layers") Also available as global: layers
modules/layers/cost
cost(): { SceneLayerCost }
What each loaded scene's per-frame tick costs, attributed to the layer
that owns it — the update / editorUpdate its entrypoint declares,
timed where it runs. totalMs is a SUM across the window
layers.observe().window reports, so divide by calls (or read avgMs)
for the per-tick figure; a tick that runs every frame makes that the
per-frame figure. Call layers.resetCostWindow() first to time a
particular stretch. A layer whose entrypoint declares no tick is absent.
layers.resetCostWindow(); task.wait(1); for _, c in layers.cost() do print(c.name, c.avgMs) end
modules/layers/find
find(ref: AssetRef<scene> | string): any?
The loaded layer for a scene, matched on guid — the canonical identity, since display names can collide and paths drift when assets move. A layer torn down but not yet pumped out of the engine's loaded list reads as gone.
Parameters
refAssetRef<scene> | string— A sceneAssetRef, or an identity string resolved throughasset.ref.
local layer = layers.find("scenes.arena")
modules/layers/fireBeforeLoad
fireBeforeLoad(proxy: any): nil
Announce that a scene layer is about to load: clears any pending
unload for that layer slot, marks the proxy loading, and fans out to every
layers.onBeforeLoad subscriber. The scene-load pipeline calls this.
Parameters
proxyany(optional) — The scene proxy about to load.
layers.fireBeforeLoad(sceneProxy)
modules/layers/fireLoad
fireLoad(proxy: any): nil
Announce that a scene layer has loaded, fanning out to every
layers.onLoad subscriber. The layer is pinned as the active one for the
duration of the fan-out, so entities a subscriber spawns are attributed to
it rather than landing orphaned. The scene-load pipeline calls this.
Parameters
proxyany(optional) — The loaded scene proxy.
layers.fireLoad(sceneProxy)
modules/layers/fireUnload
fireUnload(proxy: any): nil
Announce that a scene layer is unloading: fans out to every
layers.onUnload subscriber, then drops the layer's cached proxy and
per-layer state so the next load of that scene rebuilds from disk. The
unload path calls this.
Parameters
proxyany(optional) — The scene proxy being unloaded.
layers.fireUnload(sceneProxy)
modules/layers/install
install(): nil
Install the layers global. layers.active is exposed as a property
whose every read resolves the current root scene, so it tracks scene
changes without manual invalidation; other keys resolve against this
module. The prelude calls this once at boot.
layers.install()
modules/layers/inventory
inventory(): { SceneLayerInventory }
What each loaded layer holds: the entities the engine attributes to it,
whether it came up whole, and how many failures it carries. unattributed
in layers.observe().totals counts what exists in the world that no layer
claims.
for _, l in layers.inventory() do print(l.name, l.entities, l.ok) end
modules/layers/is_loaded
is_loaded(ref: AssetRef<scene> | string): boolean
Whether a scene currently has a loaded layer — the boolean form of
layers.find. A scene counts as loaded from the frame the engine holds a
layer slot for it — the same slot its entities are attributed to — until
an unload is issued against that slot. So a gate like
if layers.is_loaded(ref) then layers.unload(ref) end sees the layer on
the frame its entities exist.
Parameters
refAssetRef<scene> | string— A sceneAssetRef, or an identity string.
if not layers.is_loaded("scenes.hud") then layers.load("scenes.hud", { additive = true }) end
modules/layers/lastLoad
lastLoad(): SceneLoadReport?
The most recent load's report: what it loaded, what root it replaced and which overlays went with it, the entity counts on each side, how long each phase took, and every failure it produced. Nil on an engine that has loaded nothing — which is how "nothing has loaded" reads differently from a load that changed nothing.
local r = layers.lastLoad(); print(r.name, r.outcome, r.entities.added)
modules/layers/lastUnload
lastUnload(): SceneUnloadReport?
The most recent unload's report: the layer it took down under the name it was loaded with, the overlays it cascaded, and the entities that went with them. A guid no longer resolves to a name once its layer is gone, so this is where that name survives.
local u = layers.lastUnload(); print(u.name, u.entities.removed)
modules/layers/list
list(): { any }
Every loaded scene layer as a proxy, root and additive alike, in the
order the engine reports them. A proxy carries name, sceneIdentity
(the scene asset it was loaded from, e.g. scenes.main), guid, path,
additive, persistent and visible. The root one — the open scene — is
also layers.active.
for _, layer in ipairs(layers.list()) do print(layer.name, layer.sceneIdentity, layer.additive) end
print("open scene:", layers.active.sceneIdentity)
modules/layers/load
load(ref: AssetRef<scene> | string, opts: LoadOpts?): any
Parameters
refAssetRef<scene> | stringoptsLoadOpts?(optional)
modules/layers/loadHistory
loadHistory(): { SceneLoadReport }
Every load report the engine still holds, oldest first. Bounded — old reports fall off the front, so a long session's memory does not grow with how many times a scene was swapped.
for _, r in layers.loadHistory() do print(r.name, r.durationMs) end
modules/layers/loadInFlight
loadInFlight(): number
Returns the number of scene loads currently in flight (queued
but not yet visible via onLoad dispatch). Returns 0 when the
engine is in a stable load state. Used by engine.mode = ... to
block flips while a load is mid-air; agents can read this to wait
for a load to finish before driving the next operation.
modules/layers/observe
observe(): SceneObservation
What every scene load did, and what each loaded scene costs. One read covering the last load's report (what it produced, what it replaced, what it failed to produce and why, and how long each phase took), the load and unload history, a per-layer inventory of what the engine attributes to each layer, and the per-frame cost of each layer's entrypoint tick. Answers in edit mode as well as play.
local o = layers.observe(); print(o.lastLoad.outcome, o.lastLoad.durationMs)
for _, c in layers.observe().cost do print(c.name, c.avgMs) end
modules/layers/offBeforeLoad
offBeforeLoad(h: number): boolean return remove(beforeLoadCbs, h) end
Cancel a layers.onBeforeLoad subscription.
Parameters
hnumber— The handlelayers.onBeforeLoadreturned.
layers.offBeforeLoad(h)
modules/layers/offEntityChanged
offEntityChanged(h: number): boolean
Remove a subscription made with layers.onEntityChanged.
Parameters
hnumber— The handle returned bylayers.onEntityChanged.
layers.offEntityChanged(handle)
modules/layers/offLoad
offLoad(h: number): boolean return remove(loadCbs, h) end
Cancel a layers.onLoad subscription.
Parameters
hnumber— The handlelayers.onLoadreturned.
layers.offLoad(h)
modules/layers/offUnload
offUnload(h: number): boolean return remove(unloadCbs, h) end
Cancel a layers.onUnload subscription.
Parameters
hnumber— The handlelayers.onUnloadreturned.
layers.offUnload(h)
modules/layers/onBeforeLoad
onBeforeLoad(cb: (any) -> ()): number return push(beforeLoadCbs, cb) end
Run a callback just before a scene layer loads, while the previous layer's entities are still present.
Parameters
cb(any) -> ()— Receives the scene proxy about to load.
local h = layers.onBeforeLoad(function(scene) print("loading", scene.name) end)
modules/layers/onEntityChanged
onEntityChanged(cb: (any) -> ()): number
Subscribe to authored entity changes. The callback runs once per
frame with every entity edited since the previous frame, batched by
layer as { { scene = string, entities = { string } } } — a moved
transform, an edited component field, a spawn, or a despawn (the id
of a despawned entity arrives with entity.exists already false).
Any number of subscribers can watch the same edits.
Scope: authored edits in edit mode — what lands in the scene's dirty
overlay. Mutations a component makes from its own update are runtime
behavior and do not appear, so a subscriber that rebuilds derived data
cannot re-trigger itself.
Parameters
cb(any) -> ()— Called with the change batch.
layers.onEntityChanged(function(batch)
for _, row in ipairs(batch) do
for _, id in ipairs(row.entities) do print("changed", id) end
end
end)
modules/layers/onLoad
onLoad(cb: (any) -> ()): number return push(loadCbs, cb) end
Run a callback once a scene layer has loaded — the point where its entities exist and player / camera spawners can attach to them.
Parameters
cb(any) -> ()— Receives the loaded scene proxy.
local h = layers.onLoad(function(scene) print("loaded", scene.name) end)
modules/layers/onUnload
onUnload(cb: (any) -> ()): number return push(unloadCbs, cb) end
Run a callback as a scene layer unloads, while its entities are still addressable — the place to release anything keyed to them.
Parameters
cb(any) -> ()— Receives the scene proxy being unloaded.
local h = layers.onUnload(function(scene) print("unloaded", scene.name) end)
modules/layers/problems
problems(ref: (AssetRef<scene> | string | any)?): { SceneLoadFailure }
What a layer failed to produce, and why. Each entry names the phase it happened in, one reason from the closed set, and the engine's own words — plus the entity, component or lifecycle hook it is about when it is about one.
Parameters
ref(AssetRef<scene> | string | any)?(optional) — A sceneAssetRef, an identity string, or a scene proxy. Omit for the active root layer.
for _, f in layers.problems() do print(f.reason, f.entity, f.message) end
modules/layers/rebuildInFlight
rebuildInFlight(): boolean
Whether the engine is rebuilding the live scene right now: a scene
load is carrying entities in, an edit↔play flip's transition is
materialising the layer set, or a scene's build.luau build is landing
what it produced. A flip unloads the root layer and loads it again for the
new mode across many frames, and each mode materialises a different set of
entities; a build lands its records and saves the scene over several
frames. Either way the live entities are a stage of a scene being built
while this reads true. A caller whose answer belongs to the settled scene,
a test taking a root or a validator judging the live tree, polls it down
to false first.
if not layers.rebuildInFlight() then print(#entity.findAll(), "entities settled") end
modules/layers/reload
reload(ref: (AssetRef<scene> | string)?): any?
Unload and re-load a scene layer in place, so an edited scene asset
takes effect without rebuilding the surrounding layer stack. The scene's
build.luau runs against what it resolves right now, so a build script
whose inputs moved (a component that now exists, an asset that now
resolves) produces the scene it describes today. The rebuild saves the
scene, as a write to build.luau does, so scene.json holds what the
reload built and the next play loads it; unsaved edits in the scene are
saved with it. A library scene (under /libs/) is rebuilt in the live
scene alone. A reload asked for while
a build of the scene is landing (a write to build.luau rebuilds over
several frames) waits for that build to land and save first.
Parameters
ref(AssetRef<scene> | string)?(optional) — A sceneAssetRef, or an identity string. Omit to reload the active root scene.
layers.reload("scenes.arena")
modules/layers/resetCostWindow
resetCostWindow(): nil
Open a new cost window, discarding what the previous one measured. Call this before timing a stretch of frames; the load history is untouched.
layers.resetCostWindow()
modules/layers/unload
unload(refOrProxy: (AssetRef<scene> | string | any)?): nil
Unload a scene layer. Unloading the root cascades through its additive overlays first, most-recently-loaded first, so none is left as a layer the engine still lists after its entities are gone; persistent additive layers survive the cascade. A scene with no loaded layer is a no-op. An unload made while a load is part way through a scene's records waits for that load to apply the rest.
Parameters
refOrProxy(AssetRef<scene> | string | any)?(optional) — A sceneAssetRef, an identity string, or a scene proxy. Omit to unload the active root scene.
layers.unload("scenes.hud")
layers.unload() -- the active root, plus its non-persistent overlays
modules/layers/whyPartial
whyPartial(ref: (AssetRef<scene> | string | any)?): (string?, string?)
Why a layer is not whole. Returns nil when it IS — everything the scene
declared was produced — and otherwise the nearest cause from the closed set
loaderRaised, entrypointCompileFailed, entrypointBodyRaised,
entrypointRaised, buildRaised, entityFailed, parentMissing,
parentRefused, parentAbandoned, componentUnresolved,
componentRefused, subscriberRaised, updateRaised. A second return
carries the engine's own words for that cause.
Parameters
ref(AssetRef<scene> | string | any)?(optional) — A sceneAssetRef, an identity string, or a scene proxy. Omit for the active root layer.
local why, detail = layers.whyPartial(); if why then print(why, detail) end
modules/lensFx/README
require("@builtin::systems.lensFx.lensFx") -- lensFx
The lens and the film — flare thrown by bright sources, dirt on the front element, and grain that is redrawn every frame rather than a fixed screen pattern.
Usage: local lensFx = require("@builtin::systems.lensFx.lensFx")
modules/lensFx/active
active(): boolean
Whether the lens passes are running this frame.
if lensFx.active() then ... end
modules/lensFx/clear
clear()
Turn the flare and grain off and release the passes. The other settings
are kept, so a later set brings back the same look.
lensFx.clear()
modules/lensFx/get
get(): LensFxState
The lens settings currently in force.
local g = lensFx.get().grainIntensity
modules/lensFx/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = lensFx.paramsBuffer()
modules/lensFx/set
set(opts: LensFxOpts?): LensFxState
Set the lens and film. Any omitted field keeps its current value. With
both flareIntensity and grainIntensity at 0 the passes are released.
Parameters
optsLensFxOpts?(optional) — Lens settings — seeLensFxOpts.
lensFx.set({ flareIntensity = 1.0, grainIntensity = 0.04 })
modules/lensFx/sync
sync()
Bring the buffer's grain clock to the instant this frame draws at. The
render feature calls it once a frame, so the field follows a
renderer.temporal.hold the moment one is taken or released, whatever is
driving the scene's own clock.
lensFx.sync()
modules/lensFx/tick
tick(dt: number)
Advance the clock the grain is drawn against. Grain is a fresh field
every frame rather than a fixed screen pattern, so it needs the frame's
own time — which cannot arrive through set, since a value that has not
changed is not re-pushed.
Parameters
dtnumber— Seconds since the previous frame.
function update(dt) lensFx.tick(dt) end
modules/library/README
require("@builtin::modules.api.engine.library") -- library (also available as global 'library')
Discover, check, and import library assets — the @builtin/* tree the engine ships and the @namespace/* trees imported from other worlds.
Usage: local library = require("@builtin::modules.api.engine.library") Also available as global: library
modules/library/has
has(path: string): boolean
Check if a library asset exists at the given path. Answers from
the content the engine holds: an imported library's namespace
("@mylib") and its assets answer true once its pinned commit is
mounted, and false while only its marker is there.
Parameters
pathstring— Library asset path (e.g. "@builtin/models/Sample/DamagedHelmet").
assert(library.has("@builtin/models/Cube"))
modules/library/import
import(namespace: string, worldRef: string): LibraryImport
Import another world as a library under the given namespace.
Resolves the world, pins its current commit, and writes the
library marker at /source/libs/@<namespace>, then waits while the
engine fetches the pinned commit from ZeroMind and mounts it. When
it returns, the imported tree answers to
require("@<namespace>::path") and is listed by library.list().
A library that does not mount raises naming why, and running the
import again retries it.
Parameters
namespacestring— Library namespace, with or without the leading@(e.g."@mylib"or"mylib").worldRefstring— The upstream world's guid, or its name as it appears inworld.list().
library.import("@mylib", "my-shared-world")
modules/library/list
list(assetType: string?): { LibraryAsset }
List all available library assets. Optionally filter by asset
type — call asset.categories() for the live set.
Parameters
assetTypestring?(optional) — Asset type filter (optional).
for _, a in ipairs(library.list("model")) do print(a.path) end
modules/lightCookies/README
require("@builtin::systems.lightCookies.lightCookies") -- lightCookies
Project an authored image through a spot light's cone — a gobo, a window pattern, a headlight cutoff.
Usage: local lightCookies = require("@builtin::systems.lightCookies.lightCookies")
modules/lightCookies/clear
clear(light: any): boolean
Stop projecting a cookie through a light's cone. The layer keeps its contents; the light stops reading it.
Parameters
lightany(optional) — The spot light's entity id or entity proxy.
lightCookies.clear(lampId)
modules/lightCookies/configure
configure(opts: { resolution: number, layers: number }): (number?, string?)
Size the shared feature-texture array for cookies. Call once, before
setting any cookie, with a layer count covering every layer the scene
uses — resizing the array zeroes every layer in it, including layers other
features own. renderer.featureTexture.state() reports the extent the array
carries and the layers holding content, so a cookie that has left filled
is one to set again.
Parameters
opts{ resolution: number, layers: number }—{ resolution, layers }—resolutionis the square extent of each layer in pixels, a multiple of 32;layersis how many the array holds.
lightCookies.configure({ resolution = 256, layers = 4 })
modules/lightCookies/fill
fill(image: any, opts: Options): (number?, string?)
Fill one layer of the shared array with an authored image, ready for a
spot light's cookieLayer to project it. The fill lands over the frames
after the call: its rasterize is issued on the next frame and its copy into
the layer on the frame after that, and it is written once the array
reports the copy landed, one fill at a time in the order they were asked
for. It lands whatever happens to the code that asked for it.
lightCookies.status(layer) reports where the fill stands and, for a fill
that could not land, why.
Parameters
imageany(optional) — A textureAssetRef, aTextureHandle, or any stringasset.refresolves to one: a guid, an identity, a name or a source path.optsOptions—{ layer, gain?, tint? };layeris below the layer countconfiguresized the array to.
lightCookies.fill("/textures/cookies/window_blinds.png", { layer = 0 })
modules/lightCookies/layerOf
layerOf(light: any): number?
The layer a light is currently projecting, or nil when it has no cookie.
Parameters
lightany(optional) — The spot light's entity id or entity proxy.
print(lightCookies.layerOf(lampId))
modules/lightCookies/observe
observe(): { [string]: any }
What the module is doing: how many fills are waiting, the one in
progress, the loop that drains them, and how many times configure has
sized the array.
print(lightCookies.observe().pending)
modules/lightCookies/project
project(light: any, image: any, opts: Options): (number?, string?)
Project an image through a spot light's cone: fill a layer with it and point the light at that layer.
Parameters
lightany(optional) — The spot light's entity id or entity proxy.imageany(optional) — A texture asset, in any formlightCookies.fillaccepts.optsOptions—{ layer, gain?, tint? }.
lightCookies.project(lampId, "/textures/cookies/blinds.png", { layer = 0 })
modules/lightCookies/status
status(layer: number): Status?
Where the last fill of a layer stands. A fill passes through
"queued", "rasterizing" and "copying" to "written" over the frames after
fill returns, and reads "written" from the reading of the array that
first reports its copy landed in the layer; a fill that could not land
(the GPU refused its rasterize, a later configure left the array without
its layer, or its copy never reached the array) reads "refused" with the
reason.
filled is the array's own reading of the layer.
Parameters
layernumber— The layer index afillorprojectwas given.
local s = lightCookies.status(0); print(s.state, s.reason, s.filled)
modules/logs/README
require("@builtin::modules.api.engine.logs") -- logs (also available as global 'logs')
Read-only query surface over the engine's in-memory log ring buffer. Public Luau surface over the __logs Internal FFI namespace.
Usage: local logs = require("@builtin::modules.api.engine.logs") Also available as global: logs
modules/logs/clear
clear(): boolean
Drop all buffered log entries. Lifetime per-level counts
(logs.count) are preserved.
logs.clear()
modules/logs/count
count(opts: LogQueryOpts?): LogCounts
Aggregate counters for the log ring. Lifetime counts survive
eviction, so errors reflects the total seen even if the lines
have scrolled out of the buffer. opts takes the same filter table
as logs.query, and matched is how many held entries it selects,
counted without materialising them — limit and newest_first bound
and order what a query RETURNS, so they leave matched alone. mcp
is how many held entries record your own tool traffic; a query leaves
those out, so with no opts, matched + mcp is everything held.
last_seq is the cursor for
incremental polling: read it before an action, then pass it as
logs.query({ since = <that> }) afterwards to see only what the
action logged.
Parameters
optsLogQueryOpts?(optional) — Filter options, aslogs.querytakes.
print("errors:", logs.count().errors)
local before = logs.count().last_seq
modules/logs/errors
errors(limit: number?): { LogEntry }
Most-recent ERROR-level entries (newest first). limit
defaults to 100.
Parameters
limitnumber?(optional) — Maximum entries to return.
for _, e in ipairs(logs.errors(20)) do print(e.message) end
modules/logs/find
find(text: string, limit: number?): { LogEntry }
Case-insensitive substring search over log messages. limit
defaults to 200 (keeps the most recent matches). Searches what the
engine logged, so looking for a marker cannot return the call that
looked for it; logs.query({ contains = ..., include_mcp = true })
searches your own tool traffic too.
Parameters
textstring— Substring to search for.limitnumber?(optional) — Maximum entries to return.
local hits = logs.find("MY_MARKER")
modules/logs/query
query(opts: LogQueryOpts?): { LogEntry }
Query the engine's in-memory log ring — the filtered view of what
also reads as plain text at /zero/runtime/logs/engine. Answers about what the
engine logged: the MCP record of your own tool traffic is left out,
because the call carrying the query is one of those records and an
unqualified search would match itself. type = "MCP" selects them;
include_mcp = true mixes them in with everything else. On a world
several sessions share, origin = "local" narrows the answer to the
lines this session's own authoring caused.
Parameters
optsLogQueryOpts?(optional) — Filter options.
logs.query({ entity = "guard-1", limit = 20 })
logs.query({ level = "error", context = 3 })
for _, e in ipairs(logs.query({ level = "warn", limit = 50 })) do print(e.message) end
modules/logs/tail
tail(limit: number?): { LogEntry }
Most-recent entries of any level in chronological order.
limit defaults to 100.
Parameters
limitnumber?(optional) — Maximum entries to return.
for _, e in ipairs(logs.tail(20)) do print(e.level, e.message) end
modules/logs/template
template(message: string): string
Normalize a message to its template — the same line with the parts that vary between occurrences (numbers, hashes, entity ids) masked out. Two messages that differ only in those parts share a template, which is what turns "this error repeated 400 times" into one row instead of 400. The engine keys its own error retention by the same normalization, so grouping built on this agrees with what survives ring eviction.
Parameters
messagestring— Log message to normalize.
local key = logs.template(entry.message)
modules/logs/warnings
warnings(limit: number?): { LogEntry }
Most-recent WARN+ entries (newest first). limit defaults
to 100.
Parameters
limitnumber?(optional) — Maximum entries to return.
print(#logs.warnings(), "warnings")
modules/lsp/README
require("@builtin::modules.api.engine.lsp") -- lsp (also available as global 'lsp')
Embedded Luau language server — check / search / inspect Public Luau surface over the __lsp Internal FFI namespace.
Usage: local lsp = require("@builtin::modules.api.engine.lsp") Also available as global: lsp
modules/lsp/analysisFlags
analysisFlags(): AnalysisFlags
The feature-flag configuration upstream Luau's analysis library
(the linter and .luaurc parser behind these checks) runs under,
read back from Luau's flag registry. It is upstream's own: every
Luau* flag the analysis sources declare is on unless upstream's
experimental list names it, and every other flag they declare keeps
the value Luau registers it at. The flags the analysis library reads
from the parser and the VM are shared: they run at the value the
engine's runtime gives them, and one that differs from upstream's
carries its deviation. flags lists every flag those sources
declare or read, sorted by name; atUpstream counts the linked ones
whose value is upstream's. available is false, with reason, on a
build that does not link the analysis library.
modules/lsp/check
check(path: string, opts: CheckFileOpts?): DiagnosticsResult
Validate a single .luau file in the VFS and return its
diagnostics. A path the check could not read comes back as one
lsp-check-* error naming the path and the reason, and a file past the
2 MiB analysis bound as one source-too-large warning with
checked = false, so checked with errors == 0 means a code body was
analysed and is clean.
opts.upstream (true, or the options of lsp.upstreamCheck) also
checks the file with upstream Luau's type checker and sets upstream to
what lsp.upstreamCheck returns for it, whose modules say how the
check of each module it reached ended and how long it took; the
diagnostics and counts stay the engine checker's.
Parameters
pathstring— VFS path.optsCheckFileOpts?(optional) —{ severity?, limit?, context?, upstream? }.
local diags = lsp.check("/zero/source/main.luau")
modules/lsp/checkAll
checkAll(opts: CheckAllOpts?): CheckAllResult
Validate the user's Luau scripts and return an aggregate
summary plus diagnostic list. opts.scope = "user" (default)
skips library mounts; "all" includes them. The sweep is
time-budgeted (ZERO_EXECUTE_INLINE_BUDGET_MS, ~20s by default): if
the budget elapses it returns the partial result gathered so far
with budgetExceeded = true rather than blocking the engine.
opts.budgetMs sets the budget for the call and opts.maxFiles caps
the files it checks. opts.upstream (true, or the options of
lsp.upstreamCheck) also checks each file with upstream Luau's type
checker once the engine's own pass is done, within the same budget, and
sets upstream to what that pass found: every module it reached, once,
with how its check ended ("completed", "timedOut", "internal", or
"notAnalysable" with the reason) and how long it took, reused marking a
module checked before the pass reached it and unchanged since.
The pass starts no file once the budget is spent, so it ends within the
budget plus the check of the one file in progress.
Parameters
optsCheckAllOpts?(optional) —{ scope?, severity?, limit?, budgetMs?, maxFiles?, upstream? }.
modules/lsp/checkCode
checkCode(source: string, opts: CheckOpts?): DiagnosticsResult
Validate inline Luau source without a backing file. Useful
for checking code before writing it to disk. A source past the 2 MiB
analysis bound comes back as one source-too-large warning with
checked = false.
Parameters
sourcestring— Luau source.optsCheckOpts?(optional) —{ severity?, limit?, context? }.
modules/lsp/checkDirty
checkDirty(): DiagnosticsResult
Drain the dirty-file set populated by the hot-reload hook, validate each, and return the combined diagnostic list.
modules/lsp/definitions
definitions(opts: DefinitionsOpts?): Definitions
The engine's API as a Luau definitions source, upstream Luau's
.d.luau form (declare statements and export type aliases),
generated from the live API registry: the documented members, the
--!global-types aliases and the asset-category shapes lsp.check
types against, bound under the same names. It declares each global the
calling script's globals hold, so a user script, a trusted script and a
worker each get the globals they have; a name upstream's builtin
environment declares keeps upstream's type and is left out.
lsp.upstreamCheck loads the same source into every module it checks,
and an external editor running luau-lsp reads it as a definitions file
(lsp.exportDefinitions writes it out). It is generated again whenever
the registry changes, a library hot reload included. package (@zero)
keys each global's documentation symbol (@zero/global/<name>,
@zero/global/<name>.<member>). Each type string the registry holds is
declared as written, or listed in unrepresented with the reason and
declared any; a declaration upstream refuses to load (an alias that
reaches itself through aliases alone) is listed with upstream's reason,
so the rest of the source loads. opts.documentation = true also returns
documentation, the JSON documentation file luau-lsp reads beside the
definitions: each symbol's signature and description. available is
false, with reason, on a build that does not link the analysis library.
Parameters
optsDefinitionsOpts?(optional) —{ documentation? }.
local d = lsp.definitions()
print(d.bytes, #d.globals, #d.unrepresented)
modules/lsp/describe
describe(path: string, opts: DescribeOpts?): DocEntry?
Inspect a single documented entry. Returns the full doc
table (signature, args, returns, examples, level), or nil.
The path is resolved independently of which root the doc is
registered under and of separator style, so the spelling that reads
off the API surface (renderer.texture.create) finds the entry
registered as globals/renderer/texture/create. A path naming a
binding the engine registered internally answers with the entry a Luau
module publishes over it where there is one, so the signature is the
call content makes; opts.includeInternal answers with the internally
registered entry itself. When a path does not resolve,
lsp.describePaths says what the registry holds near it.
Parameters
pathstring— Doc path (e.g."asset/resolve","renderer.texture.create").optsDescribeOpts?(optional) — Optional{ includeInternal? }— default prefers the published entry.
local doc = lsp.describe("renderer.texture.create")
modules/lsp/describePaths
describePaths(path: string): { string }
List the registered doc paths related to path. A path that names
an entry returns every root it is registered under (the first is what
lsp.describe resolves to); a path that names a namespace returns the
entries registered under it. Empty when the registry holds nothing
near the path — so a lookup that returns nil can always be turned into
the list of what does exist.
Parameters
pathstring— Doc path in any spelling ("renderer.texture","ecs/query").
for _, p in ipairs(lsp.describePaths("renderer.texture")) do print(p) end
modules/lsp/describeTool
describeTool(path: string): string?
Return the full documentation text for a code-mode tool.
Parameters
pathstring— Tool path (e.g."scene/spawnLight").
modules/lsp/dirtyStatus
dirtyStatus(): DirtyStatus
How many files wait to be re-validated, whether a drain job holds the set, and how many drains have run in a caller's frame and on a job.
modules/lsp/docsByKind
docsByKind(kind: string): { MethodSummary }
List every doc whose registration kind matches kind.
Valid: "binding", "runtime_tool", "module", "component",
"library", "lua_export".
Parameters
kindstring— Registration kind.
modules/lsp/drainDirty
drainDirty(): boolean
Start re-validating every file marked dirty on a job off the frame,
and return whether a job started. The answers land in the cache the
play gate reads; lsp.dirtyStatus() reports pending == 0 and
running == false once none are left.
modules/lsp/exportDefinitions
exportDefinitions(dir: string): ExportDefinitionsResult
Write the engine's API out for an external editor (VS Code, Neovim, or
any editor running luau-lsp), so it types the engine's
globals: <dir>/zero.d.luau
(the definitions lsp.definitions returns), <dir>/zero.docs.json (the
documentation file naming each global's and member's signature and
description) and <dir>/.luaurc (nonstrict mode). Point luau-lsp at the
first two (its types.definitionFiles and types.documentationFiles
settings) and it types the engine's globals: entity.spawn("x") checks
against its signature and entity.spwan("x") is an unknown member. The
files hold the globals the calling script's globals hold; call it from
the tier whose globals the editor should know. The files land in the
VFS: userfile.save(path) (the Files panel's "Save to this device")
puts each one on the machine of the person at the screen, and over HTTP
the engine's GET /engine/vfs/<path> reads it. The engine's own checker
reads a *.d.luau file the way upstream does, by loading it, so the
files can stay in a world's content. Writing again replaces them.
globals, types and unrepresented are the lists lsp.definitions
returns; the guide topics/external-editor walks through the editor
setup.
Parameters
dirstring— VFS directory to write into, such as/zero/source/editor.
local r = lsp.exportDefinitions("/zero/source/editor")
print(r.files[1], r.bytes, #r.globals)
modules/lsp/getStrictMode
getStrictMode(): StrictMode
Return the current strict mode.
modules/lsp/isStrict
isStrict(): boolean
Is the pre-execute LSP gate fully strict? False when off or in soft mode.
modules/lsp/lastCheckGen
lastCheckGen(): number
Generation counter — bumped each time the cache is rebuilt. UI polls this to know when to redraw.
modules/lsp/methods
methods(namespace: string, opts: MethodsOpts?): { MethodSummary } | { string }
List every documented method / entry under a namespace. A broad
namespace (ui, renderer) returns a large dump by default, so two
options narrow it: opts.filter keeps only methods whose name (or
doc path) contains the substring, case-insensitively; opts.namesOnly
returns a plain list of method-name strings instead of the full
per-method summary tables, which is much smaller and leaves nothing to
unwrap. A name, in either form (a summary's name field or a
namesOnly string), is the member's path below the namespace,
dot-joined (texture.create under renderer, proxy.component.get
under entity), so each one names a single member and
lsp.describe(namespace .. "." .. name) answers for it. The listing
answers with the surface content calls: an entry registered internally
is left out where its signature spells the __ binding or a Luau
module publishes the same member, and opts.includeInternal lists
every registered entry instead.
Parameters
namespacestring— Namespace name (e.g."entity","modules/Transform").optsMethodsOpts?(optional) — Optional{ filter?, namesOnly?, includeInternal? }.
for _, name in ipairs(lsp.methods("ui", { namesOnly = true })) do print(name) end
lsp.methods("renderer", { filter = "shadow" })
modules/lsp/modules
modules(): { ModuleEntry }
List every Luau library module the engine currently knows
about — discovered via --!module headers, library scans, and
manually-recorded docs.
modules/lsp/namespaces
namespaces(opts: NamespacesOpts?): { NamespaceEntry }
List the documentation namespaces reachable from Luau. By
default only namespaces exposing at least one PUBLIC method are
returned, so the list matches what you can actually call — internal
FFI plumbing (e.g. pause, native_entity), whose public surface
lives elsewhere (engine.paused, the entity proxy, …), is left
out. Pass { includeInternal = true } to list every namespace,
internal ones included.
Parameters
optsNamespacesOpts?(optional) — Optional{ includeInternal? }— default lists public only.
for _, ns in ipairs(lsp.namespaces()) do print(ns.name) end
modules/lsp/readDirectives
readDirectives(source: string): DirectiveBlock
Parse the leading --! directive block of a Luau source
string. Used by UIs that audit which files have skip directives
and what they suppress.
Parameters
sourcestring— Luau source text.
modules/lsp/search
search(query: string, opts: SearchOpts?): { MethodSummary }
Case-insensitive substring search across every registered
doc's path, signature, and description. Hits answer with the surface
content calls: an entry registered internally is left out where its
signature spells the __ binding or a Luau module publishes the same
member, and opts.includeInternal searches every registered entry.
Parameters
querystring— Substring to search for.optsSearchOpts?(optional) —{ limit? = 50, includeInternal? }.
modules/lsp/setStrict
setStrict(enabled: boolean): boolean
Toggle the pre-execute LSP gate. Returns true when the change
was persisted to .world_settings, false when the play-mode write
lock blocked the write.
Parameters
enabledboolean— True = strict, false = off.
modules/lsp/setStrictMode
setStrictMode(mode: StrictMode): boolean
Set the pre-execute strict gate's mode. Returns true when the
change was persisted to .world_settings, false when the
play-mode write lock blocked the write.
Parameters
modeStrictMode—"off"|"soft"|"strict".
modules/lsp/summary
summary(): Summary
Counts only — does not re-run validation.
modules/lsp/symbolAt
symbolAt(path: string, line: number, col: number, name: string, chain: string?): SymbolHit?
The identifier name where it stands in path at line:col
(1-based, the file's own columns), with the static type it resolves to
THERE — a local inside a function body, a parameter, a field, a global —
and, for a name a statement in the file introduced, declaredAt = {line, col}. The answer a hover shows and a go-to-definition jumps
to. nil when nothing at that position is a reference to name: a
word in a comment or a string, a keyword.
Parameters
pathstring— VFS path of the file.linenumber— 1-based line.colnumber— 1-based column in the file's own text.namestring— The identifier at that position.chainstring?(optional) — The access path the identifier ends —entity.component.addfor a pointer onadd— which is where its API page is filed.
local hit = lsp.symbolAt("/zero/source/main.luau", 12, 9, "add", "entity.component.add")
modules/lsp/tools
tools(): { ToolEntry }
List every code-mode tool registered in the VFS under
/zero/docs/tools/<category>/<tool>.
modules/lsp/typeOf
typeOf(expr_source: string, context_path: string?): TypeDescriptor
Infer the static type of a Luau expression. When
context_path is given, the file is loaded and walked so the
inference env contains every local + alias in scope at its end.
An expression past the 2 MiB analysis bound answers kind unknown,
and a context file past it adds nothing to the env.
Parameters
expr_sourcestring— Luau expression source (no surrounding chunk).context_pathstring?(optional) — VFS path whose scope should be visible.
local td = lsp.typeOf("Transform.lookAt", "/zero/source/main.luau")
modules/lsp/upstreamCheck
upstreamCheck(path: string, opts: UpstreamCheckOpts?): UpstreamCheck
Type-check a .luau file with upstream Luau's own type checker (its
Frontend), and every module the file requires, and return what upstream
reports as data. What lsp.check, the execute gate and the play gate
report is unchanged by it. Each require literal resolves to the source
file lsp.check's require-unresolved pass holds it to, which is the
file the runtime loads wherever the runtime loads one, in whichever form
it is written (@builtin::a.b, @ns::, @root::, a bare dotted a.b,
.x, ..x, ./x, ../x, ~.x, ~pkg.x, an absolute path, a folder
asset), and
requires lists each literal of the file with the file it reached
(module) and the file the runtime's require loads for it from this
file (runtimeModule), nil where either reaches none.
findings carry upstream's error kind or lint rule, the module they are
in and 1-based positions in that module as written; they cover the file,
and with opts.includeRequired the type errors of every module it
reaches come back as well. Upstream reads every module through its
analysis view: the engine's typed declarations read as the plain Luau
functions they declare, their generic, parameter and return annotations
kept, a return type written after -> read after :, and every line
and column as in the source; view lists where the view of the file
differs from it as { line, col, written, reads }. A module whose
findings come back that upstream cannot parse through its view or past
the 2 MiB analysis bound is listed in notAnalysable with the reason,
and when that is the file itself analysable is false. The checked
modules are kept between calls: checkedModules names the ones this call
type-checked, empty when nothing the file reaches changed, and a write to
a source re-checks that module and the modules depending on it. The
phases of a module's check whose work grows with the types they meet
stop at opts.timeLimitMs, and modules
says of each module the call reached how its check ended ("completed",
"timedOut" or "internal") and how long it took, reused marking one an
earlier call checked that is unchanged since. The modules
held between calls are bounded: once a call returns their sources sum to
at most held.limitBytes, the modules the least recent calls reached
going first, and held and evicted report it. A failure
inside the analysis library comes back as an "internal" finding with
completed false, and the internal errors upstream reports for a
module come back as one "internal" finding whose count says how many. opts.typeCheck = false reads the file and every
module it reaches and resolves their requires without checking types. available is false, with reason, on a build that
does not link the analysis library.
Parameters
pathstring— VFS path of a .luau file, a module identity, or a@scope::path.optsUpstreamCheckOpts?(optional) —{ solver?, mode?, timeLimitMs?, includeRequired?, typeCheck? }.
local r = lsp.upstreamCheck("@builtin::modules.boids", { mode = "strict" })
modules/luau_coverage/README
require("@builtin::modules.api.engine.luau_coverage") -- luau_coverage (also available as global 'luau_coverage')
Luau source-based coverage dump (LCOV + sources manifest). Public Luau surface over the __luau_coverage Internal FFI namespace.
Usage: local luau_coverage = require("@builtin::modules.api.engine.luau_coverage") Also available as global: luau_coverage
modules/luau_coverage/lcov
lcov(): string
Walk every Luau chunk loaded since the VM started (or since
the last reset), collect per-line hit counts via Luau's
built-in coverage API, and render the aggregate as LCOV text.
The report comes back as a string — pair it with vfs.write to
put it in the engine's own filesystem. Writing it to the
machine's filesystem is the trusted VM's call, which the proxy's
luau_coverage_dump tool asks for through
trusted.call("coverage.dump") — a call that names no path and
supplies no bytes (#13107).
vfs.write("/source/tmp/luau.lcov", luau_coverage.lcov())
modules/luau_coverage/level
level(): number
The coverageLevel the Luau compiler was configured with
(1 = statement coverage, 2 = statement + expression). Returns 0
when coverage is off.
if luau_coverage.level() > 0 then ... end
modules/luau_coverage/reset
reset(): boolean
Drop every tracked chunk ref and clear the coverage accumulator. The VM stops reporting hits for previously loaded scripts — use before exercising a specific scenario to isolate its coverage.
luau_coverage.reset()
modules/luau_profile/README
require("@builtin::modules.api.engine.luau_profile") -- luau_profile (also available as global 'luau_profile')
Sampling profiler + manual regions for Luau scripts. Public Luau surface over the __luau_profile Internal FFI namespace.
Usage: local luau_profile = require("@builtin::modules.api.engine.luau_profile") Also available as global: luau_profile
modules/luau_profile/begin
begin(name: string): number
Open a named manual region. Returns an opaque integer id;
pass it back to end_region(id) to close and record elapsed
wall-clock under name.
Parameters
namestring— Region name; aggregated across opens.
local id = luau_profile.begin("walk"); ...; luau_profile.end_region(id)
modules/luau_profile/dump
dump(path: string): DumpResult
TRUSTED ONLY. Write the folded-stack dump to path on the
HOST filesystem, one line per stack as <ticks> <stack_csv> —
the format upstream Luau emits and tools/perfgraph.py
consumes unchanged. A path naming the engine filesystem
(/zero/..., or a bare root such as /source/...) is refused,
and says so: luau_profile.folded() with vfs.write puts the
dump there.
Parameters
pathstring— Absolute host filesystem path to write.
local r = luau_profile.dump("/tmp/profile.folded")
modules/luau_profile/dump_regions
dump_regions(path: string): DumpRegionsResult
TRUSTED ONLY. Write per-region stats to path as JSON, on
the HOST filesystem. A path naming the engine filesystem is
refused, the same way dump refuses one.
Parameters
pathstring— Absolute host filesystem path to write.
luau_profile.dump_regions("/tmp/regions.json")
modules/luau_profile/end_region
end_region(id: number)
Close a region previously opened by begin(name). Records
elapsed wall-clock under the region's name. Silently no-ops on
unknown id (typically a double-close or swapped-out VM).
Parameters
idnumber— Region id returned bybegin().
luau_profile.end_region(id)
modules/luau_profile/folded
folded(): string
The folded-stack dump as a string, one line per stack as
<ticks> <stack_csv> — the format upstream Luau emits and
tools/perfgraph.py consumes unchanged. The same bytes dump
writes, handed back instead of written, so the profile can go
wherever the caller keeps it: vfs.write puts it in the engine
filesystem, where bash and vfs.read reach it.
vfs.write("/source/tmp/sample.folded", luau_profile.folded())
modules/luau_profile/is_running
is_running(): boolean
True iff the background sampler is currently running.
if luau_profile.is_running() then luau_profile.stop() end
modules/luau_profile/reset
reset()
Clear every accumulated sample and region stat. The sampler keeps running if it was already on; only the data is wiped.
luau_profile.reset()
modules/luau_profile/sampling_available
sampling_available(): boolean
True on platforms where the background sampler can run (native targets), false on WASM. Manual regions work everywhere — only the sampler is platform-gated.
if luau_profile.sampling_available() then luau_profile.start() end
modules/luau_profile/snapshot
snapshot(top_n: number?): Snapshot
Snapshot the current accumulator without touching the
filesystem — cheap enough for per-frame UI polling. top_n
truncates stacks to the N hottest entries; omitting it
returns all stacks sorted descending by self_us. regions
is always returned in full (sorted by total_us).
Parameters
top_nnumber?(optional) — Truncate stacks to this many entries; omit for all.
local snap = luau_profile.snapshot(10)
modules/luau_profile/span<T...>
span<T...>(name: string, fn: () -> T..., ...): T...
Call fn(...) inside a manual region named name. The
region is closed even if fn raises (the call goes through
pcall internally). Returns whatever fn returned.
Parameters
namestring— Region name.fn() -> T...— Function to invoke with the trailing varargs.
local r = luau_profile.span("walk", function() return #entity.findAll() end)
modules/luau_profile/start
start(hz: number?): StartResult
Start the background Luau sampling profiler at hz samples
per second (default 1000, clamped to [1, 100000]). Idempotent
— calling while already running is a no-op. Returns
{ available, hz } — available = false on WASM (no
std::thread). Manual regions work regardless.
Parameters
hznumber?(optional) — Sampling rate in Hz.
luau_profile.start(500)
modules/luau_profile/stop
stop()
Stop the background sampler. Blocks until the sampler thread
joins (typically <1ms). Safe when not running. Does not clear
the accumulator — call reset() to drop samples.
luau_profile.stop()
modules/lut/README
require("@builtin::modules.lut") -- lut
Colour lookup tables — the table a lut post-process effect reads. Builds one from a grading description, imports one a colourist exported as a .cube file or a strip image, samples it the way the shader does, and installs it as a .texture asset the effect can bind.
A LUT is an N-entry colour cube: the answer to "what does this colour
become" stored for N^3 input colours, with everything in between read by
trilinear interpolation. A grade of any complexity therefore costs the
same eight texel reads, which is why colourists deliver a look as a table
rather than as a chain of operations.
The engine stores a cube as a STRIP: N square tiles in one row, so the
image measures N*N wide by N tall. Tile b holds the plane of
constant blue index, red runs across a tile and green runs down it. The
lut post shader reads N from the image's own height, so one shader
serves a 16-, 32- or 64-entry cube with nothing to configure.
Apply one through the post chain:
local lut = require("@builtin::modules.lut")
local ref = lut.install("warm_evening", lut.fromGrade({
exposure = 0.3, temperature = 0.25, saturation = 1.1,
}))
tools.use("pp", "add", "lut", "lut", { texture = ref.guid, amount = 1.0 })
A lut effect with no table bound passes the frame through untouched, so
adding the effect before its table exists changes nothing.
Usage: local lut = require("@builtin::modules.lut")
modules/lut/build
build(size: number, fn: (number, number, number) -> (number, number, number)): Lut
Build a table by asking fn what each of its N^3 lattice colours
becomes. The input is the lattice colour in 0..1, and so is the answer,
which is clamped to that range and stored as it stands.
Parameters
sizenumber— Cube edge — how many entries each axis holds. 2..90.fn(number, number, number) -> (number, number, number)—(r, g, b) -> r, g, b, called once per lattice entry.
local invert = lut.build(16, function(r, g, b) return 1 - r, 1 - g, 1 - b end)
modules/lut/fromCube
fromCube(text: string): Lut
Read a table out of .cube text — the interchange format DaVinci
Resolve, Photoshop and every other grading tool writes. LUT_3D_SIZE
gives the cube edge and the rows that follow are its entries with red
varying fastest, which is the order this reader expects. The table is
addressed over 0..1, so a file declaring any other DOMAIN_MIN /
DOMAIN_MAX is refused by name rather than read as if it were.
Parameters
textstring— The file's contents.
local look = lut.fromCube(vfs.read("/source/looks/kodak2383.cube"))
modules/lut/fromGrade
fromGrade(spec: GradeSpec?, size: number?): Lut
Bake a grade into a table. The same look as calling lut.grade's
function per pixel, at the cost of eight texel reads however involved the
grade is.
Parameters
specGradeSpec?(optional) — What the grade does — seeGradeSpec.sizenumber?(optional) — Cube edge. Defaults to 16.
local look = lut.fromGrade({ contrast = 1.2, saturation = 0.85, lift = { 0.02, 0.02, 0.05 } })
modules/lut/fromImage
fromImage(bytes: buffer | string): Lut
Read a table out of a strip image laid out as N*N by N — what a
grading tool exports as a "2D LUT". Takes either source image bytes (PNG,
JPEG, WebP) or the .texture blob lut.install wrote, so a table can be
read back out of the asset it was installed as.
Parameters
bytesbuffer | string— The encoded image, or a.textureblob.
local look = lut.fromImage(assert(vfs.read("/source/looks/teal_orange.png")))
modules/lut/grade
grade(spec: GradeSpec?): (number, number, number) -> (number, number, number)
The colour transform a GradeSpec describes, as a plain function.
Useful on its own — to grade a single colour, to compose two looks, or to
hand to lut.build — and it is what lut.fromGrade bakes.
Parameters
specGradeSpec?(optional) — What the grade does. Every field is optional.
Returns (number, number, number) — (r, g, b) -> r, g, b over 0..1.
local warm = lut.grade({ temperature = 0.3 }); local r, g, b = warm(0.5, 0.5, 0.5)
modules/lut/identity
identity(size: number?): Lut
The table that changes nothing — every entry answers with the colour that indexed it. The starting point for a hand-authored look, and the control an A/B measures against.
Parameters
sizenumber?(optional) — Cube edge. Defaults to 16.
local base = lut.identity(32)
modules/lut/install
install(name: string, table_: Lut, opts: { [string]: any }?): any
Write the table as a .texture asset the lut post effect can bind,
and upload it to the GPU under that asset's own guid. Stored as a float
raster, unfiltered and with no mip chain: a table's entries are addresses,
so they reach the shader as they were written, with no transfer function
between and no mip average to land on a colour the table holds nowhere.
The upload is what makes the returned guid bindable from the next frame,
and what puts a re-baked look in front of the camera under the name it
already had.
Parameters
namestring— The asset's name.table_Lut— TheLutto write.opts{ [string]: any }?(optional) —{ dest = "<vfs path>", folder = "<vfs folder>", overwrite = true }— placement, forwarded toasset.create.overwritedefaults to true, so installing under a name that exists rewrites that asset and keeps its guid.
local ref = lut.install("dusk", lut.fromGrade({ temperature = -0.2 }))
modules/lut/sample
sample(table_: Lut, r: number, g: number, b: number): (number, number, number)
What the table answers for a colour — the same trilinear read the shader performs, so a table can be checked without rendering a frame.
Parameters
table_Lut— TheLutto read.rnumber— Red, 0..1. Values outside are clamped, as they are on the GPU.gnumber— Green, 0..1.bnumber— Blue, 0..1.
local r, g, b = lut.sample(look, 0.5, 0.5, 0.5)
modules/lut/strip
strip(table_: Lut): ({ number }, number, number)
The table's strip raster — the channel values, its width and its
height. What renderer.texture.encode and asset.create("texture", ...)
take at rgba32f.
Parameters
table_Lut— TheLutto read.
local px, w, h = lut.strip(look); print(w, h)
modules/lut/toCube
toCube(table_: Lut, title: string?): string
Write a table out as .cube text, so a look built here can be opened
in a grading tool or handed to another pipeline.
Parameters
table_Lut— TheLutto write.titlestring?(optional) — What the file calls itself. Defaults to "zero".
vfs.write("/source/looks/mine.cube", lut.toCube(look, "mine"))
modules/materialGraph/README
require("@builtin::systems.materialGraph.materialGraph") -- materialGraph
Usage: local materialGraph = require("@builtin::systems.materialGraph.materialGraph")
modules/materialGraph/check
check(graph: Graph): (boolean, any)
Compile a graph without raising. The same work compile does, with the
error handed back rather than thrown — what an editor wants while the
author is still typing.
Parameters
graphGraph— The graph to check.
local ok, result = materialGraph.check(graph)
modules/materialGraph/compile
compile(graph: Graph, name: string?): Compiled
Compile a graph into the two files a .shader asset holds. Pure text
generation: it touches no asset, no renderer and no GPU, so a graph can be
checked, compared and tested with nothing installed.
Parameters
graphGraph— The graph —nodes,surface, and optionallyname+properties.namestring?(optional) — Overridesgraph.namefor the shader this compiles to.
local out = materialGraph.compile(graph)
print(out.wgsl)
modules/materialGraph/install
install(graph: Graph, opts: { name: string?, into: any? }?): Installed
Compile a graph and write it out as a real .shader asset. The result
is an ordinary shader asset — nothing keeps a link back to the graph, so it
can be read, hand-edited and shipped like any other. Installing the same
graph again rewrites the same asset. The shader itself is compiled at the
next frame boundary, the way any shader edit is;
asset.ref(name, "shader"):compileStatus() is what reports the outcome.
Parameters
graphGraph— The graph to install.opts{ name: string?, into: any? }?(optional) —{ name = <shader name>, into = { path = <folder> } }.intoplaces the asset as it is created; installing again writes wherever it already is, and anintonaming somewhere else is refused rather than ignored.
local shader = materialGraph.install(graph, { name = "rusty_metal" })
local status = asset.ref(shader.name, "shader"):compileStatus()
modules/materialGraph/material
material(graph: Graph, opts: { name: string?, shader: string?, into: any?, values: any? }?): string
Install a graph and make a material wearing the shader it compiled to.
The material is an ordinary material asset: hand it to a Model's material
field, or edit its values afterwards like any other. Calling it again with
the same material name is how an author iterates: the shader is rewritten
from the graph, the material is brought onto that shader's property list,
and values is applied over it — so what the call says is what the
material holds when it returns.
Parameters
graphGraph— The graph to install.opts{ name: string?, shader: string?, into: any?, values: any? }?(optional) —{ name = <material name>, shader = <shader name>, into = ..., values = { <property> = <value> } }.
local mat = materialGraph.material(graph, { name = "rusty", values = { wear = 0.8 } })
modules/materialGraph/nodeTypes
nodeTypes(): { [string]: { ports: { string }, required: { string }, result: string, doc: string } }
Every node operation this compiler knows: the inputs a node of that op is written with, which of them it cannot be written without, the type it produces and a line on what it does. A graph written from this listing compiles.
for op, info in pairs(materialGraph.nodeTypes()) do print(op, info.doc) end
print(table.concat(materialGraph.nodeTypes().sampleTexture.required, ", "))
modules/materialGraph/surfaceChannels
surfaceChannels(): { [string]: { field: string, ty: string } }
The channels the surface terminal accepts, and the shading-model field
each one drives.
print(materialGraph.surfaceChannels().roughness.field)
modules/mathx/README
require("@builtin::modules.api.engine.mathx") -- mathx (also available as global 'mathx')
Batch math kernels over buffer slices (damp, lerp/slerp, transform). Public Luau surface over the __mathx Internal FFI namespace.
Usage: local mathx = require("@builtin::modules.api.engine.mathx") Also available as global: mathx
modules/mathx/addScaledVec3
addScaledVec3(dstBuffer: Substrate.TypedBuffer, srcBuffer: Substrate.TypedBuffer,
dst[i] += src[i] * scale for count vec3 elements. Both
buffers must hold at least count * 3 floats. Useful for
particle integration (position += velocity * dt) and accumulator
passes.
mathx.addScaledVec3(positions, velocities, n, dt)
modules/mathx/dampScalar
dampScalar(buffer: Substrate.TypedBuffer, offset: number, count: number,
Critically-damped exponential approach toward target for
count scalars at buffer[offset .. offset+count]. smoothTime
is the time constant (~ 0.16 ⇒ ~63% per frame at 60 Hz). Pass
smoothTime <= 0 to snap to the target.
mathx.dampScalar(buf, 0, 16, 0.0, 0.16, dt)
modules/mathx/lerpVec3
lerpVec3(buffer: Substrate.TypedBuffer, offset: number, count: number,
Element-wise linear blend of count vec3s in
buffer[offset .. offset+count*3] toward (tx, ty, tz) by t.
mathx.lerpVec3(buf, 0, n, 0, 1, 0, 0.5)
modules/mathx/normalizeQuat
normalizeQuat(buffer: Substrate.TypedBuffer, offset: number, count: number): boolean
Re-normalise count quaternions in place. Zero-length quats
become identity (0, 0, 0, 1) so downstream code never sees NaN.
Parameters
bufferSubstrate.TypedBuffer— The buffer to operate on.offsetnumber— Starting f32 index.countnumber— Number of quaternions.
mathx.normalizeQuat(buf, 0, n)
modules/mathx/slerpQuat
slerpQuat(buffer: Substrate.TypedBuffer, offset: number, count: number,
Slerp count quaternions (xyzw) at buffer[offset..] toward
(tx, ty, tz, tw) by t. Falls back to nlerp+normalize for
very-close quats. Always picks the shortest-arc path.
mathx.slerpQuat(buf, 0, n, 0, 0, 0, 1, 0.25)
modules/mathx/transformVec3
transformVec3(buffer: Substrate.TypedBuffer, offset: number,
Treat each vec3 in buffer[offset..] as a position (w = 1),
multiply by the 4x4 column-major matrix mat16 (16-element
array), write .xyz of the result back. Layout matches glam,
wgpu, and GLSL conventions.
mathx.transformVec3(positions, 0, n, worldMatrix)
modules/mcpLog/README
require("@builtin::modules.api.engine.mcpLog") -- mcpLog (also available as global 'mcpLog')
Read-only MCP tool-call log ring buffer. Public Luau surface over the __mcpLog Internal FFI namespace.
Usage: local mcpLog = require("@builtin::modules.api.engine.mcpLog") Also available as global: mcpLog
modules/mcpLog/clear
clear(): boolean
Clear all entries from the engine's MCP log ring buffer.
mcpLog.clear()
modules/mcpLog/query
query(limit: number?): { McpLogEntry }
Return the most-recent MCP tool-call entries from the engine's
MCP log ring buffer (newest last). Pass limit to cap how many
entries are returned — omit for the full ring (up to 500 entries).
Parameters
limitnumber?(optional) — Maximum number of entries to return.
for _, e in ipairs(mcpLog.query(50)) do print(e.tool_name, e.status) end
modules/mediaTransmittance/README
require("@builtin::systems.volumetrics.mediaTransmittance") -- mediaTransmittance
Light attenuation through participating media, in a form both media and surfaces can sample. A fog bank dims what is behind it, and overlapping volumes stack.
Usage: local mediaTransmittance = require("@builtin::systems.volumetrics.mediaTransmittance")
modules/mediaTransmittance/active
active(): boolean
Whether the transmittance passes are running this frame.
if mediaTransmittance.active() then ... end
modules/mediaTransmittance/buffers
buffers(): { [string]: any }?
The buffer(s) this system's passes read. A pass binds what this hands it, so it has the values this module packed.
local b = mediaTransmittance.buffers()
modules/mediaTransmittance/clear
clear()
Remove every medium and release the passes. The settings are kept.
mediaTransmittance.clear()
modules/mediaTransmittance/get
get(): State
The transmittance settings currently in force.
local s = mediaTransmittance.get().strength
modules/mediaTransmittance/removeMedium
removeMedium(key: string): number
Remove a registered medium.
Parameters
keystring— The id it was registered under.
mediaTransmittance.removeMedium("bank")
modules/mediaTransmittance/set
set(opts: TransmittanceOpts?): State
Set the scene-wide transmittance settings. Any omitted field keeps its current value.
Parameters
optsTransmittanceOpts?(optional) — Settings — seeTransmittanceOpts.
mediaTransmittance.set({ sunDirection = { 0.4, 0.8, 0.2 }, steps = 32 })
modules/mediaTransmittance/setMedium
setMedium(key: string, opts: MediumOpts): number
Register (or move) a medium. Pushing the same key again replaces it.
Parameters
keystring— A stable id for this medium.optsMediumOpts— Placement and density — seeMediumOpts.
mediaTransmittance.setMedium("bank", { position = { 0, 8, 0 }, size = { 20, 6, 20 }, density = 0.12 })
modules/microphone/README
require("@builtin::modules.api.engine.microphone") -- microphone (also available as global 'microphone')
Capture from an input device and read what is arriving: a loudness, a magnitude spectrum, and the raw PCM. Public Luau surface over the __microphone Internal FFI namespace.
Usage: local microphone = require("@builtin::modules.api.engine.microphone") Also available as global: microphone
modules/microphone/awaitRunning
awaitRunning(timeout: number?): (MicState, string?)
Wait until the capture settles out of starting and
permissionPending, and report where it landed. Returns as soon as the
state settles, or when timeout seconds have passed, whichever comes
first — a browser permission prompt nobody answers never settles, so
the wait is always bounded.
Parameters
timeoutnumber?(optional) — Seconds to wait at most. Defaults to 10.
microphone.start(); local state, why = microphone.awaitRunning()
modules/microphone/devices
devices(): { MicDevice }
Every input device the platform offers. id is what
microphone.start takes to select one and is stable across reboots
where the platform provides a stable identifier; name is the label a
person recognises.
An empty list is a legitimate answer, not a failure: a machine with no input hardware offers none, and a browser names none until microphone access has been granted at least once — the labels are part of what the permission protects.
for _, d in ipairs(microphone.devices()) do print(d.name, d.default) end
modules/microphone/frequencies
frequencies(): { number }
The frequency each spectrum bin is centred on, in Hz, as an array
parallel to microphone.spectrum(). Derived from the capture's rate and
transform size, so it changes only when a capture is started with
different ones. Empty while no capture is running.
local hz = microphone.frequencies(); print(hz[#hz]) -- the Nyquist frequency
modules/microphone/level
level(): number
Loudness of the most recent analysis window, as an RMS amplitude in 0..1. A full-scale sine reads about 0.707 and silence reads 0.
Measured over only the samples that have arrived, so a capture that has just started reports the loudness of what it holds rather than a level diluted by a window it has not filled yet. 0 while no capture is running.
if microphone.level() > 0.05 then print("someone is talking") end
modules/microphone/peak
peak(): { [string]: number }?
The bin carrying the most energy and what it says: the frequency it is centred on, its amplitude, and the loudness of the whole window. A capture reading silence answers with amplitude 0 at bin 1.
local p = microphone.peak(); if p and p.amplitude > 0.05 then print(p.hz) end
modules/microphone/samples
samples(max: number?): buffer?
Captured mono PCM no caller has taken yet, oldest sample first, as a
buffer of little-endian f32 read with buffer.readf32. The samples are
removed, so successive calls walk forward through the capture and a
caller doing its own analysis sees every frame once.
nil while no capture is running, and a zero-length buffer when the
capture is running and nothing new has arrived. Samples nobody takes
are discarded once the queue fills, and status().overruns counts
every one.
Parameters
maxnumber?(optional) — How many samples to take at most. Omitted, everything held comes back.
local pcm = microphone.samples(); if pcm then print(buffer.len(pcm) // 4) end
modules/microphone/spectrum
spectrum(): { number }
Amplitude per frequency bin over the most recent analysis window:
fftSize / 2 + 1 numbers, DC at index 1 through the Nyquist frequency
at the last. Bin i covers (i - 1) * status().binHz Hz.
Each value is an amplitude estimate rather than a raw transform magnitude, so a full-scale tone sitting on a bin centre reads about 1.0 and the numbers stay comparable across transform sizes.
The window is multiplied by a Hann taper before the transform. An untapered window ends abruptly at both edges and the transform reads that as energy spread across every bin, smearing one tone into a skirt that buries quieter tones beside it. Hann trades a slightly wider main lobe — a tone occupies about three bins rather than one — for sidelobes that fall away steeply, which is what lets neighbouring tones be told apart. Read a peak as "a tone near here", not "a tone exactly here".
Reading this takes no samples away from microphone.samples(). Empty
while no capture is running.
local bins = microphone.spectrum(); print(#bins, bins[1])
modules/microphone/start
start(opts: MicOpts?): (MicState?, string?)
Open an input device and begin capturing. Returns the state the
capture reached — "running" once a device is delivering, or
"permissionPending" where the platform must ask for access first,
which is the browser's normal path. Poll microphone.status() from
there, or use microphone.awaitRunning(). Where access is refused
without asking (a native engine's fake microphone presented as deny),
it returns "denied".
A request that cannot be made at all returns nil and the reason: an
fftSize that is not a whole power of two between 64 and 16384, a
device no machine here offers, a rate the device does not capture at,
or a capture that is already running.
Omitting device opens the platform default. Omitting sampleRate
takes the device's own rate, which is what avoids a resample.
fftSize is how many samples one analysis window covers and defaults
to 1024 — at 48 kHz that spans ~21 ms and resolves ~47 Hz per bin.
Parameters
optsMicOpts?(optional) —{ device, sampleRate, fftSize }.
local state, why = microphone.start({ fftSize = 2048 })
modules/microphone/status
status(): MicStatus
Where the capture stands.
reason carries the platform's own message: the refusal for denied,
the device's message for failed, what is being waited on for
permissionPending. binHz is the width of one spectrum bin and
bins how many microphone.spectrum() returns.
framesCaptured counts every mono frame the device delivered whether
or not anything drained it, so a silent room reads differently from a
stalled device. overruns counts samples discarded because a consumer
did not keep up — it standing still is what says the readings are
continuous, and it climbing is why a caller sees gaps.
local s = microphone.status(); print(s.state, s.framesCaptured, s.overruns)
modules/microphone/stop
stop(): boolean
Stop the capture and release the device. True when a capture was open or being opened at call time. The device is let go before this returns, so a stop followed by a start opens it again rather than finding it held.
microphone.stop()
modules/modelImport/README
require("@builtin::modules.api.engine.modelImport") -- modelImport (also available as global 'modelImport')
The model-import pipeline: decompose any assimp-supported 3D model (fbx, obj, dae, gltf, glb, stl, ply, 3ds, …) into meshes, materials, textures, animation clips and a node graph; extract a single clip to its .zanim payload; and derive a .rig from a skinned mesh or from an animation-only file's driven skeleton. Public Luau surface over the __model and __rig Internal FFI namespaces.
Usage: local modelImport = require("@builtin::modules.api.engine.modelImport") Also available as global: modelImport
modules/modelImport/decompose
decompose(bytes: buffer | string, format: string): PromiseHandle
Parse raw model bytes on a background thread. format is the real source
extension ("fbx", "obj", "dae", "gltf", "glb", "stl", "ply",
"3ds", …), forwarded to assimp as the format hint. Returns a promise
handle: task.await it, then read the data with result(handle).
Parameters
bytesbuffer | string— Raw model file bytes (fromvfs.readAsync).formatstring— The source file extension (lowercase, no dot).
local h = modelImport.decompose(bytes, "obj"); task.await(h)
modules/modelImport/decomposeFiles
decomposeFiles(files: { ModelFile }, mainName: string): PromiseHandle
Parse a model plus its companion files on a background thread, so assimp
resolves the model's external references (a .gltf's external .bin and
image files, an .obj's .mtl colors/textures, MD5's .md5anim, …).
files is an array of { name = basename, bytes = <bytes> } that MUST
include the model file itself; mainName is that file's basename. Returns a
promise handle: task.await it, then read the data with result(handle) —
the same shape decompose produces.
Parameters
files{ ModelFile }— Array of{ name, bytes }: the model file plus its companions.mainNamestring— Basename of the model file to import (one offiles' names).
local h = modelImport.decomposeFiles(files, "CesiumMilkTruck.gltf"); task.await(h)
modules/modelImport/extractAnimation
extractAnimation(sourcePath: string, clipName: string): PromiseHandle
Read a model source file and extract one animation clip to its .zanim
payload, stashed for retrieval. The source extension decides the parser, so
this is format-agnostic. Returns a promise handle: task.await it, then
extractAnimationResult(handle) returns the bytes.
Parameters
sourcePathstring— VFS path to the source model file.clipNamestring— Clip name as returned byresult(handle).animations[i].name.
modules/modelImport/extractAnimationResult
extractAnimationResult(handle: PromiseHandle | string): string?
After awaiting an extractAnimation handle, return the extracted
.zanim bytes (binary-safe), consuming them. The bytes to hand to
asset.create("animation", name, { bytes }). Returns nil on failure or if
already taken.
Parameters
handlePromiseHandle | string— Promise handle fromextractAnimation.
modules/modelImport/isHandle
isHandle(handle: any): boolean
Call makeHandle, which returns a promise handle (or its id string), or a falsy
value on a transient failure (e.g. a source read that raced a pending
write during a parallel import), up to retries + 1 times, yielding via
yield between attempts so a pending write can land before the next try.
Returns the handle once one is produced, or nil when every attempt
failed. Callers task.await the result only when it is non-nil, so a
transient miss never reaches task.await as something other than a handle.
Parameters
handleany(optional)
modules/modelImport/result
result(handle: PromiseHandle | string): any?
Read the decomposed model after decompose's handle has been awaited.
Every format decomposes into the same shape, so this is format-agnostic.
Runs on the main thread; consumes the stored result.
Parameters
handlePromiseHandle | string— Promise handle fromdecompose.
modules/modelImport/retryHandle
retryHandle(makeHandle: () -> any, retries: number?, yield: (() -> ())?): (PromiseHandle | string)?
Parameters
makeHandle() -> anyretriesnumber?(optional)yield(() -> ())?(optional)
modules/modelImport/rigFromMeshSkin
rigFromMeshSkin(meshBytes: buffer | string): string?
Lift the skeleton out of a skinned .mesh (ZMSH) payload and return it
as a .rig JSON document: bones (hierarchy, rest pose, inverse-bind). The
source rig a skinned mesh's clips retarget through. Returns nil when the
bytes are not a mesh or carry no skin.
Parameters
meshBytesbuffer | string— Raw ZMSH mesh bytes carrying a skin.
modules/modelImport/rigFromSkeleton
rigFromSkeleton(skeleton: AnimationSkeleton): string?
Build a .rig JSON document from the skeleton an animation-only file was
authored on — result(handle).skeleton, the bones its clips drive with
their local rest transforms. Forward kinematics over the locals resolves
globals + inverse-bind. The source rig a standalone clip retargets through.
Returns nil on malformed input.
Parameters
skeletonAnimationSkeleton—{ names, parents, locals }(adecomposeresult'sskeleton).
local rigJson = modelImport.rigFromSkeleton(data.skeleton)
modules/motionBlur/README
require("@builtin::systems.motionBlur.motionBlur") -- motionBlur
Camera-shutter motion blur. Blur length comes from a shutter angle, and the reconstruction lets a moving object smear past its own silhouette instead of stopping dead at its edge.
Usage: local motionBlur = require("@builtin::systems.motionBlur.motionBlur")
modules/motionBlur/active
active(): boolean
Whether the motion-blur passes are running this frame.
if motionBlur.active() then ... end
modules/motionBlur/buffers
buffers(): { [string]: any }?
The parameter buffer the motion-blur passes read, carrying the settings this module packs. The render feature binds what this hands it.
local b = motionBlur.buffers()
modules/motionBlur/clear
clear()
Close the shutter and release the passes. The other settings are kept,
so a later set({ shutterAngle = ... }) brings back the same look.
motionBlur.clear()
modules/motionBlur/get
get(): MotionBlurState
The shutter settings currently in force.
local a = motionBlur.get().shutterAngle
modules/motionBlur/set
set(opts: MotionBlurOpts?): MotionBlurState
Set the camera's shutter. Any omitted field keeps its current value. A
shutterAngle of 0 closes the shutter and releases the passes.
Parameters
optsMotionBlurOpts?(optional) — Shutter settings — seeMotionBlurOpts.
motionBlur.set({ shutterAngle = 180, samples = 16 })
modules/multiplayer/README
require("@builtin::modules.api.engine.multiplayer") -- multiplayer (also available as global 'multiplayer')
Multiplayer sync state and operations — connection, peers, ownership, rooms, undo/redo. Public Luau surface over the __multiplayer Internal FFI namespace.
Usage: local multiplayer = require("@builtin::modules.api.engine.multiplayer") Also available as global: multiplayer
modules/multiplayer/beginOperation
beginOperation(description: string)
Begin recording an undoable operation. All mutations until
commitOperation() are grouped into one undo entry.
Parameters
descriptionstring— Human-readable label.
multiplayer.beginOperation("move cube")
modules/multiplayer/canRedo
canRedo(): boolean
Check if this client has any redoable operations.
modules/multiplayer/canUndo
canUndo(): boolean
Check if this client has any undoable operations.
modules/multiplayer/cancelOperation
cancelOperation()
Cancel the current operation and restore all properties to their values at begin time.
multiplayer.cancelOperation()
modules/multiplayer/claimOwnership
claimOwnership(entityId: (string | entityRef)?): boolean
Request ownership of an entity. The relay grants a claim on
an entity no peer owns (never claimed, or released by its owner)
and tells every peer; an entity another peer owns stays theirs, and
the refusal is counted in getDiagnostics().refusals and named by
lastRefusal. The owner hands an entity on by releasing it.
Parameters
entityId(string | entityRef)?(optional) — Entity id or proxy to claim.
modules/multiplayer/clearHistory
clearHistory()
Drop this client's whole undo/redo history — for boundaries where old edits stop being meaningful (a scene load, a test rig reset).
multiplayer.clearHistory()
modules/multiplayer/commitOperation
commitOperation()
Finalize the current operation and push it onto the undo stack. Only changes that actually differ from the start state are recorded.
multiplayer.commitOperation()
modules/multiplayer/connect
connect(relayUrl: string)
Connect to a multiplayer relay server for the current world.
Uses the loaded world's world_id as the room prefix for scene
isolation. A world must be loaded before connecting.
Parameters
relayUrlstring— Relay server URL.
multiplayer.connect("https://relay.example.com")
modules/multiplayer/disconnect
disconnect()
Disconnect from the multiplayer relay server.
multiplayer.disconnect()
modules/multiplayer/explain
explain(
Why a synced property is not reaching the peers this client shares its entity's room with. Answers from the engine's own registry, so a name the component never registered is reported as such instead of inferred from a second client's silence.
local v = multiplayer.explain(player, "Health", "hp")
if not v.arriving then print(v.reason) end
modules/multiplayer/getDiagnostics
getDiagnostics(): SyncDiagnostics
Get sync diagnostics — traffic counts, bandwidth, link quality,
peer count. The counts — bytesSent/Received,
datagramsSent/Received, rpcsSent/Received, ownershipChanges,
refusals — are running totals for the session, so a sparse event
stays readable long after it happened; subtract two samples for the
rate over the interval between them. refusals counts the messages
of this session's the relay refused (a claim on an entity another
peer owns, a change to one, a room outside the world the connection
was admitted to), and lastRefusal names the latest in the relay's
words once there is one. bytesSentPerSec / bytesReceivedPerSec are
averages over the last completed ~1 second window.
rttMs is the smoothed round-trip time to the relay and
packetLoss the fraction (0..1) of packets lost over the last 5
seconds; both read 0 until the transport has sampled a live
connection. messagesAwaitingEntity counts the sync messages this
peer is holding for an entity it has not received yet — each waits
for the spawn that names it, applies the moment it arrives, and is
released once its wait runs out. reliableInFlight counts the
reliable messages this peer has sent that the relay has not yet taken:
it reads near 0 while the link keeps up with what this peer sends, and
a count that grows names a link carrying less than that, every
reliable change sent behind it (a Sync field, a spawn) waiting with it.
local d = multiplayer.getDiagnostics()
if d.packetLoss > 0.05 then log.warn(("unstable connection, %d ms round trip"):format(d.rttMs)) end
print(d.messagesAwaitingEntity .. " message(s) waiting for their entity")
modules/multiplayer/getPeerId
getPeerId(): number?
Get the peer ID the relay issued this client's connection.
modules/multiplayer/getPeers
getPeers(): { PeerInfo }
Get a list of all connected peers in the current session.
for _, p in ipairs(multiplayer.getPeers()) do print(p.name) end
modules/multiplayer/getRoomPeers
getRoomPeers(roomKey: string): { PeerInfo }
Get the peers this client shares the given room with, ordered by
peer id. getPeers answers for the whole session — the union of every
room this client is in — while this answers for one room, so a peer
that leaves this room while staying in another disappears from here
and remains in getPeers.
Parameters
roomKeystring— Fully-qualified room key ({worldGuid}/{profile}/{mode}/{sceneGuid}).
for _, p in ipairs(multiplayer.getRoomPeers(key)) do print(p.id) end
modules/multiplayer/getRooms
getRooms(): { string }
The relay rooms this client has joined, sorted. A broadcast reaches
only the peers that share one of these. They are the rooms of
observe() as of the last frame, read from the rooms the session
publishes every frame, so a component can ask every frame.
for _, key in ipairs(multiplayer.getRooms()) do print(key) end
modules/multiplayer/getTickRate
getTickRate(): number
Get the current sync tick rate (network updates per second).
modules/multiplayer/heldMessages
heldMessages(): { HeldMessage }
The sync messages this peer is holding for entities it has not
received — what getDiagnostics().messagesAwaitingEntity counts, one
entry each, with the entity sync id it names, its age and the grace it
is held against.
for _, m in ipairs(multiplayer.heldMessages()) do print(m.kind, m.ageMs) end
modules/multiplayer/isConnected
isConnected(): boolean
Check if a multiplayer session is connected to a relay and the
relay has named this client. True exactly when getPeerId() answers
an id.
modules/multiplayer/isHost
isHost(): boolean
Whether THIS client is the host (authoritative owner) of the
current scene's play room — the relay room CREATOR, or offline /
single-player. Host code spawns the shared synced world (via
entity.spawnSynced or a scene's onHostLoad) and runs authoritative
simulation; a non-host (JOINER) receives that content from the relay
snapshot and must NOT re-create it. Gate ANY code that spawns synced
entities or owns shared state with this so it runs on exactly one
client — running it on every peer is the double-spawn 'explosion'.
if multiplayer.isHost() then enemy = entity.spawnSynced("enemy") end
modules/multiplayer/isOperationOpen
isOperationOpen(): boolean
Whether an operation is open: true between beginOperation and
its commitOperation or cancelOperation. A caller that records file
writes reads the file's prior contents only while one is open.
if multiplayer.isOperationOpen() then before = vfs.read(p) end
modules/multiplayer/isOwner
isOwner(entityId: (string | entityRef)?): boolean
Check if the local client owns the given entity (or the current entity if called from a component). Only the owner can modify synced properties directly.
Parameters
entityId(string | entityRef)?(optional) — Entity id or proxy to check (defaults toself.entityIdin component context).
modules/multiplayer/isRoomCreator
isRoomCreator(roomKey: string): boolean?
Whether this client created the given room — it was the FIRST peer to join it (race-free; the relay assigns it on join). In play mode the creator instantiates the scene's entities (synced) and every other joiner receives them from the relay snapshot, so the scene is never double-instantiated.
Parameters
roomKeystring— Fully-qualified room key ({worldGuid}/{profile}/{mode}/{sceneGuid}).
if multiplayer.isRoomCreator(key) ~= false then layers.load(scene) end
modules/multiplayer/joinRoom
joinRoom(roomKey: string)
Join a relay room. Room keys are built as
{worldGuid}/{profile}/{mode}/{sceneGuid} — four segments, the
{profile} one keeping a runtime peer (published content) and an
editor peer (live content) in separate rooms even when both are in
play mode. Rooms partition the relay's fan-out: only peers in the
same room receive each other's broadcasts. getRooms() reports the
keys this client is already in and roomFor(entity) the one an
entity broadcasts into, so a key can be read rather than rebuilt.
A relay that verifies its peers holds each connection to the world
it was admitted to: a key whose first segment names another world
is refused, and getDiagnostics().refusals counts the refusal and
lastRefusal names it. No-op when not connected or already joined.
Parameters
roomKeystring— Fully-qualified room key.
multiplayer.joinRoom(worldGuid .. "/" .. engine.profile .. "/play/" .. sceneGuid)
modules/multiplayer/leaveRoom
leaveRoom(roomKey: string)
Leave a relay room. The key is reported under
observe().withdrawnRooms until joinRoom names it again. No-op
when not connected or not joined.
Parameters
roomKeystring— Fully-qualified room key.
modules/multiplayer/loopback
loopback(): { [string]: any }
Loopback testing harness. Returns a table with enable(),
disable(), flush(), receive() methods for testing sync
without a relay server.
modules/multiplayer/observe
observe(): ReplicationObservation
Report what this peer is replicating and why a property is not
arriving. Carries the rooms this client joined, one record per entity
with a sync id — its owner, the room it broadcasts into, how many
other peers share that room, and every REGISTERED synced component
with its declared property names, wire indices, public/private table
and dirty bits — the messages held for entities that have not arrived,
and the registry's totals. Every property carries notArriving: one
name from reasons, or nil when it is on its way. Answers in edit
mode as well as play mode, for what the relay carries in each: in
edit mode scene content is left out of the sync-id pass, so its
changes travel to the other clients with the source they are
written into and it reads entityNotSynced here. The document
describes the session as of the last frame: when no frame has
assembled one since the surface was last read, the call waits for the
next frame to assemble it, and a caller that cannot yield receives the
one published last.
local o = multiplayer.observe()
print(#o.entities .. " entities, " .. o.totals.properties .. " synced properties")
modules/multiplayer/observeComponent
observeComponent(
The registered synced component of the named type on an entity's
record. Matches a fully-qualified type (@builtin::components.Model)
and the leaf name it ends in (Model) alike.
local c = multiplayer.observeComponent(player, "Health")
print(#c.properties .. " declared properties")
modules/multiplayer/observeEntity
observeEntity(entityId: (string | entityRef)): EntityReplication?
The replication record for one entity — its sync id, owner, room, and the synced components registered on it.
Parameters
entityId(string | entityRef)— Entity id or proxy.
local r = multiplayer.observeEntity(e)
for _, c in ipairs(r.components) do print(c.componentType) end
modules/multiplayer/on
on(channel: string, callback: (number, ...any) -> ())
Subscribe to a custom message channel. The callback runs as
callback(fromPeerId, ...args) whenever another peer calls
multiplayer.send(channel, ...). Multiple callbacks per channel fire
in registration order.
Parameters
channelstring— Channel name to listen on.callback(number, ...any) -> ()—function(fromPeerId: number, ...)— the sender's peer id then the sent args.
modules/multiplayer/recordFileWrite
recordFileWrite(path: string, before: string?, after: string?): boolean
Record a file write into the open operation. Undoing the
operation writes before back through the VFS (removing the file when
before is nil), which runs the owning asset type's onChange as the
original write did; redoing writes after. The path is resolved and held
to the rules vfs.write applies, so a sidecar (.meta, .refs), an
install's own entry or an asset root no script may write raises. A step's files
are put back all together or not at all: each file is checked (its asset
exists, and it holds what the step being reversed left in it) before any
is written and again immediately before it is written; when a check or a
write fails partway, the files the step already wrote go back to what
they held, and a notice names each file of the step and what happened to
it. Several writes of one path in an
operation undo to the first before. Records nothing and returns false
when no operation is open.
Parameters
pathstring— VFS path of the written file.beforestring?(optional) — The file's contents before the write, nil when it did not exist.afterstring?(optional) — The file's contents after the write, nil when the write removed it.
local before = vfs.read(p); vfs.write(p, body); multiplayer.recordFileWrite(p, before, body)
modules/multiplayer/recordSpawn
recordSpawn(entityId: string)
Adopt an existing entity into the open operation as its spawn — for flows that create an entity before the operation opens (a drag preview adopted on drop). Undoing the operation despawns it.
Parameters
entityIdstring— Entity id to record as spawned by this operation.
multiplayer.recordSpawn(id)
modules/multiplayer/redo
redo(): boolean
Redo this client's last undone operation.
modules/multiplayer/releaseOwnership
releaseOwnership(entityId: (string | entityRef)?): boolean
Release ownership of an entity, leaving it unowned so another peer's claim takes it. Only the owner releases an entity.
Parameters
entityId(string | entityRef)?(optional) — Entity id or proxy to release.
modules/multiplayer/roomFor
roomFor(entityId: (string | entityRef)): string?
The room key an entity's spawns and property deltas broadcast into:
the room of its observeEntity record as of the last frame, read from
the rooms the session publishes every frame, so a component can ask
every frame.
Parameters
entityId(string | entityRef)— Entity id or proxy.
local key = multiplayer.roomFor(player)
if key then multiplayer.joinRoom(key) end
modules/multiplayer/send
send(channel: string, ...: any)
Broadcast a message on a named channel to every OTHER peer in the
room. The relay forwards it transparently; peers receive it via
multiplayer.on. The arguments are delivered to listeners in order,
each one arriving as what it is, at the top level and at every depth
of a table:
nil, a boolean, a number and a string arrive as themselves.- A
vectorarrives as avector. - The proxy of a synced entity arrives as the receiving peer's proxy for that entity; the proxy of an entity no peer shares, as its id string.
- A synced component (its proxy, or the
componentRefenvelope naming it) arrives as that component on the receiving peer; the proxy of a component that holds no sync id, as the envelope{ __ref, entity, componentType }naming it. - A transform vector an entity hands out (
e.position,e.rotation,e.localScale, ...) arrives as the table of its components,{ x, y, z }or{ x, y, z, w }. - Every other table is data and arrives as a new table holding the same
keys, each key and each value carried by these same rules:
{ x = 5, kind = "coin" }arrives as{ x = 5, kind = "coin" },{ who = e, n = 1 }witht.whothe receiver's proxy fore,{ [5] = "a" }witht[5] == "a",{ 1, 2, label = "m" }with its list and itslabel,{ [true] = "yes" }witht[true] == "yes", and a list with anilin it with every entry after thenilat the index it was written under. A number inside a table arrives as that number,math.hugeand NaN included. - A value no peer can hold (a function, a thread, a buffer) arrives as
nil, and so does a table entry whose key is one; the sender logs a
warning naming the key's type.
The same rules carry the arguments of a
declare.syncedFunctionsmethod, the payload of aSyncevent and a synced table-valued field. No-op when not connected.
Parameters
channelstring— Channel name listeners subscribe to viamultiplayer.on.argsany(optional)
modules/multiplayer/setSmoothing
setSmoothing(entityId: (string | entityRef), values: SmoothingSettings?): boolean
Set how this peer draws one synced entity another peer simulates,
in place of the world's settings: any of enabled (false draws the
entity at the newest pose received), delay and extrapolation
(seconds, 0 to 2) and teleportSpeed (metres per second). A value left
out is the world's, and nil or an empty table hands the entity back to
them. The setting is this peer's own and lasts while the entity exists.
delay = 0 draws the newest pose delivered, which trails the owner by
the network transit; see smoothing for what is drawn and when.
smoothing(entityId) reads it back.
Parameters
entityId(string | entityRef)— Synced entity to set.valuesSmoothingSettings?(optional) — The values to use for this entity; nil hands it back to the world's.
multiplayer.setSmoothing(projectile, { delay = 0.05, teleportSpeed = 600 })
multiplayer.setSmoothing(car, nil) -- back to the world's settings
modules/multiplayer/smoothing
smoothing(entityId: (string | entityRef)?): Smoothing
How this peer draws the remote entities other peers simulate. A
body another peer simulates is drawn a short delay behind the newest
pose received for it, interpolated between the poses either side of
that moment, so it moves smoothly whatever the frame rate on either
side and the jitter between them, and a pose that arrives after a newer
one never moves it back. When poses stop arriving it carries on along
its last motion for up to extrapolation seconds, then holds. A step
faster than teleportSpeed (metres per second) is a teleport and is
drawn as a cut, and a stream whose sender changes (an ownership
handover) starts over from its first pose. The owner's own view is
untouched. The moment drawn is the owner's now less the network transit
less delay; the transit stays in, so delay = 0 draws the newest pose
delivered and still trails the owner by it. A body that stops dead is
carried past its stop until the pose it rests at arrives, about 0.1 s
after it stops, when delay is shorter than that.
The settings come from the world's settings sync.interpolation
(boolean), sync.interpolation_delay, sync.extrapolation_limit
(seconds) and sync.teleport_speed, with this peer's setSmoothing
values for the entity in their place (overridden). For an entity
whose poses this peer receives, stream holds the poses buffered, how
far the newest stands ahead of the moment drawn (lag, seconds,
negative while extrapolating), whether the sender stamps its poses with
its clock, the moment last drawn on the sender's clock and this
peer's clock it was drawn at (drawnAt), both in seconds so two reads
subtract into how far the drawn moment moved over how much time, and
the running counts of poses received, dropped as stale, stream
restarts and teleports. Reading asks the coming
frames to publish the streams, so the first read of one answers on the
next frame.
Parameters
entityId(string | entityRef)?(optional) — Entity to read; omit for the world's settings.
local s = multiplayer.smoothing(car); print(s.delay, s.stream and s.stream.lag)
settings.set("sync.interpolation_delay", "0.15") -- every remote entity, world-wide
modules/multiplayer/syncTotals
syncTotals(): SyncTotals
What the sync registry holds across every entity: entities with a registered synced component, component instances, declared properties, declared functions, and the component instances holding a dirty property this tick.
print(multiplayer.syncTotals().properties .. " synced properties registered")
modules/multiplayer/undo
undo(): boolean
Undo this client's last edit-mode operation.
modules/names/README
require("@builtin::avatarTypes.humanoid.names") -- names
Name hints for humanoid qualification. A bone's name never decides its role or its side; it raises the confidence of an assignment the structure already made, and a side word that disagrees with the geometry is reported. Covers the common conventions (Mixamo, Unity, VRM, CATS, Unreal, Synty, Blender).
Usage: local names = require("@builtin::avatarTypes.humanoid.names")
modules/names/score
score(role: string, name: string): number
How well a bone name fits a role, 0..1. role is a humanoid role; its side and
finger segment number are ignored (lefthandindex2 is scored as index).
Parameters
rolestringnamestring
modules/names/side
side(name: string): string?
The side a name states, "left", "right", or nil when it states none.
Parameters
namestring
modules/names/tokens
tokens(name: string): { string }
The lowercase words of a bone name: a namespace prefix (mixamorig:) is dropped,
and the name is split at separators, at lower-to-upper case changes and at letter/digit
boundaries. LeftForeArm -> { "left", "fore", "arm" }; J_Bip_L_UpperArm ->
{ "j", "bip", "l", "upper", "arm" }.
Parameters
namestring
modules/notices/README
require("@builtin::modules.api.engine.notices") -- notices (also available as global 'notices')
Post an event record that surfaces to the callers it is addressed to on the response of the tool call that posted it, or on their next tool call. Public Luau surface over the __notices_post Internal FFI global.
Usage: local notices = require("@builtin::modules.api.engine.notices") Also available as global: notices
modules/notices/post
post(template: string, params: { [string]: any }?, opts: NoticeOpts?)
Post a notice. template is a fixed sentence used to collapse
repeats; put varying values in params. A param holding a picture — an
image value from mcp.image or a capture tool — is delivered as a
picture beside the notice's line rather than as text. opts.severity
defaults to "info"; opts.includeLocation attaches the emitting call
site. opts.actionable says whether the callers a notice is addressed
to are expected to act on it, rather than take it in as background; an
agent's event receiver starts an idle agent's turn for an actionable
notice and hands the rest to its context. opts.message is the catalog
key (<namespace>.<key>, see i18n.t) of the sentence a person reads the
notice as, in their language: the editor's notification bell shows it
(notices.text), read from the world's catalogs
(/zero/source/locales/<tag>/<namespace>.json) and then the built-in
library's, while an agent reads the template. A notice with no message
reads as its template everywhere.
Parameters
templatestring— Fixed sentence identifying the notice.params{ [string]: any }?(optional) — Optional table of named values rendered alongside the template; a picture in it arrives as a picture.optsNoticeOpts?(optional) — Optional table: message (a catalog key), severity ("info" | "warn" | "error"), includeLocation (boolean), audience ("" | { string }?). Who sees the notice: "" addresses every caller; a list addresses those callers only, each entry an agent's name (as theagenttoolbox'srosterlists it) or a caller key<kind>:<id>such as "agent:". Defaults to the caller whose code is running, or every caller when none is. A notice reaches the agents on this engine: an entry naming no agent on this world's roster, an entry naming an agent the roster lists on another engine of the world, or an empty list, raises an error. actionable(boolean) states whether the callers it is addressed to are expected to act on it; omitted, a notice addressed to particular callers (the default audience included) is actionable, and one for every caller is background.
notices.post("wave complete", { wave = 3 })
notices.post("save slot corrupted, using defaults", { slot = id }, { severity = "warn" })
notices.post("bake finished", { shot = mcp.image("/source/tmp/bake.png") })
notices.post("boss defeated", nil, { audience = "*" })
notices.post("build ready for review", nil, { audience = { "terrain" }, actionable = true })
notices.post("wave complete", { wave = 3 }, { message = "hud.wave_complete" }) -- /zero/source/locales/<tag>/hud.json
modules/notices/text
text(row: { template: string, message: string? }): any
The sentence a stored notice reads as for a person: its message in
the reader's language, read from the world's catalogs and then the
built-in library's, or its template when it names none. row is a notice
as the notices toolbox's list tool states it (template, message).
The value follows the language on screen, like i18n.text.
Parameters
row{ template: string, message: string? }— A notice row:{ template, message? }.
for _, row in tools.use("notices", "list").pending do print(tostring(notices.text(row))) end
modules/notices/withdraw
withdraw(template: string): number
Withdraw the notices this code posted under template that are still
stored, whoever they are addressed to, because what they state has
stopped being true: a caller that has not read one yet would be told
something that no longer holds. A notice is keyed by its template and by
the code that posted it, so a call reaches only notices posted from the
same place. A later notices.post under the template queues again, and
reaches the callers that muted it too: their mute acknowledged what the
withdrawn notices stated.
Parameters
templatestring— The template the notices were posted under.
notices.withdraw("save slot corrupted, using defaults")
modules/onUnload
modules.onUnload(callback) -> ()
Register a teardown for the calling module's current run. It runs once, at the moment this run ends — immediately before the next run of that chunk replaces it, and when the module leaves the require cache — while this run's module-level locals are still in scope, so the run that spawned the entities, created the particle systems or subscribed to the event bus is the run that releases them. Each run registers its own, and the registration goes with the run that made it.
Parameters
callbackfunction— Called with no arguments just before this run of the module is replaced
modules/packages/README
require("@builtin::modules.api.engine.packages") -- packages (also available as global 'packages')
Discover and inspect registered packages (folders marked with package.yaml). Public Luau surface over the __packages Internal FFI namespace.
Usage: local packages = require("@builtin::modules.api.engine.packages") Also available as global: packages
modules/packages/list
list(): { PackageEntry }
List every registered package across scopes.
for _, p in ipairs(packages.list()) do print(p.name, p.scope) end
modules/packages/lookup
lookup(name_or_scope: string, name: string?): PackageEntry?
Look up a single package by name (any scope) or by exact
(scope, name).
Parameters
name_or_scopestring— Package name, or scope if a second arg is given.namestring?(optional) — Package name when the first arg is a scope.
local p = packages.lookup("@builtin", "audio")
modules/pathNetwork.geometry/README
require("@builtin::modules.pathNetwork.geometry") -- pathNetwork.geometry
The shape of a path network: the centreline of each edge through its control points, the cross-sections along it (position, heading, bank, the surface's right and up), and the meshes built from them (an edge's surface with side walls and end caps, a junction's surface joining the edges that meet at a node). Pure functions over plain tables; the network in pathNetwork owns the entities they are drawn on.
Usage: local pathNetwork.geometry = require("@builtin::modules.pathNetwork.geometry")
modules/pathNetwork.geometry/at
at(line: any, d: number): (number, number, number)
The point a distance along a sampled centreline, interpolated between its samples, held at either end.
Parameters
lineany(optional) — The tablecentrelinereturned.dnumber— Metres from its start.
modules/pathNetwork.geometry/centreline
centreline(control: { Point }, before: Point, after: Point, step: number)
Sample a centreline through control (two points or more) finely
enough to measure it: a Catmull-Rom curve through every control point,
with before and after standing in for the neighbours past each end
(the next path's control point across a node, so two paths meeting there
share one tangent).
Parameters
control{ Point }— The control points, first to last.beforePoint— The point standing before the first.afterPoint— The point standing after the last.stepnumber— Metres between samples.
modules/pathNetwork.geometry/edgeMesh
edgeMesh(sections: { Section }, opts: any): any
The mesh of one edge: its surface across the cross-sections, a wall
skirt metres deep down each side, and a cap at each end caps names.
Parameters
sections{ Section }— The edge's cross-sections.optsany(optional) —{ skirt, uvScale, capStart, capEnd }.
modules/pathNetwork.geometry/fanDistance
fanDistance(centre: Point, ring: { Point }, x: number, z: number): number
How far a point stands outside a junction's surface, seen from above: 0 inside the fan (the centre and its corners in order), else the distance to the nearest side of its outline.
Parameters
centrePoint— The junction's centre.ring{ Point }— Its corners in order round the centre.xnumber— World X.znumber— World Z.
modules/pathNetwork.geometry/fanHeight
fanHeight(centre: Point, ring: { Point }, x: number, z: number): number
The height of a junction's surface over a point: the plane of the fan triangle (centre and two neighbouring corners) whose wedge the point stands in, seen from the centre.
Parameters
centrePoint— The junction's centre.ring{ Point }— Its corners in order round the centre.xnumber— World X.znumber— World Z.
modules/pathNetwork.geometry/junctionMesh
junctionMesh(centre: Point, ends: { any }, opts: any): any
The mesh of a junction: a surface fanned from the node's centre out to the end corners of every edge that meets there, so each edge's end and the junction share their vertices, with a wall down the open sides between edges.
Parameters
centrePoint— The node's centre.ends{ any }— One{ left, right }pair of corner points per edge end at the node.optsany(optional) —{ skirt, uvScale }.
modules/pathNetwork.geometry/project
project(a: Section, b: Section, x: number, z: number): (number, number, number)
Where a point lies against one segment of cross-sections, seen from above: the fraction along it, the signed lateral distance from the centreline (positive to the right), and how far past either end it falls.
Parameters
aSection— The segment's first section.bSection— Its second.xnumber— World X.znumber— World Z.
modules/pathNetwork.geometry/sections
sections(line: any, spec: any): { Section }
Cross-sections along an edge between two distances on its
centreline, about spacing apart, each carrying the surface's frame.
Parameters
lineany(optional) — The sampled centreline.specany(optional) —{ from, to, spacing, half, bank, heights?, startHeading?, endHeading?, startPlane?, endPlane?, planeReach?, maxTwist?, tolerance? }: the trimmed range, the half width, the bank (degrees, one number or one per control point), the elevation of each section when it is not the centreline's own (a function of(x, z, index, count), called for the sectionsspacingapart), the headings an end must take (a unit{x, z}), so two edges meeting at a node join without a crease, and the plane an end lies across ({ gx, gz }, its rise per metre along X and Z): the end's cross-section tips to lie on it, easing back to the bank overplaneReachmetres, and further where the cross slope (the rise across the surface per metre) would otherwise turn by more thanmaxTwistper metre, as far as the edge reaches, so the edges meeting at a junction share its plane.toleranceis the most, in metres, the flat triangles drawn between two sections may stand off the surface the sections sweep where it twists: between two sections whose cross slope turns by more than that allows, sections are added, the centreline's height running straight between the two whereheightsstates it.
modules/pathNetwork.geometry/smooth
smooth(ys: { number }, window: number, opts: { [string]: any }?): { number }
Smooth an elevation profile with a moving average window samples
wide each side, and hold its ends. ys may carry lead samples before
the profile's first and trail after its last (the ground past each end),
which the average reads and the answer leaves out, so the window stays
full and centred right up to the ends. A held end meets its height
(first, last) and, where one is given, its grade (firstSlope,
lastSlope: rise per metre from the first sample toward the last)
through a cubic ease that leaves the smoothed profile with the profile's
own height and grade. The ease reaches far enough that it adds no more
than maxGrade to the grade to make up a height and bends the grade by no
more than maxBend per metre to meet one, so two paths meeting at a node
with the same height and grade join without a crease.
Parameters
ys{ number }— The heights,spacingmetres apart,leadandtrailincluded.windownumber— Samples each side.opts{ [string]: any }?(optional) —{ spacing, lead?, trail?, first?, last?, firstSlope?, lastSlope?, maxGrade?, maxBend? }; an end with no height given keeps its smoothed one.
modules/pathNetwork.geometry/surfaceHeight
surfaceHeight(a: Section, b: Section, t: number, lateral: number): number
The surface's height at a lateral distance across a segment, at
fraction t along it, on the two triangles edgeMesh draws the segment
with (split from the first section's left corner to the second's right),
so the height is the drawn and colliding surface's, a banked or twisting
stretch included.
Parameters
aSection— The segment's first section.bSection— Its second.tnumber— Fraction along the segment.lateralnumber— Signed metres right of the centreline, held to the surface's edge.
modules/pathNetwork.ground/README
require("@builtin::modules.pathNetwork.ground") -- pathNetwork.ground
The ground a path network stands on: the Terrain entities under it, the height of the ground as it was before any path changed it, and the conforming of that ground to the paths, so a path's bed is cut and filled into the slope rather than floating over it or buried in it. Every texel a path changes keeps the height it had, so a path moved or removed gives the ground back.
Usage: local pathNetwork.ground = require("@builtin::modules.pathNetwork.ground")
modules/pathNetwork.ground/baseHeight
baseHeight(state: any, x: number, z: number): number?
The ground's height at a point as it stood before the network changed
it: the world Y where the world's vertical through the point meets the
ground, wherever its terrain's entity puts the landscape, with the texel
cell there read the way the terrain reads it
(terrainHeightfield.cellHeight) from each texel's kept height where a
path has changed it. Nil where no terrain is under the point.
Parameters
stateany(optional) — The ground state.xnumber— World X.znumber— World Z.
modules/pathNetwork.ground/conform
conform(state: any, changed: { Footprint }, all: { Footprint }): number
Conform the ground to the network's footprints over the area the
changed footprints reach (the ones a build replaced and the ones it
made). Each texel there takes the height of the footprint holding it most
strongly, blended with its own over the falloff; a texel no footprint
holds any more is given back its own height.
Parameters
stateany(optional) — The ground state.changed{ Footprint }— The footprints whose area is conformed again.all{ Footprint }— Every footprint the network has; the ones reaching the changed area are what a texel is judged against.
modules/pathNetwork.ground/discFootprint
discFootprint(cx: number, cz: number, radius: number, y: number, ring: { any }, opts: any): Footprint
A footprint for a junction: a disc reaching the surface's farthest corner, at the height of the surface's fan over each point.
Parameters
cxnumber— Centre X.cznumber— Centre Z.radiusnumber— The surface's radius.ynumber— The surface's height at the centre.ring{ any }— The surface's corners in order round the centre.optsany(optional) —{ shoulder, falloff, bed }.
modules/pathNetwork.ground/edgeFootprint
edgeFootprint(sections: { any }, opts: any): Footprint
A footprint for an edge's cross-sections.
Parameters
sections{ any }— The edge's cross-sections.optsany(optional) —{ shoulder, falloff, bed }.
modules/pathNetwork.ground/height
height(state: any, x: number, z: number): number?
The height the ground stands at now, the network's changes included: the world Y where the world's vertical through the point meets it.
Parameters
stateany(optional) — The ground state.xnumber— World X.znumber— World Z.
modules/pathNetwork.ground/open
open(terrains: any): any
Open the ground under a network: the Terrain entities named, or every
one in the scene when none is named.
Parameters
terrainsany(optional) — A terrain entity id, a list of them,falsefor no ground, or nil for everyTerrainin the scene.
modules/pathNetwork.ground/present
present(state: any): boolean
Whether any ground is under the network.
Parameters
stateany(optional) — The ground state.
modules/pathNetwork.ground/restore
restore(state: any): number
Give the ground back every height the network changed.
Parameters
stateany(optional) — The ground state.
modules/pathNetwork.ground/settle
settle(state: any)
Record the ground as it stands now as the ground the network is
conformed to, so stale answers false until a terrain is read again.
Parameters
stateany(optional) — The ground state.
modules/pathNetwork.ground/stale
stale(state: any): boolean
Whether a terrain under the network holds ground the network has not conformed: one that loaded after the network was built, or one read again from its asset since (a re-bake, a reload, a first read that raced the asset's write), which holds none of the network's cut and fill.
Parameters
stateany(optional) — The ground state.
modules/pathNetwork.lanes/README
require("@builtin::modules.pathNetwork.lanes") -- pathNetwork.lanes
The directed lane graph of a path network and the questions asked of it: which lanes each edge carries and which way they run, how lanes join through each node, where a lane stops for a junction, the nearest lane to a point, a route between two places, and the point a set distance ahead along a lane and the lanes after it. Pure functions over the built network's tables.
Usage: local pathNetwork.lanes = require("@builtin::modules.pathNetwork.lanes")
modules/pathNetwork.lanes/connect
connect(lanes: { [string]: Lane }, degree: { [any]: number })
Join the lanes through every node: each lane arriving at a node goes
on to the lanes leaving it along the other edges there, keeping its lane
index where the next edge has that many lanes. A node at the end of one
edge turns its lanes back along it. A lane arriving at a junction (three
edges or more) stops at its end, which is its stopLine.
Parameters
lanes{ [string]: Lane }— Every lane, by id.degree{ [any]: number }— The number of edges at each node, by node id.
modules/pathNetwork.lanes/connector
connector(from: Lane, to: Lane): any
The way from the end of one lane to the start of the next, through a node: a cubic curve leaving along the first lane's heading and arriving along the second's. Lanes that meet end to start join in a single point. Worked out once per pair of lanes.
Parameters
fromLane— The lane being left.toLane— The lane being entered.
modules/pathNetwork.lanes/forEdge
forEdge(edge: any, drive: string): { Lane }
The lanes one built edge carries, start to end in the direction each
runs. With drive = "right", lanes running from the edge's first node to
its last stand right of its centreline; "left" mirrors it. Lane index 1
is the one beside the centreline.
Parameters
edgeany(optional) — The edge record, with its builtsections.drivestring—"right"or"left".
modules/pathNetwork.lanes/index
index(edges: { [any]: any }): any
An index of every edge's cross-section segments by cell, for the nearest-point query.
Parameters
edges{ [any]: any }— The built edges.
modules/pathNetwork.lanes/laneDistanceAt
laneDistanceAt(lane: Lane, s: number): number
The distance along a lane nearest a distance along its edge.
Parameters
laneLane— The lane.snumber— The distance along the edge's centreline.
modules/pathNetwork.lanes/makeConnector
makeConnector(from: Lane, to: Lane): any
The connector curve between two lanes, worked out afresh.
Parameters
fromLane— The lane being left.toLane— The lane being entered.
modules/pathNetwork.lanes/nearestSegment
nearestSegment(index: any, x: number, z: number, maxDistance: number?, edges: { [any]: boolean }?): any?
The nearest point on any edge's centreline to a world point, seen from above, searching outward ring by ring through the index.
Parameters
indexany(optional) — The indexindexbuilt.xnumber— World X.znumber— World Z.maxDistancenumber?(optional) — How far to look, in metres; nil looks across the whole network.edges{ [any]: boolean }?(optional) — Optional set of edge ids ({ [id] = true }) to look on; nil looks on every edge.
modules/pathNetwork.lanes/point
point(lane: Lane, d: number): ({ x: number, y: number, z: number }, { x: number, y: number, z: number })
The point and travel direction a distance along a lane.
Parameters
laneLane— The lane.dnumber— Metres from its start, held to its length.
modules/pathNetwork.lanes/route
route(lanes: { [string]: Lane }, start: any, goal: any, by: string): ({ string }?, number?)
The cheapest way through the lane graph from one place on a lane to another, by length or by time at each lane's speed limit.
Parameters
lanes{ [string]: Lane }— Every lane, by id.startany(optional) —{ lane, distance }.goalany(optional) —{ lane, distance }.bystring—"distance"or"time".
modules/pathNetwork.procedural/README
require("@builtin::modules.pathNetwork.procedural") -- pathNetwork.procedural
Rules that lay out a path network: a network joining a set of places (a spanning tree with extra links for loops), a grid of streets, and a closed circuit. Each answers a plan, { nodes, edges }, which pathNetwork.fromPlan (or net:addPlan) turns into a network. The same seed lays out the same network.
Usage: local pathNetwork.procedural = require("@builtin::modules.pathNetwork.procedural")
modules/pathNetwork.procedural/circuit
circuit(opts: any?): Plan
A closed circuit: count nodes round an ellipse whose radius wanders
by up to wander of itself, each joined to the next and the last to the
first, with pointsPerEdge control points between them.
Parameters
optsany?(optional) —{ origin?, radius?, radiusZ?, count?, wander?, pointsPerEdge?, seed? }: the centre, the radius along X in metres (default 200) and along Z (default the same), the nodes (default 4), the share of the radius it wanders by, from 0 to 0.9 (default 0), the control points between two nodes (default 2), and the seed.
modules/pathNetwork.procedural/connect
connect(places: { any }, opts: any?): Plan
A network joining a set of places: the shortest tree that reaches
every one of them, plus loops extra links between near neighbours that
cross no other link, so there is more than one way round.
Parameters
places{ any }— The points to join,{x, y, z}each.optsany?(optional) —{ loops?, meander?, spacing?, seed? }: extra links (default a third of the places), how far the links wander sideways in metres (default 0), metres between their control points (default 60), and the seed.
modules/pathNetwork.procedural/grid
grid(opts: any?): Plan
A grid of streets: cols by rows crossings spacing metres apart,
each joined to its neighbours, centred on origin.
Parameters
optsany?(optional) —{ cols?, rows?, spacing?, origin?, jitter?, seed? }: crossings along X (default 4) and Z (default 4), metres between them (default 80), the centre, and how far each crossing is moved at random (default 0).
modules/pathNetwork/README
require("@builtin::modules.pathNetwork") -- pathNetwork
Path networks built at runtime from Luau: roads, tracks, rails, footpaths, rivers' courses, racing lines, patrol and delivery routes. A network is NODES (places, junctions, ends) joined by EDGES (paths through control points), each edge carrying directed LANES. build turns it into drivable surfaces with static colliders and a material, conforms the terrain under them, and joins the lanes into a graph that answers the nearest lane to a point, a route between two places, and the point a set distance ahead. Editing a node or an edge and building again rebuilds the edges and junctions that edit reaches and nothing else.
local paths = require("@builtin::modules.pathNetwork"), then
local net = paths.new({ ... }), net:addNode(...), net:addEdge(...),
net:build(). The README has the whole surface; paths.procedural lays
out networks by rule.
Usage: local pathNetwork = require("@builtin::modules.pathNetwork")
modules/pathNetwork/addEdge
addEdge(self: Network, a: any, b: any, fields: any?): string
Add an edge: a path from node a to node b through points.
Parameters
selfNetworkaany(optional) — The first node's id.bany(optional) — The last node's id.fieldsany?(optional) — Optional:points(the control points between the two nodes, in order),id, and any edge setting the network takes (lanes,laneWidth,width,shoulder,speedLimit,bank,elevation,conform,material, ...).
local e = net:addEdge(a, b, { points = { { 40, 0, 10 } }, bank = 4 })
modules/pathNetwork/addNode
addNode(self: Network, position: any, fields: any?): string
Add a node: a place two or more edges meet at, or an end.
Parameters
selfNetworkpositionany(optional) —{ x, y, z }. Withelevation = "terrain"(the default) the node stands on the ground andyis read only where there is none.fieldsany?(optional) — Optional{ id, elevation, junctionRadius }: an id of your own (a string),"terrain"or"points", and the radius in plan of the junction surface built where three edges or more meet (worked out from the widths and angles of the edges when unset).
local a = net:addNode({ 0, 0, 0 })
modules/pathNetwork/addPlan
addPlan(self: Network, plan: any, edgeFields: any?): { [string]: string }
Add every node and edge of a plan (pathNetwork.procedural's, or one
written by hand: { nodes = { { id, x, y, z } }, edges = { { a, b, points } } }).
Parameters
selfNetworkplanany(optional) — The plan.edgeFieldsany?(optional) — Optional settings every edge of the plan takes.
net:addPlan(paths.procedural.grid({ cols = 3, rows = 3 }))
modules/pathNetwork/apply
apply(self: Network, spec: any)
Bring the network to the state a spec describes: nodes and edges are
matched by id, those that differ are changed, those missing are removed
and new ones added, so the next build rebuilds only what changed. An
edge in the spec without an id is given <a>-<b>.
Parameters
selfNetworkspecany(optional) —{ nodes = { { id, x, y, z, ... } }, edges = { { id?, a, b, points?, ... } } }.
modules/pathNetwork/build
build(self: Network, opts: any?): any
Build what has changed since the last build: the surfaces of every edge added, edited, or at a node that moved (and its neighbours across a node of two edges, which share its tangent), the junctions at their ends, the ground under all of them, and the lane graph. The first build builds everything, and so does a build after the surfaces were taken down from outside the network (the scene reloaded, or play ended and took the temporary entities they stand on).
Parameters
selfNetworkoptsany?(optional) — Optional{ all = true }to rebuild every edge and junction.
local stats = net:build()
modules/pathNetwork/destroy
destroy(self: Network)
Take down every surface the network built and give the ground back.
The network's nodes and edges stay; build stands it up again.
Parameters
selfNetwork
modules/pathNetwork/edge
edge(self: Network, id: any): any
An edge as data: its ends, control points, settings, and once built
its length (of the full centreline), width, lane ids and the entity
its surface stands on.
Parameters
selfNetworkidany(optional) — The edge's id.
modules/pathNetwork/edgeIds
edgeIds(self: Network): { string }
The ids of every edge, sorted.
Parameters
selfNetwork
modules/pathNetwork/entity
entity(self: Network): string?
The entity every surface of the network stands under, once built.
Parameters
selfNetwork
modules/pathNetwork/fromPlan
fromPlan(plan: any, opts: any?): Network
A network from a plan, with the network settings opts.
Parameters
planany(optional) — The plan.optsany?(optional) — Network settings, asnewtakes.
local net = paths.fromPlan(paths.procedural.circuit({ radius = 300 }))
modules/pathNetwork/groundHeight
groundHeight(self: Network, x: number, z: number): number?
The ground's height at a point now, the network's cut and fill included; nil where no terrain is under the network.
Parameters
selfNetworkxnumber— World X.znumber— World Z.
modules/pathNetwork/lane
lane(self: Network, id: any): any
A lane as data: its edge, which way it runs (direction 1 from the
edge's first node, -1 toward it), its index from the centreline, lateral
offset and width, speedLimit, length, the nodes it runs between,
the lanes it leads on to (next) and comes from (prev), and
stopLine, the distance along it where it meets a junction.
Parameters
selfNetworkidany(optional) — The lane's id.
modules/pathNetwork/laneIds
laneIds(self: Network): { string }
The ids of every lane, sorted.
Parameters
selfNetwork
modules/pathNetwork/lanePath
lanePath(self: Network, ids: { any }, opts: any?): { any }
The polyline of a run of lanes joined through their nodes, start to end: a lane loop for a follower to circle, a patrol, a racing line.
Parameters
selfNetworkids{ any }— Lane ids in order, each leading on to the next.optsany?(optional) — Optional{ closed = true }to join the last lane back to the first, the line then ending on the point it starts at.
local loop = net:lanePath({ "e1:+1", "e2:+1", "e3:+1" }, { closed = true })
modules/pathNetwork/lanePoint
lanePoint(self: Network, id: any, distance: number): (any, any)
The point and travel direction a distance along a lane.
Parameters
selfNetworkidany(optional) — The lane's id.distancenumber— Metres from the lane's start, held to its length.
local p, dir = net:lanePoint("e1:+1", 25)
modules/pathNetwork/lookAhead
lookAhead(self: Network, from: any, ahead: number, opts: any?): any
The point ahead metres further along from a place on a lane,
carrying on into the lanes after it through each node: along route
(a list of lane ids, as route answers) where it names the next lane,
else the lane choose(lane, nextIds) picks, else the first of them. What
an AI driver steers toward and a follower looks ahead with.
Parameters
selfNetworkfromany(optional) —{ lane, distance }, or a world point (its nearest lane).aheadnumber— Metres to look ahead.optsany?(optional) — Optional{ route, choose }.
local target = net:lookAhead({ lane = here.lane, distance = here.laneDistance }, 12)
modules/pathNetwork/moveNode
moveNode(self: Network, id: any, position: any)
Move a node. The edges at it, and the junctions at their other ends,
are rebuilt by the next build.
Parameters
selfNetworkidany(optional) — The node's id.positionany(optional) — The new{ x, y, z }.
net:moveNode(a, { 10, 0, -4 })
modules/pathNetwork/nearest
nearest(self: Network, position: any, opts: any?): any?
Where a world point stands against the network, seen from above: the
nearest edge and the distance along it, how far right of its centreline
the point is, whether it is on the surface, and the lane under it (the
one whose centre is nearest, preferring lanes running along heading
when one is given) with the distance along that lane and its direction.
With lanes, only those lanes and their edges are looked at: a driver
keeping to its route through a junction, where another edge stands nearer.
Parameters
selfNetworkpositionany(optional) — The world point.optsany?(optional) — Optional{ heading = {x, y, z}, maxDistance = metres, lanes = { laneId, ... } }.
local here = net:nearest(car.position, { heading = car.forward })
modules/pathNetwork/new
new(opts: { [string]: any }?): Network
A new, empty network. Every edge reads its settings from the edge,
then from here, then from pathNetwork.DEFAULTS.
Parameters
opts{ [string]: any }?(optional) — Network settings: any edge setting (laneWidth,lanes,shoulder,speedLimit,bank,elevation,smoothing,lift,conform,bed,falloff,skirt,resolution,uvScale,material,tint,collider,width), plusname(the parent entity's name),drive("right"or"left": which side of an edge its forward lanes keep to),terrain(a Terrain entity or a list of them,falsefor none; nil uses every Terrain in the scene) andparent(an entity the built surfaces go under).
local net = paths.new({ lanes = { forward = 2, backward = 2 }, speedLimit = 22 })
modules/pathNetwork/node
node(self: Network, id: any): any
A node as data: { id, x, y, z, height, edges }, height being the
height its surface was built at.
Parameters
selfNetworkidany(optional) — The node's id.
modules/pathNetwork/nodeIds
nodeIds(self: Network): { string }
The ids of every node, sorted.
Parameters
selfNetwork
modules/pathNetwork/removeEdge
removeEdge(self: Network, id: any)
Remove an edge. Its surface goes and the ground under it comes back
on the next build.
Parameters
selfNetworkidany(optional) — The edge's id.
modules/pathNetwork/removeNode
removeNode(self: Network, id: any)
Remove a node and every edge at it.
Parameters
selfNetworkidany(optional) — The node's id.
modules/pathNetwork/route
route(self: Network, from: any, to: any, opts: any?): any?
The way along the lanes from one place to another: the lanes in order, the cost, and the polyline a follower drives (lane centres joined through each node by connector curves).
Parameters
selfNetworkfromany(optional) — A world point (its nearest lane) or{ lane, distance }.toany(optional) — A world point or{ lane, distance }.optsany?(optional) — Optional{ by = "distance" | "time" }: the shortest way, or the quickest at each lane's speed limit.
local r = net:route(start, goal); follower:follow(r.points)
modules/pathNetwork/sample
sample(self: Network, id: any, s: number): any
The surface an edge was built with, at a distance along its centreline: the position, the heading, the right and up of the banked surface.
Parameters
selfNetworkidany(optional) — The edge's id.snumber— Metres from the edge's first node, held to the built surface.
modules/pathNetwork/setEdge
setEdge(self: Network, id: any, fields: any)
Change an edge: its control points (points, replaced whole) or any
edge setting. clear = { "bank", ... } drops settings the edge stated,
so it reads the network's again.
Parameters
selfNetworkidany(optional) — The edge's id.fieldsany(optional) — The fields to change.
net:setEdge(e, { points = { { 20, 0, 30 } }, lanes = { forward = 2, backward = 0 } })
modules/pathNetwork/setNode
setNode(self: Network, id: any, fields: any)
Change a node's fields (elevation, junctionRadius, x, y, z).
Parameters
selfNetworkidany(optional) — The node's id.fieldsany(optional) — The fields to change.
modules/pathNetwork/spec
spec(self: Network): any
The network as plain data: every node and edge with the fields they
state, the form apply takes and a component can store.
Parameters
selfNetwork
modules/persist/README
require("@builtin::modules.persist") -- persist
Usage: local persist = require("@builtin::modules.persist")
modules/persist_origin/README
require("@builtin::modules.persist.origin") -- persist_origin
Provenance / origin-context layer for the persist (create-flow) system. origin kinds: "execute" — an agent call (the engine's authoring window is open) "scene" — scene loader / entrypoint onLoad (__scene_load.inProgress()) "component" — a script-component lifecycle callback (awake/update/...) "engine" — engine-driven code that is none of the above (an assetType behavior composing an avatar, a bundle exploding its hierarchy). The DEFAULT: a surface is authored only while the authoring window is open, so a surface added later classifies as code without being enumerated anywhere.
Usage: local persist_origin = require("@builtin::modules.persist.origin")
modules/persist_player_camera/README
require("@builtin::modules.persist.player_camera") -- persist_player_camera
Freeze the LIVE player + camera into a scene's player/camera config. The persist north star is "what you see is what you get": the freeze PRESERVES the exact live state, it never synthesizes. PLAYER. The live player body is layers.active.players.localPlayer.avatar — whatever entity is in that slot right now, however it was built (procedurally spawned, instantiated, hand-assembled). The scene CONFIG (player.avatar_<mode>) is a BUNDLE ref the spawner instantiates on the next load. So the freeze CONVERTS the live avatar entity-tree into a bundle and points the config at it: * If the live avatar is an UNMODIFIED instance of an existing bundle (its bundleProvenance carries exactly one source bundle with no added components/entities), reference THAT bundle — don't duplicate. * Otherwise compose the live tree into a bundle (new on first freeze, re-composed in place on re-freeze) and reference it. The entity-tree -> bundle work goes through the bundle assetType's own composeTemplate path: first freeze = one-step asset.create("bundle", name, { entity = ref }) (onCreate composes the live tree), re-freeze = bundleRef:update(entityId) in place. Both capture LIVE component state via serialized component snapshots — exactly what's on screen. CAMERA. The live primary camera's behavior is a COMPONENT (the agent authors one to drive the camera); the freeze references it as camera.behavior_<mode>. Camera parameters (fov/near/far/follow) are baked into the live Camera component and preserved with it. No synthesis. Bundle CREATION is side-effecting, so it runs from confirm(), never plan() (a cancelled plan must leave no orphan bundle in /source).
Usage: local persist_player_camera = require("@builtin::modules.persist.player_camera")
modules/persist_serializer/README
require("@builtin::modules.persist.serializer") -- persist_serializer
Live-state serializer driver for persist. The missing half of the scene-save story: scene_saver.serializeEntity already turns a LIVE entity into the v6 per-entity body, but it is only ever fed ids from the EDIT-mode dirty-mark queue (empty in play). This driver supplies the play-mode side — it ENUMERATES the active layer's live entities, filters them by PROVENANCE (execute-origin only, via persist.origin) + authored-ness (scene_saver's spawner-managed / temporary filter), and assembles a loadable v6 scene body. Lighting stays ENTITY-PRIMARY: lighting comes from Light components on entities, which serialize as normal entities — so we deliberately do NOT emit scene_saver's global lighting manifest block (it would compete with / override the entity lights). Only the player + camera config blocks are carried over.
Usage: local persist_serializer = require("@builtin::modules.persist.serializer")
modules/playerSetupValidation/README
require("@builtin::modules.api.engine.playerSetupValidation") -- playerSetupValidation
Agent-facing validation for authored player setups. A player-spawn scene is built from PlayerSpawn entities (each naming a PlayerPrototype subtree to instantiate on join) and PlayerPrototype roots (marked PrototypeOnly, with a body and a camera field each naming a DESCENDANT of the prototype — the entity adopted as the avatar and the entity carrying the player's Camera). The prototype is cloned as a self-contained subtree, so both refs must resolve inside it and it may hold no camera other than the one camera names. checkEntity inspects one such entity and returns human-readable messages that name what is wrong and what to do about it; checkScene validates the scene's player intent against its PlayerSpawn / Camera counts. checkActiveScene runs the full rule set across the live active-layer scene, resolving each spawn's prototype wherever the materialisation holds it — the live entity in edit, the captured authored template in play; checkSceneJson runs it statically over a scene.json document — the path the scene assetType's validate hook uses so asset.validate, worldValidation, and the world.push gate all catch a broken player setup at authoring time.
Usage: local playerSetupValidation = require("@builtin::modules.api.engine.playerSetupValidation")
modules/playerSetupValidation/checkActiveScene
checkActiveScene(): { { entity: string, message: string } }
Gather every player-setup validation message for the live active-layer scene: the per-entity rules across all PlayerSpawn / PlayerPrototype entities, the competing-camera rule, and the scene-intent rule. Returns a flat list an agent can read to see what to fix. The verdict belongs to the settled scene, so the call holds while a scene load or a mode-flip transition is rebuilding the live tree, and judges what the rebuild lands on.
modules/playerSetupValidation/checkEntity
checkEntity(entityId: string): { string }
Validate a single PlayerSpawn or PlayerPrototype entity, returning agent-facing messages naming what is wrong and what to do. An entity carrying neither component (or one that does not exist) yields no messages.
Parameters
entityIdstring— The entity to inspect.
modules/playerSetupValidation/checkScene
checkScene(opts: { playerIntent: string, spawnCount: number, cameraCount: number }): { string }
Validate a scene's player intent against its PlayerSpawn / Camera counts, returning agent-facing messages. A "spawns" scene with no PlayerSpawn, or a "none" scene with no Camera, yields a message; every other combination is clean.
Parameters
opts{ playerIntent: string, spawnCount: number, cameraCount: number }—{ playerIntent: string, spawnCount: number, cameraCount: number }.
modules/playerSetupValidation/checkSceneJson
checkSceneJson(sceneJson: { [string]: any }): { { code: string, severity: string, message: string } }
Validate a decoded scene.json document statically: the full player-setup
rule set (per-entity, competing-camera, scene-intent) run over the scene's
authored entity tree without loading it. This is what the scene assetType's
validate hook calls, so asset.validate / worldValidation / the
world.push gate all report a broken player setup at authoring time.
Parameters
sceneJson{ [string]: any }— The decoded scene.json table ({ player, version, entities }).
modules/playerSetupValidation/playReadinessProblems
playReadinessProblems(): { { entity: string, message: string } }
The player-setup problems that must block a flip into play: the per-entity spawn/prototype rules (body + camera refs set, resolving to descendants, a single referenced camera) and the scene-intent rule, over the LIVE active scene. A "spawns" scene with none of these problems is ready to play. The competing-camera rule is deliberately excluded — the editor's own free-fly camera is a live viewport camera outside every prototype, so running it here would false-positive on every edit session; that rule stays a static / publish-time concern. Empty for a non-"spawns" scene (no player requirement), and empty while the active scene is still being materialised — the verdict belongs to the settled scene, so it waits for the layer to finish loading and for any mode-flip transition to converge.
modules/player_lifecycle/README
require("@builtin::modules.api.engine.player_lifecycle") -- player_lifecycle
Bridges the UserIdentity component's awake / onDestroy into the per-scene players registry. Installed by the prelude. The UserIdentity component requires this module and calls playerJoined(eid) in awake, playerLeft(eid) in onDestroy, and localAvatarBound(eid, av) when the local avatar slot fills. Each routes into layers.active.players._addPlayer / _removePlayer / _onLocalAvatarBound, which update the per-scene set AND fire onPlayerJoined / onPlayerLeft in one atomic step. onLocalReady is fired separately when the joining entity matches world.connectedUsers.localUser.entity. install() also registers __layers_* dispatch channels the player_spawner uses.
Usage: local player_lifecycle = require("@builtin::modules.api.engine.player_lifecycle")
modules/player_prototype_spawn/README
require("@builtin::modules.api.engine.player_prototype_spawn") -- player_prototype_spawn
The deterministic spawn core for authored player prototypes. A PlayerSpawn entity names a PlayerPrototype subtree to instantiate; spawnFor clones that subtree, activates and reveals the clone, prunes clone-subtree nodes whose networkScope excludes the caller's owner/authority role, marks the clone RuntimeOnly, and turns the clone ROOT into the joining user's internal identity: the root spawns under the name every user identity carries ("user"), leaves the PlayerPrototype / PlayerSpawn markers behind, and takes the UserIdentity component, so the root plugs into the existing players registry / join-leave / ownership / sync as a first-class local player. The clone root's authored children are detached to standalone world entities — nothing is parented to the identity. The joining user's avatar is the body named by the root's PlayerPrototype.body ref; it is positioned at the PlayerSpawn's world transform (placement at_spawn_transform) and bound by assigning the identity's avatar, which links it back through PlayerAvatar.owner. The clone's Camera node follows the bound body. Runtime provenance attributes (source prototype, owner user, owner player) are stamped on the root and read back with runtimeSpawnedInfo. The attributes are runtime-only: they live on the live entity and are not serialized into the world. installJoinHook wires spawnFor to a scene's user-join event so a joining user is placed from a PlayerSpawn automatically.
Usage: local player_prototype_spawn = require("@builtin::modules.api.engine.player_prototype_spawn")
modules/player_prototype_spawn/applyNetworkScope
applyNetworkScope(cloneRootId: string, isOwner: boolean, isAuthority: boolean)
Prune a clone subtree by each node's networkScope against the caller's
role. Walks the subtree from cloneRootId; a node scoped OwnerOnly is
despawned when the caller is not the owner, AuthorityOnly when the caller is
not the authority, and Replicated (or any other value) is kept.
Parameters
cloneRootIdstring— The clone's root entity id.isOwnerboolean— Whether the caller owns this clone.isAuthorityboolean— Whether the caller is the simulation authority for this clone.
modules/player_prototype_spawn/authorDefault
authorDefault(): { [string]: string }
Author the canonical default player setup into the active scene — the same shape the default world and the static_player canonical scene ship: a PrototypeOnly prototype whose body adopts the humanoid avatar and whose OwnerOnly camera rig runs the orbital follow behavior, plus a spawn at the origin. Returns the authored entity ids. This is the single builder the scene.player tool set to "spawns" and the "player" scene template both resolve to, so a joining user's avatar always replaces the same authored body.
modules/player_prototype_spawn/captureTemplatesFromEntities
captureTemplatesFromEntities(entities: { any })
Build the prototype-template registry from a scene's authored entity records (the parsed scene data, not live entities). This is the primary capture path: it is independent of scene-load order and runtime composition, so it captures the clean authored subtree (no composed avatar) and works in the runtime profile, which boots straight to play. Called by the scene loader for v7 scenes.
Parameters
entities{ any }— The scene's authored entity records (each{ id, name, parent, networkScope, renderLayer, transform, components }).
modules/player_prototype_spawn/capturedTemplate
capturedTemplate(prototypeId: string): any
The captured authored subtree for a PlayerPrototype — the clone source
spawnFor instantiates for each joining player, keyed by the prototype's
authored entity id (the id a PlayerSpawn's prototype field carries). Each
node is { id, name, participation, networkScope, renderLayer, position, rotation, scale, components = { [type] = data }, namedComponents?, children }:
components holds each type's anonymous instance, and namedComponents = { [type] = { [instanceName] = data } } the instances added under a name. Where the
materialisation keeps authored prototype subtrees out of the live scene —
play — this template is the authored prototype, and it is the subtree
spawnFor clones for each joining player.
Parameters
prototypeIdstring— The PlayerPrototype root's authored entity id.
local proto = player_prototype_spawn.capturedTemplate(spawn.prototype.id)
modules/player_prototype_spawn/chooseSpawn
chooseSpawn(ctx): (string?, { [string]: any }?, string?)
Pick the PlayerSpawn-carrying entity to spawn from. Enumerates entities
carrying the PlayerSpawn component in the joining user's ROOT scene, skipping
any that live in an additive overlay layer (editor UI, HUD scenes). When the
root scene resolves (ctx.rootSceneGuid, else layers.active.guid), only
spawns in that scene's layer are considered; otherwise every non-overlay
spawn is eligible. Spawns with no layer attribution yet belong to the world
root and stay eligible either way. Honors an optional ctx.spawnId
override (used for
deterministic selection), otherwise returns the first matching spawn.
Parameters
ctxany(optional) — A table;ctx.spawnIdoptionally names the spawn entity to select,ctx.rootSceneGuidoptionally names the scene layer to scope the search to.
modules/player_prototype_spawn/clearJoinHook
clearJoinHook(guid: string)
Clear a scene's join-hook flag. Called when a "spawns" scene unloads so the once-registered connect / play-entry handlers stand down (they no-op while no wired scene remains). Idempotent for an unknown guid.
Parameters
guidstring— The scene guid passed to installJoinHook.
modules/player_prototype_spawn/heldAsTemplate
heldAsTemplate(entityId: string): (any, string?)
The captured template node holding an authored entity the live scene leaves out. Where the materialisation keeps authored PlayerPrototype subtrees out of the scene (play), every entity of such a subtree is held by its prototype's template instead, carrying the authored state the scene's records give it, unsaved edits included. Answers that node and the prototype's id; nil for an entity no template holds, and wherever prototypes materialise as live entities (edit).
Parameters
entityIdstring— The authored entity's id.
local node, prototypeId = player_prototype_spawn.heldAsTemplate(row.id)
modules/player_prototype_spawn/installJoinHook
installJoinHook(sceneProxy, opts: { materialisedForPlay: boolean? }?): boolean
Wire spawnFor to the world's connected-user join event. When a user
connects, the hook picks a PlayerSpawn and instantiates that user's prototype
instance (internal identity + avatar + camera-follow) via spawnFor. The
trigger is world.connectedUsers.onConnect — the WORLD-level "a user joined
the session" event — not the room players registry, so the internal identity the
clone becomes (which folds into that registry) does not re-trigger a spawn.
Entering play spawns every already-connected user (their onConnect fired in
edit, ignored then). A scene wired while ALREADY in play — the runtime
profile boots straight into play, or a scene swapped in mid-play — gets that
same sweep immediately, since no play flip follows to trigger it. Every spawn
path is per-user idempotent: a user who already owns a live clone is skipped,
so overlapping paths and re-flips never produce a second player. A scene
whose load placed its prototypes for edit (opts.materialisedForPlay = false, a flip to play that landed part-way through its load) takes no
sweep: the flip rebuilds that scene for play, and the rebuilt scene's
hook places every connected user. Idempotent per scene proxy: a second
call for the same scene installs nothing further.
Parameters
sceneProxyany(optional) — A non-additive Scene proxy.opts{ materialisedForPlay: boolean? }?(optional) — Optional{ materialisedForPlay: boolean? }: whether the scene's load placed its prototypes as play's clone sources. Absent reads as true.
modules/player_prototype_spawn/runtimeSpawnedInfo
runtimeSpawnedInfo(id: string): { [string]: any }?
Read back the runtime provenance stamped on a clone root by spawnFor.
Parameters
idstring— The clone root entity id.
modules/player_prototype_spawn/spawnFor
spawnFor(ctx): string?
Spawn a player instance for a joining user from the chosen PlayerSpawn's
prototype. Chooses a spawn (honoring ctx.spawnId), resolves and validates
its prototype, clones the prototype subtree, activates and reveals the clone,
prunes it by networkScope against the caller's owner/authority role (both
default true), marks the clone RuntimeOnly, stamps provenance attributes,
places the clone at the spawn's world transform, and registers it with the
prototype lifecycle so it is despawned on the return to edit.
Parameters
ctxany(optional) —{ userId, playerEntityId?, spawnId?, isOwner?, isAuthority? }.
modules/player_prototype_spawn/storePrototypeTemplate
storePrototypeTemplate(prototypeId: string)
Capture a PlayerPrototype's authored subtree into the template registry. Called by PlayerPrototype.awake (before its Asset composes and before it deactivates) so spawnFor can instantiate the authored structure per player.
Parameters
prototypeIdstring— The PlayerPrototype root entity id.
modules/player_prototype_spawn/userHasSpawnedPlayer
userHasSpawnedPlayer(userId: string?): boolean
Whether a live clone spawned by spawnFor already carries this user's owner
provenance. Scans the live entities for a root whose ownerUserId attribute
matches. The idempotency guard the auto-spawn paths use so a user who already
has a spawned player never gets a second one.
Parameters
userIdstring?(optional) — The joining user's account id.
modules/player_spawner/README
require("@builtin::modules.api.engine.player_spawner") -- player_spawner
DEPRECATED: v7 scenes place players through the PlayerSpawn / PlayerPrototype flow. This engine-default-Player avatar path serves legacy v6 scenes only; M.ensure stands down (returns early) for any scene carrying a string playerIntent.
Binds the per-mode avatar bundle to the engine-default identity entity on non-additive layers.onLoad, for legacy v6 scenes. The avatar ref resolves as: per-scene settings.player.avatar_<mode> when set, else the world default world.avatar_default_<mode>. Missing-but-required is log.error + skip — no hardcoded fallback bundle. A single avatar slot combines visual + controller in one bundle. It spawns a fresh body entity from that bundle, then binds it by assigning the identity's avatar field, which marks the body synced + PlayerOwned and attaches its PlayerAvatar link. Scene-level avatar_<mode> = "" is the explicit opt-out — the scene builds its own body in entrypoint.luau::onLocalReady.
Usage: local player_spawner = require("@builtin::modules.api.engine.player_spawner")
modules/players/README
require("@builtin::modules.api.engine.players") -- players
Per-scene players registry. Tied to a non-additive Scene proxy. Reached as layers.active.players or layers.find(name).players. Returns curated player handles — never entity or component proxies — so the caller reads/writes player data (.userId, .displayName) and reaches the body via player.avatar (an entity ref) uniformly across all consumers. Both colon (p:onJoin(cb)) and dot (p.onJoin(cb)) call styles are supported on every method; the registry is a namespace surface, not an object, so neither style is canonical. Additive layers do NOT carry a players surface today (multiplayer support for players living inside additive overlays is a follow-up — see the layers.module additive-scene comment). layers.find(<additive>).players returns nil; this module is only instantiated on the root scene proxy.
Usage: local players = require("@builtin::modules.api.engine.players")
modules/plugins/README
require("@builtin::modules.api.engine.plugins") -- plugins (also available as global 'plugins')
What the plugin host loaded, and the one way to call a plugin. Public Luau surface over the __plugins Internal FFI namespace.
Usage: local plugins = require("@builtin::modules.api.engine.plugins") Also available as global: plugins
modules/plugins/awaitingPerson
awaitingPerson(plugin: string): boolean
Whether a call to this plugin is waiting on a person to answer the engine's consent dialog.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.
if plugins.awaitingPerson(PLUGIN) then print("waiting for you") end
modules/plugins/call
call(plugin: string, method: string, ...: any): any
Call a method the plugin at plugin exposes.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL: the same stringasset.identityanswers for it (motionfor a plugin in this world,@publisher::path.namefor one in a library), or its path. A computed identity is refused: runtime code has no dynamic requires and a plugin is no exception, because a name the reference deriver cannot read at authoring time is a dependency that never enters the graph.methodstring— A method the plugin'splugin.yamlexposes. One it does not is not callable, whatever the component carries.argsany(optional)
local agents = await(plugins.call("@builtin/plugins/dotbot.plugin", "agents"))
modules/plugins/isLoaded
isLoaded(plugin: string): boolean
Whether the plugin is loaded and answering calls.
Parameters
pluginstring— The plugin asset's identity, written as a LITERAL.
while not plugins.isLoaded("motion") do task.wait(0.1) end
modules/plugins/off
off(plugin: string, id: number): boolean
Stop a listener plugins.on started.
Parameters
pluginstring— The same identity the listener was started with.idnumber— The idplugins.onanswered.
modules/plugins/on
on(plugin: string, listener: (string, any) -> ()): number
Listen to the events a plugin raises.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.listener(string, any) -> ()—function(eventType, payload)—payloadis the event's decoded JSON.
local id = plugins.on("@builtin/plugins/dotbot.plugin", function(kind, body) end)
modules/plugins/openUrl
openUrl(plugin: string, url: string): any
Ask the person to open one of the plugin's own pages.
Parameters
pluginstring— The plugin asset's library identity, written as a LITERAL.urlstring— An https URL whose host the plugin declared undernetwork.hosts. Anywhere else is refused — otherwise this would be an unbounded way to put an address in front of somebody.
await(plugins.openUrl("@builtin/plugins/dotbot.plugin", "https://claude.ai/login"))
modules/plugins/status
status(): { [string]: any }
What the plugin host loaded, and what refused to load.
local report = plugins.status()
print(report.started, #report.plugins)
modules/postprocess/README
require("@builtin::modules.api.engine.postprocess") -- postprocess (also available as global 'postprocess')
Fullscreen post-process effects — register / remove / toggle / named-property updates / list the chain / read one effect's declared property schema and the value each property holds. Public Luau surface over the __postprocess Internal FFI namespace.
Usage: local postprocess = require("@builtin::modules.api.engine.postprocess") Also available as global: postprocess
modules/postprocess/add
add(name: string, shader: string | AssetRef, opts: PostprocessOpts?): (boolean, string?)
Register a fullscreen post-process effect. This call is what
puts a pass into the frame — a post-process .shader asset defines an
effect, and renders only once registered here. The chain applies the
registration on the caller's own stack and the returned boolean is its
answer, so a setProperty or setTexture naming the effect in the same
call finds it. shader is a .shader asset reference whose shader.wgsl
provides fn fragment(in: PostInput) -> vec4<f32> and whose
properties.yaml declares the effect's properties; the engine generates the
group(0) framework + schema-driven group(1) from that schema. Editing that
shader afterwards recompiles this effect in place, keeping its enabled
state, priority, layer and tuned property values. WGSL text is accepted
in place of a shader reference, and then opts.properties is the whole
schema — this form is deprecated and will be removed, author the effect
as a .shader asset instead. Effects run in priority order (lower
first, default 100).
A registered effect runs over the live viewport's frame AND over every
offscreen one — a capture from a world-space station, one orbiting an
entity, one of a named camera, a render-to-texture camera. In each of those
the effect's engine.view_proj / engine.prev_view_proj /
engine.inv_view_proj are the camera THAT render was drawn from and
engine.resolution is that target's own size, so a pass reconstructing
world space from zero_scene_depth(uv) reconstructs against the station
and lens the capture asked for. An offscreen capture is therefore an oracle
for an authored grade: it photographs a chosen station without taking the
on-screen camera from whoever else is driving the scene, and a capture's
postProcessing = false is the one control that takes the chain off the
frame it returns. An offscreen render keeps no view history of its own, so
engine.prev_view_proj there holds that same matrix rather than the frame
before it, and a pass taking camera motion from the two reads none.
Parameters
namestring— Unique effect name.shaderstring | AssetRef— A resolvedshaderasset reference, or author WGSL (fn fragment(in: PostInput)only).optsPostprocessOpts?(optional) —{ priority = 100, enabled = true, layer = "scene"|"all" (omitted: follows space), space = "light"|"display", properties = {{name, type, default?, min?, max?, textureDefault?}}, passes = {{name, entry, scale?, inputs?}} }— with a shader asset,propertieslayers over the asset's own schema.layerpicks which composited image the effect grades:"scene"runs it before the UI is drawn, over the scene's own light in a float target, so it grades the rendered picture and leaves every widget on screen as authored, and"all"runs it after the UI has landed, over the picture the display transform fitted to the screen, so the interface is graded along with the picture. A call that names no layer takes the one itsspacebelongs to: a"light"effect grades"scene"and a"display"effect grades"all", so a bloom reads the scene's highlights where they still stand above 1.0 and a lookup table reads code values. Naming"all"is what an effect that must grade the interface says — and on a world several authors share, it grades everyone else's screens too.spacenames whatfragment()reads and returns:"light"(the default) for a threshold/blur/grade on the scene,"display"for a lookup table, dither ladder or authored overlay working on code values. With a shader asset, defaults to what that asset'sgetSpace()declares.passesnames the passes the effect draws, each an entry in the shader, a fraction of the view it draws at, and what it reads. With a shader asset, defaults to what that asset'sgetPasses()declares; a single-pass effect (the common case) declares none.textureDefaultis what atype = "texture"property samples while nothing is bound to it:"white"(1,1,1,1 — the default),"black"(0,0,0,1),"normal"(0.5,0.5,1,1) or"transparent"(0,0,0,0). An effect that lays its texture over the scene wants"transparent", so the frame is untouched untilsetTexturebinds a texture that exists.
postprocess.add("vignette", asset.resolve("@builtin::shaders.post.vignette", "shader"))
postprocess.add("vignette", VIGNETTE_WGSL, { properties = {{ name = "intensity", type = "float", default = 0.5 }} })
modules/postprocess/describe
describe(name: string): PostprocessDescription?
One effect by name, read in full: the chain state
postprocess.status() lists for it, and on top of that properties — the
schema the effect declared, each entry { name, type, default?, min?, max?, textureDefault? } in the shape add takes — and values, what each of
those properties currently holds. A property's value is the one the last
setProperty wrote, or the schema's own default where nothing has written
one, and it comes back as a number for a scalar and as the array for a
wider value, which is what setProperty takes, so a property read here is
written straight back.
This is the read-back for a property write. setProperty answers whether
the uniform took the value; this answers what the effect holds now, which
is the reading a pass that writes its properties every frame needs and the
one that tells a mistyped property name from an effect that is not
grading. The schema and the values are the engine's own record of the
effect — the schema it was registered with and every write the chain
accepted into its uniform, the same record /runtime/fx/<name>/meta.json
is serialized from. A write the chain refused is not in it, and neither is
one made against a property the schema does not declare.
Before an effect is registered its schema lives on the .shader asset it
will render: asset.resolve("@builtin::shaders.post.bloom", "shader"):getProperties() names what that shader declares.
Parameters
namestring— Effect name.
local e = postprocess.describe("vignette")
print(if e then e.values.intensity else "not registered")
for _, p in ipairs(postprocess.describe("bloom").properties) do
print(p.name, p.type, p.min, p.max)
end
modules/postprocess/list
list(): { string }
List all registered post-process effect names in renderer priority order (lower priority runs first).
for _, n in ipairs(postprocess.list()) do print(n) end
modules/postprocess/remove
remove(name: string): boolean
Queue removal of a post-process effect. Takes effect on the next frame. Removing a name that isn't registered is a silent no-op.
Parameters
namestring— Effect name to remove.
postprocess.remove("vignette")
modules/postprocess/setEnabled
setEnabled(name: string, enabled: boolean): boolean
Queue an enable/disable toggle on a registered post-process effect. Targeting an unknown name is a silent no-op.
Parameters
namestring— Effect name.enabledboolean— True to enable, false to disable.
postprocess.setEnabled("bloom", false)
modules/postprocess/setProperty
setProperty(name: string, prop: string, value: (number | { number })): boolean
Set a named material property on a registered post-process
effect. The property must be declared in the effect's properties
schema; read in WGSL as material.<prop>. value is a number or a
number array (vec/color).
Parameters
namestring— Effect name.propstring— Declared property name.value(number | { number })— Number or array of numbers.
postprocess.setProperty("vignette", "intensity", 0.6)
modules/postprocess/setSampler
setSampler(name: string, opts: { [string]: any }): boolean
Configure the per-effect user sampler shared by the effect's declared texture properties. opts.filter = "linear" (default) or "nearest". opts.wrap (alias .address) = "clamp" (default), "repeat", or "mirror" — applied to all axes.
Parameters
namestring— Effect name.opts{ [string]: any }—{ filter = "linear"|"nearest", wrap = "clamp"|"repeat"|"mirror" }.
postprocess.setSampler("blur", { filter = "linear", wrap = "clamp" })
modules/postprocess/setTexture
setTexture(name: string, prop: string, path: string): boolean
Bind a texture to one of an effect's declared texture properties.
Declare it in properties ({ name = "noise", type = "texture" }) and
sample in WGSL as textureSample(noise, noise_sampler, in.uv). path
is any TextureCache-resolvable spec (@builtin::textures.foo,
color:1,0,0, default:white, a render-target name, ...). A path whose
texture has not reached the GPU yet — one this same script created — is
held and bound as soon as it does; postprocess.status() reports it under
pendingTextures until then.
Parameters
namestring— Effect name.propstring— Declared texture-property name.pathstring— Texture path / spec.
postprocess.setTexture("__vsky_composite", "cloud", "cloud_target")
modules/postprocess/status
status(): { PostprocessStatus }
Every registered effect in chain order with the state that decides
whether it reaches the frame — enabled flag, priority, layer, the
shader's compile error when it has one, the .shader asset it renders
when it was registered from one, the texture each declared slot is bound
to (textures) and the bindings still waiting for their texture
(pendingTextures). This is what the renderer draws with, so a survey of
the chain answers "is this one affecting the picture right now?" without
capturing a frame and reading pixels.
An effect this script has just registered is listed with pending = true until the renderer publishes it, since a registration is queued
for the next frame.
for _, e in ipairs(postprocess.status()) do
print(e.name, e.enabled, e.layer, e.error)
end
modules/preview.derive/README
require("@builtin::modules.preview.derive") -- preview.derive
The worker entries of the <type>.preview derive hooks: the fingerprint of the content a preview pictures. The picture itself renders on the engine thread, through preview.renderForReservation.
Usage: local preview.derive = require("@builtin::modules.preview.derive")
modules/preview.derive/compute
compute(_args: any): any
Raises: a preview renders on the engine thread.
Parameters
_argsany(optional)
modules/preview.derive/fingerprint
fingerprint(args: any): string
The fingerprint of the content args.snapshot holds: the digest of its
fingerprint lines, the value preview.inputsFingerprint states for the
same content.
Parameters
argsany(optional) —{ snapshot }.
modules/proc.code/README
require("@builtin::systems.procgen.proc.code") -- proc.code
A graph's source as code to edit. A graph and a node are the code of their init.luau (proc.define(function(g) ... end)); this module reads that code as statements and values and makes the edits the procgen tools offer on it: lift a run of statements into a node of its own, write a node's body out in place of a call to it, call an existing node in place of a run of statements, set and unset the arguments of a call, add, remove, rename and repoint calls, and declare inputs and outputs. Each edit answers with new source text and leaves the writing to its caller; build builds a source text the way loading it would, without writing it.
A SECTION is a run of whole statements of the builder function's body, named by the lines it
spans. The values it READS are the locals declared before it in the body that its code names,
and the values it MAKES are the locals it declares that the code after it names. Lifting the
section makes the first the new node's inputs and the second its outputs, and replaces the
section with one call of the node, so the graph is built from the same calls as before.
A CALL is a statement local x = g.<name>(...) or g.<name>(...), addressed by the local it
declares or by a line it spans. Its arguments are a table naming inputs ({ count = 8 }) or
values in the node's input order.
Usage: local proc.code = require("@builtin::systems.procgen.proc.code")
modules/proc.code/addCall
addCall(src: string, name: string, as: string?, args: { [string]: any }?, after: any?): string
Add a call statement local <as> = <param>.<name>(<args>).
Parameters
srcstring— The graph's source.namestring— The node to call.asstring?(optional) — The local the call declares (nil for a call whose outputs nothing reads).args{ [string]: any }?(optional) — Input name to value ({ expr = "..." }for code).afterany?(optional) — The call or line the new one follows (default: after the last statement before the outputs).
modules/proc.code/awaitRegistered
awaitRegistered(path: string)
Wait until the node written at path is registered, so a graph calling it cooks: the node type
registers a node from its source in the frames after the write.
Parameters
pathstring— The.procNodefolder.
modules/proc.code/build
build(src: string, path: string): (any?, string?)
Build the graph a source text describes, as loading it from path would, without writing it:
the static check a load holds a source to, then the build. Calls by ~ resolve from path.
Parameters
srcstring— The source text.pathstring— The folder the source is (or will be) the entry of.
modules/proc.code/callName
callName(graphPath: string, nodePath: string): string
The name a graph at graphPath calls the node at nodePath by: <box>.<name> for a node in a
nodebox, ~/<path> when both sit under one root, the node's path otherwise.
Parameters
graphPathstring— The calling graph's folder.nodePathstring— The node's folder.
modules/proc.code/calleeText
calleeText(param: string, name: string): string
The text a graph calls a node by: g.points.disc for a name, g["~/parts/crack"] for a path.
Parameters
paramstring— The builder function's parameter (g).namestring— The name,~path, path, identity or guid.
modules/proc.code/calls
calls(src: string): { { line: number, target: { string }, callee: string } }
Every call statement of a graph's body, at any depth: { line, target, callee } per call.
Parameters
srcstring— The graph's source.
modules/proc.code/inline
inline(src: string, address: any, nodeSrc: string, nodePath: string, hostPath: string?): Inlined
Write the body of the node a call names out in place of the call: its inputs become locals holding
what the call passed (or the defaults it declares), its outputs the locals the call declared, all in
a do ... end block so the node's own locals stay its own.
Parameters
srcstring— The graph's source.addressany(optional) — The local the call declares, or a line it spans.nodeSrcstring— The node's source.nodePathstring— The node's folder.hostPathstring?(optional) — The graph's folder.
modules/proc.code/lift
lift(src: string, path: string, from: number, to: number, opts: { call: string, description: string }): Lifted
Lift the statements on lines from-to of a graph's body into a node of their own. The node's
inputs are the locals declared before the section that it reads (a graph input's declaration is
carried over as it is written), its outputs are the locals it declares that the code after it reads,
and a local function it calls is copied into the node with it. The section in the graph is replaced
by one call of the node, call naming it.
Parameters
srcstring— The graph's source.pathstring— The graph's folder (what~in its calls is relative to).fromnumber— First line of the section.tonumber— Last line of the section.opts{ call: string, description: string }—{ call, description }: the name the graph calls the node by (~/parts/rim,points.rim), and the sentence the node describes itself with.
modules/proc.code/literal
literal(value: any): string
The Luau text of a plain value: a number, string, boolean, vector, or a table of them.
Parameters
valueany(optional) — The value.
modules/proc.code/parse
parse(src: string): Parsed
Read a graph or node source: its tokens, the builder function proc.define is given, and the
statements of that function's body and of the file around it.
Parameters
srcstring— The text of aninit.luau.
modules/proc.code/ports
ports(graph: any): ({ Ported }, { Ported })
A built graph's inputs and outputs in the order a call takes and gives them: each input with its type, default, range, options and description, each output with the type of the value it gives.
Parameters
graphany(optional) — A graph built in the call form.
modules/proc.code/promote
promote(partPath: string, opts: { name: string?, into: string?, description: string?, tags: { string }? }?): { [string]: any }
Make a part (a .procGraph a graph calls by its path) a node: write a .procNode that declares the
part's inputs as its own, calls the part with them and gives the part's outputs. The part keeps its
code and its callers; the node puts it among the nodes procgen.searchNodes finds and a graph calls
by name, and stays the part's: editing the part changes what the node makes.
Parameters
partPathstring— The part's folder.opts{ name: string?, into: string?, description: string?, tags: { string }? }?(optional) —{ name, into, description, tags }: the node's name (default: the part's), the folder it goes in (default: the part's folder's parent), what it does and the tags search finds it by (default: the part's own.metadata).
modules/proc.code/promoteSource
promoteSource(part: any, call: string, description: string): string
The source of a node standing for a part (a .procGraph called by its path): it declares the
part's inputs as its own, calls the part with them and gives the part's outputs as its own, so the
part keeps its code and its callers and the node puts it among the nodes a graph calls by name.
Parameters
partany(optional) — The part's graph.callstring— The name the node calls the part by.descriptionstring— What the node does.
modules/proc.code/refType
refType(graph: any, ref: any, depth: number?): string?
The type of the value a ref of graph stands for: a graph input's declared type, or the type of the
output a node gives, followed into a node's own graph where the node states no narrower type than Any.
Parameters
graphany(optional) — The graph the ref belongs to.refany(optional) — An InputRef (graph_inputornode_output).depthnumber?(optional)
modules/proc.code/reference
reference(src: string, from: number, to: number, call: string, node: any, inputs: { [string]: string }?,
Replace the statements on lines from-to with a call of an existing node. Each input of the node
takes the local the section reads under the same name unless inputs says otherwise; each local the
section makes that the code after it reads is taken from the node's output of the same name unless
outputs says otherwise.
modules/proc.code/removeCall
removeCall(src: string, address: any): string
Remove one call statement. Refused while the code after it still names a local it declares.
Parameters
srcstring— The graph's source.addressany(optional) — The local the call declares, or a line it spans.
modules/proc.code/rename
rename(src: string, from: string, to: string): string
Rename a local of the graph's body everywhere the body names it.
Parameters
srcstring— The graph's source.fromstring— The local's name.tostring— Its new name.
modules/proc.code/repoint
repoint(src: string, address: any, name: string): string
Point a call at another node, keeping its arguments.
Parameters
srcstring— The graph's source.addressany(optional) — The local the call declares, or a line it spans.namestring— The node to call (points.disc,~/parts/rim, a path).
modules/proc.code/resolveCall
resolveCall(graphPath: string, name: string): string
The folder of the node or part a graph at graphPath calls by name, resolved the way the call
resolves it.
Parameters
graphPathstring— The calling graph's folder.namestring— The name the call gives (points.disc,~/parts/rim, a path, an identity or a guid).
modules/proc.code/rootOf
rootOf(path: string): string?
The nearest folder a ~ name is relative to, for an asset at path: the nearest package, effect,
or the world's source.
Parameters
pathstring— An asset's folder.
modules/proc.code/setArgs
setArgs(src: string, address: any, set: { [string]: any }?, unset: { string }?, path: string?): string
Set and unset the arguments of one call. set maps an input name to a value ({ expr = "..." }
for code, anything else a plain value); unset lists inputs to leave to the node's defaults.
Parameters
srcstring— The graph's source.addressany(optional) — The local the call declares, or a line it spans.set{ [string]: any }?(optional) — Input name to value.unset{ string }?(optional) — Input names.pathstring?(optional) — The graph's folder, for a call by~.
modules/proc.code/setInput
setInput(src: string, name: string, default: any, opts: { [string]: any }?): string
Declare one of the graph's inputs, or change the declaration of one it has:
local <name> = g:input("<name>", <default>, <opts>).
Parameters
srcstring— The graph's source.namestring— The input's name.defaultany(optional) — Its default (nil for none: thenopts.typeis needed).opts{ [string]: any }?(optional) —{ type, min, max, options, description, optional }.
modules/proc.code/setOutput
setOutput(src: string, name: string, value: any?): string
Declare, change or remove one of the graph's outputs. value is code ({ expr = "..." } or the
name of a local as a string); nil removes the output.
Parameters
srcstring— The graph's source.namestring— The output's name.valueany?(optional) — What the output gives, or nil to remove it.
modules/proc.code/writeNode
writeNode(path: string, source: string, meta: { description: string, tags: { string }, call: string }): any
Write a node asset: its .metadata (description and tags), a README stating what it does, what it
takes and gives and how a graph calls it, and its source, in that order so the node registers from its
own source with its description already beside it.
Parameters
pathstring— The.procNodefolder.sourcestring— The node's source.meta{ description: string, tags: { string }, call: string }—{ description, tags, call }: what it does, the tags search finds it by, and the name a graph calls it by.
modules/proc.diskcache/README
require("@builtin::systems.procgen.proc.diskcache") -- proc.diskcache
A graph output's cooked value on disk, so a Generator loads what was cooked instead of cooking it again.
Usage: local proc.diskcache = require("@builtin::systems.procgen.proc.diskcache")
modules/proc.diskcache/complete
complete(index: any?, first: number, last: number): boolean
Whether an index holds every frame from first to last it will
ever hold: a graph time cannot change holds them all in one, and a write
its budget stopped holds what fit.
Parameters
indexany?(optional) — An index fromreadIndex, or nil.firstnumber— The first frame of the range.lastnumber— The last frame of the range.
modules/proc.diskcache/contentFor
contentFor(index: any, frame: number): string?
The content file a frame of an index names, or nil. A graph time cannot change names one file for every frame.
Parameters
indexany(optional) — An index fromreadIndex.framenumber— The timeline frame.
modules/proc.diskcache/decode
decode(bytes: string): any
The value bytes hold, rebuilt: columns in CPU storage, assets and
handles resolved again, a population's draws registered again.
Parameters
bytesstring— Whatencodemade.
local geometry = proc.diskcache.decode(bytes)
modules/proc.diskcache/encode
encode(value: any): string
The bytes a cooked value is stored as. A value a dispatch left on the device is read back first; anything with no disk form — a function, a field with no elements to be read over — raises, naming where it sits.
Parameters
valueany(optional) — A cooked value.
local bytes = proc.diskcache.encode(geometry)
modules/proc.diskcache/graphDigest
graphDigest(graph: any): string
The digest of a graph's document: what an index records it was cooked from, so an index made for a version of the graph that no longer stands is known and dropped.
Parameters
graphany(optional) — The Graph.
local digest = proc.diskcache.graphDigest(g)
modules/proc.diskcache/indexKey
indexKey(graph: any, outputName: string, params: any, timeline: any, timelessKey: number): string
The name of the index for one way of cooking a graph: the SHA-256 over everything that decides what it cooks — the graph's document, the params, its timeline's frame rate and range, the output's time-free key (which carries the versions of every op and node it uses, and the live state it reads) and the cache format.
Parameters
graphany(optional) — The Graph.outputNamestring— The output.paramsany(optional) — The params the graph is cooked with.timelineany(optional) —{ fps, first, last }: the rate the timeline plays at and the frames its range runs between, which a graph's time expressions read.timelessKeynumber— The output's time-free key (proc.historyKey).
local key = proc.diskcache.indexKey(g, "mesh", {}, { fps = 30, first = 0, last = 149 }, k)
modules/proc.diskcache/load
load(graphGuid: string, hash: string): any?
The value stored under content hash hash of graph graphGuid,
decoded, or nil when there is no such file.
Parameters
graphGuidstring— The graph's guid.hashstring— A content hash.
modules/proc.diskcache/provide
provide(id: string, provider: () -> { any })
Register what a generator stores when the world is committed:
provider() answers { { graphGuid, key, static, frames, valueAt, graphDigest, written? } }, one entry per output that caches and whose
index is not complete — frames and valueAt as write takes them,
graphDigest the graph as it stands, and written(result) told what the
write did. Registering the same id again
replaces it.
Parameters
idstring— The generator's id.provider() -> { any }— The function answering what to store.
proc.diskcache.provide(entityId, function() return {} end)
modules/proc.diskcache/prune
prune(graphGuid: string, graphDigest: string?): { string }
Delete what graph graphGuid's store holds for nothing: every index
cooked from a version of the graph other than graphDigest, and every
content file no remaining index names — what a frame's output used to be,
before the graph or its params changed. Answers the paths it removed.
Parameters
graphGuidstring— The graph's guid.graphDigeststring?(optional) — ThegraphDigestof the graph as it stands; an index recording another is dropped. Nil keeps every index.
local removed = proc.diskcache.prune(guid, proc.diskcache.graphDigest(g))
modules/proc.diskcache/readIndex
readIndex(graphGuid: string, key: string): any?
What the index key of graph graphGuid holds: { frames = { [frame] = contentHash }, static, stoppedAt? }, or nil when it has none.
stoppedAt is the first frame the write's budget left out.
Parameters
graphGuidstring— The graph's guid.keystring— An index name fromindexKey.
modules/proc.diskcache/store
store(): any
Write what every registered generator stores — the frames of each output whose index is not complete — and delete the content no index of those graphs names any longer. Committing the world does this first and stages every path it touched into the commit.
local touched = proc.diskcache.store()
modules/proc.diskcache/withdraw
withdraw(id: string)
Stop storing anything for generator id at commit.
Parameters
idstring— The generator's id.
modules/proc.diskcache/write
write(graphGuid: string, key: string, frames: { number }, valueAt: (number) -> any,
Write the frames of one way of cooking a graph: each value's content once, named by its hash, and the index mapping every frame to the content it produced. A frame whose output is the same as another's shares its file. Frames are asked for one at a time and encoded as they come, so a long timeline never holds more than one frame's bytes.
proc.diskcache.write(guid, key, { 0 }, function() return geo end, true)
modules/proc.edit/README
require("@builtin::systems.procgen.proc.edit") -- proc.edit
Editing a procedural graph as nodes and wires: the picture of a Graph a node editor draws (view), the catalogue of ops a node can be added from (catalogue), and every change a person makes to it (addNode, removeNode, connect, disconnect, setParam, the graph's inputs and outputs). Each change edits the Graph in memory and answers (ok, why?); writing the result into the asset is proc.saveSource. Positions are the editor's own and live beside the asset in layout.json. Ports named in:<name> and out:<name> stand for the graph's own inputs and outputs, so they wire like any node.
Usage: local proc.edit = require("@builtin::systems.procgen.proc.edit")
modules/proc.edit/addNode
addNode(graph: any, op: any, id: string?): (string?, string?)
Add a node running op (an op id, or a .procNode / .procGraph
asset ref). Its id comes from the op's name unless id is given.
Parameters
graphany(optional)opany(optional)idstring?(optional)
modules/proc.edit/catalogue
catalogue(): { any }
Every op a node can be added from: { id, pack, description, context },
sorted by id. Rebuilt when the registry changes.
modules/proc.edit/connect
connect(graph: any, fromId: string, fromPort: string, toId: string, toPort: string): (boolean, string?)
Wire the output port fromPort of fromId into the input port toPort
of toId. An input takes one wire (a socket typed T[] takes several, and
this adds one); a graph output (out:<name>) is bound to what it reads. A
wire is refused when it would close a cycle or carry a type the port does
not accept.
Parameters
graphany(optional)fromIdstringfromPortstringtoIdstringtoPortstring
modules/proc.edit/disconnect
disconnect(graph: any, toId: string, toPort: string, fromId: string?, fromPort: string?): (boolean, string?)
Take away what feeds the input port toPort of toId: every wire on
it, or with fromId and fromPort just the one that comes from there.
Parameters
graphany(optional)toIdstringtoPortstringfromIdstring?(optional)fromPortstring?(optional)
modules/proc.edit/inputTypes
inputTypes(): { string }
The types a graph input can be declared as.
modules/proc.edit/loadLayout
loadLayout(folder: string): { [string]: any }
The positions kept beside the graph in layout.json: { [id] = { x, y } }.
Parameters
folderstring
modules/proc.edit/params
params(graph: any, id: string): { any }
The params of node id as editable rows: { name, type, value, default, description, min, max, options, wired }, sorted by name. value is the
constant the node holds, nil while it takes the default or a wire.
Parameters
graphany(optional)idstring
modules/proc.edit/removeInput
removeInput(graph: any, name: string): (boolean, string?)
Remove the graph input name and every wire that read it.
Parameters
graphany(optional)namestring
modules/proc.edit/removeNode
removeNode(graph: any, id: string): (boolean, string?)
Remove a node (or composite) and every wire that read it. An output the node alone fed is removed with it.
Parameters
graphany(optional)idstring
modules/proc.edit/removeOutput
removeOutput(graph: any, name: string): (boolean, string?)
Remove the graph output name.
Parameters
graphany(optional)namestring
modules/proc.edit/renameInput
renameInput(graph: any, old: string, new: string): (boolean, string?)
Rename the graph input old to new, keeping its place in the order and
every wire that reads it.
Parameters
graphany(optional)oldstringnewstring
modules/proc.edit/renameOutput
renameOutput(graph: any, old: string, new: string): (boolean, string?)
Rename the graph output old to new.
Parameters
graphany(optional)oldstringnewstring
modules/proc.edit/saveLayout
saveLayout(folder: string, positions: { [string]: any }, keep: { [string]: boolean }?)
Keep positions beside the graph in layout.json, dropping the ids
keep (a set) does not hold. Written only when it changes.
Parameters
folderstringpositions{ [string]: any }keep{ [string]: boolean }?(optional)
modules/proc.edit/search
search(query: string, limit: number?): { any }
The ops whose id, pack or description holds every word of query.
Parameters
querystring— Space-separated words; empty answers the whole catalogue.limitnumber?(optional) — Most rows to answer (default 60).
modules/proc.edit/setDescription
setDescription(graph: any, text: string): (boolean, string?)
Say what the graph makes: the sentence search finds it by and the publish gate asks for. An empty sentence takes it away.
Parameters
graphany(optional)textstring
modules/proc.edit/setDomain
setDomain(graph: any, name: string, domain: string?): (boolean, string?)
Say which domain the graph output name stands as: "point",
"primitive", "mesh", or nil for none.
Parameters
graphany(optional)namestringdomainstring?(optional)
modules/proc.edit/setInput
setInput(graph: any, name: string, typ: string, opts: any?): (boolean, string?)
Declare (or redeclare) the graph input name: { type, default, min, max, description }. The order inputs were declared in is kept.
Parameters
graphany(optional)namestringtypstringoptsany?(optional)
modules/proc.edit/setOutput
setOutput(graph: any, name: string, fromId: string, fromPort: string): (boolean, string?)
Declare the graph output name, reading fromPort of fromId.
Parameters
graphany(optional)namestringfromIdstringfromPortstring
modules/proc.edit/setParam
setParam(graph: any, id: string, name: string, value: any): (boolean, string?)
Set the constant param name of node id to value; nil takes the
param back to its default. A wire on the param is replaced by the constant.
Parameters
graphany(optional)idstringnamestringvalueany(optional)
modules/proc.edit/uniqueId
uniqueId(graph: any, base: string): string
An id no node of graph holds, derived from base.
Parameters
graphany(optional)basestring
modules/proc.edit/updateInput
updateInput(graph: any, name: string, patch: { [string]: any }): (boolean, string?)
Change fields of the graph input name: patch holds any of type,
default, min, max, description. A change of type takes the default
the new type starts from when the old default does not fit it.
Parameters
graphany(optional)namestringpatch{ [string]: any }
modules/proc.edit/view
view(graph: any, positions: { [string]: any }?): any
The picture of graph a node editor draws: { nodes, edges } in the
shape edui.nodeGraph takes. Every graph node, composite, input and
output is a node; each producer a node or output reads is an edge. An op's
node carries a port for each socket and each declared param, a param with the
value that drives it while no wire does; a graph input's node carries its
name, type, default and range as fields. The words the editor draws on a
node (its fields' labels, the subtitle of an input, an output or a
composite) read from the procgen catalog in the editor's language; a
field's name is the one code finds it by.
Parameters
graphany(optional) — A Graph.positions{ [string]: any }?(optional) — Optional{ [id] = { x, y } }stored positions.
modules/proc.polyline/README
require("@builtin::systems.procgen.proc.polyline") -- proc.polyline
Arc-length measure along a polyline held as flat positions: its length, and the position and direction a given share of the way along it. The curves a geometry holds are read out with Geometry.curvePositions, and the ops that sample, sweep or grow along them measure them here.
Usage: local proc.polyline = require("@builtin::systems.procgen.proc.polyline")
modules/proc.polyline/length
length(pos: { number }, closed: boolean): number
The polyline's length, the closing span included when it closes.
Parameters
pos{ number }— Flat{ x0,y0,z0, ... }.closedboolean— Whether the last point joins back to the first.
proc.polyline.length({ 0,0,0, 3,4,0 }, false) --> 5
modules/proc.polyline/locate
locate(pos: { number }, closed: boolean, t: number): (number, number)
Which span t of the way along the polyline falls in, and how far
along that span: the span runs from point span to the next (to point 0
on the closing span).
Parameters
pos{ number }— Flat{ x0,y0,z0, ... }.closedboolean— Whether the last point joins back to the first.tnumber— The share of the length.
modules/proc.polyline/sample
sample(pos: { number }, closed: boolean, t: number): (number, number, number)
The position t of the way along the polyline by arc length, t in
[0, 1].
Parameters
pos{ number }— Flat{ x0,y0,z0, ... }.closedboolean— Whether the last point joins back to the first.tnumber— The share of the length.
local x, y, z = proc.polyline.sample(pos, false, 0.5)
modules/proc.polyline/tangent
tangent(pos: { number }, closed: boolean, t: number): (number, number, number)
The unit direction the polyline runs in t of the way along it.
Parameters
pos{ number }— Flat{ x0,y0,z0, ... }.closedboolean— Whether the last point joins back to the first.tnumber— The share of the length.
modules/proc.substrate/README
require("@builtin::systems.procgen.proc.substrate") -- proc.substrate
The substrate a graph carries: a geometry, its four domains, and the named columns over them.
Usage: local proc.substrate = require("@builtin::systems.procgen.proc.substrate")
modules/proc.substrate/addCurve
addCurve(self, pointIndices: { number }, closed: boolean?): number
Add one curve: a primitive running through the points pointIndices
names, in order. A curve is a line rather than a surface — a mesh built
from the geometry draws its faces and not its curves, and the ops that
sample, sweep or grow along lines read its curves — while its points are
points like any other, so every point and field op moves them.
Parameters
selfany(optional)pointIndices{ number }— 0-based point indices, in the order the curve runs.closedboolean?(optional) — Whether the curve runs from its last point back to its first.
g:addCurve({ 0, 1, 2, 3 }, false)
modules/proc.substrate/addPoints
addPoints(self, positions: { number }): any
Add count points at positions (a flat count * 3 array), each with
an id nothing else in this geometry carries. Ids are identity: a filter
renumbers indices and every id it keeps stays what it was.
Parameters
selfany(optional)positions{ number }— Flat{ x0,y0,z0, ... }.
g:addPoints({ 0,0,0, 1,0,0, 2,0,0 })
modules/proc.substrate/addPrimitive
addPrimitive(self, pointIndices: { number }): number
Add one primitive made of the points pointIndices names, in order. It
creates one vertex per entry, each naming the point it reads, and the
primitive's run over them.
Parameters
selfany(optional)pointIndices{ number }— 0-based point indices, in the order the primitive uses them.
g:addPrimitive({ 0, 1, 2 })
modules/proc.substrate/adopt
adopt(self, owner: string)
Hold this column's device runs for owner from now on
(substrate.setOwner): its own run, the mirrors it keeps of a run the CPU
holds, the indices an interned column stands on, the runs it keeps alive
with it (Column.keep), and the ones it keeps later. What something
keeping the column longer than the owner that made it — a cache several
makers read — calls when it takes the column in.
Parameters
selfany(optional)ownerstring— The owner to hold the runs for.
col:adopt(proc.sharedCacheOwner(key))
modules/proc.substrate/anyLive
anyLive(): boolean
Whether any run is live: some registration rewrites a run in place as the time it is a function of moves. A cook with no live run to follow asks nothing of the columns it handles.
if proc.substrate.anyLive() then print("a graph run is still on the device") end
modules/proc.substrate/atCapacity
atCapacity(fn: () -> any): any
Run fn with every live count (the one-word column an appended output or a device-made count holds)
sampling as the capacity it is bounded by, and answer what fn returns. A Field built over live counts,
sampled inside it, answers the largest value it can take: the capacity a count derived on the device is
allocated for. The device count itself is never read.
Parameters
fn() -> any— The function to run.
local most = proc.substrate.atCapacity(function() return field:sample(0) end)
modules/proc.substrate/attributeAt
attributeAt(self, name: string, id: number): ...any
The point attribute name at point id, as its components — what
g:getAttribute("point", name):sample(id) answers, in one call.
Parameters
selfany(optional)namestring— The attribute's name.idnumber— 0-based point index.
modules/proc.substrate/attributeNames
attributeNames(self, class: string): { string }
The attribute names in a class — every column except the intrinsics that hold the geometry itself.
Parameters
selfany(optional)classstring— "point", "vertex", "edge", "primitive" or "detail".
modules/proc.substrate/awaitPrefetch
awaitPrefetch(self, asBytes: boolean?): boolean
Wait until this column's run is on the CPU, as prefetch answers it: the
read is asked for if it is not in flight and the task parks on the read
itself, so it resumes in the frame the device answered where the engine can
wait on the device. A read of a run the device rewrites frame after frame
answers the run as the device held it when the read was taken, and the next
read or readBytes takes that answer. A read the engine gave up raises
with its reason.
Parameters
selfany(optional)asBytesboolean?(optional) — Whether the read wanted isreadBytes's rather thanread's.
col:awaitPrefetch(true); print(#col:readBytes(), "bytes")
modules/proc.substrate/bounds
bounds(self): { min: { x: number, y: number, z: number }, max: { x: number, y: number, z: number } }
Axis-aligned bounds over the live points, as { min = {x,y,z}, max = {x,y,z} }: the least and greatest of every lane, folded on the device and
read back as those six numbers. A geometry with no live point is bounded by
the origin.
Parameters
selfany(optional)
modules/proc.substrate/buffer
buffer(self): any
The substrate buffer behind a numeric column — the handle
entity.batchWrite, nx and a compute dispatch all take. A constant
column materializes here.
Parameters
selfany(optional)
entity.batchWrite(binding, "Transform", "position", col:buffer())
modules/proc.substrate/bufferLayout
bufferLayout(t: string): (string?, number?)
The substrate buffer element type a column of t is built from, and how
many of them one element occupies. A type the buffer primitive expresses
directly answers per = 1, and its buffer is one a batch write takes as it
stands.
Parameters
tstring— A procgen type tag.
local kind, per = proc.substrate.bufferLayout("Vec3") --> "vec3", 1
modules/proc.substrate/bufferName
bufferName(self): string?
The name this column's run lives under in the substrate, or nil for a column whose backing is not a named device buffer.
A device binding names its source buffer rather than holding a handle, so this is what lets a run already on the device be bound as the source of something else — placing a domain's elements from the columns that already hold their transform, rather than reading the run back to write it per element.
Parameters
selfany(optional)
local name = column:bufferName()
modules/proc.substrate/capacityOf
capacityOf(col: any): number?
The capacity a live count is bounded by: the one-word column an appended output or a count made on the device holds, or a clone of one (a clone shares the run, and the capacity is the run's).
Parameters
colany(optional) — A Column.
local most = proc.substrate.capacityOf(kept.indices_count)
modules/proc.substrate/carry
carry(src: any, dst: any, by: { [string]: any }?): any
Carry src's attributes onto dst. A domain by names an index list
for is GATHERED by it — element k of the result reads source element
by[k + 1], which is the one operation a filter, a split, a weld and a
remap all come down to, and it runs where the column lives. A domain with
no list carries its columns as they stand, and one named false is left
alone — that is the domain whose values the op computes rather than reads,
an average across a weld among them. The intrinsics are never carried: the
op that changed the topology wrote those itself.
Parameters
srcany(optional) — The geometry the attributes come from.dstany(optional) — The geometry they land on.by{ [string]: any }?(optional) —{ point = { ... } | false, vertex = ..., primitive = ... }, each list an array of 0-based source indices.
proc.substrate.carry(g, out, { point = srcPoint, primitive = srcFace })
modules/proc.substrate/carryBetween
carryBetween(src: any, dst: any, a: { number }, b: { number }, w: { number }): any
Carry src's point attributes onto dst's points, each of which lies
between two of src's: point k of dst is w[k] of the way from point
a[k] to point b[k]. Numbers are blended between the two; a value that
cannot be blended is taken from the nearer. P and id are the
destination's own.
Parameters
srcany(optional) — The geometry the attributes come from.dstany(optional) — The geometry whose points they land on, one per entry ofa.a{ number }— 0-based source point each destination point starts from.b{ number }— 0-based source point each destination point runs toward.w{ number }— How far froma[k]tob[k], in [0, 1].
proc.substrate.carryBetween(curve, samples, { 0, 0 }, { 1, 1 }, { 0.25, 0.75 })
modules/proc.substrate/carryCount
carryCount(col: any, counter: any, capacity: number): any
Make col a column of capacity slots of which the first counter words are live.
Parameters
colany(optional) — A Column the caller owns.counterany(optional) — The one-word count the column carries; it goes with the column.capacitynumber— The slots the column is allocated for.
proc.substrate.carryCount(indices, counter, 64)
modules/proc.substrate/clone
clone(self): any
A copy with its own backing. A constant column copies as a constant one, so sharing survives the copy at the cost of one value.
Parameters
selfany(optional)
modules/proc.substrate/closeLiveWindow
closeLiveWindow(window: any): boolean
Close window (openLiveWindow) and every window opened after it on this thread, and answer whether the work
inside it read a live run, or a live value made before it opened.
Parameters
windowany(optional) — The window.
local readLive = proc.substrate.closeLiveWindow(window)
modules/proc.substrate/column
column(self, name: string): any
The column named name, or nil.
Parameters
selfany(optional)namestring
modules/proc.substrate/columnMoves
columnMoves(): number
How many times a column that already stood has been let go of its run or given another, or a domain has had a column put in or taken out. A holder that read which runs a value's columns stand on at one count knows they stand there still while the count is the same: a column made afterwards changes no column that stood before.
local at = proc.substrate.columnMoves()
modules/proc.substrate/concat
concat(t: string, parts: { any }, counts: { number }, absent: { number }?): any
One column holding parts end to end, each covering the element count
counts gives it. A part that is nil covers its elements with absent,
or zeros without one (for a column carried as values, with nothing). Runs
the device holds are laid end to end on the device; runs the CPU holds are
copied there.
Parameters
tstring— The element type of the result.parts{ any }— One Column or nil per part.counts{ number }— The element count of each part.absent{ number }?(optional) — The value, one number per lane, a nil part's elements hold.
local P = proc.substrate.concat("Vec3", { a:column("point", "P"), b:column("point", "P") }, { 4, 9 })
modules/proc.substrate/constant
constant(t: string, value: any, count: number): any
A column holding value at every element. It costs one value however
many elements it stands for, and a write to any one of them materializes
the run.
Parameters
tstring— The element type tag.valueany(optional) — One element's value —lanesnumbers as an array for a numeric type, the value itself for a type carried as values.countnumber— How many elements it stands for.
proc.substrate.Column.constant("Vec3", { 0, 1, 0 }, 1000000)
modules/proc.substrate/copyToPoints
copyToPoints(sources: { any }, points: any, opts: { variant: string?, skip: { [string]: boolean }? }?): any
A copy of a source stamped at every point, all in one geometry, on the
device. Each point's copy is its source scaled by the point's scale,
turned by its orient (a quaternion x, y, z, w) and moved to its P; a
point without one stands at no scale or turn. With several sources each
point's variant attribute names the one it takes (0 is the first); a
point naming none of them takes no copy. The copies lie in point order, in
every domain: their corners name their own copy's points, their faces their
own copy's corners, and their normals turn with them. A source point's
own orient is turned by its copy's and its Vec3 scale multiplied by
it, so instances copied onto points keep their own turn and size inside
the copy's. Every other point
attribute stands on each point of its copy, over a source's own attribute
of that name; one carried as values (text, records) is carried as its
indices into the values it holds (Column.intern). The copies' ids and
slots are their own places.
The whole runs where the points are: nothing is read back, the points' live count bounds every pass, and how many copies there are in all is a count on the device, so a population a solver moves copies on every frame without a pause. A geometry whose counts the CPU cannot know — several sources, or points counted on the device — carries its live counts there.
Parameters
sources{ any }— The geometries to copy, in the ordervariantnames them.pointsany(optional) — A geometry whose points the copies stand at.opts{ variant: string?, skip: { [string]: boolean }? }?(optional) —{ variant = name?, skip = { [name] = true }? }: the point attribute that names each point's source, and point attributes the copies take nothing from.
local rocks = proc.substrate.Geometry.copyToPoints({ rock }, scattered)
modules/proc.substrate/count
count(self): number
Element count.
Parameters
selfany(optional)
modules/proc.substrate/countTraffic
countTraffic(handle: any, opts: { type: string, len: number }): any
Count what a device buffer made outside this module moves between the
CPU and the device — a buffer a shader owns (shaderRef:createBuffer) —
into proc.substrate.traffic. Every buffer createBuffer makes is counted
already.
Parameters
handleany(optional) — The buffer handle.opts{ type: string, len: number }— The{ type, len }it was created with.
local dst = proc.substrate.countTraffic(shaderRef:createBuffer("dst", opts), opts)
modules/proc.substrate/countedReads
countedReads(fn: () -> any): any
Run fn, counting the reads it makes in traffic().countReads rather than in readbacks: a read the caller
asks again itself, the way a count read where a number is needed is asked again of a recorded cook.
Parameters
fn() -> any— The function to run.
local same = proc.substrate.countedReads(function() return a:readBytes() == b:readBytes() end)
modules/proc.substrate/cpuBytes
cpuBytes(self): number
The bytes this column holds on the CPU: its words when its buffer lives there, a slot per element for a column carried as values. A column in GPU storage holds none here — its run is counted by the owner it is held for.
Parameters
selfany(optional)
modules/proc.substrate/createBuffer
createBuffer(opts: { [string]: any }): any
A substrate buffer, as substrate.createBuffer makes it, whose
traffic between the CPU and the device — when it lives on the device — is
counted into proc.substrate.traffic. The one way procedural code makes a
buffer, so what every node moves is known without the node saying.
Parameters
opts{ [string]: any }—substrate.createBuffer's options.
local tile = proc.substrate.createBuffer({ name = "t.tile", type = "f32", len = 256, kind = "gpu" })
modules/proc.substrate/curveCount
curveCount(self): number
How many of the geometry's primitives are curves.
Parameters
selfany(optional)
modules/proc.substrate/curvePositions
curvePositions(self, curve: any): { number }
The positions a curve runs through, flat, in its order.
Parameters
selfany(optional)curveany(optional) — One entry ofcurves().
modules/proc.substrate/curves
curves(self): { any }
Every curve the geometry holds, in primitive order: the primitive, the point indices it runs through and whether it closes.
Parameters
selfany(optional)
for _, c in ipairs(g:curves()) do print(#c.points) end
modules/proc.substrate/deferReleases
deferReleases(): any
Hold every column let go of from now on until releaseDeferred: the buffers a recorded cook's dispatches use
stay on the device after the nodes that made them let go.
local held = proc.substrate.deferReleases()
modules/proc.substrate/deferredReads
deferredReads(fn: () -> any): any
Run fn, counting the reads it asks for in traffic().deferredReads rather than in readbacks: reads whose
answers land in a later frame and that nothing waits for, such as the words a replay's guards are checked by.
Parameters
fn() -> any— The function to run.
local later = proc.substrate.deferredReads(function() return proc.substrate.readLater({ flag = flag }) end)
modules/proc.substrate/detailNames
detailNames(self): { string }
The names of the values covering the whole geometry, sorted.
Parameters
selfany(optional)
modules/proc.substrate/deviceWords
deviceWords(self): any?
The run in GPU storage that holds this column's own 32-bit words (element()): a kernel binding of
i32 or u32 reads an Int or UInt column through it. A column already in GPU storage is itself; a CPU
column keeps a mirror of its words that goes with it, as gpuMirror's does.
Parameters
selfany(optional)
local run = col:deviceWords()
modules/proc.substrate/distinct
distinct(self): { any }
The distinct values an interned column indexes into, 1-based.
Parameters
selfany(optional)
modules/proc.substrate/domain
domain(self, name: string): any
The domain named name.
Parameters
selfany(optional)namestring— "point", "vertex", "primitive" or "detail".
modules/proc.substrate/drain
drain(self): any
Bring every column the device holds back to the CPU, so the flat arrays
derived from them can be read. This is what a mesh algorithm written over
positions and indices pays to run on the CPU, paid ONCE and where it
can be seen, rather than per column inside a read that cannot wait. A
domain whose live elements are counted on the device (Domain.liveCount)
is read as exactly those: its count comes back with its runs, and what is
answered is a copy holding that many elements, since a CPU reader walks
count() of them. A geometry a column carries as a value (the mesh of
a packed piece's Mesh record) is drained with it, and a column carrying
one that drains to a copy is answered in a copy carrying the drained one.
Parameters
selfany(optional)
g = g:drain()
modules/proc.substrate/drainAll
drainAll(value: any): any
Bring every geometry value holds back to the CPU (Geometry.drain): a
geometry itself, the sources and points of an instance set, and every
element of an array. What a CPU reader is handed, so the flat arrays it
walks can be read; a value holding nothing on the device costs a walk of
its columns and no readback. A geometry counted on the device is answered
as the copy Geometry.drain makes, and a value holding one as a copy
holding that, so what value itself holds is left as it stands.
Parameters
valueany(optional) — Any value an op or a realize step is about to read.
local g = proc.substrate.drainAll(inputs.geometry)
modules/proc.substrate/drawVersion
drawVersion(self): string
Which version of its shape the geometry draws as: the versions of every
column a mesh is built from, as one string. The same string exactly while
none of them has been written, so a mesh built from the geometry stands
for as long as this answers what it did when the mesh was made. A mesh is
built with normals, and a geometry carrying none is given them here, the
way toMeshArgs would, so the answer is the same before its mesh is made
as after.
Parameters
selfany(optional)
if g:drawVersion() ~= held.version then print("the graph draws a new version") end
modules/proc.substrate/dropReads
dropReads(self)
Let go of the flat arrays this column holds from being read: the run a read brought back to the CPU and the bytes a byte read brought back. The buffer the column stands on is untouched, and the next read takes them again. A reader that read a column once and keeps the column calls it so the column holds its buffer alone.
Parameters
selfany(optional)
modules/proc.substrate/edges
edges(self): any
The geometry's edges on the device — each unordered point pair a side
of its fan triangles joins, numbered as proc.ops.topology numbers them
(see proc.device.edges). Derived on the first ask and held until the faces
they come from change; the geometry lets them go with its own runs.
Parameters
selfany(optional)
local edges = g:edges(); print(edges.capacity)
modules/proc.substrate/element
element(self): string
The 32-bit word form the column's run holds: "i32", "u32" or "f32".
Parameters
selfany(optional)
if col:element() == "i32" then ... end
modules/proc.substrate/elementCount
elementCount(self, class: string): number
How many elements an attribute class has. An edge is the unordered
point pair a primitive uses rather than a row of its own, so its count is
derived — proc.ops.topology.elementCount(g, "edge") answers it.
Parameters
selfany(optional)classstring
modules/proc.substrate/elementOf
elementOf(t: string): string
The 32-bit word form a column of type t holds: "i32" for Int, "u32" for UInt, "f32"
for every other type.
Parameters
tstring— A procgen type tag.
proc.substrate.elementOf("Int") --> "i32"
modules/proc.substrate/endDeferral
endDeferral(held: any)
Stop holding the columns let go of: the ones held so far stay with held.
Parameters
heldany(optional) — WhatdeferReleasesanswered.
proc.substrate.endDeferral(held)
modules/proc.substrate/following
following(fn: (...any) -> ...any, ...: any): ...any
Run fn for a reader that follows the live runs it reads: it is presented again at every rewrite of what it
read, so what it reads holds no moment's value, and those reads are not counted (liveReads).
Parameters
fn(...any) -> ...any— The function that reads.argsany(optional)
local bytes = proc.substrate.following(column.readBytes, column)
modules/proc.substrate/forgetDevice
forgetDevice()
Let go of every mirror after the render device is rebuilt. What each held stood on the device that went, so a run that reads one of those columns on the device puts it there again.
proc.substrate.forgetDevice()
modules/proc.substrate/fromArrays
fromArrays(data: { positions: { number }?, indices: { number }?,
A geometry holding the flat arrays a mesh algorithm produces: one point
per position, one triangle per index triple, and normals / uvs as point
columns. Every column is filled once, so building a mesh of any size costs
one write per column rather than one per element.
proc.substrate.fromArrays({ positions = pos, indices = idx })
modules/proc.substrate/fromCurves
fromCurves(positions: { number }, curves: { any }): any
A geometry of curves over one set of points: positions are the
points, and each entry of curves is one curve through them — the point
indices it runs through, in order, and whether it closes. Curves may share
points, the way a branch starts where its parent passes. Every column is
written once.
Parameters
positions{ number }— Flat{ x0,y0,z0, ... }.curves{ any }—{ { points = { 0-based point indices }, closed = boolean? }, ... }.
proc.substrate.fromCurves({ 0,0,0, 1,0,0, 1,1,0 }, { { points = { 0, 1, 2 } } })
modules/proc.substrate/fromPointCloud
fromPointCloud(pc: any): any
A geometry holding the points of a PointCloud value: its positions as
the point run, each attribute on the point domain, each detail as a detail
value. What a socket declared as anything but PointCloud is handed.
Parameters
pcany(optional) — A PointCloud (proc.PointCloud.new, or one read from a graph document).
local g = proc.substrate.fromPointCloud(proc.PointCloud.new({ 0,0,0 }))
modules/proc.substrate/fromPositions
fromPositions(positions: { number }): any
A geometry holding positions as its points and nothing else — what a
source op makes. One buffer write, no growth pass.
Parameters
positions{ number }— Flat{ x0,y0,z0, ... }.
proc.substrate.fromPositions({ 0,0,0, 1,0,0 })
modules/proc.substrate/gather
gather(self, keep: { number }): any
A column of the same type holding the elements keep names, in that
order — what a filter, a sort and a delete all come down to.
Parameters
selfany(optional)keep{ number }— An array of 0-based element indices.
local kept = col:gather({ 0, 3, 4 })
modules/proc.substrate/get
get(self, id: number): ...any
The value at element id (0-based): lanes numbers for a numeric
column, the value itself for one carried as values. Per-element reads are
for a small column or a probe; a column of any size is handed to a kernel
or a batch write whole.
Parameters
selfany(optional)idnumber— 0-based element index.
local x, y, z = col:get(7)
modules/proc.substrate/getAttribute
getAttribute(self, class: string, name: string): any
Read a named attribute. An element class answers the column, which is what a field is asked for too; detail answers the value it was set with.
Parameters
selfany(optional)classstringnamestring
modules/proc.substrate/getDetail
getDetail(self, name: string): any
A value covering the whole geometry, or nil.
Parameters
selfany(optional)namestring
modules/proc.substrate/gpu
gpu(t: string, count: number, usage: BufferUsage?): any
A numeric column whose buffer lives in GPU storage — the same handle a compute dispatch binds. Reading one back on the CPU is a readback, so a column meant to be read asks for it here.
Parameters
tstring— The element type tag.countnumber— Element count.usageBufferUsage?(optional) — Extra buffer usage, e.g.{ "readback" }.
proc.substrate.Column.gpu("Vec3", 30000, { "readback" })
modules/proc.substrate/gpuMirror
gpuMirror(self): any?
This column's run in GPU storage — itself when it already lives there, else a mirror the column keeps.
A compute dispatch binds GPU storage, so a run the CPU holds is uploaded once and the mirror is what a dispatch reads. The mirror belongs to the column: it is dropped the moment anything takes the right to write the buffer under it, and freed when the column is released. So a run that does not change is uploaded once however many dispatches read it, and a run that does not outlive its column does not outlive it on the device either.
A column something keeps longer than the owner that made it
(Column.adopt) keeps its mirror for that keeper, whenever the mirror is
made.
Answers nil for a column carried as values, which has no run to mirror, and for one the device refused storage for.
Parameters
selfany(optional)
local run = col:gpuMirror()
modules/proc.substrate/holdCarried
holdCarried(holder: any, value: any)
Make holder hold value, a value it carries (a geometry a record of its columns holds) that the cook which
made it lets go of: the value stands while any holder of it stands (a copy of a holder holds it too), and is
let go of with the last of them.
Parameters
holderany(optional) — A Geometry, or a Column carried as values, whose columns carryvalue.valueany(optional) — A value with a release hook (a Geometry or a Column).
proc.substrate.holdCarried(pieces, mesh)
modules/proc.substrate/holdFor
holdFor(owner: any)
Hold every device run a column makes on this thread, for the rest of
the thread's life, for owner — a name, or a function answering it when a
run is made. What a worker thread doing one owner's work calls once.
Parameters
ownerany(optional) — The owner, or a function answering it.
proc.substrate.holdFor(function() return cacheOwner end)
modules/proc.substrate/holdsIds
holdsIds(self, name: string): boolean
Whether the column named name is marked as holding point ids.
Parameters
selfany(optional)namestring— The attribute's name.
modules/proc.substrate/holdsStandIn
holdsStandIn(value: any): boolean
Whether a value an op answered holds a stand-in for a column on the device (structureOf).
Parameters
valueany(optional) — What was answered.
modules/proc.substrate/idColumns
idColumns(self, class: string): { string }
The names of the columns of class that are marked as holding point ids, sorted.
Parameters
selfany(optional)classstring— "point", "vertex" or "primitive".
modules/proc.substrate/index
index(self): any
The run of indices an interned column holds: one Float per element, each an index into its distinct values.
Parameters
selfany(optional)
local run = col:index():gpuMirror()
modules/proc.substrate/intern
intern(self): any
This column as indices into its distinct values (Column.interned),
which is how a column carried as values is placed on the device: it keeps
what it is when it already is one, and a column carried as values is
interned once — its distinct values in the order they first appear —
and remembers the answer. A text is distinct by its characters, any
other value by its identity.
Parameters
selfany(optional)
local idx = col:intern():index()
modules/proc.substrate/interned
interned(t: string, values: { any }, index: any): any
A column carried as values whose elements are placed on the device as
numbers: each element is an index into values, the distinct values the
column holds, and index is that run of indices — a Float column, on the
CPU or the device. A pass over elements moves the indices and carries the
same values; a reader on the CPU gets each element's value exactly as it
gets one from Column.values.
Parameters
tstring— The element type tag.values{ any }— The distinct values, 1-based; index 0 names the first.indexany(optional) — A Float column of 0-based indices intovalues, one per element.
local labels = proc.substrate.Column.interned("String", { "oak", "pine" }, idx)
modules/proc.substrate/isConstant
isConstant(self): boolean
Whether the column is one value standing for every element, which holds no run.
Parameters
selfany(optional)
modules/proc.substrate/isCountColumn
isCountColumn(v: any): boolean
Whether a value is a count a Column holds as one word: what a domain's .count answers while its count is on the
device.
Parameters
vany(optional) — Any value.
modules/proc.substrate/isCountValue
isCountValue(v: any): boolean
Whether a value stands for one number held on the device: a count Column, or a Field made only of counts and
constants (arithmetic over a count). readCount reads either.
Parameters
vany(optional) — Any value.
modules/proc.substrate/isCurve
isCurve(self, prim: number): boolean
Whether primitive prim is a curve rather than a face.
Parameters
selfany(optional)primnumber— 0-based primitive index.
modules/proc.substrate/isGpu
isGpu(self): boolean
Whether the column's buffer lives in GPU storage.
Parameters
selfany(optional)
modules/proc.substrate/isNumeric
isNumeric(t: string): boolean
Whether a column of t is backed by a substrate buffer.
Parameters
tstring— A procgen type tag.
modules/proc.substrate/isShared
isShared(self): boolean
Whether every element holds one shared value — true for a column still on its constant backing. What a reader gets is the same either way.
Parameters
selfany(optional)
modules/proc.substrate/join
join(self: any, col: any)
Add the run of col to the runs this counter counts writes of, from its next note on. A run already in it,
and a column holding no run on the device, are left as they are.
Parameters
selfany(optional)colany(optional) — The Column.
counter:join(col)
modules/proc.substrate/keep
keep(self, run: any)
Keep run alive with this column: it is released with the column, and held for whoever keeps the column
(Column.adopt), now or later.
Parameters
selfany(optional)runany(optional) — A Column whose run this column reads from.
col:keep(converted)
modules/proc.substrate/lanes
lanes(self): number
Numbers per element, 0 for a column carried as values.
Parameters
selfany(optional)
modules/proc.substrate/lanesOf
lanesOf(t: string): number
How many numbers one element of t occupies, or 0 when the type is
carried as values rather than as numbers.
Parameters
tstring— A procgen type tag ("Vec3", "String", "Mesh", ...).
proc.substrate.lanesOf("Vec3") --> 3
modules/proc.substrate/live
live(self): any?
The registration that rewrites this run in place, or nil for a run nothing rewrites.
Parameters
selfany(optional)
local reg = col:live()
modules/proc.substrate/liveCount
liveCount(self): any?
How many of the domain's elements are live, as a count on the device —
or nil when every element counted by count() is. A domain whose
membership is decided on the device (the particles a solver keeps, the
points a compaction kept) holds its runs at a capacity count() answers
and its live count here, so no pass reads it back to know how many there
are: a kernel over the domain reads the count where it is and leaves every
element past it alone.
Parameters
selfany(optional)
modules/proc.substrate/liveMint
liveMint(): number
A number for a live value being made (proc.fieldc.live), to be handed to noteLiveRead when it is read: a
window opened before the value was made sees a read of it as one of its own time.
local mint = proc.substrate.liveMint()
modules/proc.substrate/liveReads
liveReads(): number
How many times the calling thread has read a live run — or a live value — on the CPU. Two equal answers mean it took no snapshot of one in between, whatever other threads read meanwhile.
local before = proc.substrate.liveReads()
modules/proc.substrate/liveSize
liveSize(count: any): (number?, any?)
The room and the one-word counter of a count that sizes work: a count Column carrying its capacity, or arithmetic over counts that only grows with them (the capacity is what it comes to with every count full, the counter is that arithmetic evaluated on the device).
Parameters
countany(optional) — A count Column or a Field made of counts and constants.
local room, counter = proc.substrate.liveSize(geometry.point.count * 3)
modules/proc.substrate/markLive
markLive(self, registration: any)
Declare this GPU run to be rewritten in place by registration, which
is what live answers for it and for every clone of it. A registration
names the live registrations of the runs it reads in deps, and either the
compiled kernel that rewrites it (kernel, buffers, count, paramsRun,
values, live) or a rewrite(clock) that brings it to a new time. A
rewrite that queues the same dispatches over the same runs whatever the
clock says carries record = true, and is recorded on its first rewrite
and replayed after (proc.device.record); what holds the rewritten runs
lets the recording go with proc.fieldc.releaseRecording(registration).
One registration may stand for several runs one rewrite writes together.
Parameters
selfany(optional)registrationany(optional) — What rewrites the run.
out:markLive({ deps = {}, rewrite = function(clock) end })
modules/proc.substrate/materialize
materialize(self, count: number?): { number }
The flat run of count elements, under the name a field answers to. A
column already holds it, so this is the read rather than a walk of one
sample per element.
Parameters
selfany(optional)countnumber?(optional) — How many elements to answer for.
modules/proc.substrate/merge
merge(parts: { any }, absent: ((string) -> { number }?)?): any
Every part laid end to end in one geometry: each domain's elements in
part order, every column any part carries (a part without one fills its
elements with the value absent names for the column, or zeros), the
vertices re-pointed at their own part's points
and the primitives at their own part's vertices. Ids stay identity: an
element's id is its own id times the part count plus its part's index, so
every element of a part keeps one id however the other parts change. The
detail values are the first part's. Parts that count any domain's elements
on the device, or hold runs there, are merged there: in every domain each
part's live elements after the live elements before it, the whole counted
on the device, the indices into another domain moved past that domain's
elements before them, a point's slot moved past the capacities of the
parts before it, and an attribute indexing the labels a part's detail names
moved past the labels before it.
Parameters
parts{ any }— The geometries, in order.absent((string) -> { number }?)?(optional) — The value, one number per lane, the elements of a part that carries no column named so hold:proc.translate.absentValuegives every element the rest its components stand at.
local both = proc.substrate.Geometry.merge({ a, b })
modules/proc.substrate/mintName
mintName(prefix: string): string
prefix followed by a number no VM of the engine was handed before (substrate.mintName): a name for
something procgen files by name, unique across every VM a cook runs in.
Parameters
prefixstring— What the name starts with.
local key = proc.substrate.mintName("proc.translate.")
modules/proc.substrate/mintOwner
mintOwner(kind: string): string
A fresh owner name, unique across every VM of the engine, for what makes runs
and lets go of them together (proc.substrate.withOwner).
Parameters
kindstring— What the owner is, the name's prefix.
local owner = proc.substrate.mintOwner("cache")
modules/proc.substrate/movedAt
movedAt(v: any): number
The count (columnMoves) at which a column was last let go of its run or given another, or a domain last had
a column put in or taken out; 0 for one that has not moved. A holder that read a value's columns at one stamp knows
they stand while the stamps of the columns and domains it read are the same, whatever moved elsewhere.
Parameters
vany(optional) — A Column or a Domain.
local at = proc.substrate.movedAt(geometry:domain("point"))
modules/proc.substrate/name
name(self): string
The domain's name: "point", "vertex", "primitive" or "detail".
Parameters
selfany(optional)
modules/proc.substrate/names
names(self): { string }
Every attribute name on the domain, sorted, so iteration is the same on every run and a cook key over them is stable.
Parameters
selfany(optional)
modules/proc.substrate/new
new(): any
An empty geometry: no points, no vertices, no primitives, one detail element.
local g = proc.substrate.Geometry.new()
modules/proc.substrate/note
note(self: any)
Count one write of every run in this counter: every read of any of them taken before stops being an answer.
Parameters
selfany(optional)
counter:note()
modules/proc.substrate/noteLiveRead
noteLiveRead(mint: number?)
Count one CPU read of a live value — what a value that stands for a
live run's input, rather than a run itself, reports when it is sampled.
mint is the number the value was made under (liveMint).
Parameters
mintnumber?(optional) — The value's number, or nil for one made before any window.
proc.substrate.noteLiveRead(mint)
modules/proc.substrate/noteRewrite
noteRewrite()
Say that live runs were rewritten on the device: a read of one taken before this no longer holds, and the next read of it comes back again.
proc.substrate.noteRewrite()
modules/proc.substrate/noteWritten
noteWritten(self)
Note that a kernel wrote this column's run in place: every read of the run taken before, by this column or any other holder of the run, stops being an answer. What a pass writing into a run that already stands calls for each run it writes.
Parameters
selfany(optional)
col:noteWritten()
modules/proc.substrate/numbers
numbers(t: string, count: number, values: { number }?): any
A numeric column of count elements, backed by a substrate buffer.
values, when given, is the flat count * lanes run written into it.
Parameters
tstring— The element type tag, one that occupies lanes.countnumber— Element count.values{ number }?(optional) — Optional flat array to write.
proc.substrate.Column.numbers("Vec3", 2, { 0,0,0, 1,0,0 })
modules/proc.substrate/onCountRead
onCountRead(hook: ((any, number) -> ())?)
Say what to do with every count read where a number is needed: the evaluator records the read of a cook being recorded as a list, so a replay asks it again.
Parameters
hook((any, number) -> ())?(optional) —hook(column, number), or nil.
modules/proc.substrate/onDevice
onDevice(self): boolean
Whether any column the geometry draws from is held on the device: its
positions, its corners, its faces or its live counts. A geometry that is
becomes a mesh with toDeviceMesh, which leaves it there.
Parameters
selfany(optional) — Geometry.
if g:onDevice() then local m = g:toDeviceMesh("rock") end
modules/proc.substrate/openLiveWindow
openLiveWindow(): any
Open a window over the work that follows on this thread, closed with closeLiveWindow: whether that work
read on the CPU a live run, or a live value made before the window opened, and so holds a moment's value.
local window = proc.substrate.openLiveWindow()
modules/proc.substrate/owner
owner(): string?
The owner device runs made on this thread now are held for, or nil.
modules/proc.substrate/position
position(self, id: number): (number, number, number)
Where point id is, as x, y, z.
Parameters
selfany(optional)idnumber— 0-based point index.
local x, y, z = g:position(0)
modules/proc.substrate/prefetch
prefetch(self, asBytes: boolean?): boolean
Ask for this column's run to come back to the CPU without waiting for
it, and answer whether it has: true once a read that still holds has
arrived, after which read answers without waiting. A column the CPU
already holds answers true at once. What a reader that must not wait — a
frame's tick — polls before it reads.
Parameters
selfany(optional)asBytesboolean?(optional) — Whether the read wanted isreadBytes's rather thanread's.
if col:prefetch() then print(col:read()) end
modules/proc.substrate/primitivePoints
primitivePoints(self, prim: number): { number }
The point indices a primitive uses, in order.
Parameters
selfany(optional)primnumber— 0-based primitive index.
modules/proc.substrate/read
read(self): { number }
The numbers of a column. A column that carries a live count (an appended output, a column of a geometry whose class counts its live elements on the device) answers the live elements only: the slots past the count are never in the answer, and the count is read back once for it.
Parameters
selfany(optional)
modules/proc.substrate/readBytes
readBytes(self): buffer
The run this column holds, AS BYTES — the same memory the buffer has, without a number per element passing through Luau on the way.
That is the difference between a copy and a walk: read builds one Luau
value per component, and a run of five thousand vec3s is fifteen thousand
of them made, held and collected every time it is read. This answers the
block, which is what another buffer's writeBytes takes.
Parameters
selfany(optional)
dst:buffer():writeBytes(src:readBytes())
modules/proc.substrate/readCount
readCount(col: any): number
The number a count Column holds, read back at the point that needs a number. The read is one read-back, counted
in traffic().countReads apart from the reads a node makes of its own, and reported to the hook of onCountRead.
Parameters
colany(optional) — A count Column (isCountColumn).
local n = proc.substrate.readCount(geometry.point.count)
modules/proc.substrate/readLater
readLater(columns: { [string]: any }): any
Read columns back to the CPU without waiting for them, each answer about the frame its read was asked in.
poll() answers the numbers of every column, by name (lanes per slot, as read answers them), once the reads
asked for together have all landed, and nil until they have; whenever no read is in flight it asks for the
columns as they stand now. A read the engine gave up is asked for again. A run the device rewrites frame after
frame is read here as the value of one frame, and takes no live read: what takes the answer holds it as that
frame's. release() lets go of the columns, which the reader holds while it reads them.
Parameters
columns{ [string]: any }— The columns, by name.
local later = proc.substrate.readLater({ total = count }); local landed = later.poll()
modules/proc.substrate/readSlots
readSlots(col: any): { number }
Every slot of a column's run, the ones past a live count included: what a mirror of the run holds.
Parameters
colany(optional) — A Column.
modules/proc.substrate/recalcNormals
recalcNormals(self): any
Recompute the per-point normal column N from the primitives: each
face's unnormalized cross product, which carries twice its area, is added
to every point it touches and the sum is normalized — so a large face
weighs on a shared point in proportion to how much of it there is. A point
no primitive gives a direction gets (0, 1, 0).
Parameters
selfany(optional)
modules/proc.substrate/relaxPoints
relaxPoints(column: any, iterations: number, radius: number, strength: number): any
Push every point off its neighbours inside radius, iterations times,
on the device, finding them through a spatial grid. What a scatter runs to
even itself out.
Parameters
columnany(optional) — The point positions, a Vec3 column.iterationsnumber— How many passes.radiusnumber— The neighbourhood each point pushes within.strengthnumber— How far a point moves per pass, as a fraction ofradius.
local relaxed = proc.substrate.relaxPoints(P, 5, 0.4, 0.5)
modules/proc.substrate/release
release(self: any)
Take every run out of this counter, each keeping the writes it was counted as its own; later notes count nothing.
Parameters
selfany(optional)
counter:release()
modules/proc.substrate/releaseDeferred
releaseDeferred(held: any)
Let go of every column held holds.
Parameters
heldany(optional) — WhatdeferReleasesanswered.
proc.substrate.releaseDeferred(held)
modules/proc.substrate/removeAttribute
removeAttribute(self, class: string, name: string): any
Drop a named attribute, freeing what it held.
Parameters
selfany(optional)classstringnamestring
modules/proc.substrate/removeColumn
removeColumn(self, name: string): any
Drop the column named name, freeing its buffer.
Parameters
selfany(optional)namestring
modules/proc.substrate/restoreOwner
restoreOwner(slot: any, previous: any, ok: boolean, ...: any): ...any
Call fn(...) with every device run a column makes during it held
for owner, on this thread, and answer what fn answers. owner is a
name, or a function answering the name when a run is made. A run's owner
lets go of it with substrate.releaseOwner(owner).
Parameters
slotany(optional)previousany(optional)okbooleanargsany(optional)
proc.substrate.withOwner(owner, function() return proc.eval(graph) end)
modules/proc.substrate/sample
sample(self, id: number): ...any
The value at element id, under the name a field answers to.
Parameters
selfany(optional)idnumber— 0-based element index.
modules/proc.substrate/scratch
scratch(t: string, count: number): any
A numeric column in GPU storage whose run may have held another column's: its elements hold nothing the caller did not write. It is for a run a dispatch writes — every element, or the elements a count bounds. Its run is a range of the device arenas' pages, which a range released a few frames ago is handed out again as, so making one costs no device allocation.
Parameters
tstring— The element type tag.countnumber— Element count.
local out = proc.substrate.Column.scratch("Vec3", 4096)
modules/proc.substrate/set
set(self, id: number, ...: any): any
Write element id. A constant column materializes here, and no reader
of either form can tell which it was given.
Parameters
selfany(optional)idnumber— 0-based element index.argsany(optional)
col:set(7, 1, 2, 3)
modules/proc.substrate/setAttribute
setAttribute(self, class: string, name: string, value: any): any
Write a named attribute on a domain class. A column is stored as it stands; a field is read onto one, which is where a chain behind it is spent; a detail value is held as itself.
Parameters
selfany(optional)classstring— "point", "vertex", "primitive" or "detail".namestring— The attribute's name.valueany(optional) — A Column, a Field, or — on detail — any value.
modules/proc.substrate/setColumn
setColumn(self, name: string, column: any): any
Attach column under name.
Parameters
selfany(optional)namestring— The attribute's name, which means nothing to the substrate.columnany(optional) — A Column.
modules/proc.substrate/setCount
setCount(self, n: number): any
Set the domain's element count. A constant column covers the new count at no cost; a written one keeps the buffer it has.
Parameters
selfany(optional)nnumber
modules/proc.substrate/setDetail
setDetail(self, name: string, value: any): any
Write a value that covers the whole geometry.
Parameters
selfany(optional)namestringvalueany(optional)
modules/proc.substrate/setHoldsIds
setHoldsIds(self, name: string, flag: boolean): any
Say whether the column named name holds the ids of this geometry's points: a join of geometries moves such a column's values with the ids they name, and a selection leaves no value naming a point it removed. The mark belongs to the attribute, so a node that rewrites the column keeps it, and it goes when the column is removed.
Parameters
selfany(optional)namestring— The attribute's name.flagboolean— True to mark the column, false to clear the mark.
modules/proc.substrate/setLiveCount
setLiveCount(self, count: any?): any
Set the live count (see liveCount), or clear it with nil. The domain
holds the count it is given.
Parameters
selfany(optional)countany?(optional) — A one-word Column holding a u32, or nil.
modules/proc.substrate/setOwnerGroup
setOwnerGroup(owner: string, key: string?)
Place every device run made for owner from now on in the pages the group key owns, wherever the work
runs, as withPageGroup does for one call: work that makes the same runs in the same order stands in the same
pages each time, so the kernels that bind them are the same programs. A thread's own withPageGroup stands over
it. Nil puts the owner's runs back in the pages every run shares.
Parameters
ownerstring— The owner (mintOwner).keystring?(optional) — The group's name, or nil.
proc.substrate.setOwnerGroup(owner, "generator:" .. contentSignature)
modules/proc.substrate/setPointNumbers
setPointNumbers(g: any, name: string, t: string, values: { number }): any
Attach a point column under name — the shorthand a source op writing
an attribute alongside its positions takes.
Parameters
gany(optional) — A Geometry.namestring— The attribute's name.tstring— The element type tag.values{ number }— Flatcount * lanesnumbers.
proc.substrate.setPointNumbers(g, "normal", "Vec3", nrm)
modules/proc.substrate/stride
stride(self): number
How many numbers one element holds — what a field calls the same question. A column IS a field whose values have already been read, so an op that samples a field samples a column without knowing which it was given.
Parameters
selfany(optional)
modules/proc.substrate/structureOf
structureOf(value: any): (any, { touched: boolean }?)
What value looks like to a reader that asks only for structure: every geometry it holds with its columns
on the device standing in as columns that answer their type, width, length and run and nothing else. Asking
for the numbers of one, or for the count of a class counted on the device, sets state.touched; the reader is
then handed drainAll instead. A part, or a stand-in left in what the reader answers, has no such view.
Parameters
valueany(optional) — Any value an op is about to read.
local view, state = proc.substrate.structureOf(inputs.geometry)
modules/proc.substrate/tagForStride
tagForStride(t: string, stride: number): string
The type tag to hold a run of stride numbers an element under. t is
kept when its lanes agree with the stride — so an Int or a Color stays
what it is — and otherwise the tag for that many lanes answers, which is
what a run known only by its width is.
Parameters
tstring— The tag the run came with.stridenumber— Numbers per element.
proc.substrate.tagForStride("Float", 3) --> "Vec3"
modules/proc.substrate/toDeviceMesh
toDeviceMesh(self, name: string?, opts: { measure: boolean? }?): any?
The geometry as the renderer takes it, built on the device: a vertex
buffer and an index buffer the renderer draws from where they are, the way
toMeshArgs lays them out — one GPU vertex per point when no corner carries
a normal or uv of its own, one per corner otherwise, and every face fanned
from its first corner. Normals come from the corners, else the points,
else the faces. Two numbers come back to size the draw and frame it: how
many triangles there are, and the positions' extent, both asked for before
either is waited on. With measure = false neither is waited on and the
mesh is ready the moment this returns: the draw covers every index the
index run holds, those past the last face being empty triangles that draw
nothing. The extent is still asked for, and comes back as extent, two
runs whose reads are on their way: the caller states it on the mesh
(renderer.mesh.update with aabbMin / aabbMax) once they arrive,
since the extent is what the mesh is culled against and framed by.
Parameters
selfany(optional) — Geometry.namestring?(optional) — Debug name carried on the resulting mesh.opts{ measure: boolean? }?(optional) —{ measure: boolean? }— false skips the wait for the triangle count and the extent.
local built = g:toDeviceMesh("rock"); local mesh = renderer.mesh.create(built.args)
local card = g:toDeviceMesh("card", { measure = false })
modules/proc.substrate/toMeshArgs
toMeshArgs(self, name: string?): { name: string?, positions: { number },
The geometry as the renderer takes it: one GPU vertex per VERTEX, and triangles over them.
A GPU vertex carries one position, one normal and one UV, so a point read by two primitives that disagree about any of those is two GPU vertices. That is what the vertex domain is: the split lives there, and this is where it is spent. A point every primitive agrees about still costs one vertex each, which is the price of a format that carries no sharing.
normal and uv are read from the vertex domain first, then the point
domain, so a mesh that splits its normals says so per vertex and one that
does not says so once per point. With neither, the normals are computed
from the faces. A primitive of more than three vertices is fanned.
Parameters
selfany(optional)namestring?(optional) — Debug name carried on the resulting mesh.
renderer.mesh.create(g:toMeshArgs("rock"))
modules/proc.substrate/toPointCloud
toPointCloud(g: any): any
The PointCloud value a geometry's points make: their positions, each
point attribute as the column holding it, each detail value. What a socket
declared as PointCloud is handed. Columns the device holds are brought
back first, since the value reads its positions as an array.
Parameters
gany(optional) — A Geometry.
local pc = proc.substrate.toPointCloud(g)
modules/proc.substrate/traffic
traffic(): { uploads: number, uploadBytes: number, readbacks: number, readbackBytes: number, allocations: number,
What the calling thread has moved between the CPU and the device
through procedural columns since it began: { uploads, uploadBytes, readbacks, readbackBytes }. Two readings taken around a piece of work
on the same thread give what that work moved, whatever other threads
moved meanwhile.
local before = proc.substrate.traffic()
modules/proc.substrate/trafficCounts
trafficCounts(): (number, number, number)
The calling thread's traffic() counts a step's statistics read, as numbers rather than a table: uploads,
read-backs and device buffers made.
local uploads, readbacks, allocations = proc.substrate.trafficCounts()
modules/proc.substrate/triangleCount
triangleCount(self): number
How many triangles the geometry holds — the elements indices runs
over, counting an n-gon as the fan it draws as.
Parameters
selfany(optional)
modules/proc.substrate/tryRead
tryRead(self): { number }?
The run this column holds IF it can be answered without waiting — a CPU buffer always can, and a GPU one only once its readback has landed. nil means the device still has it.
This is what a read that CANNOT wait uses. A readback takes frames, and waiting for one means yielding; a metamethod cannot yield, so the flat-array view a geometry presents is built on this and says what to do instead.
Parameters
selfany(optional)
local run = col:tryRead()
modules/proc.substrate/type
type(self): string
The column's element type tag.
Parameters
selfany(optional)
modules/proc.substrate/valueArray
valueArray(self): { any }
The array of values behind a column carried as values, materializing a constant backing.
Parameters
selfany(optional)
modules/proc.substrate/values
values(t: string, arr: { any }, count: number?): any
A column backed by an array of values — the backing a type the buffer primitive cannot express takes: text, a reference, a handle, a record.
Parameters
tstring— The element type tag.arr{ any }— The array of values, one per element.countnumber?(optional) — How many elements, whenarrholds nil for some of them — an element with no value, such as an entity without the component a record column carries. Left out, it is the array's length.
proc.substrate.Column.values("String", { "a", "b" })
proc.substrate.Column.values("Record", records, #ids)
modules/proc.substrate/version
version(self): (number, number)
What identifies this run, and what it is on: a serial unique to the column for the life of the VM, and a revision its writes bump. Two calls answering the same pair are the same values; a different pair is a run that has changed. Nothing is read to answer it.
Parameters
selfany(optional)
local s, r = col:version()
modules/proc.substrate/vertexCount
vertexCount(self): number
How many points the geometry holds — the elements positions runs over.
Parameters
selfany(optional)
modules/proc.substrate/vertexPrimitive
vertexPrimitive(self, v: number): number?
Which primitive uses vertex v, derived from the primitive runs.
Parameters
selfany(optional)vnumber— 0-based vertex index.
modules/proc.substrate/wgslOf
wgslOf(t: string): string?
The WGSL type one element of a column of type t is read as: f32, i32 or u32 for a
column of one lane, vec2<f32>, vec3<f32> or vec4<f32> for more (Color and Quat are
four lanes). The one mapping from procgen types to WGSL types: a specialization that names a
column's type takes this.
Parameters
tstring— A procgen type tag.
proc.substrate.wgslOf("Vec3") --> "vec3<f32>"
modules/proc.substrate/withIndex
withIndex(self, index: any): any
The same distinct values over a new run of indices — what a pass that
moved an interned column's indices hands on. The column holds index.
Parameters
selfany(optional)indexany(optional) — A Float column of indices into this column's distinct values.
local kept = col:withIndex(proc.device.gather(col:index():gpuMirror(), keep, n, cap))
modules/proc.substrate/withPageGroup
withPageGroup(key: string, fn: (...any) -> ...any, ...: any): ...any
Call fn(...) with every device run a column makes during it, on this
thread, placed in the pages the group key owns, and answer what fn
answers. A run in a group stands in a page no other group's run shares, in
the first free room of the group's pages in the order they were made, so
work that asks for the same shapes in the same order is handed the same
pages in the same order each time it runs: a kernel that binds pages and
addresses its columns by offset is then the same program, over the same
bind groups, every play.
Parameters
keystring— The group's name.fn(...any) -> ...any— The work.argsany(optional)
proc.substrate.withPageGroup("step:" .. stepId, function() return proc.eval(graph) end)
modules/proc.substrate/writeCount
writeCount(self): number
How many times this column's run has been written in place, by any holder of it: what a read of the run taken before is checked against. It only grows.
Parameters
selfany(optional)
local before = col:writeCount()
modules/proc.substrate/writeCounter
writeCounter(): any
A write counter: one count a set of runs share, so a pass that writes all of them (a recorded list
replayed) notes the write once instead of once per run. counter:join(col) adds a column's run to the set,
counter:note() counts one write of every run in it, and counter:release() takes every run out, each
keeping the writes it was counted. A run's writeCount() is its own noted writes and the notes of every
counter it is in, so a run written outside the set is counted as before.
local counter = proc.substrate.writeCounter(); counter:join(col); counter:note()
modules/proc.substrate/writeRun
writeRun(self, first: number, values: { number }): any
Write values, a flat run of whole elements, into this column from
element first on. This is how the pass that owns a GPU-resident column
writes it — a solver placing the particles it spawned into the slots it
holds — and the write lands behind every dispatch already queued over the
column. A CPU column takes it too.
Parameters
selfany(optional)firstnumber— 0-based index of the first element written.values{ number }—lanesnumbers per element written.
col:writeRun(12, { 0, 1, 0, 0, 2, 0 })
modules/proc.translate/README
require("@builtin::systems.procgen.proc.translate") -- proc.translate
Turning a geometry into scene things, and keeping them that way.
Usage: local proc.translate = require("@builtin::systems.procgen.proc.translate")
modules/proc.translate/absentValue
absentValue(attribute: string): { number }?
What an element carrying no attribute stands at: the value the
component field the attribute feeds rests at when nothing sets it, one
number per lane. An element with no orient stands unrotated and one with
no scale at full size, so parts laid together fill the attribute a part
lacks with these rather than zeros.
Parameters
attributestring— An attribute name.
proc.translate.absentValue("orient") --> { 0, 0, 0, 1 }
modules/proc.translate/apply
apply(state: any, cooked: any, namePrefix: string?, spawnOpts: any?, interval: number?): any
Present a cooked frame: spawn and despawn exactly the difference in the element list, then write only the fields whose digest moved.
A frame in which nothing changed writes nothing and touches no entity. A frame in which only the transforms moved writes one buffer. Membership changing is what rebuilds the binding, and nothing else does.
Parameters
stateany(optional) — A state fromnewState.cookedany(optional) — A value fromcook.namePrefixstring?(optional) — What to name the entities this makes.spawnOptsany?(optional) — What the entities this makes are spawned as — the optionsentity.batchSpawntakes. They are born temporary: a cook's elements are what code produced, so they stay out of the scene's authored content, and a scene saved while they stand does not record them.temporary = falseis the explicit ask for elements the scene keeps.intervalnumber?(optional) — Seconds between this domain's presents. Given, the elements placed on the device are drawn every frame between the last two presents — position, rotation, scale and shader data lanes blended — so they move continuously whatever rate the domain presents at. Omitted, each present is drawn as it lands.
proc.translate.apply(state, cooked, "fx")
proc.translate.apply(state, cooked, "kept", { temporary = false })
proc.translate.apply(state, cooked, "sparks", nil, 1 / 30)
modules/proc.translate/bindFrames
bindFrames(held: any, key: string, states: { [string]: any }, spawnOpts: any?, interval: number?): (boolean, string?)
Bind a play to frames defineFrames held: each output's state stands
as one instanced draw reserving the most elements any frame holds, and
showFrame then places it from any frame by index.
Parameters
heldany(optional) — A value fromdefineFrames.keystring— The play's name, unique to it.states{ [string]: any }— The state of each output held, by output; a missing one is made.spawnOptsany?(optional) — What the draw is registered under — itsparent.intervalnumber?(optional) — Seconds between the frames' presents; given, each element is drawn between the last two frames shown.
proc.translate.bindFrames(held, "fx#12", states, { parent = id }, 1 / 30)
modules/proc.translate/bounds
bounds(state: any): any?
The box a state's instanced population reaches, in the space of the
entity it stands under: { min = {x,y,z}, max = {x,y,z} }, the latest
the device has answered, or nil before any has. Every slot's position,
widened by the drawn mesh's reach at the largest scale any slot holds.
Parameters
stateany(optional) — A stateapplyhas written into.
local box = proc.translate.bounds(state)
modules/proc.translate/clear
clear(state: any)
Release everything an applied translation is holding: the entities it spawned and the binding over them.
Parameters
stateany(optional) — A state fromnewState.
modules/proc.translate/componentOf
componentOf(name: string): (string?, string?)
Which component an attribute named after one holds: a native component of the ecs catalog, or a script
component declared as a .component. An attribute that merely feeds a component's field answers nil, since
the component is not the attribute.
Parameters
namestring— An attribute name.
proc.translate.componentOf("Mesh") --> "native"
modules/proc.translate/defineFrames
defineFrames(substrateMod: any, frames: { { [string]: any } }): (any?, string?)
Hold a timeline's frames on the engine, so plays show each one by index
with no script running per frame. frames[f] maps each output to the
{ value, domain } it realizes at frame f; every output that changes from
frame to frame must stand as one instanced draw, with one mesh and one
material for the whole timeline. An output that holds the same value on
every frame is left to stand as it was realized.
Parameters
substrateModany(optional) — The substrate module columns are built from.frames{ { [string]: any } }— The outputs at each frame, in order.
local held, why = proc.translate.defineFrames(proc.substrate, frames)
modules/proc.translate/drawn
drawn(state: any): any?
How the state's elements are drawn: { as, count, because? }. as is
"instances" for a domain drawn as one instanced draw and "entities"
for one standing on an entity per element; because names what a domain
of one mesh and one material carries that made it entities.
Parameters
stateany(optional) — A stateapplyhas written into.
print(proc.translate.drawn(state).as)
modules/proc.translate/drawnAs
drawnAs(geometry: any): string?
Cook a geometry's domain into its scene-ready form.
The result holds the element ids and one block per component the domain's attributes carry, in the order they are applied: a native component's whole records, then the native fields fed by their own attributes, then the script components. A native field laid out as a contiguous run comes out as a column whose buffer a bulk write copies; the rest come out as a values array. A script component's block holds the columns that feed it, read into each element's data when the block is applied.
A domain whose live elements are counted on the device, carrying only the
components the device draws with (Transform, Mesh, Material, ShaderData),
is cooked as the entities it stands on: its capacity of them, each column
scattered to the entity each element's slot names on the device. One
carrying any other component — a light, a script — is read back and cooked
as exactly its live elements, since the scene reads those on the CPU.
Nothing here is written to the scene — that is apply.
Which of a geometry's domains its elements stand in the scene as: the
point or primitive domain carrying a component — a Mesh, a Material, a
Light, a script component — is the one whose elements the author made into
scene things. Nil when neither carries one, which is a geometry that is
drawn whole, as one mesh.
Parameters
geometryany(optional) — A Geometry.
local cooked = proc.translate.cook(proc.substrate, points, "point")
local domain = proc.translate.drawnAs(part)
modules/proc.translate/isComponent
isComponent(name: string): boolean
Whether name names a component translation carries: a native
component in the ecs catalog, a script component declared as a
.component, or an attribute a component declares as feeding one of its
fields.
Parameters
namestring— An attribute name.
proc.translate.isComponent("Mesh") --> true
proc.translate.isComponent("P") --> true, it feeds Transform.position
modules/proc.translate/materialKeys
materialKeys(state: any): { string }
The keys every material this state filed is under — the ones its elements and its shared fields draw with — so whoever presents the state can write what those materials animate on every frame it draws them. The list is the state's own and frozen, the same list until a material is filed or released, so a caller can keep it and compare it.
Parameters
stateany(optional) — A state fromnewState.
for _, key in ipairs(proc.translate.materialKeys(state)) do print(key) end
modules/proc.translate/newState
newState(): any
The state an applied translation keeps between frames: which entities stand for which elements, the binding over them, and the digest each field was last written at.
local state = proc.translate.newState()
modules/proc.translate/piecesOf
piecesOf(value: any): { any }?
The copies of a population of several pieces as one population per piece: each holds the copies whose Mesh indexes that piece (the records the detail's labels.Mesh lists) and carries that piece's record and material, so each stands as one instanced draw. Nil for a value that is not such a population.
Parameters
valueany(optional) — A Geometry.
local pieces = proc.translate.piecesOf(population)
modules/proc.translate/refreshBounds
refreshBounds(state: any)
Ask the device again for the box a state's population reaches, over
the runs it was last placed from: a present on the device moves those runs
without placing anything anew, so the box follows them only when asked.
Asks nothing while an earlier question is on its way; M.bounds answers
once the reads arrive.
Parameters
stateany(optional) — A stateapplyhas written into.
proc.translate.refreshBounds(state)
modules/proc.translate/releaseCooked
releaseCooked(cooked: any)
Release a cooked frame share kept: the runs it stands on.
Parameters
cookedany(optional) — A value fromcook.
proc.translate.releaseCooked(cooked)
modules/proc.translate/releaseFrames
releaseFrames(held: any)
Let go of frames defineFrames held: the engine forgets them and the
runs they are placed from are released. Every play bound to them is
unbound first (unbindFrames).
Parameters
heldany(optional) — A value fromdefineFrames.
proc.translate.releaseFrames(held)
modules/proc.translate/share
share(cooked: any, source: any)
Keep a cooked frame for every state that presents it: apply then
leaves the runs it stands on in place, and whoever shares it releases it
once with releaseCooked. Plays of one effect presenting one cooked frame
cook it once.
Parameters
cookedany(optional) — A value fromcook.sourceany(optional) — The geometry it was cooked from, whichsourcenames after.
proc.translate.share(cooked, frameValue)
modules/proc.translate/showFrame
showFrame(key: string, frame: number)
Show frame frame (from 1) of the frames the play key is bound to.
Parameters
keystring— The play's name.framenumber— The frame, from 1.
proc.translate.showFrame("fx#12", 4)
modules/proc.translate/standing
standing(state: any): { any }
The runs the state's elements stand on and are placed from on the device — what a present rewriting the elements' own runs has to rewrite too.
Parameters
stateany(optional) — A stateapplyhas written into.
local runs = proc.fieldc.liveRuns(proc.translate.standing(state))
modules/proc.translate/unbindFrames
unbindFrames(key: string)
Stop showing frames for the play key; what it placed stands as the
last frame shown left it.
Parameters
keystring— The play's name.
proc.translate.unbindFrames("fx#12")
modules/proc.translate/writeLive
writeLive(state: any, clock: any)
Write every animated field of the records the state's elements share,
as each curve stands at clock: a record holding a curve — a light's
flicker, a colour's pulse — is followed on every frame drawn rather than
at the graph's presents. Only the fields a curve feeds are written, and a
field whose value has not moved is left alone. The clock is also what the
next record written whole reads its curves at. A field standing on a run
the device rewrites (a light placed at a point that moves) is read again
for clock, and lands on the entities a frame or more later.
Parameters
stateany(optional) — A stateapplyhas written into.clockany(optional) —{ time, frame, fps, duration }.
proc.translate.writeLive(state, clock)
modules/profiler/README
require("@builtin::modules.api.engine.profiler") -- profiler (also available as global 'profiler')
Frame-level profiler capture, EMA stats, and named profiling blocks. Public Luau surface over the __profiler Internal FFI namespace.
Usage: local profiler = require("@builtin::modules.api.engine.profiler") Also available as global: profiler
modules/profiler/begin
begin(name: string)
Start a named profiling block. Call profiler.finish(name) to
record the duration. Blocks appear in profiler.stats() under
"script.<name>" and inside captures.
Parameters
namestring— Block name (e.g. "MyComponent.update").
profiler.begin("MyComponent.update"); ...; profiler.finish()
modules/profiler/counters
counters(pattern: string?): { ProfilerCount }
Get the profiler's counts: unitless per-frame tallies (for example
the waits the engine thread made on the process-wide lock, under
system.schedule.frame.process_local_waits), kept apart from the
millisecond timings of stats. frame is the tally of the frame in
progress, prev_frame the last complete frame's, max_frame the
highest complete-frame tally and total the tally since the profiler
started. Optional glob pattern filters by name (supports * and ?).
Parameters
patternstring?(optional) — Filter pattern (e.g. "system.schedule.frame.*").
for _, c in ipairs(profiler.counters("system.schedule.frame.*")) do print(c.name, c.prev_frame) end
modules/profiler/disableRing
disableRing()
Disable the ring buffer and clear its history.
profiler.disableRing()
modules/profiler/enableRing
enableRing(seconds: number?): boolean
Enable the always-recording ring buffer, retaining the last
seconds of per-frame data (default 20). Query it AFTER the fact
with profiler.retro() — latency-immune, since the data is
historical. Editor profile only: returns false in the runtime
profile. The enable is the gate; the ring costs nothing until on.
Parameters
secondsnumber?(optional) — Seconds of history to retain (default 20).
if profiler.enableRing(30) then ... end
modules/profiler/finish
finish(name: string?): number?
Finish a profiling block and record the elapsed duration as
"script.<name>". Without an argument, closes the most-recently-
begun block (LIFO stack). With a name, closes the most recent
block whose name matches — useful when blocks of different names
are nested.
Parameters
namestring?(optional) — Block name to finish. Omit to pop the top of the stack.
local ms = profiler.finish("MyComponent.update")
modules/profiler/gpuFrame
gpuFrame(): GpuFrameReport
Label-aggregated GPU pass timings over the last window_frames
resolved frames, measured with GPU timestamp queries. supported
is false when the device lacks timestamp queries — spans stays
empty. Each span covers every render/compute pass recorded under
one label — compute.<shader> per compute dispatch, scene.* for
the scene passes, post.<effect> per post-process effect,
feature.* for render-feature passes: ms is the median of its
per-frame totals, min_ms/max_ms the range that median sits in,
count the passes per frame and frames how much of the window
carried it. at_floor marks a label whose every sample landed
within a few ticks of the device's timestamp counter (tick_ms) —
those passes ran and the device resolved no duration for them,
which is not the same as a measured zero. ran is whether the
label recorded a measured pass in the newest resolved frame, and
last_frame the newest frame that did. The window outlives the
work it describes, so a pass that stops being recorded leaves a row
standing for up to window_frames frames carrying the median of
the frames it did run in: read ran to answer whether a pass is
running, frame - last_frame for how many resolved frames ago it
last did, and ms as the cost of the frames it ran in.
frame_span_ms (first pass begin to last pass end) and
total_ms are medians too, so
rows do not sum to total_ms, and the GPU may overlap passes so
total_ms can exceed frame_span_ms. The readback is
asynchronous: the window lags the live frame by a few frames.
local g = profiler.gpuFrame(); print(g.frame_span_ms, g.spans[1] and g.spans[1].label)
modules/profiler/hits
hits(label: string?): string?
Drain the watchdog's recorded hit frames into a capture stored
under label (default "watch_hits") and clear the buffer.
Returns the capture JSON (same shape as stopCapture), or nil if
there were no hits.
Parameters
labelstring?(optional) — Capture label to store under (default "watch_hits").
local json = profiler.hits()
modules/profiler/isCapturing
isCapturing(): boolean
Check if a profiler capture is currently active.
if profiler.isCapturing() then ... end
modules/profiler/lastCapture
lastCapture(): string?
Get the most recent completed capture result as a JSON string.
Same shape as profiler.stopCapture(). Returns nil if no capture
has been completed yet.
local last = profiler.lastCapture()
modules/profiler/measure<T...>
measure<T...>(name: string, fn: () -> T...): T...
Run a function inside a profiling block. Equivalent to a begin/finish pair but handles errors correctly. Returns the function's return values.
Parameters
namestring— Block name.fn() -> T...— Function to profile.
local count = profiler.measure("walk", function() return #entity.findAll() end)
modules/profiler/perfLine
perfLine(): string?
The engine's own one-line performance summary, exactly as it
rides a tool response: the headline frame time, and when the frame
is slow or CPU moved since the last edit, the severity marker, the
delta and the systems the time went to. A DIFFERENT measurement
from everything below: this is the published smoothed frame, while
stats and the profiler toolbox report the effective frame time
(wall clock minus the cost of the call doing the asking), so a line
composed from those disagrees with what other callers are told
about the same engine. Reading it does not move the edit-to-edit
baseline the delta is measured against.
local line = profiler.perfLine()
modules/profiler/recordingHold
recordingHold(): string?
Who holds the one windowed recording, as a JSON string
{ label, owner, started_at, held_seconds }, or nil when nothing is
recording. owner is the caller key of whoever called
startCapture, the same value vfs.currentAuthor().id reads for
the calling caller, so a caller refused the slot tells its own
earlier recording from a sibling session's; it is absent when that
call attested no caller. Several agent sessions share one engine and
one recording, which is why a refusal is answered with this.
local held = profiler.recordingHold()
modules/profiler/retro
retro(seconds: number?, label: string?): { [string]: any }?
Retroactively aggregate the last seconds of the ring (default:
the whole ring). The full per-frame capture is retained under label
(default "retro") for in-engine drill-down (the frame / hotspots
tools);
this RETURNS a compact structured aggregate table (frame-time distribution
- per-system summary), never the raw per-frame array — bounded, so it is
safe over the ZeroMind bridge. Code-facing primitive; the
retrotool renders the agent-facing report. Latency-immune: the data is historical.
Parameters
secondsnumber?(optional) — How many seconds back to include (default: whole ring).labelstring?(optional) — Capture label to store under (default "retro").
local agg = profiler.retro(8, "collapse")
modules/profiler/ringStatus
ringStatus(): string
Ring buffer status as a JSON string:
{ enabled, frames, capacity, span_seconds }.
local s = profiler.ringStatus()
modules/profiler/startCapture
startCapture(label: string?): boolean
Start recording per-frame profiler data, held by the calling
caller. Each frame's system timings are captured until
stopCapture() is called. Results are accessible via
profiler.lastCapture() and VFS at
/zero/runtime/profiler/<label>.json. The recording is one
engine-wide slot, so a start while another recording holds it
returns false and profiler.recordingHold() names the label and the
caller holding it.
Parameters
labelstring?(optional) — Capture label (default"capture").
if profiler.startCapture("frame-spike") then ... end
modules/profiler/stats
stats(pattern: string?): { ProfilerStat }
Get current EMA profiling statistics from the SystemProfiler.
Optional glob pattern filters by metric name (supports * and ?
wildcards). Each entry carries two averages: avg_ms averages one
RUN of the block and is folded when the block runs, so a block that
has stopped running keeps the last value it saw; avg_frame_ms
averages one FRAME and is folded every frame, including the frames
the block did not run in, so it is the block's share of the current
frame and falls back to zero once the block stops running.
Parameters
patternstring?(optional) — Filter pattern (e.g. "schedule.", "system.schedule.render.").
for _, s in ipairs(profiler.stats("schedule.*")) do print(s.name, s.avg_frame_ms) end
modules/profiler/stopCapture
stopCapture(): string?
Stop the active profiler capture and return its result as a
JSON string. The capture is also saved to VFS at
/zero/runtime/profiler/<label>.json. Top-level fields: label,
frame_count, started_at, ended_at, frames, summary,
callers. Compute duration as ended_at - started_at. callers
holds { caller, total_ms, max_ms, frames } per caller whose queued
Luau ran in the window, heaviest first, and each frame carries its
own split as agent_by_caller.
local json = profiler.stopCapture()
modules/profiler/unwatch
unwatch()
Disarm the watchdog. Recorded hits are kept for a final
profiler.hits().
profiler.unwatch()
modules/profiler/watch
watch(ceilingMs: number, mode: string?, excludeAgent: boolean?, maxHits: number?): boolean
Arm the frame-time watchdog. When a frame's EFFECTIVE time
(total minus agent-injected execute cost) crosses ceilingMs,
mode "record" logs every offending frame (read with
profiler.hits()), and mode "pause" pauses gameplay ONCE to
freeze the bad state, then disarms. Editor profile only: returns
false in the runtime profile. excludeAgent (default true) keeps
the agent's own calls from tripping it.
Parameters
ceilingMsnumber— Effective frame-time ceiling in ms.modestring?(optional) — "record" (default) or "pause".excludeAgentboolean?(optional) — Subtract agent cost before comparing (default true).maxHitsnumber?(optional) — Max frames retained in record mode (default 240).
if profiler.watch(50, "pause") then ... end
modules/profiler/watchStatus
watchStatus(): string
Watchdog status as a JSON string: { armed, ceiling_ms, mode, exclude_agent, hits, dropped_hits, tripped }.
local s = profiler.watchStatus()
modules/prototype_lifecycle/README
require("@builtin::modules.api.engine.prototype_lifecycle") -- prototype_lifecycle
The play-mode invariant for authored player prototypes and EditorOnly entities. In play a PlayerPrototype subtree is the clone source, not a live scene entity: the scene loader spawns it only in edit and the spawn-on-join flow instantiates a clone per joining user in play. This module deactivates and hides any prototype still live when play begins (the fallback when the loader spawned one) and every EditorOnly entity, so neither is simulated nor rendered in play. In edit both are fully live. Runtime clones are tracked here and despawned on the return to edit. Deactivating and hiding a root cascades to its subtree through the hierarchy, so operating on the root covers its children.
Usage: local prototype_lifecycle = require("@builtin::modules.api.engine.prototype_lifecycle")
modules/prototype_lifecycle/activatePrototypes
activatePrototypes()
Reactivate and unhide every prototype root and EditorOnly entity.
modules/prototype_lifecycle/applyCurrentMode
applyCurrentMode()
Hold what is live now to the invariant of the mode the engine is in.
A scene load that lands while play runs (a root scene, an additive overlay
such as the editor UI layer, or a load a slow boot finishes after the flip)
brings in prototypes and EditorOnly entities after enterPlay ran. In play
this deactivates and hides every prototype root, and holds the EditorOnly
authoring surface to the state the session's pause gave it: stood down
while play runs, live while a pause has it shown over the frozen world. It
tracks that surface either way, so pause and resume reach it. In edit both
are already live, and it changes nothing.
PrototypeLifecycle.applyCurrentMode()
modules/prototype_lifecycle/deactivatePrototypes
deactivatePrototypes()
Deactivate and hide every prototype root and EditorOnly entity so play mode neither simulates nor renders them.
modules/prototype_lifecycle/despawnClones
despawnClones()
Despawn every still-existing tracked clone and clear the tracking list.
modules/prototype_lifecycle/enterEdit
enterEdit()
Enter edit mode: despawn runtime clones, then reactivate prototypes and EditorOnly entities.
modules/prototype_lifecycle/enterPlay
enterPlay()
Enter play mode: deactivate and hide prototypes and EditorOnly entities.
modules/prototype_lifecycle/hideEditorSurface
hideEditorSurface()
Deactivate and hide the EditorOnly authoring surface without touching player-prototype roots. Used when play mode resumes so the surface disappears and gameplay cameras take the viewport back.
modules/prototype_lifecycle/install
install()
Keep the play-mode invariant applied for every flip, in every world.
enterPlay / enterEdit are what make PrototypeOnly and EditorOnly
mean something at runtime, and until something calls them on the flip a
template stays live: its camera competes for the viewport with the camera
of the player cloned from it, carries no follow target, and holds the shot
at the spawn point; its body answers the same input as a second character.
Registered from the prelude beside the other engine installs rather than from a scene-load path — a load that does not run leaves the invariant unapplied with nothing reporting it, and a flip that reloads no scene never reaches a loader hook at all. Idempotent: a second call registers nothing, and the current mode is applied once on install so a world opened straight into play does not start with its templates live.
PrototypeLifecycle.install()
modules/prototype_lifecycle/prototypeRoots
prototypeRoots(): { string }
Ids of every active-layer entity carrying the PlayerPrototype component.
modules/prototype_lifecycle/registerClone
registerClone(id: string)
Track a runtime clone root so it can be despawned on the return to edit.
Parameters
idstring— The clone's root entity id.
modules/prototype_lifecycle/showEditorSurface
showEditorSurface()
Reactivate and unhide the EditorOnly authoring surface (free camera + editor-only visualizers) without touching player-prototype roots. Used when play mode is paused so the editor camera returns over the frozen world.
modules/proxyOcclusion/README
require("@builtin::systems.proxyOcclusion.proxyOcclusion") -- proxyOcclusion
Analytic occlusion from coarse proxy shapes — grounding shadow for subjects a shadow map does not reach, at a cost that scales with the number of proxies rather than with scene geometry.
Usage: local proxyOcclusion = require("@builtin::systems.proxyOcclusion.proxyOcclusion")
modules/proxyOcclusion/active
active(): boolean
Whether the occlusion pass is currently running.
if proxyOcclusion.active() then print("occluding") end
modules/proxyOcclusion/buffers
buffers(): { [string]: any }?
The buffer(s) this system's passes read. A pass binds what this hands it, so it has the values this module packed.
local b = proxyOcclusion.buffers()
modules/proxyOcclusion/clear
clear()
Drop every proxy and release the pass. The settings are kept.
proxyOcclusion.clear()
modules/proxyOcclusion/configure
configure(opts: ProxyOcclusionOpts?): ProxyOcclusionState
Adjust how the occlusion is applied. Any omitted field keeps its current
value. An intensity of 0 releases the pass.
Parameters
optsProxyOcclusionOpts?(optional) — Settings — seeProxyOcclusionOpts.
proxyOcclusion.configure({ intensity = 0.8, minDistance = 40 })
modules/proxyOcclusion/count
count(): number
How many proxies are registered.
print(proxyOcclusion.count())
modules/proxyOcclusion/remove
remove(key: string): boolean
Remove the proxy registered under key.
Parameters
keystring— The identifier the proxy was registered with.
proxyOcclusion.remove("boulder")
modules/proxyOcclusion/set
set(key: string, shape: ProxyShape): number
Add or replace a proxy under key. Re-submitting the same key moves
that proxy rather than adding another, which is what lets a component push
its shape every frame as its entity moves.
Parameters
keystring— Stable identifier for this proxy — an entity id works well.shapeProxyShape— The capsule — seeProxyShape.
proxyOcclusion.set("boulder", { a = { 0, 1, 0 }, radius = 2 })
modules/proxyOcclusion/settings
settings(): ProxyOcclusionState
The settings currently in force.
local i = proxyOcclusion.settings().intensity
modules/radianceCache/README
require("@builtin::systems.radianceCache.radianceCache") -- radianceCache
A world-space store of lighting results that survives the frame that produced it. A lighting technique that gathers per pixel throws its answer away when the frame ends and pays for it again the next one; a technique that writes into a cache pays once per patch of world and reuses the answer for every later frame and every pixel standing on that patch. The cache is a fixed table of slots addressed by hashing a world-space cell, so it covers an unbounded world in bounded memory: capacity slots at 68 bytes each, and nothing about the size of the scene changes that. Cells coarsen with distance from the camera, and a slot no pixel has asked for in maxAge frames is reclaimed, so what the table holds tracks the view rather than accumulating everything ever seen. Each cache is created by name and owns its own table, so two techniques caching in the same frame do not share slots. Either drive the built-in screen-space producer with run, or enqueue your own producing pass over bindings() and let this own the table, the addressing and the eviction.
Usage: local radianceCache = require("@builtin::systems.radianceCache.radianceCache")
modules/radianceCache/allocate
allocate(self: Cache, ctx: any, opts: { phase: string?, order: number? }?)
Claim a slot for every patch of world the frame is looking at, and keep the ones already held alive. Every technique using the cache runs this first: it is what decides what the table holds, and a producing pass can only fill patches this has stamped.
Parameters
selfCachectxany(optional) — The render context the calling feature received.opts{ phase: string?, order: number? }?(optional) —{ phase, order }— where the pass runs.
cache:allocate(ctx, { phase = "afterLighting", order = 40 })
modules/radianceCache/bindings
bindings(self: Cache): { [string]: any }
The buffers a pass binds to reach this cache. Hand them to
ctx.enqueue's buffers and #include "@builtin::systems.radianceCache.radiance_cache" in the shader — that is
the whole contract for a technique that wants to produce into this cache
or read out of it with its own pass.
Parameters
selfCache
local function render(ctx) ctx.enqueue { kind = "compute", program = mine, buffers = cache:bindings() } end
modules/radianceCache/create
create(name: string, opts: CacheOpts?): Cache
Create a cache that owns its own table. name keys its buffers and its
resolve target, so two techniques caching in the same frame each pass their
own name and never share slots.
Parameters
namestring— Identifies this cache's resources. Unique per technique.optsCacheOpts?(optional) — How the cache is sized and how it fills — seeCacheOpts.
local c = radianceCache.create("indirect", { capacity = 65536, stride = 8 })
modules/radianceCache/destroy
destroy(self: Cache)
Release the table, the read-back and the resolve target. The cache rebuilds — empty — on its next use.
Parameters
selfCache
cache:destroy()
modules/radianceCache/gather
gather(self: Cache, ctx: any, opts: { phase: string?, order: number? }?)
Gather light into the slots this frame is scheduled to visit, from the scene that was just drawn. The built-in producer: it needs no acceleration structure and no bake, so it runs wherever the deferred path does. A technique with its own way of computing radiance enqueues that instead and skips this.
Parameters
selfCachectxany(optional) — The render context the calling feature received.opts{ phase: string?, order: number? }?(optional) —{ phase, order }— where the pass runs.
cache:gather(ctx, { phase = "afterLighting", order = 41 })
modules/radianceCache/get
get(self: Cache): CacheState
This cache's settings.
Parameters
selfCache
local n = cache:get().capacity
modules/radianceCache/invalidate
invalidate(self: Cache)
Declare that the lighting which produced what is in the cache is gone.
Every slot takes its next gather whole instead of averaging it into light
that no longer exists, so the cache is rebuilt within stride frames
rather than over history * stride. Call it after moving, recolouring or
switching off a light.
Parameters
selfCache
cache:invalidate()
modules/radianceCache/memoryBytes
memoryBytes(self: Cache): number
What this cache's TABLE costs, in bytes: capacity slots of payload
plus one key word each. Fixed at creation and independent of the scene —
the resolve target the cache also owns is screen-sized and scales with the
viewport instead.
Parameters
selfCache
print(cache:memoryBytes() // 1024, "KiB")
modules/radianceCache/resolve
resolve(self: Cache, ctx: any, opts: { phase: string?, order: number? }?): string
Read the cache back out per pixel and answer the guid of the texture holding it. The light in it arrived over however many frames have visited the patches on screen, so a pixel drawn for the first time still gets the converged answer.
Parameters
selfCachectxany(optional) — The render context the calling feature received.opts{ phase: string?, order: number? }?(optional) —{ phase, order }— where the pass runs.
local gi = cache:resolve(ctx, { phase = "afterLighting", order = 42 })
modules/radianceCache/run
run(self: Cache, ctx: any, opts: { phase: string?, order: number? }?): string
Allocate, gather and resolve in three consecutive slots — the whole cache for a technique that wants the built-in screen-space producer.
Parameters
selfCachectxany(optional) — The render context the calling feature received.opts{ phase: string?, order: number? }?(optional) —{ phase, order }—orderis the first of three consecutive slots.
local gi = cache:run(ctx, { phase = "afterLighting", order = 40 })
modules/radianceCache/set
set(self: Cache, opts: CacheOpts?): CacheState
Change this cache's settings. Any omitted field keeps its current value.
capacity is fixed at creation — a table cannot be resized under the
patches already in it — so changing it is refused rather than silently
ignored.
Parameters
selfCacheoptsCacheOpts?(optional) — The settings to change — seeCacheOpts.
cache:set({ stride = 4, samples = 16 })
modules/radianceCache/stats
stats(self: Cache): CacheStats?
What the cache did on the most recent frame a read-back has landed for, or nil before the first one arrives. Counted on the GPU by the passes.
Parameters
selfCache
local s = cache:stats(); print(s.live, s.dropped)
modules/range_bounds/README
require("@builtin::modules.range_bounds") -- range_bounds
The range field-constraint validator: a constrained value must be a finite number inside the interval the field declared. A rejection names the interval, so the error carries the range the caller may write in. A constraint carrying whole = true (Field.integer) takes whole numbers alone. Registers itself with the generic field_constraints registry on load. nil passes, so a ranged field may be left unset.
Usage: local range_bounds = require("@builtin::modules.range_bounds")
modules/referenceView/README
require("@builtin::systems.pathTracing.referenceView") -- referenceView
A progressive path-traced view of the scene through the active camera, accumulating samples while the view holds still, so the real-time image has a converged reference to be judged against.
Usage: local referenceView = require("@builtin::systems.pathTracing.referenceView")
modules/referenceView/__frame
__frame(): { [string]: any }?
Advance one frame of accumulation: read the camera, restart if it has
moved, and write the parameter block the trace pass reads. Called by the
pathTrace render feature once per frame.
modules/referenceView/active
active(): boolean
Whether the reference view is tracing.
if referenceView.active() then ... end
modules/referenceView/disable
disable()
Stop tracing and release the accumulation buffer and scene snapshot. The render feature's own targets are released with it.
referenceView.disable()
modules/referenceView/enable
enable(opts: ViewOpts?): ({ [string]: any }?, string?)
Start path tracing the active camera. Allocates the accumulation buffer and snapshots the scene's geometry and lights; the image begins converging on the next frame the camera holds still for.
Parameters
optsViewOpts?(optional) — Trace settings — see the fields below. All are optional.
referenceView.enable({ samplesPerFrame = 4, bounces = 5 })
modules/referenceView/refresh
refresh(): (boolean, string?)
Retake the scene snapshot — geometry and lights as they now stand — and begin converging again. What to call after moving, adding or removing anything the tracer must see.
referenceView.refresh()
modules/referenceView/reset
reset()
Throw away every sample gathered so far and begin converging again from the current camera. The camera is watched automatically — this is for a change the view cannot see, such as a light being retuned.
referenceView.reset()
modules/referenceView/settings
settings(): { [string]: any }?
The settings in force, the size of the scene snapshot, and how far the
image has converged — samples is the count folded into the displayed
image, and converged is true once it has reached maxSamples.
local s = referenceView.settings(); print(s.samples, s.converged)
modules/reference_names/README
require("@builtin::modules.reference_names") -- reference_names
The world sources that spell a reference by a name its target no longer has, the ones among them the world's author owns, and the reconcile that writes the current names into those.
A source records, beside every reference name it uses, the guid of the
asset the name reached. When that asset later sits at another path (it
was moved, or the engine's library files it somewhere else), the
reference keeps resolving through the guid, while the text keeps the old
name.
Nothing rewrites a source for this on its own. Engines of different
versions can hold one world open together, and their libraries can file
the same asset at different paths: a source rewritten to the layout of
whichever engine read it would be rewritten back by the other, and every
rewrite is a change to the world that runs the asset's change hooks
(shader recompiles, preview renders) with nobody having asked for it. So
the old name stays until someone reconciles it. Until then, each time the
world becomes ready, a notice names every owned source that still spells
an old name, and assets.reconcileReferenceNames writes the current ones.
Reconciling changes no behaviour: every reference already resolves to the
asset its guid names, and afterwards the text names it the same way.
A source is the author's when the world authors it and it is not inside
an installed asset still as it was published. The engine library
(/source/libs/) and pulled dependencies (/source/deps/) keep the text
they were published with. An installed asset the author has modified
since installing it is theirs, and is reconciled like their own files.
Usage: local reference_names = require("@builtin::modules.reference_names")
modules/reference_names/__owned
__owned(source: string, held: { InstallOwnership }): boolean
Whether source is the author's, given the installs the world holds.
The innermost install holding the source decides: an install the author
has changed or deleted anything in is theirs, the files they left as
published included; one they have left as published is still the
publisher's text. A source no install holds is the author's, and a
pulled dependency (/source/deps/) never is.
Parameters
sourcestring— The source's path.held{ InstallOwnership }— The installs, asworld.installslists them.
reference_names.__owned("/zero/source/a.material/mat.yaml", world.installs())
modules/reference_names/install
install()
Check, each time a world becomes ready, for owned sources spelling a moved reference's old name, and post a notice for each. Installed by the prelude.
modules/reference_names/pending
pending(paths: { string }?): { MovedSource }
The owned world sources that spell a reference by a name its target
no longer has. Owned: authored by this world, outside /source/deps/,
and not inside an installed asset still as it was published. Reads only.
Parameters
paths{ string }?(optional) — Sources to ask about; every owned source when absent.
for _, s in ipairs(reference_names.pending()) do print(s.source, #s.names) end
modules/reference_names/reconcile
reconcile(opts: { paths: { string }?, dryRun: boolean? }?): ReconcileReport
Write the current name of every moved reference into the owned
sources that still spell an old one. The write is the source's own
change: it syncs to the world and runs the asset's change hooks like any
edit. What each reference resolves to stays as it was; only its spelling
changes, and the source drops out of pending. The notices already
posted about moved names are withdrawn and posted again for the owned
sources still holding one, so a caller that has not read them yet is
told only what is still true.
Parameters
opts{ paths: { string }?, dryRun: boolean? }?(optional) —{ paths?: { string }, dryRun?: boolean }:pathsnarrows to those sources;dryRunreports what would be written and writes nothing.
reference_names.reconcile({ dryRun = true })
modules/reflectionProbe/README
require("@builtin::modules.api.engine.reflectionProbe") -- reflectionProbe (also available as global 'reflectionProbe')
Reflection-probe system — multiple proximity-blended reflection probes in a scene. Each probe bakes the scene into its own cube slot from its position; surfaces reflect the probes covering them, gathered highest priority first and blended by proximity within a rank (the renderer's per-fragment probe blend), with the scene's sky under whatever coverage the probes leave. A probe reflects once it holds a cube (baked, or loaded from its persisted bake); until then it is registered and listed with baked = false and adds nothing to the frame. One-liner authoring (reflectionProbe.add) and a one-call bake-everything (reflectionProbe.bakeAll).
Usage: local reflectionProbe = require("@builtin::modules.api.engine.reflectionProbe") Also available as global: reflectionProbe
modules/reflectionProbe/add
add(x: number, y: number, z: number, opts: { [string]: any }?): string
Add a reflection probe at (x, y, z) in one call: spawns a probe entity
carrying a ReflectionProbe component, which registers it and loads its
persisted bake when one exists. A probe with no bake reflects nothing until
it is baked (bakeAll(), or bake(id)). The probe is an editor gizmo,
invisible in play mode. Returns the probe entity id.
Parameters
xnumber— World X.ynumber— World Y.znumber— World Z.opts{ [string]: any }?(optional) — Optional{ radius = 12, probeId = "...", name = "..." }.probeIdis the STABLE asset identity (so a re-created probe reloads the same baked cube); defaults to the entity id. The probe does NOT bake on add — callbakeAll()once the scene is built (baking is an authoring step).
reflectionProbe.add(0, 3, 0, { radius = 15, probeId = "lobby" })
modules/reflectionProbe/apply
apply(): number
Push the current active-probe blend data (live positions + radii) to the renderer. Builds a dense slot array so each probe's data lands at its cube slot; freed/missing slots, and the slot of a probe that holds no cube yet, become inert placeholders that reach no surface. Called automatically by add / bake / remove; call it directly after moving a probe entity.
modules/reflectionProbe/bake
bake(id: string): (string?, string?)
Bake the scene into probe id's cube slot from its current position AND
persist it to a faces6 .texture asset (so it survives reload + syncs),
then re-apply the probe set. Yields a few frames; call from a task/coroutine
context (component hook via task.spawn, bakeAll, or execute).
Parameters
idstring— Probe entity id.
modules/reflectionProbe/bakeAll
bakeAll(): { baked: number, failed: number, errors: { string } }
Bake EVERY registered probe in the active layers, in one call. Captures
the sky into the fallback slot, then each probe's scene from its position
into its slot, persists it, and applies the full probe set. The agent/editor
one-liner. Yields; call from a task/coroutine context (execute, a tool, or
task.spawn).
reflectionProbe.bakeAll()
modules/reflectionProbe/baking
baking(id: string?): boolean
Whether a bake under way will reach probe id: its own bake, or a
bakeAll that has it still to reach. With no id, whether any bake is
under way.
Parameters
idstring?(optional) — Optional probe entity id.
reflectionProbe.baking(id)
modules/reflectionProbe/count
count(): number
Number of registered probes.
modules/reflectionProbe/ensureSkyFallback
ensureSkyFallback(): boolean
Ensure the scene's sky is in the environment's sky fallback: a reflective surface no probe covers then reflects the sky rather than black, and a partially covered one blends the shortfall against it. Queues a capture when the sky slot holds none, and re-arms the fallback when a capture is there but switched off. The engine's own state answers both questions, so calling this on every probe that comes up costs one capture between them, and a scene that lost its fallback gets it back. Once captured, the fallback follows the sky the scene draws on its own.
reflectionProbe.ensureSkyFallback()
modules/reflectionProbe/isBaked
isBaked(id: string): boolean
Whether probe id holds a cube it reflects: baked by bake / bakeAll,
or loaded from its persisted bake by loadBaked. An unbaked probe adds
nothing to the frame.
Parameters
idstring— Probe entity id.
reflectionProbe.isBaked(id)
modules/reflectionProbe/list
list(): { any }
List every registered probe: { { id, slot, radius, priority, baked, asset, position }, ... }.
baked is whether the probe holds a cube it reflects; an unbaked probe adds
nothing to the frame. asset names the persisted bake once there is one.
modules/reflectionProbe/loadBaked
loadBaked(id: string): boolean
Load probe id's PERSISTED baked cube (probe_<key>.texture) into its
slot WITHOUT re-rendering the scene — the runtime path. A probe bakes once at
authoring time and loads the asset on every subsequent scene load. Returns
false (not an error) when no baked asset exists yet.
Parameters
idstring— Probe entity id.
modules/reflectionProbe/register
register(id: string, radius: number, key: string?): number?
Register a reflection probe for entity id with influence radius.
Assigns a free cube slot and applies the updated probe set. Idempotent — a
re-register keeps the same slot and just updates the radius. Called by the
ReflectionProbe component's awake; rarely called directly.
Parameters
idstring— Probe entity id.radiusnumber— Influence radius (world units) — surfaces within blend it.keystring?(optional) — Optional STABLE asset identity (the probe's probeId). Defaults toid. The baked cube persists atprobe_<key>.textureso an authored probe keeps the same asset across reloads even though its runtime entity id changes.
modules/reflectionProbe/setPriority
setPriority(id: string, priority: number)
Set a probe's blend rank against the probes it overlaps, and re-apply. Probes are gathered highest rank first and each rank takes the coverage the ranks above it left, so a small interior probe ranked above the large exterior one it sits inside wins outright wherever it reaches full weight, while probes of equal rank crossfade by proximity as before.
Parameters
idstring— Probe entity id.prioritynumber— Blend rank. Defaults to 0 on every probe.
reflectionProbe.setPriority(interiorId, 1)
modules/reflectionProbe/setProxy
setProxy(id: string, kind: string, x: number, y: number, z: number)
Anchor a probe's reflections to a proxy volume and re-apply. A cube records the environment from one point, so sampling it along the raw reflection vector puts everything it recorded at infinity and the reflection slides across a surface as the camera moves. Sizing a proxy to the geometry the probe recorded — a room's walls, say — keeps the reflection anchored to what it depicts.
Parameters
idstring— Probe entity id.kindstring— "box" (sized by all three half-extents), "sphere" (sized byx), or "none" to sample along the raw reflection vector.xnumber— Half-extent along X, in world units — the sphere radius for "sphere".ynumber— Half-extent along Y.znumber— Half-extent along Z.
reflectionProbe.setProxy(id, "box", 5, 3, 4) -- a 10x6x8 room
modules/reflectionProbe/setRadius
setRadius(id: string, radius: number)
Update a probe's influence radius and re-apply.
Parameters
idstring— Probe entity id.radiusnumber— New influence radius.
modules/reflectionProbe/unregister
unregister(id: string)
Unregister entity id's probe, freeing its cube slot, and re-apply.
Parameters
idstring— Probe entity id.
modules/renderer.refs/README
require("@builtin::modules.api.engine.renderer.refs") -- renderer.refs
How renderer.* names a live resource: the guid a runtime resource is minted and checked under, and the one coercion per resource kind from whatever a caller holds (a key or guid, a handle, an AssetRef) to the key the renderer's stores index it by, with the rejection that names the accepted forms.
Usage: local renderer.refs = require("@builtin::modules.api.engine.renderer.refs")
modules/renderer.shading/README
require("@builtin::modules.api.engine.renderer.shading") -- renderer.shading
The readings renderer.shadingOf builds out of the document the renderer publishes every frame: the subject a question names, the row that answers for it, and the fault reading a row carries.
Usage: local renderer.shading = require("@builtin::modules.api.engine.renderer.shading")
modules/renderer.sources/README
require("@builtin::modules.api.engine.renderer.sources") -- renderer.sources
The src shapes renderer.mesh.create / update and renderer.texture.create / update take: which shape a src is, the per-vertex record form a mesh src may be written in, the index-range fault a geometry src is refused for, and the bounds and counts raw geometry implies.
Usage: local renderer.sources = require("@builtin::modules.api.engine.renderer.sources")
modules/renderer/README
require("@builtin::modules.api.engine.renderer") -- renderer (also available as global 'renderer')
GPU-resource factory + CPU codec/store wrappers — the GPU/CPU half of the asset↔resource split. This module (under modules/api/) is the SOLE caller of the internal __mesh / __meshcpu / __meshgpu / __splat / __texture / __texturecpu / __texturegpu / __instancedata FFI; assetType behaviours, components, and every other module call renderer.*, never the __ internals.
Usage: local renderer = require("@builtin::modules.api.engine.renderer") Also available as global: renderer
modules/renderer/anisotropy
anisotropy(): number
The maximum anisotropy material textures are sampled with right now — the requested level clamped to what this device honours.
if renderer.anisotropy() < 4 then ... end
modules/renderer/atmospherics.held
atmospherics.held(): boolean
Whether a hold is standing on the air right now.
if renderer.atmospherics.held() then print("clear air") end
modules/renderer/atmospherics.hold
atmospherics.hold(share: number?, options: AtmosphericsHoldOptions?): () -> ()
Hold the air between the camera and every surface at a stated share of
what the scene authored, and return the release. At the default 0 the
media contribute nothing and a surface renders in its own colour, which is
what lets a reader judge an albedo, a tint or a material while another
slice of a shared world drives the weather. The share reaches aerial
perspective, height fog and volumetric light scattering; the sky, the sun
and the light they put on a surface are untouched, because those are what
the surface's colour is made of. Holds nest: the innermost names the
share, and the authored air is back once the last release is called. Each
release ends its own hold whatever order the releases come in, so two
callers holding at once each end their own.
exclusive takes the air for the owner key the call states: while that
hold stands, a hold is admitted only when it states the same key, and
every other one is refused with an error naming the key and the share
holding it. That is what lets one caller clear the air to read a surface
and keep it clear while another agent drives the same engine. The key is
what an owner presents to take a nested hold of its own, and what
renderer.atmospherics.release hands the air back by.
Parameters
sharenumber?(optional) — How much of the authored air reaches the image, in [0, 1]. Defaults to 0 -- no air at all.optionsAtmosphericsHoldOptions?(optional) —owneris the key this hold is taken under, and an exclusive hold states one. A hold that states no key is labelled with the caller the call is attributed to, which names the calling session where the transport attested one and the ZeroMind account otherwise.exclusivetakes the air for the stated key until the hold is released.
Returns () — A function that releases this hold. Calling it twice releases once.
local release = renderer.atmospherics.hold() ; local picture = tools.use("capture", "fromPosition", { position = { 0, 2, 8 } }) ; release()
local release = renderer.atmospherics.hold(0, { exclusive = true, owner = "albedo-read" })
modules/renderer/atmospherics.onChange
atmospherics.onChange(listener: (number) -> ()): () -> ()
Register a listener called with the share now in force whenever it changes — a hold taken, a hold released — and return the unsubscribe. A system that packs a medium into a GPU buffer registers here and re-packs what it has already pushed, so the buffer carries the share before the frame the hold was taken on is drawn rather than a frame later.
Parameters
listener(number) -> ()— Called with the share now in force, in [0, 1].
Returns () — A function that removes this listener.
local stop = renderer.atmospherics.onChange(function(share) print("atmosphere share", share) end)
modules/renderer/atmospherics.owner
atmospherics.owner(): { id: string?, name: string?, share: number, exclusive: boolean }?
The hold naming the share of the authored air that reaches the image
right now: who took it, what share it asked for, and whether it took the
air exclusively. Several agents drive one engine at once and a hold any of
them takes moves the air every surface in every other agent's frame is
rendered through, so this is how a caller sees that another agent holds it
before its own share is quietly replaced -- and, when exclusive is true,
id is the key a hold of its own states to be admitted, and the key
renderer.atmospherics.release hands the air back by. id and name are
nil for a hold that stated no key and that the engine attributes to no
agent.
local who = renderer.atmospherics.owner()
if who ~= nil and who.exclusive then print(who.name, "holds the air at", who.share) end
modules/renderer/atmospherics.release
atmospherics.release(owner: string): number
Hand the air back by the key its holds were taken under, and report how many came off. A hold stands until its release is called, and the release is a closure the call that took the hold holds: a caller that takes a hold in one call and comes back in another, and a task that ends between the two, both leave the air pinned with nobody holding a release for it. Naming the key is how the authored air comes back, and how a caller refused by an exclusive hold takes one over.
Parameters
ownerstring— The key the holds to release were taken under -- whatownerstated when they were taken, whichrenderer.atmospherics.ownerreports.
renderer.atmospherics.release("albedo-read")
modules/renderer/atmospherics.share
atmospherics.share(): number
The share of the authored air that reaches the image: the innermost
hold's share while one stands, and 1 otherwise. A system that packs a
medium multiplies its extinction — aerial, a fog density — by this,
and a hold then reaches that medium however it is being driven.
local density = state.density * renderer.atmospherics.share()
modules/renderer/blendedBatching
blendedBatching(): boolean
Whether blended neighbours sharing a draw key draw together.
modules/renderer/bounds.clear
bounds.clear(id: string): boolean
Withdraw the box an entity published, so it stops contributing to the entity's reported extent.
Parameters
idstring— Entity id.
renderer.bounds.clear(id)
modules/renderer/bounds.set
bounds.set(id: string, min: any, max: any): boolean
Publish the local-space box an entity's content-drawn geometry occupies.
entity:bounds() and entity:hierarchyBounds() union it with whatever
mesh geometry the entity has, each carried out of its own local space, so
framing a camera on the entity frames what a feature actually draws.
Parameters
idstring— Entity id.minany(optional) — Local-space minimum corner — a Vec3 table or a 3-element array.maxany(optional) — Local-space maximum corner, same shape asmin.
renderer.bounds.set(id, cloud.boundsMin, cloud.boundsMax)
modules/renderer/captureView.channelId
captureView.channelId(name: string): number?
The debug channel a registered view draws on — what a feature passes as
its pass debugChannel. Nil when no view is registered under name.
Parameters
namestring— The view name.
local debugChannel = renderer.captureView.channelId("lightmap") -- a render feature passes it as an enqueued pass's `debugChannel`
modules/renderer/captureView.list
captureView.list(): { any }
Every registered capture view as { name, channel, description } records
— what backs the discoverability of capture pass=<name> and the
unknown-view error's suggestion list.
for _, v in ipairs(renderer.captureView.list()) do ... end
modules/renderer/captureView.ready
captureView.ready(name: string): boolean
Whether a registered view can draw yet. A view's passes are enqueued
from the moment its render feature first runs, but they are skipped while
the materials they name have no pipeline — their shader is still compiling —
so for the first frames of a session a camera bound to the view renders the
ORDINARY view into its target, and the image gives no sign of it. This
reports the difference, and reports it before any camera is on the view, so
it is answerable for the first camera bound to one. Asking builds the
view's parts if they are not yet there. A view that registered
a ready of its own is also held to it, so a view whose feature is not
running, or whose draw has not landed, reads false. False for an
unregistered name.
Parameters
namestring— The view name.
repeat task.wait() until renderer.captureView.ready("zfighting")
modules/renderer/captureView.register
captureView.register(name: string, config: any): number
Register (or update) a content capture view under name and return the
debug CHANNEL number assigned to it. A render feature gates its pass to this
channel (debugChannel = channel) so the pass draws only when a capture
selects the view. Idempotent: re-registering the same name keeps its channel.
Parameters
namestring— The view name, selected viacapture pass=<name>.configany(optional) —{ description?, ensure?, ready?, warmup?, renderLayers? }.ensureis called before a capture of this view so the feature that draws it is live (e.g. create it on demand).readyis the view's own statement of whether what it draws is in place: afunction(): (boolean, string?)answering true, or false and the reason. A capture of the view waits on it afterensureand before it renders, so a view whose draw lands over the frames afterensure(an entity it spawns, a feature that reads the stateensurebuilt on its next frame, a material still compiling) is drawn rather than captured empty, and a view that stays unready is refused with that reason.warmupis how many present frames a capture lets the view accumulate, once it is ready, before it reads: set it when the feature retains prior-frame state (a temporal diff) so the first capture reads a warm result.renderLayersis the layer spec a capture of this view uses when the caller named none. A view that draws its own geometry and wants the scene's kept out of the frame (and out of the depth buffer it tests against) names only its own layer.
local ch = renderer.captureView.register("lightmap", { description = "...", ensure = fn })
modules/renderer/captureView.resolve
captureView.resolve(name: string): any
Resolve a capture view by name to its { channel, ensure, ready, description, warmup, renderLayers } record, or nil when no view is
registered under name.
Parameters
namestring— The view name.
local v = renderer.captureView.resolve("lightmap")
modules/renderer/captureView.unregister
captureView.unregister(name: string): boolean
Withdraw a capture view. A subsequent capture pass=<name> no longer
resolves to it (falls through to the unknown-view error).
Parameters
namestring— The view name.
renderer.captureView.unregister("lightmap")
modules/renderer/clearShadowHero
clearShadowHero(): boolean
Release the hero caster, so every receiver samples the level its footprint selects again.
renderer.clearShadowHero()
modules/renderer/clearShadowProxy
clearShadowProxy(mesh: string?): number
Stop proxying mesh, so it rasterizes its own geometry into shadow
pages again. Called with no argument, drops every registration.
Parameters
meshstring?(optional) — The mesh to stop proxying. Omit to clear all of them.
renderer.clearShadowProxy(statueMesh)
print(renderer.clearShadowProxy(), "proxies dropped")
modules/renderer/clusterErrorPx
clusterErrorPx(px: number?): number
The cluster cut's error threshold, in pixels. Every static mesh draws the coarsest clusters whose simplification error projects to at most this many pixels in the view drawing it — measured against that view's own pixel height and projection, so a small render target draws coarser geometry than the full-screen view does from the same place. Lower draws finer geometry at more cost; higher draws coarser geometry. A client graphics setting. Default 1.
Parameters
pxnumber?(optional) — A finite number above 0. Omit to read the threshold.
renderer.clusterErrorPx(0.5) -- finer geometry on this machine
modules/renderer/collect
collect(): RuntimeCollection
Release every runtime texture, material, mesh and render feature nothing
holds: no handle a script still reaches, no live owner, no reference from
live engine state, no asset backing it, no hold. A root scene load runs this
once the new scene stands, so what the previous scene's content created and
nothing still wears goes with that scene; calling it directly collects at
any other moment. A session material's handle counts as reached while the
entity it was keyed for stands, and stops counting once that entity is
gone.
It reaches the GPU textures the device holds beside the registry's own: a
texture the cache loaded for an asset goes once nothing live names it and
is read back from that asset the next time something asks for it, while one
no asset answers for stays, there being nothing to read it back from — a
render pass's own target, a colour swatch, an atlas the engine built. A
texture the ASSET path uploaded and whose asset has since been removed has
nothing to come back from either, and the collection decides about it from
its holders the way it does about every other resource: a handle a script
still reaches, a live owner, a reference from live engine state, a hold.
Features go first, then materials, then meshes, then textures, so a texture
only a released material named goes with the material. Runs a full garbage
collection first, so a handle nothing reaches counts as let go, and yields
for the frame the census runs on. A handle the calling function still has
in a variable — or in a temporary it has not overwritten — is one a script
reaches, so a resource created in the function that collects is let go by
the next collection rather than this one. A runtime mesh needs no call:
once the garbage collector has taken its last handle, the engine judges it
against the same holders, again whenever what displays it changes or its
hold is released, and every few hundred frames while something holds it,
and releases it once nothing does.
Returns once what it released has left the device: the GPU objects of the
textures and meshes it let go are freed over the frames after the call,
and it waits for those frames (up to 60 drawn frames), so
renderer.texture.list, renderer.mesh.list, renderer.material.list,
renderer.textureMemory() and renderer.gpuMemory() read after it in the
same script no longer count anything it reports released. landed says
whether every release left the device within that wait; false names a
texture or mesh something put back on the device before it could be seen
gone, which renderer.references explains. Code that cannot yield (a
metamethod, onDestroy, a module's top level while require runs it)
is answered at once, without the wait: there landed is false while a
release is still on its way, and the listings and totals stop counting it
over the drawn frames that follow.
local c = renderer.collect() print(c.released.texture, c.kept)
local c = renderer.collect() print(c.landed, renderer.gpuMemory().meshes)
modules/renderer/compiledShaders
compiledShaders(): { string }
Every key renderer.compiledSource answers for — one per shader key
(guid@checksum) or variant program a compile has run under, whether it
succeeded or failed, for as long as the shader that compiled under it
stands: a removed .shader takes its keys with it. What makes the
composed-source surface enumerable rather than something to guess a key
for.
for _, name in renderer.compiledShaders() do print(name) end
modules/renderer/compiledSource
compiledSource(shader: string): string?
The WGSL the shader compiler received under one name, exactly as it
received it — the composed module, which is what a compile error's line
numbers and handle indices are positions in. Answers for a shader key
(guid@checksum), a program from renderer.shaderVariants(), or any
reference to a shader asset (identity, path, guid), which reaches the key
of the version that reference resolves to now; for a shader that declares
no features, and for a shader whose compile FAILED, which is the case it
exists for: a message about a function body carries a position and nothing
else, and the text that position is in is this. The failed text stands for
as long as shaderRef:compileStatus() reports that failure.
Parameters
shaderstring— A shader key, ashaderVariants()program name, or a reference to a shader asset.
local status = asset.resolve("myShader", "shader"):compileStatus()
if status.status == "failed" then
print(status.error)
print(renderer.compiledSource("myShader"))
end
modules/renderer/compositeSize
compositeSize(): { width: number, height: number }
The size of the image the post-scene phases worked on in the last
presented frame — the target the UI composites onto, which every pass
after the scene reads as @scene.color and writes into, and which a
screenSpace = "composite" render target follows. While the renderer
presents the viewport itself that is the display's own size, whatever
fraction of it the scene rasterized at; while a UI viewport panel owns
the presentation it is the size the scene rasterized at, since the panel
draws the scene target at its own rect and nothing upscales before the
composite. Both read 0 before a frame has drawn.
local c = renderer.compositeSize()
modules/renderer/cullStats
cullStats(): {
What the last completed frame decided to draw. total renderables went
into the frustum test, culled fell outside it and visible survived. Of
those, occlusion culling measured occlusionTested against the depth
pyramid and proved occlusionCulled were entirely behind other geometry —
both 0 while renderer.occlusionCulling() is false. A renderable the
pyramid has no say over — one that laid no depth in the visibility raster, one whose
bounds were never recorded, one straddling the near plane — is measured
against nothing and counted in neither, so the gap between visible and
occlusionTested reads how much of the frame the test could speak for.
This answers for the main camera. What the shadow page cull did with the
frame's casters for each light is on that light's row in
renderer.shadowViews().
views is the engine cull's own count, one row per camera view that
rendered: view is "main" for the main camera and the camera's entity
id for an offscreen one, kind says which, and frame is the frame the
counts describe. The main view's row is first. drawn is whether a
render drew the view in that frame: a frame the renderer declined still
ran the cull's first test, so its row carries that test's counts and no
second one, for a picture nothing rasterized. The
counts are read back from the GPU and handed out oldest first, one frame
per render, so a script reading once a frame reads the frames in the
order they ran. A frame's counts wait at most two renders to be handed
out: a row describes a frame as many frames back as the read took and at
most two more, and when more frames' counts come back at once than that
lets wait, the oldest of them are the frames a script does not read.
instancesTested renderables were tested;
instancesCulled breaks the rejections down by reason (hidden, layer, range,
frustum, screenSize, and occludedPass1/occludedPass2 for occlusion
against the depth of the frame that last drew the view and then this
frame's); instancesRecovered
came back in the second test. Then the clusters of the survivors:
clustersTested, rejected by the level-of-detail cut
(clustersLodRejected), the frustum (clustersFrustumCulled), facing away
(clustersConeCulled) or occlusion (clustersOccludedPass1, of which
clustersRecovered came back), and clustersDrawn / trianglesDrawn.
binsPending counts material pipelines still compiling, whose clusters wait
a frame; overflow counts clusters that did not fit the view's lists.
total/culled/visible and occlusionTested/occlusionCulled above are
the main view's count for the renderables drawn outside the cluster lists.
local s = renderer.cullStats(); print(s.visible - s.occlusionCulled, "drawn")
for _, v in renderer.cullStats().views do if v.view == "main" then print(v.clustersDrawn, "clusters,", v.instancesCulled.frustum, "outside the frustum") end end
modules/renderer/debugPass.builtins
debugPass.builtins(): { string }
The built-in debug-pass names, one per channel in channel order — the engine's built-in pass vocabulary (final, albedo, normal, depth, …).
for _, n in ipairs(renderer.debugPass.builtins()) do ... end
modules/renderer/debugPass.channel
debugPass.channel(name: string): number?
The channel a debug-pass NAME renders on: a built-in pass, else a content
capture view registered via renderer.captureView. Nil when the name is
neither — the signal a selector uses to reject an unknown pass.
Parameters
namestring— A debug-pass name (e.g. "normal", "depth", "lightmap").
local ch = renderer.debugPass.channel("normal") -- 7
modules/renderer/debugPass.list
debugPass.list(): { string }
Every selectable debug-pass name: the built-in passes plus every registered content capture view. What a debug-pass selector offers.
local passes = renderer.debugPass.list()
modules/renderer/debugPass.name
debugPass.name(channel: number): string?
The canonical NAME for a debug channel: a built-in pass name for a built-in channel, else a registered capture view's name. Channel 0 is "final" (the lit image). Nil when no pass owns the channel.
Parameters
channelnumber— The channel number.
local name = renderer.debugPass.name(7) -- "normal"
modules/renderer/destroy
destroy(handleOrKind: any, id: string?): boolean
Free the GPU resource a renderer resource holds (the GPU-destroy verb).
Takes any of the forms that name it: the handle a create returned, routed
by its category so one call releases a mixed set of handles; the id a
listing hands out, whose kind is read back off what the renderer holds
under it — the runtime registry, the material definitions, the live
features, and the device itself for an asset's own texture or mesh; or the
kind with the id beside it, the shape renderer.hold and
renderer.references take, which is what names the kind for an id two of
them answer to. An id nothing holds anything under releases nothing and
answers false. The on-disk asset, if any, is untouched. A CPU handle's
:unload() frees the CPU copy separately.
Parameters
handleOrKindany(optional) — AMeshHandle,TextureHandle,MaterialHandleor feature handle; the id itself; or the kind ("texture","material","mesh","feature") with the id as the second argument.idstring?(optional) — The guid or registry key, when the first argument is a kind.
renderer.destroy(meshHandle); renderer.destroy(materialHandle)
renderer.destroy(renderer.texture.list()[1].guid)
renderer.destroy("mesh", guid)
modules/renderer/deviceGeneration
deviceGeneration(): number
Which render device this process is on, counted from the first.
A render device is lost when a driver resets, when the GPU is taken away,
or when a browser reclaims a WebGPU context. The engine answers by building
another device and re-deriving this session's resources onto it, and this
number moves by one each time it does. Anything held across frames that was
built from a GPU resource records this beside it and remakes it when the two
differ; engine.onDeviceRebuilt is the hook that fires when it moves.
local generation = renderer.deviceGeneration()
engine.onDeviceRebuilt(function(g) print("device " .. g) end)
modules/renderer/deviceState
deviceState(): string
Whether the render device this process draws through is the one it is using, one it is replacing, or one the platform has refused every quick attempt to replace.
"ready" is a live device. "rebuilding" is the window between a device
reporting itself lost and another being in place: every GPU resource built
from the old one is invalid, the frames in that window draw nothing, and
anything reaching the GPU refuses. "abandoned" is after every quick
attempt at another device was refused (a browser whose GPU process crashed
twice answers no adapter for minutes): nothing is drawn, the engine log
names the platform's last answer, and the engine keeps asking at a slower
pace, so the state returns to "ready" on its own once the platform hands
a device over. Restarting the engine (reloading the page on the web)
builds one from scratch.
Work that spans the device — build a render target, draw into it, read it
back — reads this to tell an operation that failed because the device went
out from under it, which is worth doing again once
renderer.deviceGeneration() moves, from one that failed on its own terms.
The loss is reported before the next device exists, so the two readings
answer different halves: this one says a replacement is coming, the
generation says it arrived.
if renderer.deviceState() == "rebuilding" then return end
modules/renderer/drawDiagnostics
drawDiagnostics(): { DrawDiagnostic }
Every renderable that is NOT drawing what its material says — the one
call for "why does this surface look wrong". Three states land here: a
surface rendering as the magenta placeholder (substituted), one the
renderer could bind nothing for at all (outcome = "skipped"), and one
drawing a program whose most recent compile FAILED (stale), which is what
a shader edited into brokenness looks like — the pipeline its last good
compile built keeps drawing, so the picture is intact and answers to none of
the edits since. Each row names the entity, the program asked for, the
program bound, programStatus — the compile gate's word about the program
the material NAMED — and the one cause
from shaderCompileFailed / shaderNotRegistered / shaderNotCompiledYet
/ noGbufferEntry / renderStateKeyNotBuilt / noPipelineForTarget /
unshaded, with the compiler's own message in detail or programError.
Covers every renderable the renderer holds, whether or not a camera reached
it: a row with observed = false and outcome = "notDrawn" carries the
renderer's own resolution for one this frame drew nowhere, so a broken
surface off-screen is reported the same as one in frame. An empty result
means every renderable the renderer holds is drawing the program its
material named and that program compiles. Answers on the deferred path as
well as forward, and in edit mode as well as play.
for _, d in renderer.drawDiagnostics() do print(d.entity, d.reason, d.detail) end
if #renderer.drawDiagnostics() == 0 then print("every surface is drawing what it says") end
modules/renderer/drawStats
drawStats(): {
What the last completed frame actually submitted. draws counts every
geometry draw call the frame issued — the camera's passes, each shadow
view a shadow-casting light adds, and whatever a render feature draws —
and instances counts the instances those draws covered. The pair is what
separates one draw carrying five hundred instances from five hundred draws
carrying one each, so it reads how well the scene batches rather than how
many objects are in it.
compacted is how many of those instances the frame planned through draws
whose instance count the GPU decides: the culler's own per-object answers
packed into a dense run, so an object it rejects is absent from the draw
instead of collapsing to nothing in the vertex stage. compactedDrawn is
how many of them survived, counted on the GPU as it packed them — a pass
that then skips a whole draw over its own layer or visibility answer
leaves that draw's instances in both numbers.
The plan is made over the populations the frame draws, and the tests
answer which of their instances the packing keeps. That packing runs
before any pass has resolved the depth occlusion culling is tested
against, so on its own it reads the frustum and screen-size answers
alone. With setOcclusionCulling armed the frame packs the same plan a
second time once the test has answered, and compactedDrawn then counts
what came through occlusion as well.
compactedDrawn comes back from the buffer the GPU wrote, so it describes
a frame that has finished while compacted describes the most recent
plan, and it holds the last count the GPU wrote until another arrives — a
frame that compacts nothing reads compacted 0 beside the count from the
last frame that did. In a scene standing still the gap between the two is
the front-end work culling removed.
materialBinds is how many times the frame's geometry passes set a
material group's textures (group 1), and materialBindsElided how
many times a pass reached that decision and found the group already bound.
On the bindless backend every material group binds the one texture group
of the frame, so a pass binds it once; on buckets a pass binds once per
group it draws (see renderer.materialTable().groups). Their sum is how many times the
decision was reached — once per unit of geometry submitted, which sits at
or below draws, since a mesh of several primitives draws once per
primitive under one set of binds. materialExtraBinds and
materialExtraBindsElided are the same pair for group 2, the storage
buffers a shader declares, bound per distinct buffer set, which only the
shaders that declare them ever bind.
pipelineBinds and pipelineBindsElided are the same pair for the
pipeline itself: how many times the frame's geometry passes set one, and
how many times a pass reached that decision and found the pipeline it
wanted already bound. Which pipeline a unit needs follows its shader, its
material's render state and its mesh's vertex layout together, so a scene
whose units share all three costs one set for the run of them, while units
differing in any one of the three each pay their own. Their sum is how
many units reached the pipeline decision, which sits at or above what the
material pair reports: a unit the pass settles a pipeline for and then
abandons — one whose material group resolved to nothing — counts here and
never reaches the material decision.
Every figure here is the whole frame's. renderer.shadowViews() carries
the main camera's own share of compacted and compactedDrawn.
clusters and clusterTriangles are the clusters and triangles the
camera views drew from the cluster lists, from the GPU's own count.
drawsByPass splits draws by the part of the frame that submitted
them — visibility (the id raster: one draw per raster bin per Hi-Z
phase in each camera view, submitted whether or not the GPU cull left
anything in the bin), resolve (one draw per resolve draw in each
camera view: one per shader, and on the array-bucket backend one per
shader and material group), legacy (geometry drawn outside cluster
storage: skinned, morphed and compute-written meshes, line topology,
shaders that write their own vertex stage), blended, exception
(opaque materials whose depth state the visibility buffer cannot
express), featureGeometry, featureDraw, shadow and splat (one
draw per splat buffer a render feature draws) — and the nine sum to
draws.
instances counts instances named by draws whose size the CPU decided;
the visibility raster's work is clusters and clusterTriangles, which
the GPU decided. pixelsResolved is how many pixels the resolve shaded,
summed over camera views, and pixelsByShader the same split by shader.
clusters, clusterTriangles, pixelsResolved and pixelsByShader
come back from the GPU and describe the frame numbered frame, which is
earlier than the frame draws describes. frame is the renderer's own
frame number, counted from 0 when the renderer was built (again after a
device loss), a count of its own that compares only with another
drawStats().frame.
local d = renderer.drawStats(); print(d.instances / math.max(d.draws, 1), "instances per draw")
print(renderer.drawStats().compactedDrawn, "of", renderer.drawStats().compacted, "survived the cull")
local d = renderer.drawStats(); print(d.materialBinds, "material group binds over", d.materialBinds + d.materialBindsElided, "units")
local d = renderer.drawStats(); print(d.pipelineBinds, "pipeline sets over", d.pipelineBinds + d.pipelineBindsElided, "units")
local d = renderer.drawStats(); print(d.clusters, "clusters,", d.clusterTriangles, "triangles from the cluster lists")
local d = renderer.drawStats(); print(d.drawsByPass.visibility, "id-raster draws,", d.drawsByPass.resolve, "resolve draws")
local d = renderer.drawStats(); for shader, px in d.pixelsByShader do print(shader, px) end
modules/renderer/editorChromeOnWindow
editorChromeOnWindow(): boolean
Read back the frames the engine presents, exactly as presented: no
camera is spawned and nothing is drawn for the read, so the frames carry
the viewport's real temporal history (TAA and every accumulating effect),
its camera motion (motion blur), its auto exposure and its render scale and
upscale. From the first frame presented after the call, every
interval-th frame is copied out as it is finished, until frames are
taken; the call yields until all of them have landed and returns them in
the order they were presented. Each frame's pixels are its cpu field, a
TextureCpuHandle (readPixel, tone, rgba, encodePng, unload).
scope = "viewport" (the default) is the game view as finished for the
player: after the post chain, the upscale, the display transform, the
content UI and every post-scene pass, at the size the frame was composed
at (a viewport panel's own texture where a panel shows it). scope = "window" is the whole presented surface (the window, the browser canvas
or the headless framebuffer) with every window-level UI pass on it, the
editor's chrome included. Where no panel shows the viewport the two are
the same image, and while the editor's chrome is on the window each such
viewport frame carries a note saying the chrome stands over the scene
in it and how to show the Scene panel.
Each frame states what it was drawn with: frame (consecutive frames carry
consecutive numbers), the raster and composite sizes, renderScale and
scaleMode, the projection jitter, the display exposure, and
historyReset. Call frame.cpu:unload() when done with the pixels.
velocity = true also takes the viewport's velocity buffer with each
frame, copied at the same moment as its pixels, as frame.velocity (a
VelocityField): each pixel's travel between the previous frame and this
one in pixels per frame of the scene's raster, x right and y down, signed
and unclamped, measured against the projection without its jitter. It is
the field motion blur, temporal antialiasing and every other temporal
effect read, camera motion included; field:at(x, y), field:row(y) and
field:region(rect) read it.
local f = renderer.presentedFrames({ frames = 8 }); for _, fr in f do print(fr.frame, fr.renderScale, fr.cpu:tone().mean); fr.cpu:unload() end
local fr = renderer.presentedFrames({ velocity = true })[1]; local v = fr.velocity :: any; local c = v:at(v.width // 2, v.height // 2); print(fr.frame, c.x, c.y); fr.cpu:unload()
modules/renderer/feature.configure
feature.configure(handleOrRef: any, settings: { [string]: any }): { [string]: any }
Lay settings over a live feature's knobs. Any omitted knob keeps its
value; a knob the feature never declared, or a value of the wrong shape, is
refused by name. The feature reads the result as ctx.settings from its
next frame.
Parameters
handleOrRefany(optional) — ARenderFeatureHandle, its guid, or the feature's ref.settings{ [string]: any }— The knob values to apply.
renderer.feature.configure(h, { intensity = 0.5, quality = "medium" })
modules/renderer/feature.create
feature.create(ref: any, opts: (string | { guid: string?, settings: { [string]: any }? })?): any
Instantiate a render feature so the engine calls its render(ctx) hook
every frame. ref is an AssetRef<renderFeature> whose init.luau returns
{ setup?, render, teardown? }. Returns a live RenderFeatureHandle (its
guid is the stable id, same as mesh/texture handles); tear it down with
renderer:destroy(handle). Pass guid to assign a specific id.
Parameters
refany(optional) — AnAssetRef<renderFeature>, or a string identity/guid resolved viaasset.resolve(ref, "renderFeature").opts(string | { guid: string?, settings: { [string]: any }? })?(optional)
local h = renderer.feature.create(asset.resolve("acrylic", "renderFeature"))
local h = renderer.feature.create("acrylic")
local h = renderer.feature.create("@builtin::systems.reflections.ssr", { settings = { intensity = 0.8 } })
modules/renderer/feature.destroy
feature.destroy(handleOrGuid: any): boolean
Tear down a live render feature by its RenderFeatureHandle OR its guid
string — the by-id path for when the handle was lost (e.g. across execute
calls). Same effect as renderer.destroy(handle). Returns true if a feature
was live under that id.
Parameters
handleOrGuidany(optional) — ARenderFeatureHandleor itsguidstring.
renderer.feature.destroy("eb623975-d8bd-47a1-a0a4-5c0e56238e2f")
modules/renderer/feature.find
feature.find(ref: any): any
The live handle of the feature running ref — an AssetRef
Parameters
refany(optional) — An AssetRef, a renderFeature identity, or a guid.
local h = renderer.feature.find("@builtin::systems.reflections.ssr")
modules/renderer/feature.list
feature.list(): { { guid: string, identity: string, settings: { [string]: any } } }
List every render feature currently live (running its render(ctx) each
frame). Each entry is { guid, identity, settings } — the guid is the same
id a RenderFeatureHandle carries, so you can tear a feature down by guid
even after losing its handle (e.g. across separate execute calls), and
settings is every knob the feature declares at the value in force.
for _, f in renderer.feature.list() do print(f.identity, f.guid) end
modules/renderer/feature.schema
feature.schema(ref: any): { [string]: any }
The settings a .renderFeature declares, with each knob's descriptor,
read without running it: what a caller may pass to create / configure.
Parameters
refany(optional) — An AssetRefor a renderFeature identity.
for name, desc in pairs(renderer.feature.schema("@builtin::systems.reflections.ssr")) do print(name, desc.default) end
modules/renderer/feature.settings
feature.settings(handleOrRef: any): { [string]: any }?
A live feature's settings as they stand: every declared knob at its
default or at what create / configure set. A copy — writing to it
changes nothing; configure does.
Parameters
handleOrRefany(optional) — ARenderFeatureHandle, its guid, or the feature's ref.
local s = renderer.feature.settings(h); print(s.intensity)
modules/renderer/feature.shaded
feature.shaded(): { [string]: number }
How many pixels each fragment pass a render feature enqueued shaded on
the last drawn frame, keyed by the pass's shader/effect name. A fragment
pass draws one triangle over its target, so it shades the whole screen
whatever its effect actually reaches — unless it declares bounds on the
pass spec, the world-space box its effect stays inside, in which case it
shades the rectangle that box projects into for the camera drawing it and
is skipped for a camera that cannot see the box at all. This is the reading
that says which of the two a pass is: it moves when the effect moves, and a
pass absent from it shaded nothing. Summed over every camera the frame drew.
local px = renderer.feature.shaded(); for name, n in pairs(px) do print(name, n) end
modules/renderer/featureTexture.configure
featureTexture.configure(width: number, height: number, layers: number)
Size the shared feature-texture array — the layers a surface shader reads
through zero_feature_texture(uv, layer), and the layers a SpotLight
projects through its cone via cookieLayer. Layers are rgba16f.
A call for the size the array already has is left alone. One that changes
the size reallocates, and the replacement is zeroed — so it empties every
layer in the array, including the layers other features and other cookies
own. renderer.featureTexture.state() reports the extent and the layers
holding content, which is how a feature re-fills the layer a resize took
from it.
Parameters
widthnumber— Layer width in pixels.heightnumber— Layer height in pixels.layersnumber— How many layers the array holds.
renderer.featureTexture.configure(512, 512, 4)
modules/renderer/featureTexture.setLayer
featureTexture.setLayer(layer: number, textureKey: string, x: number, y: number)
Copy a texture already on the GPU into one layer of the shared array,
its top-left corner at (x, y) — GPU to GPU, with no readback. Several
small images pack into one layer by calling this once per image at
different offsets. The source must be rgba16f and fit at that offset.
Parameters
layernumber— Which layer of the array to write into.textureKeystring— The source texture's name — the one it was created under. Acompute.createStorageTexture2Dtarget, acompute.createTextureHistorypair (its current side), and a texture acompute.copyBufferToTexturewrote all answer to the name they were given.xnumber— Left edge of the destination rectangle, in pixels.ynumber— Top edge of the destination rectangle, in pixels.
compute.createStorageTexture2D("gobo", { width = 256, height = 256, format = "rgba16f" })
renderer.featureTexture.setLayer(0, "gobo", 0, 0)
modules/renderer/featureTexture.state
featureTexture.state(): {
What the shared feature-texture array is right now: the extent every
layer carries, and filled, the ascending 0-based indices of the layers a
setLayer has landed in since the array was last sized. One array is
shared by every feature and every light cookie in the scene, and it has no
allocator, so this is the call that tells a feature whether the array it
sized and filled is still the array it is writing into — a configure that
changed the size reallocates and zeroes every layer, and the layer it
emptied leaves filled without it. Measured off the renderer at the end of
the last rendered frame, so a configure or setLayer issued this frame
reads back on a later one.
What this describes is the array a shader samples. The source texture a
setLayer copied FROM is a GPU resource of its own and keeps the bytes it
was written with for as long as it lives, so filled is the reading that
answers whether the layer behind a cookieLayer is live right now.
fills counts, per layer, the setLayers that have landed in it since the
array was last sized: fills[layer + 1] for a 0-based layer. A fill of a
layer that already holds content leaves filled as it was, so the count
moving is how a feature re-filling its own layer reads its fill arriving.
local ft = renderer.featureTexture.state()
print(("feature textures: %dx%d over %d layers"):format(ft.width, ft.height, ft.layers))
-- Re-fill the cookie layer this module owns if anything emptied it.
if ft.width ~= myWidth or table.find(ft.filled, myLayer) == nil then
print("refill the cookie layer", myLayer)
end
modules/renderer/framePacing
framePacing(): FramePacing?
How far the CPU is allowed to run ahead of the GPU, and what holding it there cost the frame just finished. Submitting work to the GPU returns before the GPU has done it, and everything that submission holds — its staging allocations, its bind groups, its command buffer — stays alive until it completes. A frame that asks for more work than the GPU finishes in a frame's time therefore leaves that behind it, and unbounded that is memory growth rather than a lower frame rate.
framesInFlight is how many submitted frames have not reported done
through the queue's completion signal, held under maxFramesInFlight: a
device that keeps up reads under the bound, one that is behind reads at it.
It counts submissions, which is its own quantity — how many presented
images the swapchain permits in flight is a separate setting.
mechanism names how that bound is enforced
here: submission-wait waits for the frame that many frames back and
reports the wait in waitMs, so a paced frame costs latency and still
draws; submitted-work-done counts outstanding frames off the queue's
completion signal and declines to start a frame while the bound is met,
counting those in pacedFrames and leaving the last presented image up.
submittedFrames counts the frames that were admitted and submitted, so it
rises for as long as the renderer is producing frames — which is what tells
a renderer running slowly under a tight bound from one that has stopped.
stalled reads true while the pacer has given the bound up rather than
hold the image indefinitely, on either mechanism: the counting one stands
down when the completion signal goes quiet across a whole run of declined
frames, and the waiting one when a wait on a frame reaches its ceiling
with the GPU still holding it. Both clear on the first word the GPU sends
after that. A signal that is merely late — a GPU finishing frames more
slowly than the loop asks for them — keeps the bound, so stalled answers
for a GPU that went silent. standDowns counts those over the session,
which is how a session that lost the signal and got it back
(stalled = false with standDowns above zero) reads apart from one that
never lost it.
producing is whether the renderer drew the last frame. A headless
renderer draws into an offscreen framebuffer that nothing presents, so its
image reaches a reader only through something that copies it out: it draws
while a consumer is asking — an MCP call in flight, a queued texture
readback, a recording, a frame-egress session — and declines the frames
between two asks. A renderer presenting to a display draws while what is on
screen changes, and for a short settling run after the last change, and
declines the frames of a still picture, which stays on screen; whatever
else moves (the gameplay clock, a task owed the next frame, held input, a
tool call) keeps running at the display's rate meanwhile, and an engine
with nothing moving waits instead (engineStill, below). Both count the
frames they declined in idleSkippedFrames. Every other
renderer stat answers with the last frame that drew, so producing is what
separates a live reading from a frozen one.
drawPolicy names the rule the last frame was decided under: consumers
(headless), changes (presenting to a display) or every_frame (content
asked for every frame with renderer.setDrawEveryFrame(true), also read as
drawEveryFrame). pictureChanges counts, per source, the frames on which
something changed what the next frame draws: ui (a new UI layout or UI
texture), camera (the viewport camera, the viewport, a frame setting or
a renderer setting a script states: the projection offset, the shadow
configuration, the render path),
scene (a renderable added, removed, moved, shown or re-described),
material (a material created, removed or given new properties,
textures or a new shader), lighting (a light, the ambient term or the
sky), surface (its size, format or present mode),
arrivals (a pipeline,
texture or material row still landing), world (a component written, an
entity spawned or removed), clock (something drawn with a shader that
reads the frame clock, while the clock runs), compute (a compute buffer written or dispatched
over), window (the platform asked for the window to be drawn again),
texture (a texture's contents replaced from the CPU, a video frame among
them) and content (a script's command reached the engine: a
post-process effect, a sky, an environment, a render feature). Every
renderer counts them, a headless one included.
lastPictureChange names the source of the latest, and
lastPictureChangeDetail what within it changed where the source names
it, and pictureChangeDetails holds, per source, what its latest named
change named: the component a world change wrote, the command a
content change applied, the program a clock change draws with. Read
them on a renderer that keeps drawing a picture that looks still to find
what is moving.
presentMode is what the surface presents with and presentModes what it
offers; both are empty of meaning on a headless renderer, which never
presents. A desktop presents mailbox unless told otherwise, and Android
presents fifo, which shows each frame on a vsync of the panel and makes
no frame the panel never shows.
The rest describe the rate frames run at. displayRefreshHz is the
refresh rate of the display the frames are shown on, where the platform
reads it: the phone's panel, the monitor a desktop window is on, the
cadence of a browser's animation frames. A headless engine presents to no
display and states none. frameRateCap is the cap
renderer.setFrameRateCap set, absent while none is. frameRateMode is
how the rate is chosen (renderer.setFrameRateMode), chosenFps the rate
the frame loop chose and frameRateReason why: cap (the highest rate
the cap delivers), display (the display's highest rate, with no cap),
frame_time (a lower even rate, because frames did not hold the faster
one) or uncapped (no target: a surface that shows frames on any
refresh, or no display, with no cap). targetFps is the rate the chosen
one delivers on the mode the display runs in now and refreshesPerFrame
the refreshes each frame stays on screen there; these and chosenFps are
absent while no target is in force. frameWorkMs is the 90th percentile
of the time recent drawn frames took, the time the rate is chosen from.
lateFrames counts the drawn frames the loop came back to later than the
vsync each was due for, missedPresents those the compositor showed
later than one interval after the frame before them (a judder; 0 where
the surface reports no present times), and
rateStepsDown / rateRaises the times the chosen rate went down and up,
all since the rates to choose from last changed (a new cap, mode or
display). Each change is also one [frame rate] line in the engine log
naming what decided it.
displayVote names the platform call that tells the display the rate
(none where there is none, and frames are held to the display by
pacing alone) and displayVoteFps the display mode it last asked for.
deliveredFps is the rate the frame loop has run frames at over about
the last twenty frames.
The last describe whether the engine runs frames at all. An engine with
nothing to draw, its gameplay clock stopped, no deferred task or settled
promise to resume, no commands waiting to be applied, no tool call in
flight, no streamed sound playing and no input held is still, and its
loop runs a frame at once when something reaches the engine, else when
the earliest wait a task holds comes due, with frames at least a quarter
of a second and at most a second apart. engineStill is whether the
engine stated itself still at the end of its last frame (a reading taken
inside a tool call reads false, since the call is in flight) and
movingBecause names what kept it moving otherwise: picture,
gameplay, boot, tasks, input, recording, calls, audio or
replay (a physics replay plays).
stillWaits counts the frames the loop held back for a still engine,
framesAfterStill the frames run after such a wait, wokenFrames those
of them an arrival started, and stillSeconds the seconds spent waiting;
stillFrames counts the frames after which the engine stated itself
still and movingFrames those after which it stated itself moving, per
reason, so the reason a still scene keeps running frames is the count
that grows between two readings.
local p = renderer.framePacing()
print(("%d of %d frames in flight, paced by %s"):format(p.framesInFlight, p.maxFramesInFlight, p.mechanism))
modules/renderer/getRaytrace
getRaytrace(): boolean
Whether ray tracing is currently enabled.
modules/renderer/gpuMemory
gpuMemory(): GpuMemory
Where the renderer's GPU memory went at the last completed frame — the call to reach for when something is holding memory and you do not know what.
Three figures answer three different questions, and they are meant to be read against each other:
- The categories —
shadow,textures,meshes,instances,compute, summing tocategorised— are the renderer's own accounting of what it asked for on purpose. Always present, on every backend.texturesis what the resident textures occupy, and on the texture-array backend also the slack its shared arrays hold beyond them (renderer.materialTable().bucketSlackBytes). allocatoris the device allocator's ledger, with a row per creation label largest first, which is what names an allocation no category claims. A render target's colour texture is reported under what holds it now: the target drawing into it, orreleased_scratch[<width>x<height>].colorwhile it waits for the next target of its size. It exceedscategorisedby the per-frame render targets and the scratch nothing categorises, and on the texture-array backend, for the frame after an array grows or is repacked, by the array it replaced. The allocator hands memory out from blocks it reserves whole from the device and returns a block only once nothing is left in it, soreservedBytesruns aboveallocatedBytesby what those blocks hold unused;blockslists them emptiest first with the labels that keep each one alive, andemptyBytesplusslackBytesis that distance exactly — the pool held in empty blocks, and the room pinned inside blocks something still sits in.driver.deviceLocalBytesis what the graphics driver charges this process, out of the kernel's own accounting. It is the biggest of the three and the one that fills a card, because it also holds the swapchain, the images the driver keeps on the renderer's behalf, and the rounding to whole pages and heap blocks that neither figure above sees. Read it when the question is how much of the machine's GPU this engine is using; read the two above when the question is what the engine spent it on. A platform with no per-process accounting reportsavailable = falseand the reason.driver.outsideAllocatorBytesis that charge less everything the allocator reserved — what the driver holds on its own account, and the one figure here nothing releases: a dropped pipeline, another scene andrenderer.collect()all leave it where it is, and it falls when the device is destroyed. Read it when a session's device memory has grown and no ledger row accounts for the growth.
compute is what the compute subsystem holds; compute.observe() names
each of those resources and what it costs. arenas states the part of it
the pages runs stand in hold, and what those pages' bytes are spent on. renderTargets counts the
offscreen render targets the renderer holds at that frame, which is what
says a renderer.destroy has been applied rather than queued.
textureBudgetBytes is the texture budget in force and pressure the
memory pressure level that shapes it: under "critical" the budget reads
half the device's, and renderer.memoryPressure() says what the newest
report released.
local m = renderer.gpuMemory()
print(("shadows %.1f MiB"):format(m.shadow.total / 1024 / 1024))
-- how much of the card this engine is holding:
if m.driver.available then
print(("driver %.1f MiB"):format(m.driver.deviceLocalBytes / 1024 / 1024))
else
print("no driver figure: " .. m.driver.reason)
end
-- the biggest allocation in the engine:
local top = m.allocator and m.allocator.byLabel[1]
print(top and top.label, top and top.bytes)
-- the block held for the least, and what pins it:
local block = m.allocator and m.allocator.blocks[1]
if block and block.allocationCount > 0 then
print(block.size, block.allocatedBytes, block.byLabel[1].label)
end
modules/renderer/hold
hold(handleOrKind: any, id: string?): boolean
Pin a runtime resource for the session. A held texture, material, mesh
or render feature survives every collection — the one a root scene load
runs and a direct renderer.collect() alike — until renderer.release
lets it go or its destroy frees it. It is the way to keep an ad-hoc
resource across the scenes that come and go under it. A hold keeps the
resource in the registry; a mesh's GPU buffers are governed by what draws
it, parked as a CPU definition when the last instance naming it goes and
brought back when one names it again, so renderer.mesh.isResident(guid)
is the separate question about the buffers.
Parameters
handleOrKindany(optional) — The resource's handle, or its kind ("texture","material","mesh","feature") with the guid or key as the second argument.idstring?(optional) — The guid or key, when the first argument is a kind.
renderer.hold(tex)
renderer.hold("material", "swatch")
modules/renderer/instanceData.clear
instanceData.clear(target: string | entityRef)
Drop every lane of an entity's per-instance shader data, so its draws read zero again — how a feature releases a subject it is still holding. Despawning an entity releases its block too, so this is for a subject that stays. It takes an entity that has already gone, which is when a feature releasing its subjects often runs, and does nothing for an entity holding no block.
Parameters
targetstring | entityRef— The entity — a proxy fromentity(...)/entity.spawn(...), or an entity-id string.
renderer.instanceData.clear(subject)
modules/renderer/instanceData.laneCount
instanceData.laneCount(): number
How many vec4 lanes each entity's per-instance block holds, so a lane
index runs 0 .. laneCount() - 1. The same count a surface shader indexes
input.shader_data against.
for lane = 0, renderer.instanceData.laneCount() - 1 do
renderer.instanceData.set(subject, lane, 0)
end
modules/renderer/instanceData.set
instanceData.set(
Write one vec4 lane of an entity's per-instance shader data — the
channel that lets ONE material serve many entities that differ in a value.
A surface shader reads the lane back as input.shader_data[lane], so a
dissolve at its own progress per subject, an effect at its own age per
firing, or a per-entity mask costs one material rather than one material
per entity.
The engine attaches no meaning to a lane: a feature picks the lane indices it owns and packs whatever its shader agrees they carry. Name those indices in the module that writes them, so the writer and the shader read the block the same way.
A per-instance colour needs no shader of its own: the built-in
@builtin::materials.instance_color (lit) and instance_color_unlit read
lane 2 as (r, g, b, coverage), and instance_color_lane names the lane
on any @builtin::shaders.pbr or unlit material, so a stress colour, a
heat map or a damage flash recoloured every frame is one set per entity.
The write reaches the block where it is called, so the entity it names is the one holding that id at that point in the tick, and the value is on the draw from the next frame. It is held until the lane is written again, the entity's block is cleared, or the entity is despawned — a despawned entity releases its whole block. A lane an entity was never given reads zero.
-- One dissolve material, each subject at its own progress.
local DISSOLVE_LANE = 0
for _, subject in ipairs(dying) do
renderer.instanceData.set(subject.entity, DISSOLVE_LANE, subject.progress)
end
modules/renderer/lighting
lighting(): boolean
Whether the scene renders lit.
modules/renderer/loseDevice
loseDevice()
Destroy the render device on the next frame, so the engine meets a real device loss.
This is the one loss that can be caused on purpose, and it travels the same
path a driver reset does: frames draw nothing until the rebuild lands,
GET /engine/status reports the renderer as recovering while it does,
engine.onDeviceRebuilt fires afterwards, and renderer.deviceGeneration()
moves. Use it to prove that a world's content survives a device loss —
anything it holds only on the GPU has to be remade from the rebuild hook, and
this is how you find out whether it is.
renderer.loseDevice()
-- some frames later:
print(renderer.deviceGeneration()) -- one higher than before
modules/renderer/mainCameraView
mainCameraView(): { number }?
The main camera's inverse view-projection (column-major, 16 numbers)
followed by its world position (3 numbers) — {m0..m15, px,py,pz} — for
reconstructing world positions from the depth buffer in a ray-tracing pass.
Nil before the first render.
modules/renderer/markBaseline
markBaseline(): number
Record which render features are live and how the feature-texture array
is configured, and make that the point renderer.resetToBaseline returns
to.
A caller running work in an engine it shares — a sweep of test suites, a tool driving a session — leaves the renderer holding whatever that work set up: a feature a module created on first use, an array reconfigured to the size one pass wanted. This is how such a caller says where its own changes start. mark above the marks before it.
local mark = renderer.markBaseline() -- then run, then renderer.resetToBaseline(mark)
modules/renderer/material.animatedTexture
material.animatedTexture(
Build a material that PLAYS a layered texture: its layers bound as the
frames, its timing bound beside them, and the engine's animatedTexture
shader turning the clock into the layer showing now. One call from an
imported animated image to a material an entity can wear.
The layer showing is resolved per pixel against the texture's own schedule,
so frames of unequal length are shown for the lengths they were authored
with, and the sequence loops. speed scales the clock (2 plays twice as
fast, 0 holds the frame startTime lands in) and startTime offsets into
the sequence, so two surfaces sharing one texture can run out of phase.
The clock is the engine's, and it runs in edit mode as much as in play and
through a pause, so two screenshots of one surface taken moments apart are
two different frames of it. speed = 0 holds one frame for as long as it
is set, which is the state to compare two screenshots in.
The returned handle is what a surface wears — Model:applySessionMaterial
takes it, and so does a Model's material field. The handle's guid is
this material's REGISTRY KEY, the currency of setProperty, describe and
destroy; a component field resolves an asset, so a bare key in one leaves
the component waiting for an asset to register under that name.
The builtin plane mesh emits uv = (u, v) with v along its own +Z, so
a quad pitched +90° about X (Transform.eulerToQuat(0, math.pi / 2)) shows
the image upright to a camera on +Z, and -90° shows it first-row-last.
A texture whose layers carry no timing is rejected — there is nothing to
play. renderer.texture.info(bytes).animated is the test.
local mat = renderer.material.animatedTexture("banner.texture")
local id = entity.spawn("billboard", { rotation = { Transform.eulerToQuat(0, math.pi / 2) } })
entity(id).component.add("Model", { model = "plane" })
entity(id).component.get("Model"):applySessionMaterial(mat)
renderer.material.setProperty(mat.guid, "speed", 2)
modules/renderer/material.create
material.create(content: MaterialContent, key: string): MaterialHandle
Parameters
contentMaterialContentkeystring
modules/renderer/material.describe
material.describe(key: string | { [string]: any } | AssetRef): any
The recoverable definition ({ shader, properties, textures, name, render, features, bindings })
this module registered under key via renderer.material.create, or nil
for keys registered elsewhere (e.g. material assets resolved by the
assetType). properties and textures carry the material's current values:
each setProperty / setTexture write lands on this record, a texture slot
under the GPU key the slot binds by — these are the WRITES, held here
whether or not the renderer took them up. renderer beside them is what the
renderer holds for the same key: the program its prepared bind group was
built against, the texture each slot of its row names (renderer.textures,
the writes the renderer took up), the render state its draws are looked up
under, whether a pipeline exists for that key, and the draws, instances
and binds the last published frame counted for it. A frame counts those
only while something observes the renderer (renderer.materialCost(),
renderer.observe() and renderer.drawDiagnostics() each keep it
observing for the next 120 drawn frames, and describe does not), so
renderer.observed states whether they were counted: true with the
counts, false with draws, instances, placeholderDraws, binds and
bindsElided all nil. renderer is nil when the renderer holds no
material under this key at all, and resident states the same fact as a
boolean. Writes reach the screen through both halves: resident = false
says the renderer holds nothing to put them in, and renderer.draws = 0
on a resident material says it holds them and no renderable is drawing
with it. For a material that is resident AND drawn and still looks wrong,
renderer.drawDiagnostics() names the renderable and the cause. A
material that is not resident carries shaderStatus and reason, where
its shader stands: "absent" when the shader it names resolves to no
shader asset (nothing will compile it, so it stays unprepared until one
arrives), "pending" while that shader has not compiled, "failed" with
the compiler's message, or "compiled" when the shader is ready and the
material has not been prepared yet. A resident material carries neither.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.
modules/renderer/material.destroy
material.destroy(key: string | { [string]: any } | AssetRef): boolean
Drop a runtime material registered via renderer.material.create: clears
its recoverable definition, unregisters its runtime-resource stamp so it is no
longer swept into the material freeze/save flow, and frees the GPU record. Use
for transient materials (e.g. a preview swatch) that must not outlive their use.
The on-disk asset, if any, is untouched.
The reach is the registry: after this, describe and list stop answering
for the key. A surface already wearing the handle goes on drawing what it
was given — Model:restoreSessionMaterial is what puts a Model back on its
authored material.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key (the one passed tocreate), theMaterialHandlecreatereturned, or anAssetReffromasset.resolve.
renderer.material.destroy("__preview_swatch_" .. texGuid)
modules/renderer/material.list
material.list(): { any }
Every runtime material currently registered, ordered by registry key.
Each entry carries the key, where it came from, the shader it binds, and
for a key a .material asset filed (guid@checksum) the asset it is.
renderer.references("material", key) says what is still holding a row,
and renderer.collect() releases the rows nothing holds.
for _, m in ipairs(renderer.material.list()) do print(m.asset or m.guid, m.shader) end
modules/renderer/material.renderState
material.renderState(key: string | { [string]: any } | AssetRef): MaterialObservation?
What the renderer holds for a material, which is a different document
from the values written to it. index is the material index its row in
the material table is filed under, which an edit rewrites in place, and
textures the texture each slot of that row names, by slot name, under the
key the texture is resident as; a slot drawing its shader's declared
default is absent, so a setTexture the renderer has taken up reads here
as the key it bound. shader is the program its prepared bind
group was built against, renderState the blend / cull / topology / queue /
depth key its draws are looked up under, keyBuilt whether a pipeline
exists for that key, and draws / instances / placeholderDraws /
binds / bindsElided what it cost in the frame the renderer last
published. A frame counts those only while something observes the
renderer, which renderer.materialCost() and renderer.drawDiagnostics()
start, so observed states whether they were counted: true with the
five counts, false with all five nil. nil means the renderer holds no material
under this key at all — the writes landed on a record nothing is drawing
with.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.
local r = renderer.material.renderState("water"); print(r.renderState.blend, r.keyBuilt)
modules/renderer/material.sessionKeyFor
material.sessionKeyFor(entityId: string): string
The canonical registry key for an entity's SESSION material — the
runtime material a system (e.g. GI baking) shows on an entity in place
of its authored material for the lifetime of the engine session. One
session material per entity: create it under this key, hand the handle
to Model:applySessionMaterial, and the component re-adopts it across
VM reloads by probing this key with describe. The key names the entity
for as long as the entity stands: once it is gone the session store lets
the handle go, and a collection releases the material and whatever its
bindings were the last to hold.
Parameters
entityIdstring— The entity carrying the material.
local key = renderer.material.sessionKeyFor(entityId)
modules/renderer/material.setClock
material.setClock(key: string | { [string]: any } | AssetRef, seconds: number?, rate: number?): ()
Drive a material's surfaces from a clock of its own: the time its
shader's vertex(), vertex_clip() and fragment() read. The clock reads
seconds now and runs on by itself, rate of its seconds for every second
of the world's gameplay time, so it is stated again only when that changes —
a pause is a rate of 0, a seek is a new seconds, slow motion is a rate
below 1. Every surface drawing the material follows it, motion vectors
included. seconds = nil hands the material back to the world's time. A
procedural graph's Generator drives the materials it realizes from its
playhead this way, so an effect's shaders pause, slow and scrub with it.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.secondsnumber?(optional) — The time the material's surfaces read now, or nil to release it.ratenumber?(optional) — Seconds of the clock per second of gameplay time (default 1).
renderer.material.setClock(asset.resolve("frost_ice", "material"), 12.5, 0)
modules/renderer/material.setProperty
material.setProperty(key: string | { [string]: any } | AssetRef, name: string, value: any): ()
Push one changed uniform property to a registered material's GPU record
(frame-fast incremental update; no re-register). Keyed by the material's
registry key. The value written becomes the material's current one: it is
what describe reports, and — for a property the material's shader
declares, which is what the uniform buffer is packed by — what a material
AssetRef reads back through getProperty / getProperties and what the
surface is drawn with. A write under any other name reaches the record
describe reports, which is where it reads back.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.namestring— Property name.valueany(optional) — New value.
renderer.material.setProperty(asset.resolve("wall", "material"), "roughness", 0.2)
modules/renderer/material.setTexture
material.setTexture(key: string | { [string]: any } | AssetRef, slot: string, ref: string | { [string]: any } | AssetRef): boolean
Push one changed texture slot to a registered material's GPU record. Keyed by the material's registry key. The slot is one the material's shader declares as a texture: a slot it does not declare is refused with a warning naming the texture slots it does declare, and the material is left as it was. While the shader's vocabulary has not been read (a custom shader that has not loaded) every slot is taken.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.slotstring— Texture slot name ("base_color_texture", …).refstring | { [string]: any } | AssetRef— Texture reference — a.textureguid / identity / name / path, the image path it was imported from, acolor:/default:form, a live GPU handle, or a textureAssetRefcarrying one. An asset reference is materialised (Disk→CPU→GPU) and bound by the key the upload lands under.
renderer.material.setTexture("sky", "sky_texture", "panorama.texture")
modules/renderer/material.vocabulary
material.vocabulary(key: string | { [string]: any } | AssetRef): MaterialVocabulary?
A material's property names under props and its shader-declared and
assigned texture slots under textureSlots, each a { [name] = true } set —
with byRole beside them, the index a key spelled in another engine's
convention resolves to a declared name through. This is what a write's key
is routed against on the record, in the shape MaterialSchema.route takes.
It is read off the definition this module holds and touches nothing the
renderer holds, so a call costs a table lookup and belongs on a per-frame
write path; describe is the read that carries the renderer's own state.
One frozen table per record, shared by every key that reaches it, rebuilt
on the first read after a write puts a new name on the record.
Parameters
keystring | { [string]: any } | AssetRef— The material's registry key, theMaterialHandlefromrenderer.material.create, or anAssetReffromasset.resolve.
local MaterialSchema = require("@builtin::modules.material_schema")
local route, name = MaterialSchema.route(assert(renderer.material.vocabulary(handle)), "color", { 1, 0, 0, 1 })
modules/renderer/materialCost
materialCost(): { MaterialObservation }
What each material cost the frame the renderer last drew, and the state
it holds each one under. One row per material the renderer holds a prepared
bind group for — a material an author wrote and the renderer never prepared
is absent, which is itself the answer to "why is nothing I set reaching the
screen". draws and instances cover that one frame; placeholderDraws
is how many of those draws bound the magenta placeholder instead of this
material's own program. Those three count what this material drew itself:
a batch drawing several materials of one group adds to each material the
draws and instances that wore it.
group is the material group the material draws in — the unit a pass
binds a material's textures (group 1) and its shader's storage buffers
(group 2) by — or nil while the material resolves no group, which leaves
its draws nothing to bind. binds is how many group-1 and group-2 binds
the frame's passes issued for draws of this material's shader in that
group, and bindsElided how many times such a draw found the group already
bound, which is what draw-key sorting buys. Those binds belong to the
group, so every material of one group reports the same pair; a material
with no group reports 0 for both, and a draw that fell back to the
placeholder counts in placeholderDraws and in neither bind count.
uniformBytes is the size of the property block in the material's row of
the material table: the shader's declared properties, packed at the offsets
the shader reads them from and padded to a whole 16 bytes. The row also
carries a 64-byte header and a 4-byte handle per texture slot, padded to a
whole 16 bytes. renderer.materialTable().rowBytes is the space the table
reserves for all rows — its row capacity, free rows included — plus its
directories. renderer.drawDiagnostics() names WHICH
renderable is not drawing what its material says, and why.
material is the key the renderer holds the material under; asset
names the .material asset a guid@checksum key is a version of.
for _, m in renderer.materialCost() do print(m.asset or m.material, m.draws, m.binds, m.bindsElided) end
modules/renderer/materialIdentity
materialIdentity(): MaterialIdentity
Which material each renderable draws with, as a number a shader can
carry. A material is authored and bound by name, and no shader can read a
string — so every renderable's per-instance record holds a material index
instead. slots is the name → index table those indices are drawn from: an
index is assigned the first time the renderer draws with that material and
does not move while the renderer holds the material, so two renderables that
differ only in material read different indices, and one renderable reads the
same index frame after frame. A destroyed material's name leaves the table
once nothing draws with it, and the next material takes its index, so the
table holds a row per name the renderer holds a material under or
something draws with. renderables is
a row per renderable that owns a GPU slot — the entity it belongs to, that
slot, and the index the record at it carries; populations is the same for
an instanced draw, whose whole reserved run of slots carries the one
material its registration named. That index is what a shader reads as
zero_instance(slot).material_index, and the row a ray hit resolves
through zeroMaterial(). A renderable draws with the material its entity
references, so one whose entity names none carries index 0.
local id = renderer.materialIdentity()
for _, r in id.renderables do print(r.entity, r.slot, r.index, r.material) end
modules/renderer/materialIndex
materialIndex(name: string): number?
The index standing for a material, or nil for a name the renderer
holds no index for: one it has not drawn with yet, or a destroyed material
nothing draws with any more. Pass it to a shader (or compare it against what a shader
read out of zero_instance(slot).material_index) to tell which material a
drawing instance carries.
Parameters
namestring—stringMaterial name, asrenderer.material.createfiled it.
local red = renderer.materialIndex("brick_red")
modules/renderer/materialTable
materialTable(): MaterialTable
How this device resolves material textures, and what that storage
costs. backend is "bindless" (a descriptor array indexed by each
material's texture handles) or "buckets" (exact-size texture arrays, one
per size, format and mip count, bound per material group). Bindless is
taken on a Vulkan adapter that has texture binding arrays with non-uniform
indexing and partially bound arrays, and room for descriptor arrays of at
least 4096 textures; every other device — the browser build, Android,
Metal, DirectX 12, and Vulkan without those — takes buckets.
materials is how many materials have a row, rowBytes the space the
table reserves in the scene buffer (its row capacity, free rows included,
plus the material and texture directories), textures how many distinct
textures the rows name, descriptorCapacity the length of each bindless
array (0 on buckets), and groups how many material groups the materials
form. A group is the unit a pass binds a material's textures (group 1) and
a shader's own storage buffers (group 2) by, and every material of a group
draws under the same binds. On bindless every group binds the one texture
group of the frame, so groups differ only by the set of storage buffers
they bind. On buckets a group also names, per texture slot, the bucket its
members' textures live in and the sampler those textures sample through:
materials of one shader split into one group per distinct combination of
(bucket and sampler per texture slot, storage buffers), and each group is
its own draw.
buckets lists every texture array: its format, size, mip count, the
layers textures occupy, its capacity, what it costs, the slack it holds
beyond its live layers, whether it is frozen (a layer's view is held by
something outside the material system — a UI image, a post-process input
— or a copy out of a layer is taken this frame, such as a readback, so the
array neither grows nor compacts), which shard of its
key it is, and whether it is external (a one-layer bucket over a texture
the GPU writes — a render target, a video frame, a compute output — which
its producer owns). bucketBytes is what the shared buckets occupy
together, and bucketSlackBytes the slack they hold together, which
renderer.setTextureBucketSlack bounds; an external bucket counts in
neither. slackBudgetBytes is the budget the buckets bound growth by. On
bindless buckets is empty, both totals are 0, and slackBudgetBytes is
the budget recorded, which bounds nothing.
local t = renderer.materialTable(); print(t.backend, t.groups, "groups over", t.materials, "materials")
for _, b in renderer.materialTable().buckets do print(b.format, b.width, b.height, b.layers, "/", b.capacity) end
modules/renderer/maxAnisotropy
maxAnisotropy(): number
The highest anisotropy this device honours: 16 on hardware that filters
anisotropically, 1 on hardware that does not, where a higher request would
be downgraded to trilinear regardless. Read it to report quality honestly —
renderer.setAnisotropy clamps for you, so a request never needs guarding.
local best = renderer.maxAnisotropy()
modules/renderer/maxViewportExtent
maxViewportExtent(): number
The largest number of pixels this device draws a surface at, per axis
— the bound renderer.setViewportSize refuses past. 0 before the first
frame has drawn.
local bound = renderer.maxViewportExtent()
modules/renderer/memoryPressure
memoryPressure(): MemoryPressureReport
What memory pressure is doing to the engine. level is the level in
force: "normal", "moderate", "low" or "critical". A report puts
its level in force, whatever stood before, for holdSeconds after the
last report, and then the level returns to normal. Reports come from the
system (on Android, onTrimMemory: RUNNING_MODERATE is moderate,
RUNNING_LOW and UI_HIDDEN low, RUNNING_CRITICAL, BACKGROUND, MODERATE and
COMPLETE critical; Android 14 and later report only UI_HIDDEN, when the
app leaves the screen, and BACKGROUND) and from
renderer.signalMemoryPressure. signals
counts the reports taken; lastLevel, lastSource and lastAgeSeconds
describe the newest (absent before the first).
Each report releases at once what its level releases, and released says
what the newest one freed: the textures taken to the level the frame
samples and the textureBytes they gave up, and the render targets
whose storage was freed. Moderate frees the mip levels the frame does not
sample; low also frees render-target storage the last frame did not draw
into; critical also halves the texture budget. While a level stands the
residency plan keeps the textures there, and textureBudgetBytes is the
budget the level leaves in force. engine.onMemoryPressure(cb) fires with
each report once its release is done.
local mp = renderer.memoryPressure()
print(mp.level, mp.released.textureBytes / 1048576, "MiB freed")
modules/renderer/mesh.bounds
mesh.bounds(mesh: string | { [string]: any } | AssetRef): Aabb?
The mesh's extent in its own space: the box its vertices span, or the
one its author stated (aabbMin / aabbMax) for a mesh whose vertices live
only on the GPU. It is what the mesh is culled against and what framing
reads; place it in the world through whatever draws the mesh — an entity's
transform, or instanceBounds for an instanced population.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
local box = renderer.mesh.bounds(mesh)
modules/renderer/mesh.boundsSource
mesh.boundsSource(mesh: string | { [string]: any } | AssetRef): string
Where this mesh's culling bounds come from. "compute" once a compute
pass has written its vertices: the engine reduces those vertices to an AABB
every frame, so the mesh is culled against the geometry the pass produced
wherever it puts it. "geometry" otherwise: the AABB of the geometry the
mesh was created with.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
print(renderer.mesh.boundsSource(mesh))
modules/renderer/mesh.buildClusters
mesh.buildClusters(mesh: string | { [string]: any } | AssetRef): string?
Build a cluster-LOD DAG (Nanite-style virtualized geometry) for the
static CPU mesh held under guid and return its serialized data.clusters
bytes. Returns nil when the mesh is degenerate, and on an engine whose
renderer.mesh.canBuildClusters reports false. Pair with
renderer.mesh.uploadClusters.
Parameters
meshstring | { [string]: any } | AssetRef— A mesh loaded into the CPU store (renderer.mesh.loadCpu) — theMeshCpuHandle, aMeshHandle, a guid, or a meshAssetRef.
local cb = renderer.mesh.buildClusters(cpu)
modules/renderer/mesh.canBuildClusters
mesh.canBuildClusters(): boolean
Whether this engine bakes cluster-LOD hierarchies. It reads the binding
the running engine registered: every target the engine ships on carries the
builder, so a mesh loaded in a browser bakes its own clusters the same way
one loaded natively does, and an engine built without it reports false and
answers nil from renderer.mesh.buildClusters.
if renderer.mesh.canBuildClusters() then ... end
modules/renderer/mesh.clusterBakeBudget
mesh.clusterBakeBudget(ms: number?): number
The wall time one frame may spend advancing scheduled cluster bakes, in
milliseconds — set first when ms is given. A slice always runs at least
one unit of the build, so the budget bounds what a frame spends by choice
and the largest single unit a mesh imposes sets the floor under it.
Parameters
msnumber?(optional) — New per-frame budget in milliseconds, capped at 1000. A value that is not a positive, finite number raises.
renderer.mesh.clusterBakeBudget(2)
modules/renderer/mesh.clusterBakes
mesh.clusterBakes(): { [string]: any }
What the scheduled cluster bakes are costing. budgetMs is the slice a
frame may spend, pending how many bakes are queued, completed how many
have finished since the engine started, dropped how many left the queue
because the geometry they were scheduled over stopped being readable or
cannot be drawn as clusters, and
heldBytes the source geometry the queue is holding across all of them —
the vertex pool and index run the bake at the head is reading.
inFlight is one row per queued bake —
{ guid, cpuMs, frames, slices, bytes, state, levels }: the wall time
spent advancing it, the frames it has been queued for, the slices it has
been advanced by, the geometry it is holding, "baking" for the one being
advanced against "queued" for the ones waiting their turn, and levels
the depth the bake builds, "dag" or "single".
print(renderer.mesh.clusterBakes().heldBytes)
modules/renderer/mesh.clusterComponents
mesh.clusterComponents(clusterBytes: buffer | string): (ClusterComponents?, string?)
Split a cluster blob (from renderer.mesh.buildClusters) into its
GPU-ready component byte pools — the cluster vertex pool, the
geometry-addressing pool (every cluster's local→global vertex map, then
every cluster's triangle bytes), and the per-cluster record array — plus
their counts. A cluster's triangles address positions inside its own vertex
map one byte at a time, and a record's vertexOffset indexes the geometry
pool in u32 elements while its indexOffset indexes it in bytes, so ONE
binding resolves a corner. A pure decode (no GPU work): upload the pools
into buffers a compute shader owns (shaderRef:createBuffer +
buf:writeBytes) to drive a cluster draw from Luau.
Parameters
clusterBytesbuffer | string— Serialized cluster bytes (binary-safe).
local c = renderer.mesh.clusterComponents(cb)
modules/renderer/mesh.clusterStore
mesh.clusterStore(): {
What the geometry heap holds for cluster drawing. heapCapacity and
heapLive are the heap's size and the bytes in use. The heap grows to
place what does not fit, and gives memory back as meshes leave it: once
what it holds has packed into a quarter of its size for 60 frames in a
row, it shrinks to double that, never below the size it started at. A
mesh destroyed and created again inside those frames finds the heap at
the size it left it. vertexBytes and
lightmapBytes are the vertex pools and lightmap-UV runs of the meshes
drawn through clusters. bakedBytes is the cluster sets of meshes drawing a
baked set; unbakedBytes is the sets of meshes still drawing lod0 plus
those meshes' vertex pools — geometry drawn at full detail while its bake is
outstanding. meshes counts meshes drawing any set, unbakedMeshes those
on lod0. scriptSetBytes is CPU memory beside the heap: the sets
scripts installed with renderer.mesh.uploadClusters, held so each mesh
draws its set again after it returns to the device.
local s = renderer.mesh.clusterStore(); print(s.unbakedBytes / 1048576, "MiB drawn at full detail while bakes are outstanding")
modules/renderer/mesh.clusters
mesh.clusters(mesh: string | { [string]: any } | AssetRef): { [string]: any }?
The cluster set a mesh draws. Every static mesh the geometry heap holds
draws through clusters: kind is "lod0" while it draws the full-detail
set built from its geometry as it uploaded, "single" for one baked level
(clusterLod = false), and "dag" for the baked LOD hierarchy.
clusterCount, levelCount and triangleCount describe that set, nodes
how many node transforms its clusters lie in, and bytes its size in the
heap. A mesh that is not drawn through clusters reads resident = false
with reason: "heapFull" (the heap cannot grow to hold it),
"spansNodes" (a triangle joins two independently moving parts) or
"deformable" (a pass deforms its vertices). Nil for a mesh the renderer
holds no GPU geometry for.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh to read — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
local c = renderer.mesh.clusters(gpu) ; if c and c.kind == "lod0" then print("still baking") end
modules/renderer/mesh.create
mesh.create(src: any, guid: string?): MeshHandle
Create (or fetch) a GPU mesh resource and return its MeshHandle. src:
a MeshCpuHandle from meshRef:load() (CPU→GPU upload under the asset's
guid, idempotent — returns the resident handle if already uploaded); raw
geometry {positions, indices, normals?, uvs?, colors?, uvs1?, unwrapUvs?, tangents?, skinning?, skins?} (a new runtime mesh — uvs1 is the lightmap
UV set, unwrapUvs generates one, skinning/skins bind a skeleton); GPU
compute buffers {vertexBuffer, indexBuffer, vertexCount, indexCount, aabbMin?, aabbMax?, prevVertexBuffer?} (size the vertex buffer at
vertexCount * engine.vertexStride bytes, the engine's standard Vertex
layout); or a MeshHandle (returned as-is). NEVER takes an AssetRef —
load the CPU first.
prevVertexBuffer is a second buffer of the same size and layout holding
those vertices as they stood on the previous frame. Naming it is what makes
geometry a compute pass moves report a motion vector: the surface
differences the two streams, so every consumer of screen-space velocity —
motion blur, temporal reprojection — sees the movement. The engine fills it
from the current vertices once per frame, ahead of that frame's compute
dispatches, so a frame in which the pass does not run leaves the two
streams equal and the geometry reports standing still.
morphTargets are the shapes the mesh can blend towards: a list of
{ name?, positions, normals? } records, each holding one offset per vertex
from the base geometry, in the mesh's own vertex order. An entity blends
them with ecs.MorphWeights, weight i scaling target i. A name makes
the shape addressable as itself — renderer.mesh.morphTargets reads the
names back and renderer.mesh.morphWeights drives them by name.
Raw geometry is read against the mesh type's conventions: indices count
vertices from 0, and a triangle's FRONT face is the one whose vertices turn
counter-clockwise as the viewer sees them — cross(v1 - v0, v2 - v0) points
out of it. A material culls its back faces by default, so a triangle wound
the other way draws nothing where it stands; reverse the index triple, or
give the material render = { cull = "none" }, to draw that side. normals
give the surface its outward direction and shade the face; the side that
draws comes from the index order alone. uvs sample (0,0) at the image's
top-left. Model space carries the world's basis: +X right, +Y up, -Z the
direction transform.forward points. guides { path = "types/mesh" } has
the whole table.
A geometry src carrying keepCpu = true also keeps its geometry in the
guid-keyed CPU store, so renderer.mesh.getVertices reads it and
renderer.mesh.setVertices rewrites its positions in place — the per-frame
deformation path, which sends positions alone where renderer.mesh.update
re-sends the whole geometry. renderer.mesh.unloadCpu(mesh) releases that
copy. Without it the geometry lives on the GPU alone and
renderer.mesh.readback(mesh) is what brings it back.
A mesh this call builds lives while the returned handle, or another
handle over the same guid, is reachable from a script, or while something
else holds it (an entity or instanced draw displaying it, its owner, a
renderer.hold). Once nothing holds it and the garbage collector has
taken its last handle, the engine releases it mid-session: its definition,
its buffers and its renderer.mesh.list row go, and its guid names
nothing. A script that displays a mesh again later keeps its handle (or
holds it) for as long as it means to.
A handle a script keeps names its mesh for the rest of the session: a
module table or _SCRATCH holding it carries it across play/edit flips,
scene loads and hot reloads of the components that use it, and a Model
handed it after any of them draws the mesh. While nothing displays the
mesh, the engine holds it off the device (renderer.mesh.heldOffDevice)
and the next display puts it back. Only a destroy ends a mesh a handle
still reaches (renderer.destroy, renderer.mesh.destroy): every handle
a create returned over it then carries released, the verb that released
it, and a point of use (ecs.Mesh, a Model's model field) refuses
such a handle by name until a mesh stands under its guid again, which the
handle then names and holds.
Parameters
srcany(optional) — A MeshCpuHandle, geometry, compute buffers, or a MeshHandle.guidstring?(optional) — Optional v4 guid for a NEW runtime mesh (minted Luau-side when absent). Ignored for the CPU-handle path (the asset's guid is used).
local gpu = renderer.mesh.create(meshRef:load())
local gpu = renderer.mesh.create({ positions = {...}, indices = {...} })
-- a runtime mesh whose positions are rewritten in place each frame
local m = renderer.mesh.create({ positions = P, indices = I, keepCpu = true })
renderer.mesh.setVertices(m, P)
-- a runtime mesh carrying a lightmap UV set (unwrapped at creation)
local gpu = renderer.mesh.create({ positions = {...}, indices = {...}, unwrapUvs = true })
-- a mesh with one shape to blend towards, driven by ecs.MorphWeights
local gpu = renderer.mesh.create({ positions = P, indices = I, morphTargets = { { positions = D } } })
modules/renderer/mesh.decode
mesh.decode(zmsh: buffer | string): (MeshGeometry?, string?)
Decode engine-native ZMSH bytes back into a MeshGeometry. Inverse of
renderer.mesh.encode; each optional stream is present only when the blob
carries it. Takes the bytes themselves — the geometry of a mesh the engine
is holding comes from renderer.mesh.geometry(mesh).
Parameters
zmshbuffer | string— Engine-native ZMSH bytes (binary-safe).
local geom = renderer.mesh.decode(meshRef:getBytes())
modules/renderer/mesh.destroy
mesh.destroy(mesh: string | { [string]: any } | AssetRef): boolean
Release the GPU mesh mesh names, the release that pairs with
renderer.mesh.create. Takes every form that names a mesh — the
MeshHandle create returned, the guid renderer.mesh.list hands out, a
MeshCpuHandle or a mesh AssetRef — and routes through
renderer.destroy, the verb that releases any renderer resource by its
kind. The CPU copy, if one was loaded, is freed separately by the CPU
handle's :unload().
Parameters
meshstring | { [string]: any } | AssetRef— The mesh to release — aMeshHandle, a guid, aMeshCpuHandleor a meshAssetRef.
local m = renderer.mesh.create(cpu); renderer.mesh.destroy(m)
renderer.mesh.destroy(renderer.mesh.list()[1].guid)
modules/renderer/mesh.drawInstanced
mesh.drawInstanced(mesh: string | { [string]: any } | AssetRef, opts: any): InstancedDraw
Draw one mesh instanceCount times in a single call, each copy placed by
a world matrix read from a GPU buffer. The population is a renderable in its
own right — it goes through the mesh's ordinary pipeline and the material's
ordinary bind groups, so it appears in the deferred pass, the forward passes
and the shadow maps exactly as an entity-backed draw of that mesh does.
The buffer holds instanceCount column-major 4x4 matrices, 64 bytes
each, tightly packed — the layout a vertex shader reads as
array<mat4x4<f32>>, which puts each matrix's translation in its LAST four
floats (Lua indices 13/14/15 for x/y/z). Packing row-major transposes every
instance.
The matrices are COPIED into the engine's transform slots, which is what
buys that full-pass parity. Rewrite the buffer between frames and the
instances move, with no re-registration and no re-upload. The copy is
made on the frames that follow a write of the buffer (a :write, a compute
pass whose shader binds it read_write, and every frame a material whose
shader binds it read_write is live), so a population whose buffer
nothing writes costs no copy per frame however many instances it holds;
renderer.uploadStats() counts the copies a frame made.
material is what the population draws with, and it is required: a
MaterialHandle (matRef:handle()), an AssetRef, or a registry key.
instanceDataBuffer names a second buffer, holding 64 bytes per instance —
four vec4 lanes, tightly packed, in instance order. Those lanes arrive in
the fragment stage as zero_object_data(in.instance_id, lane), the same
read a per-entity __instancedata block answers, so the members of one
population can differ in whatever their material's shader agrees the lanes
carry. Copied like the transforms, on the frames that follow a write of
the buffer, from a buffer a compute pass writes: the values never touch the
CPU. Omit it and the lanes read zero.
@builtin::materials.instance_color (and instance_color_unlit) colour
each copy from lane 2 of its block, (r, g, b, coverage), given as its
AssetRef: material = asset.resolve("@builtin::materials.instance_color", "material").
reserveCount sizes the reservation above instanceCount so
renderer.mesh.setInstanceCount can raise the drawn count later without
re-registering; both buffers must back the reservation, not just the count.
mobility states whether the copies stand still — "static", or
"movable" when it is left out. It is what a scene gather collecting
geometry for precomputed lighting admits a population on, the same
declaration Model.mobility makes for an entity: the transforms live in a
buffer anything may rewrite between frames, so a population that says
nothing is taken as one that moves.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh the population draws — aMeshHandle, the guidrenderer.mesh.listhands out, aMeshCpuHandleor a meshAssetRef. A registration holds the mesh on the device for as long as it lives, and takes a mesh that is currently held off the device — one nothing displays — back onto it.optsany(optional) —{ transformBuffer, instanceCount, material, instanceDataBuffer?, reserveCount?, renderLayer?, castsShadows?, receivesShadows?, mobility?, parent? }.castsShadowsandreceivesShadows, both true when left out, state whether the copies cast shadows and whether shadows darken them.parentstands the copies in an entity's space, assetInstanceParentdoes.
local m = renderer.mesh.create({ positions = ..., indices = ... })
local buf = substrate.createBuffer({
name = "crowd.xf", type = "mat4", len = 64, kind = "gpu",
})
-- Column-major: translation lives at indices 13/14/15.
local xf = {}
for i = 0, 63 do
local m4 = { 1,0,0,0, 0,1,0,0, 0,0,1,0, i * 2, 0, 0, 1 }
for _, v in ipairs(m4) do xf[#xf + 1] = v end
end
buf:write(xf)
local rock = asset.resolve("rock", "material"):handle()
local draw = renderer.mesh.drawInstanced(m, { transformBuffer = "crowd.xf", instanceCount = 64, material = rock })
modules/renderer/mesh.dropClusters
mesh.dropClusters(mesh: string | { [string]: any } | AssetRef): boolean
Return a mesh to its lod0 set and cancel a bake still in flight for
it. The inverse of renderer.mesh.uploadClusters.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh to return — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
renderer.mesh.dropClusters(gpu)
modules/renderer/mesh.dropInstanced
mesh.dropInstanced(draw: InstancedDraw): boolean
Release an instanced-draw registration and the transform slots it
reserved. The mesh and the transform buffer outlive it — destroy those
through renderer.destroy and the buffer handle's :destroy().
Parameters
drawInstancedDraw— TheInstancedDrawto release.
renderer.mesh.dropInstanced(draw)
modules/renderer/mesh.encode
mesh.encode(geom: MeshGeometry): (string?, string?)
Encode raw geometry into engine-native ZMSH bytes (the on-disk mesh
payload). The CPU codec behind the mesh assetType's onCreate. Every stream
the format carries — including tangents, per-vertex skinning, and the
skeleton — round-trips back through renderer.mesh.decode. This pair moves
DATA the caller is holding; the geometry of a mesh the ENGINE is holding
comes from renderer.mesh.geometry(mesh).
Parameters
geomMeshGeometry—MeshGeometry— flat per-vertex float / u32 arrays plus optionalskinningandskins.
local bytes = renderer.mesh.encode({ positions = {...}, indices = {...} })
local bytes = renderer.mesh.encode(renderer.mesh.geometry(meshHandle))
modules/renderer/mesh.encodeCpu
mesh.encodeCpu(mesh: string | { [string]: any } | AssetRef): string
Encode a mesh's resident CPU copy into ZMSH bytes. Reads the ONE
guid-keyed CPU store — meshRef:load() populates it for assets, and
renderer.mesh.readback(mesh) populates it for a runtime mesh. Errors
loudly when the mesh has no resident CPU copy.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
local bytes = renderer.mesh.encodeCpu(handle)
modules/renderer/mesh.geometry
mesh.geometry(mesh: string | { [string]: any } | AssetRef): MeshGeometry
The complete geometry of a mesh the engine is holding, as a
MeshGeometry — the same shape renderer.mesh.create and
renderer.mesh.encode take, carrying every stream the mesh has
(positions, indices, and whichever of normals, uvs, colors,
uvs1, tangents, skinning, skins it was built with). The read that
pairs with create: hand it the MeshHandle create returned and get the
vertex data back. Reads the resident CPU copy when there is one; for a
runtime mesh that lives only on the GPU it reads the geometry back off the
GPU first (yielding a frame or two) and leaves CPU residency as it found it.
An optional stream is present only when the mesh carries one, so uvs1 == nil is the answer to whether it has a second UV set. The drawable mesh
the renderer holds carries the tangent basis its positions, uvs and normals
determine — supplied by the caller, or derived at the ingest that made it
drawable — and that is what the GPU read gives back. The CPU store answers
with the streams the bytes it decoded hold, so a .mesh written without a
tangent stream reads back tangents == nil for as long as a CPU copy of it
is resident.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
local geom = renderer.mesh.geometry(renderer.mesh.create({ positions = P, indices = I }))
local tangents = renderer.mesh.geometry(handle).tangents
modules/renderer/mesh.getVertices
mesh.getVertices(mesh: string | { [string]: any } | AssetRef): { any }
Read the vertices of a mesh's resident CPU copy — one entry per vertex,
{ pos = {x,y,z}, normal = {x,y,z}, uv = {u,v} }. Reads the resident CPU
store directly (no re-decode). Errors when the mesh has no resident CPU copy
— renderer.mesh.geometry(mesh) is the read that works wherever the mesh
lives, and returns the tangent, colour and skinning streams too.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
modules/renderer/mesh.heldOffDevice
mesh.heldOffDevice(mesh: string | { [string]: any } | AssetRef): boolean
True while the engine holds this mesh off the device: nothing displays
it, so its GPU buffers were given back and the engine keeps what rebuilds
them. The next Model or instanced draw that names the mesh puts it back
on the device, where renderer.mesh.isResident reads true again from the
frame that bind lands in. A mesh is one of three things: resident, held off
the device, or gone; a mesh neither this nor isResident answers true for
names nothing the engine can draw.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh: aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
local named = renderer.mesh.isResident(h) or renderer.mesh.heldOffDevice(h)
modules/renderer/mesh.instanceBounds
mesh.instanceBounds(draw: InstancedDraw, opts: { keep: number? }?): (Aabb?, string?)
The world box a registration's drawn copies occupy: every copy of the
mesh's extent (renderer.mesh.bounds) where the engine composed it for the
last frame drawn, carried through the entity the copies stand in when
setInstanceParent named one. It reads the copies back from the GPU, so it
waits a few drawn frames. A copy scaled to nothing draws nothing and is
left out. A mesh whose extent nobody knows answers with the box around the
copies' origins, and says so.
Parameters
drawInstancedDraw— TheInstancedDrawto measure.opts{ keep: number? }?(optional) —{ keep? }— the share of the copies the box holds along each axis (default 1, all of them). Below 1, the copies reaching furthest out on each side are left out:keep = 0.9is the box around where the body of a spray stands, without the few copies thrown far from it.
local box, note = renderer.mesh.instanceBounds(draw)
local body = renderer.mesh.instanceBounds(draw, { keep = 0.9 })
modules/renderer/mesh.instanceInfo
mesh.instanceInfo(draw: InstancedDraw): InstancedDrawInfo?
What a live instanced-draw registration is drawing: which mesh, which transform buffer, which per-instance data buffer if it named one, how many instances, and how many slots it reserved. Returns nil once the registration has been dropped.
status is what the renderer did with it. The fields above it are the
request, made a stage before the renderer sees it; status is the answer:
"drawing" for a registration the renderer is drawing, "hidden" for one
it holds but does not draw while its parent entity, or an ancestor of it, is
deactivated or gone, "refused" for one it turned away — error carries
its reason — and "pending" for the frame between the call and the renderer
answering. So a registration whose copies are not being drawn says so here.
Parameters
drawInstancedDraw— TheInstancedDrawto report on.
print(renderer.mesh.instanceInfo(draw).instanceCount)
local info = renderer.mesh.instanceInfo(draw)
if info.status == "refused" then error(info.error) end
modules/renderer/mesh.instanceTransforms
mesh.instanceTransforms(draw: InstancedDraw): any
Read back the world matrices a registration's drawn copies are placed
by: instanceCount matrices of 16 floats, column-major and tightly
packed, in the layout the transform buffer holds them. The read is of the
buffer as it stands when it runs, so a population a compute pass rewrites
every frame answers with the placement of the frame the read lands in.
Parameters
drawInstancedDraw— TheInstancedDrawwhose copies to locate.
local pending = renderer.mesh.instanceTransforms(draw)
while not pending:ready() do task.wait() end
local floats = pending:result()
modules/renderer/mesh.instanceWorlds
mesh.instanceWorlds(draw: InstancedDraw): any
Read back where a registration's drawn copies stand in the world, as
the engine composed them for the last frame drawn: each copy's matrix from
the transform buffer, carried through the world matrix of the entity the
copies stand in when they have one (setInstanceParent). instanceCount
column-major 4x4 matrices, 16 floats each. Async — poll the handle it
returns the same way as instanceTransforms.
Parameters
drawInstancedDraw— TheInstancedDrawto read.
local pending = renderer.mesh.instanceWorlds(draw)
while not pending:ready() do task.wait() end
local x = pending:result()[13]
modules/renderer/mesh.isCpuResident
mesh.isCpuResident(mesh: string | { [string]: any } | AssetRef): boolean
True if this mesh has a resident CPU copy in the guid-keyed CPU store.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
if renderer.mesh.isCpuResident(handle) then ... end
modules/renderer/mesh.isResident
mesh.isResident(mesh: string | { [string]: any } | AssetRef): boolean
True if a GPU mesh is resident under this mesh's guid — the device
holds its buffers, or the upload queued this frame is still going to hand
them over. This is the store the draw paths are gated on, so a mesh this
reports resident is one renderer.mesh.drawInstanced and a Model can
draw — from the frame after the upload commits: a render asked for in the
same tick the upload was queued does not carry the mesh yet.
renderer.mesh.onDevice is the answer that waits for that commit.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
print(renderer.mesh.isResident(handle))
modules/renderer/mesh.list
mesh.list(): { any }
Every mesh currently registered, ordered by guid — the ones a script
created and the ones that reached the device through an asset alike.
Answers "which mesh is this?" when all that is known is a size: each entry
carries the guid, the vertex/index counts it was created with, where it came
from (origin is "asset" for a mesh the asset path uploaded), whether the
GPU still holds it, and where its culling bounds come from (boundsFrom is
"compute" for a mesh a compute pass writes). A resident entry also carries
the bytes its buffers cost. bytes is the mesh's whole VRAM footprint and
is the sum of the THREE buffer columns beside it — vertexBytes + vertexStorageBytes + indexBytes, where the storage column is the same
vertices bound as a storage buffer for the passes that read them that way.
Summing only the vertex and index columns understates a mesh by its vertex
size. The bytes column is what sums to the meshes category of
renderer.gpuMemory().
renderer.references("mesh", guid) says what is still holding a row, and
renderer.collect() releases the rows nothing holds.
for _, m in ipairs(renderer.mesh.list()) do print(m.guid, m.bytes) end
modules/renderer/mesh.listInstanced
mesh.listInstanced(): { InstancedDrawInfo }
Every instanced-draw registration this engine is drawing, in
registration order. Each record is what instanceInfo answers with, and
carries a draw handle of its own — so a population whose handle its
caller no longer holds is reached here and released, resized or read like
any other.
for _, pop in ipairs(renderer.mesh.listInstanced()) do
renderer.mesh.dropInstanced(pop.draw)
end
modules/renderer/mesh.loadCpu
mesh.loadCpu(ref: string | AssetRef): MeshCpuHandle
Load a .mesh asset's geometry into the ONE guid-keyed CPU store (the
Disk→CPU step) and return a CPU handle. The handle holds NO geometry — only
the guid plus counts and the per-handle read/encode/unload ops (which read
the Rust-side store). Called by meshRef:load(). DEFAULT lifecycle: upload
to the GPU then handle:unload(); the store is populated only by this call.
Parameters
refstring | AssetRef— A meshAssetRef(carries.guidand reads its primary via getBytes), or any stringasset.refresolves to one — the guidencodeCputakes, an identity, a name or a source path.
local cpu = meshRef:load(); local gpu = renderer.mesh.create(cpu); cpu:unload()
local cpu = renderer.mesh.loadCpu(gpuMesh.guid)
modules/renderer/mesh.morphTargets
mesh.morphTargets(mesh: string | { [string]: any } | AssetRef): { string }
The names of the shapes this mesh blends towards, in the order an
entity's ecs.MorphWeights addresses them — weight i drives the target
named at i. An imported model carries the names its source file gave its
blend shapes, so content drives a face by the shape it means rather than by
the ordinal that shape happened to import at (which moves when the model is
re-exported). A target the source never named reads as an empty string.
Empty for a mesh with no morph targets. Errors when the mesh is neither
GPU- nor CPU-resident — materialise it first (meshRef:handle()).
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
for i, name in renderer.mesh.morphTargets(meshRef) do print(i, name) end
modules/renderer/mesh.morphWeights
mesh.morphWeights(
Turn weights named by shape into the ordered weight array
ecs.MorphWeights takes — the drive-a-face-by-name call. Every target the
mesh carries gets a slot; the ones weights names take their value and the
rest are 0, so the returned array always describes the whole mesh and a
shape left out is a shape at rest.
A name the mesh does not carry is an error listing the names it does: a mistyped viseme that silently moved nothing would be indistinguishable from a rig that never had it.
local w = renderer.mesh.morphWeights(meshRef, { Eyes_Blink = 1, Mouth_Smile = 0.4 })
ecs.set(face, ecs.MorphWeights { weights = w })
modules/renderer/mesh.onDevice
mesh.onDevice(mesh: string | { [string]: any } | AssetRef): boolean
True once the device holds this mesh's buffers — the upload queued
for it has committed — so the next render asked for carries the mesh.
renderer.mesh.isResident answers true one frame earlier, while the
upload is still queued; a reader about to render and read the picture
back waits on this one.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
while not renderer.mesh.onDevice(guid) do task.wait() end
modules/renderer/mesh.readback
mesh.readback(mesh: string | { [string]: any } | AssetRef, into: string?): MeshCpuHandle
Read a runtime GPU mesh's geometry back to CPU and return a
MeshCpuHandle for it — the GPU→CPU half of the runtime-mesh freeze path. A
mesh made with renderer.mesh.create keeps no CPU copy, so persisting it
(:encode() → asset.create("mesh", …)) reads it back here first. Yields
until the readback completes (a frame or two). After it returns the geometry
is resident in the guid-keyed CPU store: :getTriangles, :getVertices,
:getBounds, :geometry, :encode, :unload all work. Errors if the mesh
never becomes resident in the vertex pool.
The CPU store is keyed by guid and shared by everything that reads the
mesh, and whatever owns the mesh can retire the copy under its own guid:
renderer.mesh.update from compute buffers unloads it, which an ocean
surface does every frame it steps. into lands the copy under a
key of the caller's own instead: the handle answers for that key, and it
stays resident until the caller unloads it, whatever happens to the mesh.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — theMeshHandlerenderer.mesh.createreturned, a guid, or a meshAssetRef.intostring?(optional) — The CPU-store key the geometry lands under. Defaults to the mesh's own guid.
local cpu = renderer.mesh.readback(handle); local zmsh = cpu:encode(); cpu:unload()
local snap = renderer.mesh.readback(handle, "bake:" .. handle.guid); local tris = snap:getTriangles(); snap:unload()
modules/renderer/mesh.readbackPosed
mesh.readbackPosed(requests: { { entity: string, mesh: any } }): { [string]: MeshCpuHandle }
Read the POSED geometry of skinned entities back to CPU: for each request, the vertices the skinning pass wrote for that entity this frame, joined by the indices of the mesh it is posed from. A skinned surface's world-space triangles are produced on the GPU from the entity's joint matrices, so the mesh asset holds the bind pose and only this reads where the surface actually is. The posed vertices are in model space, so the entity's own world transform still places them — the same transform the raster draw uses.
Takes a LIST and answers a map, because the readbacks are queued together
and polled together: a scene's worth of characters costs the frames of one
readback rather than one entity's after another. Each posed mesh lands in
the CPU store under a guid of its own, derived from the entity, so
compute.buildBvh, meshcpu.* and every other guid-keyed reader takes it
like any other mesh. Call handle:unload() when done with it.
An entity the map omits holds no live pose — nothing skinned it this frame, which is also what makes its draws read the source mesh, so its bind-pose geometry is what stands for it.
The vertices read are ones the skinning pass wrote for the pose the entity is bound to. An entity bound to a pose that pass has not written yet — the frame it was posed, before the pass reached the queue — is asked again on the next frame rather than read from a slice still holding what stood there before.
Parameters
requests{ { entity: string, mesh: any } }—{ { entity = <id>, mesh = <mesh> } }— the entity to read, and the mesh it is posed from (a guid,MeshHandleor meshAssetRef).
local posed = renderer.mesh.readbackPosed({ { entity = id, mesh = ecs.get(id, ecs.Mesh).mesh } })
local tris = posed[id]:getTriangles()
modules/renderer/mesh.scheduleClusters
mesh.scheduleClusters(mesh: string | { [string]: any } | AssetRef, opts: { levels: string? }?): boolean
Queue a cluster bake over the mesh's geometry, off the frame loop. The
mesh keeps drawing its current cluster set while the bake runs, and the set
the bake produces replaces it when it lands. opts.levels is "dag" for
the LOD hierarchy or "single" for one level of clusters at full detail;
when omitted, a mesh AssetRef bakes the depth its clusterLod setting asks
for and any other argument bakes "dag". The CPU mesh may be unloaded on
the very next line. Geometry with a triangle joining two independently
moving parts leaves the queue unbaked with a warning; a mesh
renderer.mesh.clusters reports as "deformable" or "heapFull" leaves
it unbaked without one.
One bake is advanced per frame — the one at the head of the queue — and the
geometry is read once a bake gets there and the mesh's GPU upload has
landed, from the definition the engine holds for the mesh. The queue
therefore holds one mesh's geometry rather than one per mesh, whatever its
depth, and the set installs only on the geometry it was read from: a mesh
whose geometry is replaced before its set lands keeps the set of its new
geometry. renderer.mesh.clusterBakes().heldBytes reports what the queue
is holding, and its inFlight rows report which bakes it is holding for.
This is what the .mesh assetType materialisation path uses; reach for
renderer.mesh.buildClusters when you want the bytes in hand instead.
Scheduling the same mesh again replaces the bake already in flight for it.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh to bake — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef, loaded into the CPU store (renderer.mesh.loadCpu).opts{ levels: string? }?(optional) —{ levels: "dag" | "single" }?
renderer.mesh.scheduleClusters(cpu, { levels = "single" }) ; cpu:unload()
modules/renderer/mesh.setInstanceCount
mesh.setInstanceCount(draw: InstancedDraw, count: number): InstancedDraw
Change how many of a registration's instances draw. Constant time — the
reservation, the transform buffer and the pipeline all stay put, so this is
the verb for a population whose size changes per frame. The new count must
fit the reservation drawInstanced was given.
Parameters
drawInstancedDraw— TheInstancedDrawto reconfigure.countnumber— Instances to draw, at least 1 and within the reservation.
renderer.mesh.setInstanceCount(draw, visibleCount)
modules/renderer/mesh.setInstanceParent
mesh.setInstanceParent(draw: InstancedDraw, parent: any?): InstancedDraw
Stand a registration's copies in an entity's space: every copy's matrix
is taken relative to the entity, so the population moves, turns and scales
with it from the next frame on, with its transform buffer untouched. nil
puts the copies back in world space. It is the verb for a population that
belongs to something — a generator's output, an asset stood on an entity.
Parameters
drawInstancedDraw— TheInstancedDrawto reconfigure.parentany?(optional) — The entity the copies stand in (a proxy or its id), or nil for world space.
renderer.mesh.setInstanceParent(draw, entity.find("Forest"))
modules/renderer/mesh.setInstanceRenderLayer
mesh.setInstanceRenderLayer(draw: InstancedDraw, renderLayer: number): InstancedDraw
Change which render layers a registration's copies belong to. Constant time — the reservation, the transform buffer and the pipeline all stay put, and the next frame drawn tests the copies against the new membership. It is the verb for a population that follows something whose membership moves: a camera or a capture including the layer draws the copies, one excluding it does not.
Parameters
drawInstancedDraw— TheInstancedDrawto reconfigure.renderLayernumber— The membership bitmask, the same valuedrawInstancedtakes asrenderLayer. At least one bit must be set.
renderer.mesh.setInstanceRenderLayer(draw, mask)
modules/renderer/mesh.setVertices
mesh.setVertices(mesh: string | { [string]: any } | AssetRef, positions: { number })
Replace a mesh's resident CPU vertex positions (flat { x,y,z, ... })
IN PLACE — indices, normals/uvs, and skinning are preserved, the AABB
recomputes, and the GPU re-fetches the new geometry so it shows on screen.
The positions alone travel, so this is the per-frame deformation path where
renderer.mesh.update re-sends the whole geometry. The mesh must be
CPU-resident: renderer.mesh.create({ ..., keepCpu = true }) keeps a copy
from the start, renderer.mesh.readback(mesh) recovers one from the GPU,
and meshRef:load() loads one for a .mesh asset. Errors with the reason
otherwise, or when the vertex count doesn't match.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.positions{ number }— Flat{ x,y,z, ... }— one xyz per vertex; count must match the mesh.
local m = renderer.mesh.create({ positions = P, indices = I, keepCpu = true })
renderer.mesh.setVertices(m, P) -- P mutated in place each frame
modules/renderer/mesh.unloadCpu
mesh.unloadCpu(mesh: string | { [string]: any } | AssetRef)
Drop a mesh's resident CPU copy from the guid-keyed CPU store. The explicit release for a runtime geometry mesh's recoverable definition.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.
modules/renderer/mesh.update
mesh.update(mesh: string | { [string]: any } | AssetRef, src: any): MeshHandle
Overwrite the GPU resource mesh names IN PLACE, under the same guid,
from new geometry or compute buffers. Never writes a .mesh file — the
play-mode mutate path. A Model bound to the guid reflects the change with no
re-bind. Takes every form that names a mesh — the MeshHandle create
returned, the guid renderer.mesh.list hands out, a MeshCpuHandle or a
mesh AssetRef. Returns a handle carrying the bounds the new geometry has:
the handle it was given, refreshed, and a handle over the guid otherwise.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh to update — aMeshHandle, a guid, aMeshCpuHandleor a meshAssetRef.srcany(optional) — New geometry{positions, indices, ...}or compute buffers{vertexBuffer, indexBuffer, vertexCount, indexCount, prevVertexBuffer?}.
modules/renderer/mesh.uploadClusters
mesh.uploadClusters(mesh: string | { [string]: any } | AssetRef, clusters: string): boolean
Replace the cluster set a mesh draws with a serialized set (bytes from
renderer.mesh.buildClusters), built from the geometry the mesh holds as
the call is made. A set whose vertex count, vertex maps or nodes do not
describe the mesh, or one whose mesh's geometry is replaced before it
lands, is refused with a warning, and the mesh keeps its current set and
the set it was asked for. Once the set is installed, a bake still in
flight for the mesh is cancelled, and the engine keeps the bytes on the CPU
(renderer.mesh.clusterStore().scriptSetBytes) so the mesh draws this set
again when it returns to the device after nothing displayed it, or after
the device is rebuilt. The bytes go when the mesh's geometry is redefined,
when renderer.mesh.dropClusters returns it to lod0, and when the mesh
is destroyed.
Parameters
meshstring | { [string]: any } | AssetRef— The mesh the clusters belong to — aMeshHandle, aMeshCpuHandle, a guid, or a meshAssetRef.clustersstring— Serialized cluster bytes (binary-safe).
renderer.mesh.uploadClusters(gpu, cb)
modules/renderer/minScreenSize
minScreenSize(): number
The on-screen radius, in pixels, an object must reach to be drawn. 0
while the cutoff is off.
local px = renderer.minScreenSize()
modules/renderer/morphStats
morphStats(): {
The morph state the last frame drew with. A mesh carries the shapes it
can blend towards and an entity carries how strongly each is blended
(ecs.MorphWeights); where both are present, the vertex stage adds the
weighted deltas to the base geometry.
instances is how many render slots that happened at, and blends how
many single-target blends those slots carry between them: a slot
contributes one per target its weights move, or that they moved the frame
before, so the number of targets a mesh can be given is bounded by the
buffer the blends live in. meshes is how
many meshes hold a delta block and targets how many targets those blocks
cover between them; deltaBytes is what the shared buffer they are
appended into holds, and deltaBufferBytes the size of that buffer, which
the vertex stage binds whole.
deltaBudgetBytes is the most that buffer may hold on this device: the
largest storage buffer the device binds at once (128 MiB on many mobile
browsers). A block costs 32 bytes per vertex per target, over every vertex
of the mesh. A mesh whose block would take the resident blocks past the
budget is refused by name in the engine log and draws in its base shape,
and refusedMeshes counts the meshes refused that way; the refusal holds
until the mesh is uploaded again. A morph-target mesh whose weights are all
zero reads a meshes above zero beside an instances and blends of zero.
local m = renderer.morphStats()
print(("%d instances carrying %d blends over %d meshes"):format(m.instances, m.blends, m.meshes))
modules/renderer/observe
observe(): RenderObservation
Everything the renderer knows about the frame it last drew: what
program it bound for each renderable, the render state it holds each
material under, and what each program has cost in pipeline builds.
renderables is one row per renderable in the renderer's draw list,
carrying the program its material named (requestedProgram) beside the one
that was bound (boundProgram) — __error__ wherever the lookup missed
and the draw went ahead on the magenta placeholder — plus substituted,
the outcome (drew / drewPlaceholder / skipped / notDrawn), the
reason that forced it and the compiler's own detail for a failed
compile. observed says which of two answers a row is: true for a
resolution a geometry pass took as it drew, false for the renderer's own
resolution of a renderable this frame drew nowhere, which is what a
renderable outside every camera's frustum or layer mask reports.
materials is one row per
material the renderer holds a prepared bind group for; shaders is one row
per program pipelines have been built for. frame names the frame every
per-frame count covers; retainedFrames how many frames a resolution a
pass took is kept for after the last frame that drew it; window and
costWindow state both in the document itself. Recording is armed by the
first read, so this waits for the frame that first records rather than
answering empty.
local o = renderer.observe(); print(o.placeholderDraws, "renderables drew the placeholder in frame", o.frame)
modules/renderer/occlusionCulling
occlusionCulling(): boolean
Whether occlusion culling is currently enabled.
modules/renderer/passSchedule
passSchedule(): {
The schedule check over this frame's enqueued render passes. Passes
declare what they read (inputs) and what they write (output /
outputs / storage), and the frame runs them in phase order and, inside
a phase, in order order. violations holds every input bound to a
resource the frame produces LATER: that read samples the resource as it
stands ahead of that pass, which is the previous frame's contents for a
render target that persists, an empty target for one just created, and the
scene draw's own output for a @scene.* buffer — and the pass renders
either way. The frame's own buffers are checked on the same terms as a
render target: bind @scene.motion at a phase ahead of the pass that
writes it and the read is reported, naming the buffer and its writer.
A pass reading a resource ahead of that write on purpose declares that slot
in its enqueue's readsPrevious and drops out of the list;
unboundPrevious holds declared slots the pass binds no such resource to,
which cover nothing.
A resource no queued pass writes is not reported — a camera rendering to
texture and compute.dispatch both fill targets outside the pass queue,
and the scene draw fills the @scene.* buffers every frame.
A read the frame has only one order for is not reported either: where the
writing pass consumes something the reading pass produces, the reader runs
first or the writer has nothing to write, which is what a pass reading a
buffer into a target of its own and a second pass copying that target back
over the buffer forms.
unreachable holds passes at a phase that does not run their kind: every
phase drains its fragment and compute passes, while afterLighting is the
one that draws geometry, draw and splat passes, so one of those enqueued
elsewhere sits in the queue and never runs.
Each finding is also stated in the engine log the first time it appears.
local s = renderer.passSchedule()
for _, v in s.violations do print(v.message) end
modules/renderer/pendingWork
pendingWork(): PendingWork?
What the renderer still owes the picture — the work it has taken on and has not yet put in the frame.
A frame draws what the renderer holds at the moment it runs, and several of
the things it holds arrive over more than one frame. A pipeline is built
off the frame thread and bound the frame its result is taken in; a texture
is uploaded under a per-frame time budget; a released texture's GPU object
is freed on the frame the release queue is drained; a streamable texture
climbs toward the level its screen size asks for one level at a time.
pipelineBuilds, textureUploads, textureReleases and
textureResidency are those four. textureTransfers counts the textures
the texture cache is still moving over several frames: a large upload
written a band at a time, a promotion waiting on its finer levels to be
read or decoded, a demotion waiting on its levels to be read back. Each
lands as a new GPU texture on a frame of its own, and the frames between
two landings replace nothing, so textureResidency alone reads zero on
them. outstanding is the sum of every count.
settled is true when outstanding is zero, and says the renderer owes
this picture nothing: the frames after this one draw the same picture
unless something changes the scene. That is the renderer's own word for
what a test measuring a picture holds for before it reads one.
epoch counts the times the renderer has gone from owing nothing to owing
something since the process started. It is what a pair of readings needs: a
run of work that begins AND ends between two samples leaves both of them
reading settled and leaves epoch higher, so settled at both ends with
the same epoch at both ends is the statement that nothing arrived across
the whole span, rather than at its two endpoints alone. Test.settleReading
is built on exactly that pair of conditions.
frame names the drawn frame the reading was published on. Every count is
published from the frame thread on every frame the renderer runs, so a
headless engine declining frames answers as readily as a windowed one.
deviceRebuild is one while the engine is between render devices: the
picture is owed the device itself, every frame in that window draws
nothing, and what content puts back on the new device lands on the frames
after it. computeCommands counts the compute commands a drain held
over: a dispatch waiting on the program it names and every command over
the buffers it would write queued behind it, each of which runs or drops
on a later drain. clusterSets counts the meshes whose cluster set is
still being built, or is owed again after a device rebuild: each lands as
the set the mesh draws, and the geometry a cut of it draws changes on the
frame it does. materialRows counts the materials the frame does not yet
draw as they ask: one whose raster or resolve pipeline is still building
draws nothing until it lands, one whose shader's resolve gate has not
reached a verdict resolves through the error shader until it does, and one
whose routing changed since the frame last published it is still drawn by
the previous routing. Each changes the picture on the frame it lands.
skippedDraws counts the renderables the last drawn frame left undrawn
because a pipeline or a material group they draw with was not built yet;
each appears on the frame what it waits on lands. shaderCompiles counts
the shader compiles running off the frame thread that no frame has landed:
each lands as the program its keys name, and the materials drawing with
those keys change on the frame it does.
if renderer.pendingWork().settled then print("the picture is what it is going to be") end
local w = renderer.pendingWork(); print(w.outstanding, "arrivals still owed, over", w.epoch, "runs of work")
modules/renderer/pipelineCache
pipelineCache(): PipelineCache?
What the driver's compiled-pipeline store held, built, and wrote back. A pipeline is machine code the GPU driver compiles from the shader bound into it, and that compile is what a launch pays before the first frame drawing with each pipeline can appear. The store keeps that compiled code across runs, so a launch whose shaders have not changed reads back what the previous one compiled.
restoredBytes is what a previous run left for this GPU and this launch
read; pipelinesBuilt counts the pipelines built since startup and
buildMs is what they cost together, which is the number the store lowers.
saves and savedBytes describe writing it back — deferred until a burst
of builds settles, so one launch is one write — and dirty is true while
pipelines have been built that the file does not hold, including after a
write that failed, which lastError then names. path is the file, named
after the GPU it belongs to.
supported is false where the platform holds no store a program can carry:
a browser keeps its own and hands none out, and an adapter can lack the
capability. reason says which, and the build count and timing still read
true there. lastError names a read or write failure; a failed store costs
the saved compile and never the frame, since every pipeline is built from
its source either way.
A pipeline a material, the sky, a depth view, a post-process pass or a
compute program a script registers needs after boot is built off the
frame thread — the shader module behind that compute program with it —
on buildWorkers worker threads on native, behind the browser's
asynchronous entry point on the web, where buildWorkers reads 0. So a
burst of new materials costs a frame nothing beyond drawing the
placeholder until each pipeline lands, and a burst of effects costs it
nothing beyond each effect starting on the frame its pipeline does.
offFrameBuilt and offFrameBuildMs are the pipelines and the
milliseconds that never held a frame; pipelinesBuilt - offFrameBuilt
is what the frame thread built, which is the renderer's own — the set it
stands up before its first frame, and the few it stands up on the frame
a pass first asks for them. buildsSubmitted, buildsFinished,
buildsFailed and buildsInstalled count build requests (shader modules
and pipelines) made, completed, refused and taken back by a frame.
buildsAbandoned counts the requests a renderer still held when a device
rebuild let it go, which no frame will take back, and buildsPending is
what the renderer drawing now has yet to take back: asked for and not
yet in use, a finished result included until a frame installs it. So
every request made is installed, abandoned or pending, and a reader
waiting on buildsPending to reach zero reads pipelinesBuilt with every
build it waited for counted, and can tell a queue draining from one that
is stuck. modulesBuilt and moduleBuildMs are
the shader modules compiled off the frame thread, parse and validation
included.
pipelinesBuilt and buildMs are engine-wide totals; renderer.shaderCost()
is the same cost broken down per program, with each one's permutation count.
local c = renderer.pipelineCache()
print(("%d pipelines in %.1f ms, %d bytes restored"):format(c.pipelinesBuilt, c.buildMs, c.restoredBytes))
modules/renderer/presentedFrames
presentedFrames(opts: { scope: string?, frames: number?, interval: number?, velocity: boolean? }?): { PresentedFrame }
Parameters
opts{ scope: string?, frames: number?, interval: number?, velocity: boolean? }?(optional)
modules/renderer/projectionJitter
projectionJitter(): { { number } }
The offsets renderer.setProjectionJitter stated, each {x, y} in
pixels from the pixel centre.
local offsets = renderer.projectionJitter()
modules/renderer/projectionOffset
projectionOffset(): (number, number)
The sub-pixel projection offset in force for the main camera, in NDC.
local ox, oy = renderer.projectionOffset()
modules/renderer/qualityTier
qualityTier(): QualityTier
The device's quality tier and the renderer defaults it chose. The
engine assigns every device one of "low", "medium" and "high" at
boot, from its GPU family and limits, its memory and its display, so a
world authored on a desktop plays on a phone at the phone's defaults
without knowing it runs on one. A desktop, and any device whose GPU is
outside the handheld families, is "high": the renderer as a desktop runs
it, one scene pixel per display pixel. A phone renders the scene below a
dense display's resolution with UI and text at full resolution, and
spends less on shadows, textures and filtering the lower its tier. A lower
tier chosen on a desktop renders the scene within that tier's pixel
budget the same way, so renderer.setQualityTier alone is a whole
graphics setting on every platform.
Every default the tier states stands wherever the world's settings name no
value of their own (render.anisotropy), and the matching renderer call
overrides any one of them: renderer.setResolutionScale,
renderer.setTextureBudget, renderer.setAnisotropy.
renderer.setQualityTier chooses another tier altogether.
local q = renderer.qualityTier()
print(q.tier, q.reason, q.defaults.resolutionScale)
modules/renderer/raycast
raycast(
Cast a ray against the geometry the renderer DRAWS and return the
nearest surface it meets. Every visible mesh answers, whether or not
anything gave it a rigid body — so a terrain, a procedurally generated
mesh, or any plain Model reports the surface at a point, which is what a
camera station, a prop, a sound source or a scatter standing on the ground
needs to know. The answer is the nearest triangle of the mesh, so a sloped
or terraced surface reports its height where it was asked rather than the
extent of its bounding box.
distance is measured from origin along the direction given, so it is a
world-space distance whenever that direction is a unit vector, and it is
directly comparable to a physics.raycast distance along the same ray.
normal is a unit vector turned to face back along the ray. exact is
true when the answer is a triangle and false when it is the object's
bounding box, which is what a mesh whose vertices live only in GPU buffers
answers with. The triangles are the mesh's own, placed by the entity's
transform and by the mesh's bind pose, so a surface a skinning or morph
pass deforms on the GPU answers as the geometry the mesh holds.
EVERYTHING drawn is in scope — the ground you meant, and equally a
character standing on it, a prop, a placeholder floor. The hit names its
entity in entityId, exclude steps over the ones you do not want, and
renderer.raycastAll hands back the whole column so you can pick the
surface yourself. A height you did not expect is usually a nearer surface
you did not mean to ask about, so read entityId before trusting a number.
local hit = renderer.raycast({ x, 100, z }, { 0, -1, 0 }, 200)
if hit then entity(cameraId).position = { x, hit.point.y + 1.7, z } end
modules/renderer/raycastAll
raycastAll(
Cast a ray against the geometry the renderer draws and return every
surface along it, nearest first. One entry per renderable the ray crosses —
the nearest intersection with each — so a stack of surfaces reads as the
order they stand in, and a caller after one particular surface finds it by
entityId rather than hoping it is the nearest. Each entry carries the
fields renderer.raycast returns.
for _, hit in renderer.raycastAll(eye, look, 500) do print(hit.entityId, hit.distance) end
modules/renderer/raytraceCapability
raytraceCapability(): string
The active ray-tracing backend: "hardware" (GPU ray query) or
"compute" (software traversal — the path on devices without hardware ray
query, e.g. the web). The same ray-tracing features work on both.
if renderer.raytraceCapability() == "hardware" then ... end
modules/renderer/raytraceStats
raytraceStats(): { [string]: any }
What the ray-tracing acceleration structure holds, and what this
session's frames have spent building it. A ray walks a structure built over
the scene's geometry, and keeping it current is work a frame pays before it
traces anything. On the "compute" backend geometry that has stood still
long enough is filed under a static partition the frames after it leave
alone: staticTriangles + dynamicTriangles = triangles, nodes is the
hierarchy over them, fullRebuilds / partialRebuilds / reusedFrames
count what the session's frames did, and trianglesRebuilt is what those
rebuilds re-emitted, summed. On the "hardware" backend blas is the
bottom-level structures cached, blasBuilt how many the last frame built,
and tlasInstances what the top-level structure names. The counters are
cumulative — sample, run the scene, sample again.
local before = renderer.raytraceStats().trianglesRebuilt
modules/renderer/references
references(handleOrKind: any, id: string?): RuntimeResourceStatus?
What holds a runtime resource right now — the answer a root scene load
reads before releasing it. references names each live consumer the engine
found: { by = "entity", id } for an entity wearing the material or mesh,
"material" for a material whose slot names the texture (or names a
texture array the device has not assembled from it yet), "instancedDraw",
"camera", "sky", "lightmap", "ui" (a screen drawing it) and
"postProcess" (an effect sampling it). handleHeld says whether a script
still reaches a handle to it, assetBacked whether an asset stands behind
it, ownerLive whether the component instance, scene load or feature that
created it still stands, and held whether a hold pins it. origin reads
"device" for a GPU texture the device holds that no script created — the
one the cache loaded for an asset, the atlas the engine built — whose
holders are the references, a handle and the asset. Runs a full garbage
collection first, the same one renderer.collect runs, so a handle nothing
reaches counts as let go and the row says what the next collection does
with the resource. Yields for the frame the census runs on.
Parameters
handleOrKindany(optional) — The resource's handle, or its kind with the id second.idstring?(optional) — The guid or key, when the first argument is a kind.
local s = renderer.references(mat) for _, r in s.references do print(r.by, r.id) end
modules/renderer/reflectionEnvironment
reflectionEnvironment(): {
What a reflective surface is reflecting. probes is how many reflection
probes the shading blends; they are gathered highest priority first, each
rank taking the coverage the ranks above it left, so a small interior probe
ranked above the large exterior one it sits inside wins outright wherever it
reaches full weight. ranks is the priority each of those probe slots was
published with, in slot order. sky is whether the sky fallback is armed:
with it, coverage no probe claims reflects the captured sky, and without it
a surface outside every probe's radius falls back to the nearest probe
alone. skyCaptured is whether the sky slot holds a capture — arming is
refused until it does, since an uncaptured slot reflects black. skyStale
is whether the sky changed after that capture, so the slot still depicts
the sky from before the change until the engine's recapture, or an
explicit environment.captureSky(), retakes it. The engine retakes a sky
swapped for another material or turned off on the first frame the new sky
can be drawn, and a sky whose look moved once a pacing window has passed
since the last capture. skyPosition is where the capture was taken
from, absent before one. skyCaptures counts the sky
captures that have landed since the renderer was built, so one retaken from
the same position reads as new, and skyMaterial names the material the
sky pass draws from, absent when no sky is drawn.
slots is how many cube slots the environment array holds right now: the
sky's alone, at index skySlot, until a probe is captured into it, then
that one, the slot a camera's stated environment is held in, and one per
probe. maxProbes is how many of them probes may
take, and resident whether the array has grown past the sky's single
slot. Capture the sky with environment.captureSky().
local env = renderer.reflectionEnvironment()
print(("%d probes, sky fallback %s"):format(env.probes, tostring(env.sky)))
modules/renderer/registeredCopy
registeredCopy(content: { [string]: any }): { [string]: any }
Destroy every render feature created since renderer.markBaseline,
withdraw every capture view registered since, and put the feature-texture
array back to the size it recorded.
A feature the mark recorded is known by its identity: one destroyed and created again under the same identity since the mark stands, under whatever guid it now carries. A capture view is known by its name.
A feature is usually created by the module that needs it, on first use, and
that module holds its own record of having done so. Drop the module's cache
alongside this (engine.resetScriptingState) or the module will go on
believing it has a feature this destroyed, and nothing will rebuild it.
A hold on the clock (renderer.temporal.hold) or on the air
(renderer.atmospherics.hold) taken since the mark comes off; one the
mark recorded stands until the caller that took it releases it.
What this asks for lands on the renderer's next frame, so a caller that must see the renderer already back — one handing the engine to somebody else — waits a frame when the answer is above zero. recorded size, from the next frame on.
Parameters
content{ [string]: any }
if renderer.resetToBaseline(mark) > 0 then task.waitFrames(1) end
modules/renderer/release
release(handleOrKind: any, id: string?): boolean
Let go of the hold renderer.hold placed. The resource stays until
nothing else holds it and a collection releases it — the one a root scene
load runs, or a direct renderer.collect(). A runtime mesh no script
reaches a handle to is judged again once its hold goes, and released
with no collection when nothing else holds it.
Parameters
handleOrKindany(optional) — The resource's handle, or its kind with the id second.idstring?(optional) — The guid or key, when the first argument is a kind.
renderer.release(tex)
modules/renderer/releaseBaseline
releaseBaseline(generation: number): boolean
Drop the mark generation names, and every mark taken after it, once
the caller that took it is done resetting to it. It touches the
marks alone.
Parameters
generationnumber— The mark to drop, asrenderer.markBaselinereturned it.
renderer.releaseBaseline(mark) -- the run is over
modules/renderer/renderTargetLimits
renderTargetLimits(): {
The size a render target may be on this device. maxDimension is the
device's own maximum 2D texture dimension — the largest either side of a
render target may take. maxPixels is how many pixels one render target
may hold, so the RGBA8 image it reads back as fits in a single buffer on
every platform the engine runs on, and maxSquare is the largest square
that budget buys. A capture, a renderer.texture.create({ width, height })
or a render-to-texture camera past either bound is refused at the call with
the reason, so ask here for the size to request.
local lim = renderer.renderTargetLimits()
local w = math.min(want, lim.maxSquare)
modules/renderer/renderTargets
renderTargets(): {
Every render target the renderer owns and what each one costs, measured
from the texture that is allocated. One row per target, each carrying its
name, whether it is resident, the bytes it holds while it is, its
width/height/layers/mipLevels, and onDemand.
An onDemand target exists only while something needs it: a target nothing
writes into reads resident = false and bytes = 0 and appears again the
frame something writes it, and one sized by content (the reflection-probe
cube array) holds the slots content asked for. The scene's occlusion and
reflection channels and its lit colour history (scene_occlusion,
scene_reflection, scene_color_history) are resident at the scene's
extent while a render-feature pass writes or reads them, and
shadow_page_pool while a light casts into the virtual shadow map, with
shadow_transmittance_pool beside it while a translucent caster casts
into it.
The scratch the draws into
a render target have needed is reported as camera[<handle>].* rows:
depth and motion vectors under any rasterized pass, and the occlusion,
reflection and colour-history channels, the scene copies and the G-buffer
over them under a camera's scene render. A draw builds what it needs, or
takes the scratch a released target of the same size left. A target
releases its set to the next target of its size when no live camera names
it and when it is destroyed or resized, and frees it once sixty frames
pass without a draw, so a target nothing draws into carries no such row.
Released scratch waits as
released_scratch[<width>x<height>].* rows for the next target of that
size, held newest first within 64 MiB and freed once sixty frames pass
without a target taking it. The colour image drawn into belongs to the
texture cache while its target stands; a destroyed or resized target's
colour texture waits on the same terms as a
released_scratch[<width>x<height>].color row for the next target made at
that size and format, which starts from it cleared to transparent black.
totalBytes is what the resident targets hold together. allocations
counts the render-target allocations the renderer has made since it was
built, the colour textures of the live targets included, each on the first
frame whose report holds it: a target taken back
at a size it held before adds nothing, so the difference between two
readings is what the frames between them allocated. Measured at the end of
the last rendered frame.
local rt = renderer.renderTargets()
print(("render targets: %.1f MiB over %d resident"):format(rt.totalBytes / 1048576, rt.residentCount))
for _, t in rt.targets do
if t.onDemand then print(t.name, t.resident, t.bytes) end
end
modules/renderer/resetToBaseline
resetToBaseline(generation: number?): number
Parameters
generationnumber?(optional)
modules/renderer/resolutionScale
resolutionScale(): number
The fraction of the display resolution the scene is currently rendered
at. Until something sets it, the scale the device's quality tier chose for
its display (renderer.qualityTier().defaults.resolutionScale): 1 on a
desktop at the high tier, below 1 on a dense handheld display and on a
desktop at a lower tier.
local s = renderer.resolutionScale()
modules/renderer/resolutionScaleMode
resolutionScaleMode(): string
Where the render scale resolves: "present" or "reconstruct".
"present" until something sets it.
local m = renderer.resolutionScaleMode()
modules/renderer/setAnisotropy
setAnisotropy(level: number): number
Set the maximum anisotropy material textures are sampled with. Takes effect on the next frame for content already on screen — no reload, no texture re-upload. 1 is plain trilinear.
Parameters
levelnumber— One of 1, 2, 4, 8, 16. Any other value is an error.
renderer.setAnisotropy(16)
modules/renderer/setBlendedBatching
setBlendedBatching(enabled: boolean): ()
Whether neighbours in a view's back-to-front blended order draw
together. On by default: alpha-blended geometry is submitted farthest-first,
and a stretch of neighbours in that order sharing a mesh, a material, a
shader and a pose is submitted as one instanced draw over those neighbours,
which puts the same members on screen in the same order out of a single
submission. A run stops wherever a differently-drawn renderable sorts
between two of its members, and a mesh of several primitives keeps a draw
per renderable — both would otherwise move fragments through each other.
Off, every blended renderable draws on its own at its own slot, so a
transparent crowd costs a draw per member. The image is the same either way,
which is what makes this the comparison a frame suspected of being formed by
the batching is made against; renderer.drawStats().draws counts the
difference.
Parameters
enabledboolean—boolean
renderer.setBlendedBatching(false) -- a draw per blended renderable
modules/renderer/setDrawEveryFrame
setDrawEveryFrame(everyFrame: boolean): boolean
Draw every frame continuously (true), or redraw only while there
is something new to show (false, the default), so an idle screen whose
picture stands still is not redrawn.
By default a renderer presenting to a display draws while what is on
screen changes (the UI, the camera, a renderable, a material, a light, an
animation, a texture, the window) and for a short settling run after the
last change, then declines the frames of a still picture, which stays on
screen. While anything else moves (the gameplay clock, a task owed the
next frame, held input, a tool call in flight) the frames keep running at
the display's rate while it declines, and an engine that is still waits
for the next arrival or timer instead (renderer.framePacing().engineStill);
the next change is drawn on the frame after it. On a phone that is the GPU work, the heat and the battery
of every frame an idle menu or a paused editor would otherwise redraw. A
headless renderer draws while something reads its frames.
true draws every frame on every renderer, for content whose picture
changes in a way the engine does not see, or that is measured frame by
frame. renderer.framePacing() reports the rule in force (drawPolicy),
whether the last frame was drawn (producing), the frames declined
(idleSkippedFrames) and what woke the renderer (pictureChanges,
lastPictureChange). Takes effect on the next frame. draw_every_frame
under [render] in the world's .world_settings seeds it, so a world
states it once; a call here stays in force until that value changes.
Parameters
everyFrameboolean— boolean true to draw every frame, false to draw only frames that show something new.
renderer.setDrawEveryFrame(true) -- a benchmark measures every frame
print(renderer.framePacing().drawPolicy) --> every_frame
renderer.setDrawEveryFrame(false) -- back to drawing changes only
modules/renderer/setFrameRateCap
setFrameRateCap(fps: number?): number?
Hold the engine to at most fps frames per second, or lift the cap
with 0 or nil. The whole frame waits for its turn: scripts, physics, audio
mixing and networking run once a frame as the drawing does, so a game
capped at 30 runs at 30, and a phone spends no battery on frames past it.
Frames come due on an even grid. Where the display's refresh rate is known
(a phone's panel, a desktop window's monitor, a browser's animation
frames), the grid is a whole number of refreshes, the fewest whose rate
stays inside the cap, so every frame stays on screen for the same number
of vsyncs: on a 120 Hz display a cap of 30 shows each frame for 4
refreshes and 60 for 2, and a cap the refresh rate does not divide evenly
delivers the next rate below it (50 on a 120 Hz display delivers 40). On
Android the system compositor is told the rate as well, so a panel with
more than one refresh rate can run at one the cap divides. On a display
that shows frames on its vsync the cap is the highest rate the engine
chooses (renderer.setFrameRateMode): frames that cannot hold it run at
the next even rate below.
Read renderer.framePacing() for the effect: targetFps is the rate the
cap delivers, refreshesPerFrame the refreshes each frame holds,
displayRefreshHz the display it was worked out against, and
deliveredFps the rate frames actually ran at. Takes effect on the next
frame. frame_rate_cap under [render] in the world's .world_settings
seeds it (0 for no cap), so a world states its cap once and every session
opens under it; a call here stays in force until that value changes.
Parameters
fpsnumber?(optional) — number? Frames per second, 1 through 1000; 0 or nil lifts the cap.
renderer.setFrameRateCap(30) -- a steady 30 on any display 30 divides
print(renderer.framePacing().targetFps, "fps delivered under the cap")
renderer.setFrameRateCap(nil) -- every frame the display shows
modules/renderer/setFrameRateMode
setFrameRateMode(mode: string): string
Choose how the engine picks the frame rate it runs at on a display
that shows each frame on a vsync (presentMode fifo, fifo_relaxed or
auto_vsync: a phone, a browser tab, a desktop window set to fifo).
adaptive, the default, runs at the highest rate the display shows
evenly that the frames sustain, at most the cap
(renderer.setFrameRateCap; the display's highest refresh rate without
one). A frame that cannot hold 120 on a 120 Hz panel runs at an even 60
rather than at 60 to 67, one that cannot hold 60 at 40, never below 30,
and the rate goes back up once the frames hold a faster one again (in one
step after a load). fixed holds the
cap's rate (the display's highest rate without a cap) whatever the frames
take, for content that needs one set rate.
In both modes every frame is due on its own vsync, so the engine makes no
frame the display has no refresh to show. On Android the display is asked
for the lowest of its modes the chosen rate divides into whole refreshes,
so a panel whose frames come at 60 can run at 60 Hz and spend less power;
a desktop window and a browser hold frames to their
display by pacing alone. On a surface that shows a frame on whatever
refresh it lands on (mailbox, immediate), or with no display, the cap
alone holds the loop. renderer.framePacing() reports the mode
(frameRateMode), the rate chosen (chosenFps), why (frameRateReason),
the time frames take (frameWorkMs) and what the display was told
(displayVote, displayVoteFps). Takes effect on the next frame.
frame_rate_mode under [render] in the world's .world_settings seeds
it; a call here stays in force until that value changes.
Parameters
modestring— string "adaptive" or "fixed".
renderer.setFrameRateCap(120) -- a game that wants 120 where frames hold it
renderer.setFrameRateMode("adaptive")
print(renderer.framePacing().chosenFps, renderer.framePacing().frameRateReason)
renderer.setFrameRateMode("fixed") -- hold the cap's rate whatever frames take
modules/renderer/setGpuMemoryTracking
setGpuMemoryTracking(frames: number?): number
Set how often the GPU allocator sampler reads — one reading every
frames frames — or turn it off with 0. It starts at 60, a reading a
second at 60 Hz, so renderer.gpuMemory().allocator answers without
anything arming it. Building the ledger walks every live allocation, which
is why it is sampled rather than read every frame; the category figures
cost nothing either way, and a reader between samples sees the most recent
ledger, so a slow interval still answers.
Called with no argument it reports the interval in force and changes nothing, which is how something that retimes the sampler puts it back afterwards instead of restoring a number it assumed was the default.
Parameters
framesnumber?(optional) —number?Frames between readings; 0 turns the sampler off. Omit to read the interval without changing it.
renderer.setGpuMemoryTracking(60)
local was = renderer.setGpuMemoryTracking()
renderer.setGpuMemoryTracking(1)
-- ... take a tight reading ...
renderer.setGpuMemoryTracking(was)
modules/renderer/setLighting
setLighting(enabled: boolean): ()
Turn the scene's lighting on or off. Off, every lit surface renders as its own colour with no light on it, emissive included: the editor's lighting toggle, for reading a scene's materials without its lights. With no light applied there is no shadow either, so the shadow maps draw nothing while it is off, and the shadow switches apply again once lighting is back on. The sky and post-processing stay as they are.
Parameters
enabledboolean—truerenders the scene lit,falseunlit.
renderer.setLighting(false); print(renderer.lighting())
modules/renderer/setMaxFramesInFlight
setMaxFramesInFlight(frames: number): number
Set how many frames of GPU work may be outstanding before the renderer stops running ahead. One is the least overlap this can express — a frame's work is waited for as soon as the next frame has been submitted — which is the lowest latency and the lowest throughput; higher values let a slow frame build a longer backlog, and that backlog is memory. Takes effect on the next frame.
Answers the bound after clamping to [1, 8], so asking for more than the renderer honours reports what you actually got.
Parameters
framesnumber— number Frames of GPU work that may be outstanding, 1 through 8.
renderer.setMaxFramesInFlight(1) -- lowest latency
print(renderer.setMaxFramesInFlight(99), "was clamped")
modules/renderer/setMaxTextureSize
setMaxTextureSize(px: number?): { px: number, devicePx: number }
The longest side a texture loaded from an asset may be resident at on this client, in texels. Such a texture larger than the cap is served from the first level of its mip chain that fits, so a 4096² texture under a 1024 cap holds its 1024² level and the levels below it, and the texture budget never takes it finer than that level. A changed cap moves the resident textures over the next frames; a raised one reads their finer levels back from their assets. A texture made from pixels with no asset behind it keeps every level it was made with, because the device holds its only copy. The device's own maximum 2D texture dimension bounds the cap from above. Call with no argument to lift the cap to the device's limit.
Parameters
pxnumber?(optional) —number?— texels, a whole number of at least 1; nil for the device's own limit
renderer.setMaxTextureSize(2048)
renderer.setMaxTextureSize() -- the device's own limit
modules/renderer/setMinScreenSize
setMinScreenSize(pixels: number): ()
Stop drawing an object once its on-screen radius falls below this many
pixels. A few pixels across, an object carries no detail a viewer can
resolve while still costing a full vertex and submission pass, and the
cutoff drops it from the camera's draws entirely — 0, the default,
keeps every object however small it lands. Measured from the object's own
bounds against the camera's projection, so the same threshold means the
same apparent size at any distance or field of view. Shadow casters have
their own threshold in renderer.setShadowCasterCutoff.
Parameters
pixelsnumber—number— smallest on-screen radius still drawn; 0 disables.
renderer.setMinScreenSize(4) -- drop anything under 4 px of radius
print(renderer.drawStats().compactedDrawn, "instances survived it")
modules/renderer/setOcclusionCulling
setOcclusionCulling(enabled: boolean): ()
Enable or disable occlusion culling. While enabled the renderer reduces the depth the visibility raster lays into a pyramid each frame and tests every renderable that cleared the frustum against it, dropping the ones another surface entirely covers before their geometry is submitted. The pyramid describes the frame being drawn, so an object that becomes visible this frame is never held back a frame.
Parameters
enabledboolean—boolean
renderer.setOcclusionCulling(true); print(renderer.cullStats().occlusionCulled)
modules/renderer/setPresentMode
setPresentMode(mode: string): string
Set how a presented frame reaches the display. fifo queues every frame
and shows it on a vertical blank, which never tears and never drops one;
mailbox replaces the queued frame with the newest, which does not tear
and does not hold the renderer to the refresh rate; immediate presents as
soon as a frame is ready and can tear; fifo_relaxed is fifo that tears
rather than stall when a frame misses its blank; auto_vsync and
auto_no_vsync leave the choice to the backend.
A surface that does not offer the mode presents fifo instead, so read
renderer.framePacing().presentMode for what took effect and
.presentModes for what this surface offers. Takes effect on the next
frame.
Parameters
modestring— string One of "fifo", "fifo_relaxed", "mailbox", "immediate", "auto_vsync", "auto_no_vsync".
renderer.setPresentMode("mailbox")
print(renderer.framePacing().presentMode, "is what the surface took")
modules/renderer/setProjectionJitter
setProjectionJitter(offsets: { { number } })
State where inside the pixel consecutive renders of a view sample, for
the frames until it is stated again: a list of {x, y} offsets in pixels
from the pixel centre, each within half a pixel. Every view the renderer
draws (the viewport, each render-to-texture camera, each capture) walks the
list by its own count of renders in a row, so a camera drawn beside the
viewport takes nothing out of the viewport's sequence: a view's first
render, and its first after a cut, samples the pixel centre, and its next
renders take the offsets in order, wrapping. Each offset is applied in the
view's own pixels. Velocity (@scene.motion) is measured against the
offset-free projection, and a history target's state buffer carries the
offset each render took. renderer.setProjectionOffset, while it is not
(0, 0), and an upscale backend's own jitter both stand over the list on
the viewport. An empty list samples pixel centres. An offset outside half
a pixel is refused, naming it, and leaves the list in force.
Parameters
offsets{ { number } }— The offsets, each{x, y}in pixels from the pixel centre.
renderer.setProjectionJitter({ { 0.25, -0.25 }, { -0.25, 0.25 } })
modules/renderer/setProjectionOffset
setProjectionOffset(x: number, y: number)
Offset the main camera's projection by a sub-pixel amount, in NDC, for
the frames until it is set again. The offset is in NDC because that is the
space it is constant in: one pixel is 2.0 / width across, so half a pixel
is 1.0 / width. Velocity (@scene.motion) is measured against the
offset-free projection, so a still scene reports no motion however the
samples are placed — and picking resolves a click to the same ray either
way. (0, 0) samples pixel centres.
Parameters
xnumber— Horizontal offset in NDC. One pixel is2.0 / width.ynumber— Vertical offset in NDC. One pixel is2.0 / height.
renderer.setProjectionOffset(0.5 * 2 / w, -0.25 * 2 / h)
modules/renderer/setQualityTier
setQualityTier(tier: string?): QualityTier
Render at another quality tier than the one the device was assigned:
"low", "medium" or "high", or nil / "default" for the device's
own. A change of tier stands the new tier's defaults at once wherever
the world's settings state none, replacing what an earlier renderer call
set for the render scale, the shadow budgets and the anisotropy; choosing the tier already in force changes no setting. A call
made after it, in the same script or later, overrides that one default
again. A budget renderer.setTextureBudget names stands over the tier's
texture cap until it is returned to the device's own. The choice holds for the
process, across scene loads and restarts of the scene, until it is set
again. A settings screen offering the player a quality choice is this call.
Parameters
tierstring?(optional) —string?:"low","medium","high", ornil/"default"for the device's own.
renderer.setQualityTier("low")
renderer.setQualityTier() -- back to the device's own
modules/renderer/setRaytrace
setRaytrace(enabled: boolean): ()
Enable or disable GPU ray tracing. While enabled the engine builds the scene acceleration structure each frame so ray-tracing render features can trace against it; disabling stops the build (so it costs nothing until a ray-traced effect is active). Required before any ray-traced shadows / AO / reflections render.
Parameters
enabledboolean—boolean
renderer.setRaytrace(true); renderer.feature.create("rt_shadows")
modules/renderer/setResolutionScale
setResolutionScale(scale: number): number
Render the scene at a fraction of the display's resolution. Shading cost
scales with pixel count and with nothing else, so this trades sharpness for
frame time without taking anything out of the scene: at 0.5 the scene
rasterizes a quarter of the pixels. What the smaller raster MEANS for
everything composed on top of it — the post chain, the UI, every post-scene
pass — is renderer.setResolutionScaleMode. The scene rows in
profiler.gpuFrame() are what move.
Parameters
scalenumber—number— fraction of the display resolution, clamped to [0.25, 1].
renderer.setResolutionScale(0.7)
modules/renderer/setResolutionScaleMode
setResolutionScaleMode(mode: string): string
Where in the frame the render scale is resolved — what a smaller raster
MEANS. "present" (the default) composes the whole frame at the raster: the
scene, every post-process layer, the UI and every post-scene pass, carried
up to the size it is shown once it is finished. A smaller raster is then a
smaller picture, so an effect whose output is a function of pixel size — a
dither ladder, a posterize, a pixel grid — resolves at the pitch it was
authored at, and the frame carries one composite resolution throughout.
"reconstruct" carries the scene up to the size it is shown BEFORE the
post-scene phases and composes everything from there, which is what a
temporal upsampler needs: it refines the upscale it is handed and has
nowhere to put the detail it recovers unless the image it accumulates into
is the display's. Either reading is honoured identically whether a viewport
panel or the swapchain shows the frame, so what an editor draws and what a
shipped runtime draws are the same picture of the same scene.
Parameters
modestring—string—"present"or"reconstruct".
renderer.setResolutionScaleMode("present")
modules/renderer/setShadowCaching
setShadowCaching(enabled: boolean): ()
Whether a shadow page that nothing changed is kept rather than drawn again. On by default: every light's pages — the sun's, and each spot, area and point light's — are drawn again only where a caster that changed reaches them. Off, every requested page is invalidated and drawn on every pass, which is what a shadow suspected of holding a stale image is compared against.
Parameters
enabledboolean—boolean
renderer.setShadowCaching(false) -- draw every requested shadow page, every frame
modules/renderer/setShadowCasterCutoff
setShadowCasterCutoff(cfg: {
Set the shadow-caster cutoff. An omitted field keeps its current value,
so a call can adjust one threshold without restating the other. Both are
measured against the camera the frame draws from rather than against each
light, so one setting covers every light's pages, and a
caster that stops casting is one whose shadow the viewer could not have
resolved. maxDistance is measured to the near side of the caster's
bounding sphere, so a large object keeps casting while any part of it is in
range. 0 releases a threshold; releasing both draws the casters the frame
drew before either was set.
renderer.setShadowCasterCutoff({ minRadiusPx = 2 })
renderer.setShadowCasterCutoff({ minRadiusPx = 1.5, maxDistance = 120 })
modules/renderer/setShadowConfig
setShadowConfig(cfg: {
Set the sun's shadow settings. Any omitted field keeps its current
value, so a call can adjust one knob without restating the rest. Values are
clamped: distance >= 0, fadeFraction [0, 1], softness [0, 1]. A distance
of 0 shadows out to the camera's far plane, and a positive one caps it,
which is what a scene bounding its shadow cost states; the sun's clipmap
holds the levels that reach it. punctualMipFloor (a whole number, 0 to
5) caps how fine a spot, area or point light's map renders; it is refused
outside that range, and every punctual light's map is drawn again under a
new floor. detailBias ([-8, 8] levels) trades
shadow detail for pages: each level coarser asks a quarter as many.
budgetMegabytes (>= 1) bounds the depth the pages hold. Each takes
"default" to return to the device's bias or the quality tier's budget,
and a change to either sizes the pool again, which draws every page again.
renderer.setShadowConfig({ softness = 0.65, fadeFraction = 0.28 })
renderer.setShadowConfig({ distance = 240 })
renderer.setShadowConfig({ detailBias = 1, budgetMegabytes = 8 })
renderer.setShadowConfig({ detailBias = "default", budgetMegabytes = "default" })
modules/renderer/setShadowHero
setShadowHero(entity: string, padding: number?): ()
Give one caster a finer sun shadow, in a box around its world bounds.
The sun's virtual shadow map resolves every receiver at the level its
screen footprint selects, so a character standing in the view gets the
texel density every surface at its distance gets. A registered hero widens
its bounds by padding into a box, and every receiver inside it requests
and samples a level renderer.shadowHero().levelBias levels finer — each
level halving the world a texel covers — where that level's window holds
it, crossing back to its footprint's level at the box's edge. Nothing else
about the shadow changes: the same casters reach it through the same
filter.
Parameters
entitystring— The entity whose renderables the box is made around.paddingnumber?(optional) — How much room the box leaves around those bounds — for a pose that leaves the bind-pose box and for the filter that samples outside a silhouette. 1.0 holds them exactly.
local before = time.drawnFrameCount()
renderer.setShadowHero(player.id)
local h = renderer.shadowHero()
while h.frame <= before do
task.waitDrawnFrames(1)
h = renderer.shadowHero()
end
print(("hero shadow: %d levels finer over %.1f units"):format(h.levelBias, h.worldExtent))
modules/renderer/setShadowProxy
setShadowProxy(mesh: string, proxy: string): ()
Rasterize proxy in place of mesh in every shadow page. A shadow is a
silhouette resolved at the resolution of a shadow map, so the triangles that
carry a mesh's close-up detail write depth no reader can resolve — a
decimated version of the shape, a level of its own LOD chain, or a
hand-built hull casts the same shadow for a fraction of the geometry.
The registration is keyed by MESH, so one call covers every instance of it — entities and GPU-driven populations alike — and a crowd sharing that mesh stays one draw. The proxy is placed by whatever places the caster, its instance's own transforms, so it stands where the caster stands, at the caster's scale.
An entity caster keeps its own geometry where a stand-in could not be placed
or deformed correctly: it is skinned (it rasterizes the post-skinned
vertices written for its own mesh), it blends morph targets (whose deltas
describe its own mesh and are read by vertex id), or its proxy would be
placed by a different node of its model than the source mesh is. Either
caster keeps it where the renderer holds no geometry under the proxy's
guid. Each of those is counted in renderer.shadowProxies().
Nothing else in the scene draws a proxy, so this call is what brings it onto the GPU, and it raises where it cannot. A proxy already resident there is registered as it stands.
Parameters
meshstring— The mesh a caster draws, as a guid or any mesh reference.proxystring— The mesh it rasterizes into shadow pages instead.
renderer.setShadowProxy(statueMesh, statueHullMesh)
print(renderer.shadowProxies().triangles, "vs", renderer.shadowProxies().sourceTriangles)
modules/renderer/setSkinnedBatching
setSkinnedBatching(enabled: boolean): ()
Whether skinned instances holding one pose draw together. On by default:
instances of one mesh wearing one material and posed alike read the same
post-skinned vertices, so the camera's colour passes submit them as a single
instanced draw. Off, each
skinned instance draws on its own at its own slot in every pass that
rasterizes it. The image is the same either way, which is what makes this
the comparison a frame suspected of being formed by the batching is made
against — renderer.drawStats().draws counts the difference and
renderer.skinningStats().poses says how many distinct poses it holds.
Parameters
enabledboolean—boolean
renderer.setSkinnedBatching(false) -- a draw per skinned instance
modules/renderer/setSkinningPoseHold
setSkinningPoseHold(enabled: boolean): ()
Whether a pose the skinning pass already wrote is read as it stands. On
by default: the pass produces an instance's vertices from its joint
matrices, its node transforms, its blend weight and its blend model, so the
slice holding a pose already holds what running the pass over those same
inputs would write. A frame binding a pose whose slice still holds it reads
the slice and dispatches nothing, and skinning costs what the frame's poses
CHANGED — a paused clip, a skeleton nothing drives, a cast standing in one
pose, each cost compute the frame the pose arrived and nothing after it.
Off, every pose a frame binds is dispatched again, which is the comparison a
frame suspected of reading a slice that no longer holds its pose is made
against; the image is the same either way and
renderer.skinningStats() counts the difference as dispatches against
held. A mesh whose vertices a compute pass writes is dispatched every
frame however this stands.
Parameters
enabledboolean—boolean
renderer.setSkinningPoseHold(false) -- dispatch every pose, every frame
modules/renderer/setTextureBucketSlack
setTextureBucketSlack(bytes: number?): TextureBucketSlack
Bound the GPU memory texture-array buckets may hold beyond the
textures in them. A bucket without room doubles while the total slack stays
under this budget, and past it grows to the largest capacity whose slack
the budget still holds, at least by what the arrival needs. A growth copies
every layer the bucket held, so a large one that would gain few layers for
what it copies opens another bucket of the same size instead. The default
follows the device (a sixty-fourth of the system's RAM where the GPU draws
from it, otherwise a sixteenth of the memory scale it reports; between
32 MiB and 512 MiB either way); nil restores it. bytes is a positive number of
bytes, 1 or more — 0, a negative number or a non-finite one raises an error
naming that range. A budget bounds the next growth; slack a bucket already
holds stays until a compaction takes it. On the bindless backend no bucket
exists, so the budget is recorded and reads back but bounds nothing. The
textures themselves are bounded by renderer.setTextureBudget; read what
the buckets hold with renderer.materialTable().
Parameters
bytesnumber?(optional) —number?— the slack budget in bytes, or nil for the device's
renderer.setTextureBucketSlack(16 * 1024 * 1024)
renderer.setTextureBucketSlack(nil) -- the device's budget
modules/renderer/setTextureBudget
setTextureBudget(opts: TextureBudgetOpts?): TextureBudget
Bound the VRAM textures occupy, by keeping only the mip levels the
frame is actually sampling once the textures outgrow the budget. Every
device starts at its own budget and a bias of 0. Where the GPU draws from
the system's RAM (every Android phone, an integrated GPU, a software
rasterizer) and the system states how much, the budget is an eighth of
that RAM; otherwise it is half the memory scale the adapter reports;
between 256 MiB and 2 GiB either way, and held to 768 MiB on a
medium-tier and 384 MiB on a low-tier device (renderer.qualityTier()).
renderer.textureStreaming() names the rule (budgetRule) and the RAM it
read (deviceMemoryBytes), and memory pressure narrows what the budget
keeps (renderer.memoryPressure()). Pass
{ megabytes = 256 } to override the budget for the process; megabytes
is a positive number, 1 to 65536, and 0 or a negative number is an error.
A field set to the string "default" returns that one value to the
device's own, a field the table leaves out keeps the value it has, and a
field holding anything else — a boolean, another string — is an error
naming what it holds. nil restores the device's budget and bias
together. The budget belongs to the device the world is played on.
Below the budget every texture keeps its whole mip chain, whatever its
surfaces cover. Mips stream down only while the whole chains of the
streamable textures exceed the budget. Then each frame measures how many
screen pixels ONE traversal of a texture's coordinate range covers on the
surface that spans it widest, and asks for the mip level that serves that
span one texel per pixel — the level the GPU picks from the fragment's own
derivatives. A material with uvScale = 8 lays eight copies of its texture
across a surface, so each copy spans an eighth of the surface and asks for
three levels coarser than the surface's own size would. A shader that
declares // @uv_space: world advances its coordinate over world units
rather than over the mesh's UVs, so how many copies a surface carries
follows how large that surface is. The textures whose surfaces cover the
fewest pixels give up levels until the set fits. Detail climbs one level
per frame, from the image already on screen, so a surface the camera
approaches sharpens rather than popping, and no texture is taken below the
level whose longest side is 64 texels.
bias shifts every measurement by whole mip levels either way — negative
for finer than the sampling implies, positive for coarser — over a look
that wants a different trade than one texel per pixel. It is clamped to
[-8, 8].
The plan moves a texture whose demand the frame can measure: one at least 256 texels on its narrowest side, worn by a surface an entity draws. A texture a UI image, a post-process property or a render feature holds a view of stays whole, because nothing measures how much of the screen those cover.
Which textures the budget governs follows the surfaces the frame draws. A
texture whose asset still holds its bytes is enrolled the frame a measured
surface wears it, whenever it loaded, because a level change reads the
levels it needs back from the asset; when the last such surface goes it
leaves the set whole, at the level it uploaded at, and a surface reaching
it again takes it back up. A texture a script uploaded has its pixels on
the device alone, so it holds no copy while it is at its whole chain; the
first time the budget takes it coarser its chain is read back off the
device before any level is freed, and it holds that copy
(renderer.textureMemory().streamSourceBytes) while it stays coarser.
Once a surface has worn it and gone it leaves the set whole and stays out
for the rest of the process.
renderer.textureMemory().pinnedTextures counts those, together with the
textures whose asset could not be read back and the ones a UI image, a
post-process property or a render feature holds a view of.
Parameters
optsTextureBudgetOpts?(optional) —{ megabytes: (number | "default")?, bias: (number | "default")? }?— nil for the device's budget and bias
renderer.setTextureBudget({ megabytes = 128 })
renderer.setTextureBudget({ megabytes = 128, bias = -1 }) -- one level finer everywhere
renderer.setTextureBudget({ megabytes = "default" }) -- the device's budget, the bias as it stands
renderer.setTextureBudget() -- back to the device's budget and bias
modules/renderer/setTransmissionShadows
setTransmissionShadows(enabled: boolean): ()
Let translucent casters tint the sunlight they block instead of blocking
it outright. A shadow map holds one depth per texel and is compared as a
yes-or-no test, so stained glass, water and thin fabric all project the same
black silhouette a wall does. With this on, a caster whose material declares
transmission draws into a light-space transmittance map instead, and the
colour it lets through multiplies into the directional light reaching
whatever stands behind it. Stacked casters compose. A surface whose
material blends writes no depth shadow at all and throws its shadow through
this map alone: a transparent or premultiplied blend lets 1 - alpha of
the light through untouched and its transmission of the rest tinted by
its base colour, so red stained glass throws red light; a multiply blend
lets its base colour through; an additive one blocks nothing. Opaque
casters are unaffected, and a scene with no translucent caster allocates
nothing and records no pass.
Parameters
enabledboolean—boolean
renderer.setTransmissionShadows(true) -- stained glass tints the floor
modules/renderer/setUpscaleBackend
setUpscaleBackend(backend: string, quality: string?): string
Request a backend for the upscale seam — the step that brings a scene
rendered below display resolution back up to it. "blit" stretches;
"dlss" reconstructs from motion and history through NGX DLSS Super
Resolution on an adapter that has it. The renderer resolves the request
against its own capability and reports the outcome through
renderer.upscaleBackend() — a request for "dlss" on an adapter
renderer.upscaleCapabilities() omits it from resolves to "blit"
there, answered truthfully rather than echoed back here. quality names
the reconstruction quality mode a reconstructing backend derives its
render scale from; the blit keeps whatever renderer.setResolutionScale()
set and reads no value from quality.
@builtin::systems.temporalUpscale.temporalUpscale is the content-facing
surface built on this primitive — it carries the policy this raw setter
carries none of: refusing "dlss" where unavailable, refusing quality
alongside an explicit render scale, and keeping its own reconstruction
from stacking with a reconstructing backend.
Parameters
backendstring—string—"blit"or"dlss".qualitystring?(optional) —string?—"quality" | "balanced" | "performance" | "ultraPerformance", read only by a reconstructing backend.
renderer.setUpscaleBackend("dlss", "balanced")
modules/renderer/setViewportSize
setViewportSize(width: number, height: number): { width: number, height: number }
Draw at this many pixels for the rest of the task that asks. The
engine's drawing surface is resized to it, and everything measured
against that surface follows within a frame: getViewportSize(),
ui.screenSize(), the layout every UI screen rebuilds from it, each
camera's aspect, and what a capture taken in that task encodes. This is
how one session checks a responsive layout at a second shape: a HUD
written against ui.screenSize() is re-laid-out at the new size, so an
anchored element is drawn where that shape puts it rather than scaled
from where the boot size put it.
The size is held for the task that asked for it (an execute call is
one task), and when that task ends, however it ends, the surface goes
back to the size it had before. So a check reads what it needs at the
new shape inside the call that set it, and the window or browser canvas
a person is looking at is handed back as it was. While several tasks
hold a size the surface draws at the one asked for last, and when that
task ends it draws at the size the task before it holds. Asked for
outside any task, from a component's lifecycle, the size stands until
another is asked for.
Who honours the size depends on who owns the surface. A headless engine
and a browser canvas own theirs and are resized exactly; a browser page
that lays its canvas out at a new size meanwhile ends every hold, and the
page's size stands. Where an OS window owns it, the window manager is
asked and has the last word: a tiled or maximized window keeps the size
it has. Read renderer.surfaceSize() on a later frame for what was
realized.
The new size is in force from the NEXT frame, so wait a frame before
reading it back: renderer.surfaceSize() read straight after the call
still reports the size the surface had.
The logical UI space is normalised to about 1280 points wide, so a resize
to a size of the same aspect moves ui.pixelRatio() and leaves
ui.screenSize() where it was, while a resize that changes the aspect
changes that shape too. Both resize the surface.
A size larger than the device draws is refused naming the bound, which
renderer.maxViewportExtent() reports.
Parameters
widthnumber—number— width in pixels, at least 1.heightnumber—number— height in pixels, at least 1.
renderer.setViewportSize(390, 844); task.waitFrames(2); print(ui.screenSize()) -- the phone shape, then the surface goes back when the call ends
modules/renderer/shaderCache
shaderCache(): ShaderCache?
What the shader compile gate's store of baked WGSL held, answered and
wrote back. Compiling a .shader wraps the author's body in its framework,
expands every #include, and hands the result to naga to parse and
validate — work that is a pure function of the text going in, and that a
launch would otherwise repeat for every shader it draws with. The store
keeps that baked text across launches.
restoredEntries and restoredBytes are what a previous launch left that
this one read back. hits counts the compiles answered out of the store
and misses those that ran in full; savedMs sums what each hit's own
recorded compile had cost, against compileMs, what the misses spent.
stale counts the misses whose key was held but whose #included modules
had changed underneath — an entry records every module its expansion
consumed, so editing a module invalidates exactly the shaders that included
it and leaves the rest. The store also keeps each resolve gate pass a
surface shader's resolve module earned, so a launch does not validate the
same resolve text again: verdictHits counts the verdicts answered out of
it and verdictMisses the ones whose gate ran, apart from the compile
counts above.
entries and bytes are what the store now holds, evictions how many a
write dropped to stay inside its bounds, and saves / savedBytes /
dirty describe writing it back, deferred until a burst of compiles
settles. persistent is false where a launch has nowhere to keep
artifacts and reason says why; location is the file, or the browser
store, they are kept in. restoreState is how the read of what a previous
launch left has gone — pending while it is still out (a browser answers
through a promise, so a launch reaches its first frames before it lands),
restored once entries came back, empty when there were none to come
back, failed when what was there could not be read, and none where a
launch keeps nothing. A cold, missing or corrupt store leaves every
shader compiling from source with identical output, and lastError then
names what went wrong.
local c = renderer.shaderCache()
print(("%d hits, %d misses, %.1f ms saved"):format(c.hits, c.misses, c.savedMs))
modules/renderer/shaderCost
shaderCost(): { ShaderCost }
What each program has cost in pipeline builds, beside the compile
gate's most recent word about it. variants is how many pipelines this
engine has built for it — one per (target format, vertex layout,
render-state key) permutation reached — and buildMs what those builds
cost, both summed since engine start. A pipeline the driver's own store
restored is not built and so is not counted, so a second launch on the same
adapter reports less than the first. status is compiled, failed or
pending, and error carries the compiler's message for a failure.
Ordered by cost, most expensive first. shader is the key the program
is registered under; asset names the .shader asset a guid@checksum
key is a version of.
local top = renderer.shaderCost()[1]; print(top.asset or top.shader, top.variants, top.buildMs)
modules/renderer/shaderVariants
shaderVariants(): { ShaderVariants }
Every shader that declares optional features, and the programs its
materials have made it compile. Each row carries the features the shader
declares, the base program it ships as, and one entry per variant with the
features that variant holds — so the permutation count a scene's materials
are spending is a number to read rather than something to infer from
compile time. A shader whose variants reach budget compiles no more; the
materials asking for further feature sets draw with the base program.
for _, s in renderer.shaderVariants() do print(s.shader, #s.variants, s.budget) end
modules/renderer/shadingOf
shadingOf(subject: string | { [string]: any }): ShadingReading
What the renderer is shading ONE subject with, taken from the document
the renderer publishes — the call a system holding a handle makes to find
out whether what reaches the screen is its own material or the magenta
placeholder standing in for it, without reading the engine log. subject is
an entity that draws or the registry key of a material. state reads
itsMaterial where the renderer bound the program the material names,
errorMaterial where it bound the placeholder instead, stalePipeline
where the pipeline drawing it was built before that program's most recent
compile, nothingBound where the renderer resolved no pipeline for it,
pending where this call is the one that armed per-draw recording and the
frame after it publishes, and unknown where the renderer holds a
resolution under no such subject. A fault state carries the renderer's own
reason from the closed set renderer.drawDiagnostics() names — plus
materialNotPrepared, which a material subject reads where the renderer
prepared nothing under that key — the compiler's detail, the program
the material asked for and the bound one; means states the reading in a
sentence. A material subject answers from the renderables drawing with it,
and from the renderer's record for the material itself where a draw
registered against the material carries no row of its own; a subject that
several renderables draw answers with a refused one wherever there is one.
The reading follows the renderer, so a program that compiles on a later
edit puts the subject back on itsMaterial from the frame the renderer
draws it with again.
Parameters
subjectstring | { [string]: any }— The entity — a proxy fromentity(...)or an entity-id string — or the material, as its registry key or theMaterialHandlerenderer.material.createreturned.
local s = renderer.shadingOf(emitter); if s.state ~= "itsMaterial" then print(s.means) end
modules/renderer/shadowCacheStats
shadowCacheStats(): {
What the main camera's newest counted run did with the shadow pages it
asked for, in pages, by the kind of light that owns them. A page is drawn
again only when something it holds changed: its light moved, a caster over
it moved or appeared or vanished, a caster's geometry or material changed,
or the caster changed pose or moved the nodes its parts are placed by.
Anything else keeps the depth already in the pool, so a scene that stops
moving reads rendered 0 while its pages stay cached. A caster moving on
one side of a point light dirties only the pages of the faces it reaches. A
mesh whose vertices a compute pass writes — a population, or a mesh built
from a compute buffer — re-renders the pages it stands over every frame.
spot counts spot and area lights.
These are totals over every light of a kind. renderer.shadowViews() is
the same run one light at a time.
local s = renderer.shadowCacheStats()
print(("shadow pages: %d drawn, %d cached"):format(s.rendered, s.cached))
modules/renderer/shadowCaching
shadowCaching(): boolean
Whether a shadow page may keep the depth it already holds.
modules/renderer/shadowCasterCutoff
shadowCasterCutoff(): ShadowCasterCutoff
How small, and how far away, a caster may get before it stops writing depth into any shadow page. A shadow page rasterizes a caster's whole triangle count whatever the shadow it produces ends up covering, so an object the viewer resolves a fraction of a pixel of, and one past the range the scene cares about, each cost a full depth draw per page it reaches for detail nothing reads. Both thresholds are 0 — released — until something sets them.
local c = renderer.shadowCasterCutoff(); print(c.minRadiusPx, c.maxDistance)
modules/renderer/shadowConfig
shadowConfig(): ShadowConfig
The sun's shadow settings now in force. distance bounds how far from
the camera the sun shadows (the world's render.shadow_distance until
renderer.setShadowConfig sets it); fadeFraction and softness shape
how the shadow is sampled. The sun's virtual shadow map follows each
receiver's screen footprint, so its resolution follows the view.
punctualMipFloor is the finest mip a spot, area or point light's map
renders. detailBias and budgetMegabytes are what a caller stated, or
"default"; what the renderer sized the pages with is
renderer.shadowSizing(). The table is one renderer.setShadowConfig
takes back.
print(renderer.shadowConfig().distance)
modules/renderer/shadowHero
shadowHero(): ShadowHeroReport
The registered hero caster and what the last drawn frame's box was. A
frame that made no box says why in decline.
entity is the live registration; everything else is the box of the
drawn frame frame names, and stands until the renderer draws another.
So a reading taken straight after setShadowHero or clearShadowHero
describes the registration before the call: read the drawn frame count as
the change is made, and take the report once its frame is past it.
local h = renderer.shadowHero()
print(h.active, h.levelBias, h.decline)
local before = time.drawnFrameCount()
renderer.setShadowHero(player.id)
task.waitDrawnFrames(1)
print(renderer.shadowHero().frame > before)
modules/renderer/shadowMemory
shadowMemory(): {
How much GPU memory the virtual shadow map's pools hold right now, in
bytes. One pool serves every light — the sun, and every spot, area and
point light that casts. pool is the depth page pool with the sun's static
cache laid out as it, held while any light casts; transmittance is the
transmittance pool, held while a translucent caster casts into it
(renderer.renderTargets() names them shadow_page_pool,
shadow_static_cache and shadow_transmittance_pool). Both read 0 while
released.
local m = renderer.shadowMemory()
print(("shadows: %.1f MiB"):format(m.total / 1024 / 1024))
modules/renderer/shadowPageBreakdown
shadowPageBreakdown(): { { [string]: any } }
The breakdowns renderer.watchShadowPages gathered since the last call,
oldest first, one per run of the main camera. levels has a row per
clipmap level: texelWorld (world units per texel), the pages it
requested, held (resident), drew (rendered) and had dirtied by the
frame's caster changes (invalidated), the pages those changes reach in its
window (reached) and the smallest size a change projects to there
(smallestRecordTexels). records lists each caster change with its
light-space sizeWorld and, per level, the texels it covers and the
pages it reaches. cull is what the page cull walked (slotsWalked
caster slots, ncMembers casters drawn from their own vertex buffers) and
kept (pairs, casters tested, admitted and cutOff, chunks,
visible clusters, ncPairs, batchPages). pages has a row per batch
page: its level, the casters it drew and how many changed this frame
(dynamicCasters), its chunks, clusters and triangles with the
changed casters' shares, and its pairs of casters drawn from their own
vertex buffers (ncPairs, dynamicNcPairs).
renderer.watchShadowPages(30)
task.wait(1)
for _, run in renderer.shadowPageBreakdown() do print(run.frame, #run.pages) end
modules/renderer/shadowPageStats
shadowPageStats(): {
What the sun's virtual shadow map did on the main camera's newest run
the GPU counted. The sun's shadow lives in pages around the camera; a run
marks the pages the receivers on screen ask for and draws the ones that
are missing or that a moved caster dirtied. A still camera over a still
scene runs nothing, so ran reads false and runs stands still while
frames climbs. The counts come back from the GPU a few frames after the
run, so frame names the frame they describe.
proxyPairs counts the (caster, page) pairs a shadow proxy stood in for,
proxyTriangles the triangles those pairs drew from the proxy and
sourceTriangles what the casters' own meshes would have drawn there.
castersDropped counts the casters drawn outside the cluster lists (a
deforming mesh, a population whose mesh has no cluster set) that the
newest frame could not list, which cast no shadow that frame.
local s = renderer.shadowPageStats()
if s then print(("%d pages asked for, %d drawn"):format(s.requested, s.rendered)) end
modules/renderer/shadowProxies
shadowProxies(): ShadowProxyReport
The shadow proxies in force and what the shadow pages did with them.
triangles and sourceTriangles are what the main camera's newest counted
run submitted through proxies and what the same (caster, page) pairs would
have submitted from the source meshes — the before/after of every
registration, equal while nothing is proxied.
local p = renderer.shadowProxies()
print(("shadow triangles: %d of %d"):format(p.triangles, p.sourceTriangles))
modules/renderer/shadowSizing
shadowSizing(): ShadowSizing
What the sun's virtual shadow map was sized with. Its pool of pages
holds about twice the pages a frame at the render resolution asks for,
within the depth budget (the quality tier's: 64, 12 and 8 MiB at high,
medium and low, or the one renderer.setShadowConfig states). It is sized
again only when the render resolution, the detail bias or the budget
changes. A run that finds no slot for a page it asked for raises
overflowBias by a level, up to 4, until the pool is sized again.
print(renderer.shadowSizing().depthMegabytes)
modules/renderer/shadowViews
shadowViews(): ShadowViewReport?
Every shadow-casting spot, area and point light's virtual shadow map on the main camera's newest counted run, one row each.
renderer.shadowCacheStats() and renderer.shadowPageStats() sum these
counts over every light; this is the same run one light at a time. The
sun's pages are reported by renderer.shadowPageStats().
Each row names its light and says what its pages did: how many its
receivers asked for, how many it holds, how many were drawn, dirtied,
starved or left for a later run, and what the page cull did with the
casters it walked for the light. camera carries the main camera's share
of the instanced-compaction counters.
The counts come back from the GPU a few frames after the run, and frame
names the frame they belong to. A light that stops casting leaves views.
The frame names its lights only while something is reading them, so this call asks the frames after it to publish theirs and waits out the first one. Nil on an engine that renders no frame at all.
local report = renderer.shadowViews()
for _, view in report.views do
print(("%s %d (%s): %d of %d pages resident, %d drawn"):format(
view.role, view.index, view.light, view.pagesResident,
view.pagesRequested, view.pagesRendered))
end
modules/renderer/signalMemoryPressure
signalMemoryPressure(level: string): ()
Report memory pressure the way the system does: the engine releases
what level releases on its next frame, and engine.onMemoryPressure
subscribers hear it with source "script". Content about to need a lot of
memory (a large scene load, a big decode) frees room ahead of it with
this, and "normal" lifts a level a script put in force. level is
"normal", "moderate", "low" or "critical"; anything else is an
error naming the four. Read the outcome with renderer.memoryPressure()
once a frame has passed.
Parameters
levelstring—"normal","moderate","low"or"critical"
renderer.signalMemoryPressure("moderate") -- free unsampled mips before a big load
modules/renderer/skinnedBatching
skinnedBatching(): boolean
Whether skinned instances holding one pose draw together.
modules/renderer/skinningPoseHold
skinningPoseHold(): boolean
Whether a pose already written into its slice skips its dispatch.
modules/renderer/skinningStats
skinningStats(): {
What the last frame's skinned instances cost. A skinned instance is
posed by a compute pass that writes its vertices into a shared pool, and
instances holding the same pose read one slice of that pool and the single
dispatch that fills it. instances is how many were posed, poses how
many distinct poses they held, and dispatches how many dispatches those
poses cost this frame — so a crowd whose members move together costs what
its poses cost rather than what its head count does, while members at
different animation times each hold their own pose and pay for it.
held is how many of the frame's poses cost no dispatch at all. The pass
produces a slice from what the pose is made of, so a slice an earlier frame
filled already holds what running it again would write, and a pose still
wearing that slice is read as it stands. Skinning is paid for by the poses
that CHANGED: a cast standing still reads dispatches 0 beside a held
equal to its poses, and the two add up to poses in any frame. A slice
counts as filled once a render carrying its dispatch has been drawn: the
frame's own view, or a render of the scene into a target, such as a
camera drawing into its render texture. A frame whose view the renderer
declines (a headless one nothing is consuming, a browser behind its GPU)
and that renders the scene into no target records nothing, so a pose that
arrives over such frames is counted in dispatches on each of them and
reads as held from the frame after the first one that records it. A
wait for a crowd to settle is therefore counted in drawn frames
(task.waitDrawnFrames).
reusedSlices is how many of the frame's poses took a slice the pool
already held — one a retired pose gave back, or one a pose nothing has
asked for this frame was holding — rather than one cut from pool the
engine had never used. A scene whose poses keep changing reads a non-zero
count beside a poolBytes that stays where it was.
liveBytes is what the slices holding this frame's poses occupy, against
unsharedBytes — what the same instances would occupy with a slice each.
poolBytes is what the pool holds; a previous-position buffer of the same
size rides alongside it so skinned deformation reaches motion vectors.
The same pass draws a soft body's model through the body's elements (its
cage). cages is how many soft bodies it draws that way, cageBytes what
their buffers occupy, and cageUploads how many of them wrote their
elements' maps to the GPU this frame: a soft body at rest writes nothing,
and a removed one takes its cage with it.
local s = renderer.skinningStats()
print(("%d instances over %d poses"):format(s.instances, s.poses))
print(("%d poses dispatched, %d read as they stood"):format(s.dispatches, s.held))
print(("skinned vertex storage: %d B of an unshared %d B"):format(s.liveBytes, s.unsharedBytes))
modules/renderer/splat.components
splat.components(bytes: any, convention: string?): (SplatComponents?, string?)
Decode a Gaussian splat capture — a Niantic .spz (gzipped or raw) or a
3DGS .ply — into the GPU-ready byte pools a render feature uploads.
records is the packed splat array at recordBytes per splat (position,
log scale, quaternion, DC colour + opacity); sh is the quantized
higher-order spherical-harmonics pool at shStrideWords u32 words per
splat, empty at degree 0. A pure decode (no GPU work): upload the pools with
shaderRef:createBuffer + buf:writeBytes and draw them with a
kind = "splat", channel = "gaussian" pass.
Parameters
bytesany(optional) — Capture bytes —.spzor.ply, as abufferor a binary string.conventionstring?(optional) — Source axis convention:"rightDownFront"(the default, what COLMAP-trained captures use) or"engineNative"for a capture already in engine space.
local c = renderer.splat.components(vfs.read("/source/captures/ceramic.spz"))
modules/renderer/surfaceSize
surfaceSize(): { width: number, height: number }
The whole drawing surface in pixels — the window, the browser canvas
or the headless framebuffer. This is the size renderer.setViewportSize
sets and the size every UI screen is laid out over, so it is what says
whether a resize was realized, on every layout including an editor one
whose viewport panel holds a smaller rect than the window.
{ width = 0, height = 0 } before the first frame has drawn.
local s = renderer.surfaceSize()
modules/renderer/temporal.held
temporal.held(): boolean
Whether a hold is pinning the per-frame clock right now.
if renderer.temporal.held() then print("frame is pinned") end
modules/renderer/temporal.hold
temporal.hold(at: number?, options: TemporalHoldOptions?): () -> ()
Pin the clock every per-frame effect draws itself against, and return
the release. While the hold stands, renderer.temporal.now answers at
instead of the running clock, so film grain and every other field redrawn
each frame is redrawn as the same field. Two renders taken under holds at
the same instant therefore agree pixel for pixel wherever the scene itself
has not moved, which is what makes one frame comparable with another.
Holds nest: the innermost names the instant, and the clock runs again once
the last release is called. Each release takes its own hold off the stack
whatever order the releases come in, so two callers holding at once — two
captures in flight together — each end their own hold and the clock runs
again when both have.
exclusive takes the clock for the owner key the call states: while
that hold stands, a hold is admitted only when it states the same key, and
every other one is refused with an error naming the key and the instant
holding it. That is what lets one caller wind the clock to the second it
means to photograph and keep it there while another agent drives the same
engine. The key is what an owner presents to take a nested hold of its
own, and what renderer.temporal.release hands the clock back by. A
capture taken while the hold stands renders at the held instant, and a
deterministic capture states that key as its own owner option to be
admitted under the hold and photograph the instant it pinned.
Parameters
atnumber?(optional) — The instant to pin the clock at, in seconds. Two holds that state the same instant produce the same field; the default 0 is that shared instant.optionsTemporalHoldOptions?(optional) —owneris the key this hold is taken under, and an exclusive hold states one. A hold that states no key is labelled with the caller the call is attributed to, which names the calling session where the transport attested one and the ZeroMind account otherwise.exclusivetakes the clock for the stated key until the hold is released.
Returns () — A function that releases this hold. Calling it twice releases once.
local release = renderer.temporal.hold() ; local picture = tools.use("capture", "fromPosition", { position = { 0, 2, 8 } }) ; release()
local release = renderer.temporal.hold(46.0, { exclusive = true, owner = "stage-air" })
modules/renderer/temporal.now
temporal.now(): number
The instant a per-frame effect should draw itself at: the innermost hold's instant while one stands, and seconds since boot otherwise. A system that redraws a field every frame reads this rather than the running clock, and a capture asking for a repeatable frame then gets one.
local params = { grainTime = renderer.temporal.now() }
modules/renderer/temporal.onChange
temporal.onChange(listener: (number) -> ()): () -> ()
Register a listener called with the pinned instant whenever it changes — a hold taken, a hold released — and return the unsubscribe. A system whose shader reads the clock out of a GPU buffer registers here, so the buffer carries the pinned instant before the frame that hold was taken on is drawn rather than a frame later.
Parameters
listener(number) -> ()— Called with the instant now in force, in seconds.
Returns () — A function that removes this listener.
local stop = renderer.temporal.onChange(function(t) print("temporal clock", t) end)
modules/renderer/temporal.owner
temporal.owner(): { id: string?, name: string?, at: number, exclusive: boolean }?
The hold naming the instant the clock answers right now: who took it,
what instant it pinned, and whether it took the clock exclusively. Several
agents drive one engine at once and a hold any of them takes moves the
clock every registered field is redrawn against, so this is how a caller
sees that another agent holds it before its own instant is quietly
replaced — and, when exclusive is true, id is the key a hold of its
own states to be admitted, and the key renderer.temporal.release hands
the clock back by. id and name are nil for a hold that stated no key
and that the engine attributes to no agent.
local who = renderer.temporal.owner()
if who ~= nil and who.exclusive then print(who.name, "holds the clock at", who.at) end
modules/renderer/temporal.release
temporal.release(owner: string): number
Hand the clock back by the key its holds were taken under, and report how many came off. A hold stands until its release is called, and the release is a closure the call that took the hold holds: a caller that takes a hold in one call and comes back in another, and a task that ends between the two, both leave the clock pinned with nobody holding a release for it. Naming the key is how the clock runs again, and how a caller refused by an exclusive hold takes one over.
Parameters
ownerstring— The key the holds to release were taken under — whatownerstated when they were taken, whichrenderer.temporal.ownerreports.
renderer.temporal.release("stage-air")
modules/renderer/texture.capture
texture.capture(texture: string | { [string]: any } | AssetRef): string
Request a CPU readback of the GPU texture texture names (e.g. a
camera's rendered output). Returns a result key to pass to a
TextureCpuHandle's :encode() once the readback completes. Takes every form
that names a texture — the TextureHandle create returned, the guid
renderer.texture.list hands out, a TextureCpuHandle or a texture
AssetRef.
Parameters
texturestring | { [string]: any } | AssetRef— The texture to read back — aTextureHandle, a guid, aTextureCpuHandleor a textureAssetRef.
local key = renderer.texture.capture(cameraTarget)
modules/renderer/texture.cpuCreate
texture.cpuCreate(width: number, height: number, fill: any?): TextureCpuHandle
Allocate a blank CPU image (RGBA8) filled with a solid colour and return a
TextureCpuHandle. Compose into it with canvas:blit(src, x, y, w, h), then
canvas:encodeJpeg() / :encodePng() for the bytes; :unload() drops it.
Parameters
widthnumber— number Canvas width in pixels.heightnumber— number Canvas height in pixels.fillany?(optional) — Optional{ r, g, b, a }(0-255) solid fill; defaults to opaque white.
local c = renderer.texture.cpuCreate(1024, 576, { 255, 255, 255, 255 })
modules/renderer/texture.cpuFromBytes
texture.cpuFromBytes(bytes: buffer | string, encodeOpts: any?): TextureCpuHandle
Load engine-native ZTEX bytes — or an encoded image (png / jpg / webp)
— into the CPU store under a fresh guid and answer the CPU handle, for
pixels that come from somewhere other than a texture asset: a data.ztex
read as a file, a payload held in memory. The pixels stay at the format
they were encoded in. DEFAULT: handle:unload() once done with them.
Parameters
bytesbuffer | string— The ZTEX or image bytes.encodeOptsany?(optional) —{ colorSpace?, compression?, generateMipmaps?, maxDimension?, filter?, textureType?, alpha?, alphaIsTransparency? }— the optsrenderer.texture.encodeFromImagetakes — applied when the bytes are an encoded image and need the engine-native encode.maxDimensionbounds ZTEX bytes too: a payload that stores a mip chain is read from the first level whose longest side is within it, that level alone, so a thumbnail of a 4096² texture decodes a level near the thumbnail's size.
local cpu = renderer.texture.cpuFromBytes(assert(vfs.read(path))); local png = cpu:encodePng(); cpu:unload()
local thumb = renderer.texture.cpuFromBytes(assert(vfs.read(texPath .. "/data.ztex")), { maxDimension = 256 })
modules/renderer/texture.create
texture.create(src: any, guid: string?): TextureHandle
Create (or fetch) a GPU texture resource and return its TextureHandle.
src: a TextureCpuHandle from texRef:load() (CPU→GPU under the asset's
guid, idempotent); raw pixels {rgba, width, height, srgb?, format?} (a
flat widthheight4 byte payload, 0-255, row-major, top-to-bottom, RGBA —
a buffer, a binary string, or a number array; format = "rgba16f"
uploads an HDR texture instead, where rgba carries float channel
values); a TextureHandle (returned as-is);
or render-target dimensions {width, height, name?, format?} with no pixel
source — an empty GPU texture a render pass writes into (camera output,
UI surface) and that samples like any other texture. format names the
colour format the target is allocated in, and the passes drawing into it
are built for that format: "rgba8unorm" / "bgra8unorm" (the two
eight-bit channel orders, either of which a surface may carry),
"rgba16f" / "rgba32f", "rg16f" / "rg32f", "r16f" / "r32f".
Each also answers to its spelled-out width ("rgba16float", "r32float",
and so on), in any case. Omit it and a screen target takes the scene's
own format ("rgba16f") — a screen-sized target holds a picture of the
scene, and that is the format the scene is held in: linear light with
headroom above the display's white and no 256-step floor under a dark
gradient. A target that is not screen-sized and names no format takes the
surface's. "rgba8" is what a mask, a weight or an occlusion term asks
for, where 0..1 is the whole range; hand one back over @scene.color and
the frame loses every highlight above white and bands every gradient, and
the engine says so in the log. A float format carries what eight bits
quantize — positions, velocities, HDR. Any other
format raises an error naming every name that works, so a target is
allocated in the format it was asked for or not at all. A render target
takes filter the way raw pixels do: "nearest" keeps its own pixels square
wherever something draws it larger than it is — a viewport widget, a
magnified capture — which is what an image whose pixels ARE the subject
needs, since a 64x32 panel holds no detail between its pixels to
interpolate; "linear" (the default) smooths between them. It also
takes screen (the engine keeps it the size of the image being drawn),
screenScale (the fraction of that size it takes) and screenSpace
("scene", the default, or "composite" — the image the post-scene
phases draw into, which is the display's own resolution while the renderer
presents the viewport itself and the scene's size while a UI viewport panel
owns the presentation). A scene-space target is resized for every render
target drawn and cleared before an offscreen one; a composite-space target
follows the presented frame alone, which is what lets a pass keep an
accumulation in it. One scene-space screen target is therefore one
resource every render target draws through in turn, so its guid holds the
last one's image at the last one's size, and a value read back from it
belongs to whichever render target was drawn last. A screen target a
live Camera draws into is that camera's output instead: the frame's other
render targets neither resize nor clear it, so what the camera drew there
stays for as long as the camera does. A reading that has to
be the viewport's own comes from screenSpace = "composite", or from a
target created without screen. history = true makes a history target
instead, the target an accumulation across frames lives in: it is
screen-sized and keeps one pair of images per view a frame draws (the
viewport, every render-to-texture camera, every capture). For the length
of each view's render, the handle's guid names the image that render
writes and previous.guid the image that view's previous render wrote, so
a pass binds the two like any other targets and reads its own view's
history wherever it runs; no other view resizes, clears or overwrites
them. Before each render of a view the engine writes the compute buffer
named by the handle's state (one vec4<f32>, bound through a pass's
buffers): x is 1 when previous holds that view's previous image and
0 when it does not (the view's first render, its first after a cut or a
change of size, or a render of the view that ran without the target, and
then previous reads transparent black), y how many renders in a row
have carried the history, zw the render's sub-pixel projection offset in
pixels (renderer.setProjectionJitter). A view's images are freed when
the view stops drawing, and all of them with the handle. NEVER takes an
AssetRef — load the CPU first.
Parameters
srcany(optional) — A TextureCpuHandle, raw pixels, a TextureHandle, or render-target dimensions.guidstring?(optional) — Optional v4 guid for a NEW runtime texture — the asset identity the texture is filed under, which a material's texture slot resolves through. Minted when absent. Ignored for the CPU-handle and render-target paths.
local gpu = renderer.texture.create(texRef:load())
local gpu = renderer.texture.create({ rgba = pixels, width = 16, height = 16 })
local px = buffer.create(16 * 16 * 4); local gpu = renderer.texture.create({ rgba = px, width = 16, height = 16 })
local rt = renderer.texture.create({ width = 512, height = 256, name = "panel_rt" })
local hdr = renderer.texture.create({ width = 512, height = 256, name = "cam_rt", format = "rgba16f" })
local led = renderer.texture.create({ width = 64, height = 32, name = "panel", filter = "nearest" })
local hist = renderer.texture.create({ width = 1, height = 1, history = true, name = "accum" })
modules/renderer/texture.createFromAsset
texture.createFromAsset(
Put a .texture asset on the GPU under its own guid and answer its
handle at once. The asset's bytes are decoded off the frame and the
texture lands on the device when the decode finishes, a frame or more
later: a material naming the guid draws the shader's default for that
slot until then and rebinds when it arrives, and
renderer.texture.isResident reports the arrival. The decoded pixels are
dropped once uploaded unless keepCpu holds them in the CPU store for
textureRef:load()-style reads. An asset the device already holds is
answered from the shape the device reports, without reading the asset's
bytes and without a second decode. An asset whose bytes have not arrived
here yet, asked for by code that cannot wait for them (onPropertyChanged,
a metamethod, any place coroutine.isyieldable() is false), is answered a
handle sized 0x0 at once: a task reads the bytes and decodes them, the
texture lands under the asset's guid as above, and the handle takes the
decoded size when the decode is scheduled.
local h = renderer.texture.createFromAsset(texRef) -- bind h.guid on a material; it draws once resident
modules/renderer/texture.decode
texture.decode(bytes: buffer | string, opts: { straightAlpha: boolean? }?): (any, any, any, any)
Decode a texture payload to its pixel buffer. Takes the two shapes the renderer's own texture loader takes, told apart by their leading bytes:
- an engine-native
ZTEXpayload — handed back at the texel format the payload was written in, so a height field read back here keeps every bit it was authored with. AZTEXholding block-compressed or verbatim source-image levels decodes to"rgba8". - source image bytes — png, jpeg, gif or webp, straight off disk or out of
a
capture— decoded to"rgba8"at whatever colour type, bit depth or interlacing the file was written with. This is the call that reads the pixels of a screenshot.
The fourth return names the format the buffer came back in: "rgba8" (4
bytes/texel, channels 0-255), "rgba16" (8 bytes/texel, 16-bit unsigned
normalized channels 0-65535) or "rgba32f" (16 bytes/texel, float
channels).
The pixels are the texels the payload stores. With opts.straightAlpha = true, a payload encoded with alpha = "premultiplied" has its colour
divided back by alpha, in the colour space it was premultiplied in — the
straight-alpha pixels renderer.texture.encode takes. A texel whose alpha
is 0 keeps the black premultiplying left in it.
Parameters
bytesbuffer | string— AZTEXpayload or source image bytes.opts{ straightAlpha: boolean? }?(optional) —{ straightAlpha? }
local pixels, w, h = renderer.texture.decode(vfs.read("/source/tmp/shot.png"))
local straight = renderer.texture.decode(vfs.read(texPath .. "/data.ztex"), { straightAlpha = true })
modules/renderer/texture.destroy
texture.destroy(texture: string | { [string]: any } | AssetRef): boolean
Release the GPU texture texture names. For an empty render-into texture
(camera output, UI surface) this also frees its render scratch; for an
uploaded runtime texture it drops the GPU resource (and any CPU shadow).
After this, renderer.texture.list stops answering for the guid. Takes
every form that names a texture — the TextureHandle create returned, the
guid the listing hands out, a TextureCpuHandle or a texture AssetRef.
Parameters
texturestring | { [string]: any } | AssetRef— The texture to release — aTextureHandle, a guid, aTextureCpuHandleor a textureAssetRef.
renderer.texture.destroy(rt)
renderer.texture.destroy(renderer.texture.list()[1].guid)
modules/renderer/texture.encode
texture.encode(rgba: any, width: number, height: number, opts: any): (string?, string?)
Encode raw pixels into an engine-native ZTEX payload (the on-disk
texture content). The CPU codec behind the texture assetType's onCreate.
Called from a task (an execute chunk, a component hook the engine lets
wait, task.spawn), a "uastc" or "bc7" encode runs where the frame loop keeps
stepping: on a worker where the build has one, and otherwise a bounded
slice of its blocks per frame (__texture.encodeBudget, reported by
__texture.encodeJobs). The call returns on the frame the payload lands.
Code that cannot yield, and a coroutine the script resumes itself
(coroutine.create / coroutine.wrap), encode in place, and every other
compression is encoded on the call. The payload is the same bytes either
way.
opts.compression selects what the texels are stored as: "rgba8"
(default, 8 bits/channel, rgba is widthheight4 bytes), "uastc"
(UASTC 4x4 blocks, a quarter of the RGBA8 size, transcoded on each device
to the block format it holds; rgba is widthheight4 bytes and each
side is resampled to the nearest power of two, halfway rounding up),
"bc7" (BC7 blocks, a quarter of the RGBA8 size; rgba is still
widthheight4 bytes and both sides a multiple of 4) or the high-precision data compressions
"rgba16" (16-bit unsigned normalized, widthheight8 bytes) /
"rgba32f" (32-bit float, widthheight16 bytes) — for height/displacement
fields, baked lightmaps, and other data rasters 8 bits quantize visibly.
The two high-precision compressions store rgba verbatim, reject
opts.generateMipmaps / opts.maxDimension, and take opts.colorSpace = "linear" only. opts.colorSpace is "srgb" (default, colour data) or
"linear" (normal maps, masks, heights). opts.input ("rgba8" /
"rgba16" / "rgba32f") names the texel format rgba arrives in when it
is not the one opts.compression stores — the pixels
renderer.texture.decode hands back at their own width, say — and the
encoder carries each channel across as the same normalized value,
natively, before storing it.
opts.textureType records what the texture holds — "color"
(default), "normalMap" (when the encode generates mips, every level
of the chain, the base included, is renormalised to unit length),
"mask" or "sprite".
opts.alpha is what the encode does to alpha: "input" (default, kept
as given), "premultiplied" (RGB multiplied by alpha — in linear light
under srgb, as stored under linear — the source a material with the
premultiplied blend mode composites) or "none" (every texel opaque, RGB
kept). opts.alphaIsTransparency = true fills each fully transparent
texel with the average colour of its non-transparent neighbours,
spreading outward, alpha kept at 0 — before the alpha mode and the mips,
so filtering never pulls black into an edge. All three are recorded in
the payload and reported by renderer.texture.info.
The sampler opts are recorded the same way: opts.filter ("linear",
the default, or "nearest"), opts.wrapU / opts.wrapV ("repeat", the
default, "clamp" or "mirror" — how the texture is sampled past its
edges) and opts.anisotropy ("world", the default, following the
world's render.anisotropy, or a fixed "1" / "2" / "4" / "8" /
"16", also taken as the number). opts.effort ("fastest", the default,
"fast" or "thorough") is how long a uastc encode searches for each
block: every effort writes a payload the same size on the GPU, and a
higher one lands closer to the source. opts.uastcRdo ("none", the
default, "low", "medium" or "high") is how strongly a uastc encode
trades accuracy for a payload that compresses smaller. A block-compressed
encode (uastc, bc7) called from a task that can yield runs off the frame
and the task waits for it, so the world keeps running while it cooks.
Parameters
rgbaany(optional) — Pixel payload atopts.input's (elseopts.compression's) native byte width — abuffer, a binary string, or a number array.widthnumber— numberheightnumber— numberoptsany(optional) —{ colorSpace?, compression?, uastcRdo?, generateMipmaps?, maxDimension?, filter?, wrapU?, wrapV?, anisotropy?, textureType?, alpha?, alphaIsTransparency?, input? }
modules/renderer/texture.encodeFromImage
texture.encodeFromImage(bytes: buffer | string, opts: any): (string?, string?)
Encode source image bytes (png/jpg/webp/…) into an engine-native ZTEX
payload. Used by the texture importer / assetType onChange. A "uastc"
or "bc7" encode called from code that can yield runs where the frame
loop keeps stepping, as renderer.texture.encode describes.
opts.compression is "rgba8" (default), "uastc", "bc7", "rgba16"
or "rgba32f", opts.colorSpace "srgb" (default) or "linear", and
opts.uastcRdo as renderer.texture.encode takes it. "rgba8" with
generateMipmaps = false, a maxDimension the image fits within (or
none), alpha = "input" and no alphaIsTransparency stores the source
image bytes verbatim.
"rgba16" and "rgba32f" decode a still image at its own bit depth and
store one linear level: a 16-bit PNG keeps every bit, an 8-bit channel v
is stored as v * 257 (rgba16) or v / 255 (rgba32f). The frames of an
animated image (GIF, APNG, animated WebP) are decoded at 8 bits, so a
16-bit APNG's frames are stored as v * 257 of their 8-bit values. Like
encode, they
reject opts.generateMipmaps and a maxDimension the image exceeds.
opts.textureType records what the texture holds — "color"
(default), "normalMap" (when the encode generates mips, every level
of the chain, the base included, is renormalised to unit length),
"mask" or "sprite".
opts.alpha is what the encode does to alpha: "input" (default, kept
as given), "premultiplied" (RGB multiplied by alpha — in linear light
under srgb, as stored under linear — the source a material with the
premultiplied blend mode composites) or "none" (every texel opaque, RGB
kept). opts.alphaIsTransparency = true fills each fully transparent
texel with the average colour of its non-transparent neighbours,
spreading outward, alpha kept at 0 — before the alpha mode and the mips,
so filtering never pulls black into an edge. All three are recorded in
the payload and reported by renderer.texture.info, as are the sampler
opts filter, wrapU, wrapV and anisotropy, which take the values
renderer.texture.encode takes.
Parameters
bytesbuffer | string— source image bytes.optsany(optional) —{ colorSpace?, compression?, uastcRdo?, generateMipmaps?, maxDimension?, filter?, wrapU?, wrapV?, anisotropy?, textureType?, alpha?, alphaIsTransparency? }
modules/renderer/texture.frameSchedule
texture.frameSchedule(texture: string | AssetRef): { number }?
The times at which each layer of a timed texture stops being shown, in seconds from the start of the sequence — the running total of the layer display times, so the last entry is the length of one pass.
This is the form a sampler reads a sequence through: a time is turned into
a layer by finding the first entry it has not passed, whatever the
individual layer times are. It is what the schedule slot of the builtin
animatedTexture shader holds, one entry per layer.
A texture whose layers carry no timing — a still image, a sprite sheet, a LUT stack — has no schedule and answers nil.
Parameters
texturestring | AssetRef— The texture — a guid, an identity, a name, a path, or a textureAssetRef.
local ends = renderer.texture.frameSchedule(texRef) -- {0.1, 0.15, 0.35}
modules/renderer/texture.info
texture.info(ztex: buffer | string): (any, any)
Read the header of an engine-native ZTEX payload without copying the
pixels. Returns its format, its compression ("rgba8", "bc7", "rgba16"
or "rgba32f" — what the texels are stored as) and colorSpace ("srgb" or
"linear" — how they are read when sampled), dimensions, mip count,
the sampler recorded in the payload from the asset's settings — filter
("nearest" or "linear"), wrapU and wrapV ("repeat", "clamp" or
"mirror") and anisotropy ("world", or a fixed "1" / "2" / "4" / "8" /
"16"); a payload written before wrap and anisotropy were recorded reads
repeat / repeat / world — what the payload was encoded as —
textureType ("color", "normalMap", "mask" or "sprite"), alpha
("input", "premultiplied" or "none") and alphaIsTransparency (boolean);
a payload written before these were recorded reads color / input /
false — and the payload's layer shape.
layers counts the array layers the payload carries and isArray is true
past one — the answer to "am I about to sample a texture_2d_array?",
available before anything samples it. animated is true when those layers
are a sequence in time; then frameDelaysMs lists each layer's display
time in milliseconds in display order, and durationMs totals one pass.
An animated image imports as one layer per frame, so layers is its frame
count. A still texture reports layers = 1, isArray = false.
Parameters
ztexbuffer | string— ZTEX bytes.
local i = renderer.texture.info(bytes); if i.animated then print(i.layers, "frames", i.durationMs, "ms") end
modules/renderer/texture.isCpuResident
texture.isCpuResident(texture: string | { [string]: any } | AssetRef): boolean
True if this texture has a resident CPU copy in the guid-keyed CPU store.
Parameters
texturestring | { [string]: any } | AssetRef— The texture — aTextureHandle, aTextureCpuHandle, a guid, or a textureAssetRef.
if renderer.texture.isCpuResident(handle) then ... end
modules/renderer/texture.isResident
texture.isResident(texture: string | { [string]: any } | AssetRef): boolean
True if a GPU texture is resident under this texture's guid.
Parameters
texturestring | { [string]: any } | AssetRef— The texture — aTextureHandle, aTextureCpuHandle, a guid, or a textureAssetRef.
print(renderer.texture.isResident(handle))
modules/renderer/texture.keepCpuOnLanding
texture.keepCpuOnLanding(texture: string | { [string]: any } | AssetRef, keep: boolean): boolean
Set whether the decode on its way to this texture — scheduled by
textureRef:handle() or renderer.texture.createFromAsset and not yet on
the device — keeps its decoded pixels in the CPU store once it lands. A
texture's keepCpu setting changing while its decode is in flight reaches
the texture through this.
Parameters
texturestring | { [string]: any } | AssetRef— The texture — aTextureHandle, aTextureCpuHandle, a guid, or a textureAssetRef.keepboolean— Keep the CPU copy once the decode lands.
renderer.texture.keepCpuOnLanding(texRef, true)
modules/renderer/texture.list
texture.list(): { any }
Every texture currently registered, ordered by guid — the ones a script
created and the ones that reached the device through an asset alike. Each
entry carries the guid, where it came from (origin is "asset" for a
texture the asset path uploaded), and whether the GPU still holds it. A
resident entry also carries the bytes it costs, its dimensions, its
texel format and the mip levels the device holds (mipLevels), so the
listing sums to renderer.textureMemory(). A streamable one carries
streamOrigin — "asset" when a level change reads the levels it needs
back from the asset, "device" when no asset answers for it and its whole
chain on the device is the only copy, "retained" when it is resident
coarser and holds the levels read back off the device.
A resident entry carries how a material binding it samples it, as the
texture records it: filter ("linear" / "nearest"), wrapU and
wrapV ("repeat" / "clamp" / "mirror") and anisotropy
("world" or a fixed "1".."16"), and samplerAnisotropy, the level
the texture's sampler takes: anisotropy resolved against
renderer.anisotropy() and the device's ceiling, and 1 for a nearest
texture — the entry of the renderer's sampler table the texture's
handle names.
A script-created entry also carries held — whether renderer.hold pins
it for the session — and scene, the load that created it.
renderer.references("texture", guid) says what is still holding a row,
and renderer.collect() releases the rows nothing holds.
for _, t in ipairs(renderer.texture.list()) do print(t.guid, t.bytes) end
modules/renderer/texture.loadCpu
texture.loadCpu(
Load a .texture asset's pixels into the ONE guid-keyed CPU store (the
Disk→CPU step) and return a CPU handle for per-pixel access (no GPU
readback). The handle holds NO pixels — only the guid, dims and texel
format plus the read/write/encode/unload ops (which read the Rust store).
The pixels stay at the format they were authored in: handle.format is
"rgba8", "rgba16" or "rgba32f", and :readPixel reports channels in
that format's own units. Called by texRef:load(). DEFAULT: upload to the
GPU then handle:unload().
local cpu = texRef:load(); local r,g,b,a = cpu:readPixel(3, 4); cpu:unload()
modules/renderer/texture.readback
texture.readback(texture: string | { [string]: any } | AssetRef): TextureCpuHandle
Read a runtime GPU texture's pixels back to CPU and return a
TextureCpuHandle for them — the GPU→CPU half of the runtime-texture freeze
path. A texture made with renderer.texture.create keeps no CPU copy, so
persisting it (:encode() → asset.create("texture", …)) reads it back
here first. Yields until the readback completes (a frame or two). After it
returns the pixels are resident in the guid-keyed CPU store: :readPixel,
:writePixel, :getInfo, :encode, :unload all work. Errors if the
texture never becomes GPU-resident.
A SCENE-space screen-sized render target is one resource shared by every
render target drawn — the viewport, an offscreen capture, a camera
rendering into a texture — resized and re-derived for each of them in
turn. The copy is taken ahead of all of them for the frame, so what a
readback of its guid answers is the content of the last frame the renderer
drew: the presented view's own image at the presented resolution, since
the presented view is the sink that draws last. A request made while the
renderer is holding frames back is carried to the next frame it draws
rather than being answered from a target another sink left standing, so a
readback can wait a frame longer than the copy itself takes.
Parameters
texturestring | { [string]: any } | AssetRef— The texture — theTextureHandlerenderer.texture.createreturned, a guid, or a textureAssetRef.
local cpu = renderer.texture.readback(handle); local ztex = cpu:encode(); cpu:unload()
modules/renderer/texture.reencode
texture.reencode(ztex: buffer | string, opts: any): (string?, string?)
Re-encode an engine-native ZTEX payload against new opts. A "uastc"
or "bc7" re-encode called from code that can yield runs where the frame
loop keeps stepping, as renderer.texture.encode describes. opts is
the complete encode spec, exactly as for renderer.texture.encode: every
field it leaves out takes its default, so textureType, alpha,
alphaIsTransparency, filter, wrapU, wrapV and anisotropy come
from opts — not from the payload's header — and a payload re-encoded
with { compression = "uastc" } alone loses a nearest filter or a
premultiplied alpha it carried. renderer.texture.withSampler changes
how a payload is sampled without re-encoding it. The
payload's layers and their display times are kept, whatever compression
either side is in. Each layer's texels are read back with straight alpha (a payload
encoded with alpha = "premultiplied" has its colour divided back by
alpha), carried to the width the new compression stores as the same
normalized value, and encoded exactly as renderer.texture.encode would
encode them; a payload that embeds its source image is re-encoded from
that image, read at its own bit depth. What an earlier encode discarded
stays discarded: after alpha = "none" the alpha is opaque. The texture
assetType re-encodes a container that holds no source image through this
call when its settings change. A block-compressed encode called from a
task that can yield runs off the frame while the task waits.
Parameters
ztexbuffer | string— AZTEXpayload — abufferor a binary string.optsany(optional) —{ colorSpace?, compression?, uastcRdo?, generateMipmaps?, maxDimension?, filter?, wrapU?, wrapV?, anisotropy?, textureType?, alpha?, alphaIsTransparency? }
local wide = renderer.texture.reencode(vfs.read(texPath .. "/data.ztex"), { compression = "rgba16", colorSpace = "linear", generateMipmaps = false })
modules/renderer/texture.tone
texture.tone(histogram: any): TextureTone
Reduce a histogram to what the picture's tone IS: where its darkest and brightest pixels sit, where the body of it sits, and how much of it is standing on the floor or the ceiling — all in code values on the 0-255 scale the pixels were delivered at.
span (max - min) is the whole range including a single stray pixel;
spread (p95 - p5) is the range the body of the picture occupies, which
is the reading that says whether a shot is legible. A frame whose subject is
modelled and shaded but delivered inside a few code values reads a large
mean and a tiny spread, and no mean alone can tell that apart from a
frame with a subject in it.
crushed and clipped are the shares of the picture at code 0 and at code
255, each 0..1 — what a shot loses to the floor and to the ceiling.
Parameters
histogramany(optional) — A histogram fromcpu:histogram().
local t = cpu:tone(); if t.spread < 24 then error("the shot is flat") end
modules/renderer/texture.unloadCpu
texture.unloadCpu(texture: string | { [string]: any } | AssetRef)
Drop this texture's resident CPU copy from the guid-keyed CPU store.
The explicit release for a texture asset's keepCpu setting turning off.
Parameters
texturestring | { [string]: any } | AssetRef— The texture — aTextureHandle, aTextureCpuHandle, a guid, or a textureAssetRef.
renderer.texture.unloadCpu(texRef)
modules/renderer/texture.update
texture.update(texture: string | { [string]: any } | AssetRef, src: any): TextureHandle
Overwrite the GPU texture texture names IN PLACE, under the same guid,
from new pixels. Never writes a .texture file — the play-mode mutate
path. Takes every form that names a texture — the TextureHandle create
returned, the guid renderer.texture.list hands out, a TextureCpuHandle
or a texture AssetRef. src is raw pixels, or a TextureCpuHandle
(texRef:load(), renderer.texture.loadCpu, renderer.texture.readback),
whose pixels arrive with everything they carry: texel format, colour
space, mip chain, layers and filter. Every material, UI image and
post-process effect sampling the guid draws the new texture. Returns a
handle carrying the new dimensions: the handle it was given, refreshed,
and a handle over the guid otherwise.
Parameters
texturestring | { [string]: any } | AssetRef— The texture to update — aTextureHandle, a guid, aTextureCpuHandleor a textureAssetRef.srcany(optional) — New raw pixels{rgba, width, height, srgb?, format?}—rgbaas abuffer, a binary string, or a number array — or aTextureCpuHandle.
modules/renderer/texture.withSampler
texture.withSampler(ztex: buffer | string, opts: { filter: string?, wrapU: string?, wrapV: string?, anisotropy: (string | number)? }): (string?, string?)
Change how an engine-native ZTEX payload is sampled without
re-encoding it. opts names any of filter ("linear" / "nearest"),
wrapU and wrapV ("repeat" / "clamp" / "mirror") and anisotropy
("world", or "1" / "2" / "4" / "8" / "16", also taken as the
number); a field it omits keeps the payload's value. The result is the
same bytes with only the sampler bits of the header replaced, so every
level is byte-identical to the input — the cheap path the texture
assetType takes when a settings change touches only these four fields.
An unrecognised value raises.
Parameters
ztexbuffer | string— AZTEXpayload — abufferor a binary string.opts{ filter: string?, wrapU: string?, wrapV: string?, anisotropy: (string | number)? }—{ filter?, wrapU?, wrapV?, anisotropy? }
local clamped = renderer.texture.withSampler(vfs.read(texPath .. "/data.ztex"), { wrapU = "clamp", wrapV = "clamp" })
modules/renderer/textureMemory
textureMemory(): {
What the GPU texture cache holds, split by whether the texture is
block-compressed. compressedBytes and uncompressedBytes are what those
textures cost in VRAM, measured from each texture's own format and mip
chain — so a .texture whose settings name compression = "uastc" appears in the
compressed columns at a quarter of what the same image costs as RGBA8.
blockCompressionSupported is whether this adapter samples any
block-compressed format; where it is false a block-compressed payload is
uploaded decoded and lands in the uncompressed columns instead, so the
texture is present everywhere and compressed where the hardware allows it.
blockFormat names the format block-compressed textures are resident in
on this adapter ("bc7" on desktop, "astc4x4" on a phone, "etc2" on
a phone without ASTC) and is nil where it samples none. A texture stored
as UASTC is transcoded to blockFormat; one stored as BC7 keeps its
blocks where the adapter samples BC7 and is re-encoded into blockFormat
where it does not, each at the same one byte per texel.
Measured at the end of the last rendered frame.
streamableTextures is how many of them the texture budget can move the
base mip level of, split by where a level change reads the levels it needs
from: assetStreamedTextures are read back from the asset they came from
and hold nothing in system memory; the rest no asset answers for, so the
device holds their only copy. Such a texture holds no copy of its own while
it is at its whole mip chain; the first time the budget takes it coarser
its chain is read back off the device before any level is freed, and it
holds that copy while it stays coarser. retainedTextures counts the ones
holding a copy, and streamSourceBytes is what those copies occupy in
system memory — bytes that are not VRAM. pinnedTextures counts the
textures big enough to stream that stand at a level nothing can move: no
asset answers for them and they left the streamable set, the asset behind
them could not be read back, or a UI image, a post-process property or a
render feature holds a view of them.
A texture out of the streamable set only because no measured surface wears
it stands in neither count: a surface reaching it takes it back up, so its
level moves again as soon as there is a footprint to move it by.
byFormat names every GPU format a cached texture is held in, keyed by
the format's name (Bc7RgbaUnormSrgb, Astc { block: B4x4, .. },
Rgba8UnormSrgb, ...), with how many textures it holds and their bytes.
heldAboveCap lists the textures resident larger than
renderer.setMaxTextureSize allows: one whose mip chain has no level
within the cap, and one with no asset behind it, which keeps every level
it was made with. decodedFallback lists the
UASTC textures this device holds as texels because it samples no block
format.
local tm = renderer.textureMemory()
print(("%d compressed textures hold %.1f MiB"):format(tm.compressedTextures, tm.compressedBytes / 1048576))
print(("%d textures stream from their asset, %d hold %.1f MiB of pixels"):format(
tm.assetStreamedTextures, tm.retainedTextures, tm.streamSourceBytes / 1048576))
modules/renderer/textureStreaming
textureStreaming(): TextureStreaming
What the last frame's texture-residency plan decided. budgetBytes is
the budget in force: the device's own, or the one setTextureBudget
names, as much of it as the memory pressure in force leaves (half at
"critical"). deviceBudgetBytes is the device's own budget (what
setTextureBudget names deviceMegabytes): memoryBudgetBytes, held to
the quality tier's cap where the tier states one. memoryBudgetBytes is
what the device's memory affords and budgetRule the rule it came from:
"systemMemory", an eighth of the RAM the system states
(deviceMemoryBytes, nil where it states none), on a GPU that draws from
that RAM, or "bufferSize", half the adapter's max_buffer_size; between
256 MiB and 2 GiB either way. pressure is the memory pressure level in force; from
"moderate" up the plan holds every texture at the level its surfaces
sample, below the budget as well as past it (renderer.memoryPressure()).
streamable is how many textures the plan can move.
residentBytes is what those textures occupy now, measured from the
textures that are allocated; demandedBytes is what the frame asks for
before the sweep — every texture's whole chain while those fit the budget,
and the level each surface asked for once they exceed it — so the two part
exactly where the budget is doing something. starved counts the textures left
coarser than the frame asked for, promoted the ones that climbed a level
this frame, and changed the ones whose GPU texture was replaced. A camera
approaching a surface reads promoted above zero for a few frames and then
zero once it settles.
textures is one row per streamable texture, ordered by key, carrying the
level each one was asked for and the measurement that asked. Two byte
totals can agree while a single texture sits several levels off what its
surface samples, so read the row when the question is which level a texture
holds and why.
local ts = renderer.textureStreaming()
print(("textures: %.1f MiB resident of %.1f MiB demanded, %d starved"):format(
ts.residentBytes / 1048576, ts.demandedBytes / 1048576, ts.starved))
modules/renderer/transmissionShadows
transmissionShadows(): boolean
Whether translucent casters tint the directional light they block.
modules/renderer/uploadStats
uploadStats(): {
What the last frame the renderer drew spent re-describing its
renderables to the GPU, counted from the frame it drew before that, so a
read after task.waitDrawnFrames describes the frame waited for even where
the frame pacer declines frames between two drawn ones. Every renderable
owns a slot in the per-instance data a draw reads (its world matrix, the
bounds the culler tests it by, and the flags that decide which passes and
which culling stages see it), and a frame uploads
only the slots whose contents changed. A renderer.mesh.drawInstanced
population's slots are filled by copies from its own buffers, counted the
same way: a frame that copies a population's transforms or shader data
counts one write per copy and the bytes it moved. bytes is what those
uploads and copies carried, fullBytes what re-sending every slot would
have cost, and writes how many buffer writes carried it. The three numbers
cover that per-renderable data alone, so a scene standing still reads
bytes = 0 against a fullBytes that grows with the scene, and the ratio
says how much of it the scene's own churn, rather than its size, is
paying for.
local u = renderer.uploadStats()
print(("instance upload: %d B of %d B in %d writes"):format(u.bytes, u.fullBytes, u.writes))
modules/renderer/upscaleBackend
upscaleBackend(): string
The backend actually filling the upscale seam this frame — "blit"
or "dlss". Reports what the renderer resolved the last
renderer.setUpscaleBackend() request into, which reads "blit" after a
request for "dlss" on an adapter renderer.upscaleCapabilities() omits
it from.
local backend = renderer.upscaleBackend()
modules/renderer/upscaleCapabilities
upscaleCapabilities(): { string }
The backend names this engine can actually run for the upscale seam,
from a boot-time probe of the adapter. "blit" always answers, since the
stretch needs no adapter capability; "dlss" joins it only where NGX
DLSS Super Resolution is available. Read this before
renderer.setUpscaleBackend("dlss", ...) to know ahead of the request
what it resolves to.
local caps = renderer.upscaleCapabilities()
modules/renderer/variantSource
variantSource(program: string): string?
The WGSL one of the programs renderer.shaderVariants() lists holds,
exactly as the shader compiler received it. program is the program
field of a row's base or of one of its variants. Reading a base
alongside a variant shows what a feature set selected: each program's text
holds the code its own features guard. The variant-report spelling of
renderer.compiledSource, which answers the same for every other shader.
Parameters
programstring— Aprogramname fromrenderer.shaderVariants().
local row = renderer.shaderVariants()[1]
local base = renderer.variantSource(row.base.program)
modules/renderer/viewportSize
viewportSize(): { width: number, height: number }
The rect the scene was drawn into in the frame just drawn, in pixels.
That is the whole drawing surface in a runtime window, a browser canvas
and a headless engine, and the editor's viewport panel — smaller than the
surface — in an editor layout. Follows a renderer.setViewportSize, a
window drag and a browser page resize alike, so it reports what is
realized rather than what was asked for.
local v = renderer.viewportSize()
modules/renderer/watchShadowPages
watchShadowPages(runs: number)
Gather a breakdown of what the sun's virtual shadow map does on each of
the main camera's next runs runs. Each run's counts come back from the
GPU a few frames after it, and renderer.shadowPageBreakdown() hands them
over. Nothing is gathered while no reader has asked. 0 stops a
gathering under way.
Parameters
runsnumber— How many of the main camera's runs to gather.
renderer.watchShadowPages(120)
modules/restirLighting/README
require("@builtin::systems.restirLighting.restirLighting") -- restirLighting
Direct light from many small sources at a cost that does not grow with how many there are. A shading pass that loops every light pays for every light at every pixel, which is why the count has to be capped; resampled importance sampling instead draws a few candidates per pixel, keeps one in proportion to what it would contribute, and carries a weight that makes the survivor stand for the whole set. What a pixel keeps is reused — by its neighbours this frame and by itself on the next one — so the number of candidates each pixel has to draw stays small while the set it effectively samples keeps growing. A cave of glowing crystals or a street of practicals costs what a handful of lights costs. Sources registered here are additional to the lights the engine holds rows for: this lights what it is given, on top of the scene as it was drawn. Register a source with set, drop it with remove, and the pass starts and stops with the registry.
Usage: local restirLighting = require("@builtin::systems.restirLighting.restirLighting")
modules/restirLighting/active
active(): boolean
Whether the resampling pass is currently running.
if restirLighting.active() then print("resampling") end
modules/restirLighting/beginFrame
beginFrame(width: number, height: number): { [string]: any }?
Size the buffers to the frame, advance the frame counter and push the settings. The render feature calls this once per frame before it enqueues the passes; it is what gives the temporal reuse a frame to count and the grid a size.
Parameters
widthnumber— Viewport width in pixels.heightnumber— Viewport height in pixels.
local f = restirLighting.beginFrame(ctx.viewport.w, ctx.viewport.h)
modules/restirLighting/capacity
capacity(): number
The most sources the registry holds.
print(restirLighting.capacity())
modules/restirLighting/clear
clear()
Drop every source and release the pass. The settings are kept.
restirLighting.clear()
modules/restirLighting/configure
configure(opts: Settings?): State
Change how the resampling is run. Any omitted field keeps its current value.
Parameters
optsSettings?(optional) — The settings to change — seeSettings.
restirLighting.configure({ candidates = 16, mode = "reference" })
modules/restirLighting/count
count(): number
How many sources are registered.
print(restirLighting.count())
modules/restirLighting/defaults
defaults(): State
The settings a registry runs under until something changes them. Pass
this to configure to put every one of them back.
restirLighting.configure(restirLighting.defaults())
modules/restirLighting/memoryBytes
memoryBytes(): number
What the reservoir grid costs, in bytes: two vec4 per cell, twice over because reuse reads one grid and writes the other.
print(restirLighting.memoryBytes() // 1024, "KiB")
modules/restirLighting/perPixelCost
perPixelCost(): number
How many candidate evaluations a pixel pays for, per frame. It is the answer the whole technique exists to give: fresh candidates plus borrowed neighbours plus the one history, and no term in it is the source count.
print(restirLighting.perPixelCost(), "evaluations regardless of light count")
modules/restirLighting/remove
remove(key: string): boolean
Remove the source registered under key.
Parameters
keystring— The identifier the source was registered with.
restirLighting.remove("crystal")
modules/restirLighting/set
set(key: string, source: Source): number
Add or replace the source registered under key. Re-submitting the same
key moves that source rather than adding another, which is what lets a
component push its position every frame as its entity moves.
Parameters
keystring— Stable identifier — an entity id works well.sourceSource— Where it is and what it emits — seeSource.
restirLighting.set("crystal", { position = { 2, 1, 0 }, color = { 0.4, 0.8, 1 }, intensity = 6 })
modules/restirLighting/settings
settings(): State
The settings currently in force.
local c = restirLighting.settings().candidates
modules/restirLighting/stats
stats(): Stats?
What the resampling did on the most recent frame a read-back has landed for, or nil before the first one arrives.
local s = restirLighting.stats(); print(s.lit, "of", s.cells, "cells lit")
modules/retarget/Bake:error
Bake:error(): string?
Why the bake failed, once poll() answers "failed".
modules/retarget/Bake:poll
Bake:poll(): string
Advance the bake: dispatch once the kernel is compiled, read the result back, and build the clip.
modules/retarget/Bake:report
Bake:report(): any
What the bake used and measured: { sourceBind, targetBind, mappedBones, frames, travelSpeed, left, right }. A bind of rest means the rig had no bind pose and its rest
pose stood in for it. travel is the velocity the clip carries the target at over the
ground, in the target rig's space and units per second, over the frames the source has a
foot down (the stance ground passing under a clip that plays in place, plus any root
motion), pointing forward, sideways or back as the clip moves; travelSpeed its length.
left / right describe each leg: plantedFrames (the frames the source's foot is
planted, where the target's foot is held), worstSlide (how far the target's foot
strays within a plant against the moving ground, in the target rig's units),
transferSlide (the same before the hold), ground (the lowest the target's foot
reaches before the hold), and jointAngleMeanDeg / jointAngleMaxDeg (how far the hold
turns the thigh, shin and foot from the source's joint angles, over the clip).
modules/retarget/Bake:result
Bake:result(): string?
The retargeted clip's zanim bytes, once poll() answers "ready".
modules/retarget/README
require("@builtin::modules.retarget") -- retarget
Skeletal animation retargeting: carry a clip authored on one humanoid rig onto another, so the target's anatomy makes the source's motion. start bakes a clip on the GPU and hands back a handle that is ready a few frames later; bake waits for it; bakeBytes caches a bake under a key. plan reports which roles map across two rigs.
Usage: local retarget = require("@builtin::modules.retarget")
modules/retarget/aux
aux(cacheKey: string)
Read what was cached beside the bake at cacheKey.
Parameters
cacheKeystring
modules/retarget/bake
bake(clipBytes: buffer | string, srcRig: any, tgtRig: any): (string?, string?)
Retarget a clip and wait for it: start, then poll once a frame until the bake is
ready or has failed. Yields; call it where a script may wait.
Parameters
clipBytesbuffer | string— The source clip'szanimbytes.srcRigany(optional) — The rig the clip was authored on (parsed rig / table / JSON).tgtRigany(optional) — The rig to retarget onto (parsed rig / table / JSON).
modules/retarget/bakeBytes
bakeBytes(clipBytes, srcRig, tgtRig, cacheKey: string?): (string?, string?)
Bake with a cache: the first call for cacheKey bakes (and waits), every later call
returns the same bytes. Pass a key that names the clip and both rigs' content.
Parameters
clipBytesany(optional) — The source clip'szanimbytes.srcRigany(optional) — Source rig (parsed rig / table / JSON).tgtRigany(optional) — Target rig (parsed rig / table / JSON).cacheKeystring?(optional) — Optional stable key; when given, the result is cached and reused.
modules/retarget/clearCache
clearCache(cacheKey: string?)
Drop every cached bake, and the rig pairs they were built from (or just cacheKey
when given).
Parameters
cacheKeystring?(optional) — Optional single key to evict; omit to clear all.
modules/retarget/facing
facing(rig: any): V?
The direction a rig's body faces at rest, in the rig's own space: forward from its body frame (the hip line crossed with the stand axis), read from its bind pose. The retarget keeps every body facing this way, so it is the forward a controller turns the body by.
Parameters
rigany(optional) — A rig (parsed rig / table / JSON) with humanoid roles.
modules/retarget/loadRig
loadRig(ref)
Resolve a .rig asset and return it parsed for the bake: its bones, its effective
humanoid mapping (none when the rig is not a humanoid) and where its bind comes from.
Parameters
refany(optional) — A.rigasset ref (identity / guid / path / handle).
modules/retarget/parseRig
parseRig(rig)
Normalize a rig for the bake: its bones, its role -> bone map, where its bind pose
comes from, and its structure. Takes a .rig document (table or JSON) carrying either
roles or profile.roles; an already-parsed rig is returned unchanged.
Parameters
rigany(optional) —{ bones, roles | profile = { roles }, bind? }, or its JSON.
modules/retarget/plan
plan(srcRig, tgtRig)
Which roles map across two rigs: { mapped = { [role] = { source, target } }, unmappedSource, unmappedTarget, sourceRoleCount, targetRoleCount }.
Parameters
srcRigany(optional) — Source rig (parsed rig / table / JSON).tgtRigany(optional) — Target rig (parsed rig / table / JSON).
modules/retarget/request
request(clipBytes: buffer | string, srcRig: any, tgtRig: any, cacheKey: string): any
The bake for cacheKey: a handle that is already ready when the key's clip has
landed, the bake running for the key when one is, or a new bake otherwise, which lands
its clip under the key. Every caller polls its own reference; they all read one bake.
Parameters
clipBytesbuffer | string— The source clip'szanimbytes.srcRigany(optional) — Source rig (parsed rig / table / JSON).tgtRigany(optional) — Target rig (parsed rig / table / JSON).cacheKeystring— A key naming the clip and both rigs' content.
modules/retarget/setAux
setAux(cacheKey: string, value)
Cache a value beside the bake at cacheKey. It is dropped whenever that bake is.
Parameters
cacheKeystringvalueany(optional)
modules/retarget/start
start(clipBytes: buffer | string, srcRig: any, tgtRig: any): any
Start retargeting a clip onto a target rig on the GPU. Returns a handle: poll()
advances it and answers "pending", "ready" or "failed"; once ready, result() is
the retargeted clip's zanim bytes and report() says what the bake used. The clip's
keys go to the transfer kernel as they are stored; the retargeted clip is keyed at the
source's key rate (at least 30 per second).
Parameters
clipBytesbuffer | string— The source clip'szanimbytes.srcRigany(optional) — The rig the clip was authored on (parsed rig / table / JSON).tgtRigany(optional) — The rig to retarget onto (parsed rig / table / JSON).
modules/rigStructure/README
require("@builtin::modules.rigStructure") -- rigStructure
The shape of a skeleton, read from a rig document or a live Skeleton: parents and children, world positions and rotations of the rest pose (rest scale included), and the questions an avatar type asks of that shape: which bone two others share, how far a subtree reaches along a direction, how well two subtrees mirror each other. A structure is memoized by the content hash of the bones it was built from.
Usage: local rigStructure = require("@builtin::modules.rigStructure")
modules/rigStructure/bindPose
bindPose(s: Structure): Structure?
The structure of the pose a rig's inverse-bind matrices state — its skin's bind
pose — in place of the rest pose: the same bones and hierarchy, with gPos, gRot
and gScale the bind's. A rest pose can be anything (a clip's first frame); the bind is
the pose the mesh was modelled in. A skin states its bind in the mesh's space, which an
exporter can leave turned against the bones' own (a Z-up armature under a Y-up scene), so
the bind is carried into the space rest-pose forward kinematics answers in, by the
turn most bones agree takes their bind to their rest.
Parameters
sStructure— A structure whose bones carryinverseBind(a rig document's) orinverse_bind(a live Skeleton's).
modules/rigStructure/chainLength
chainLength(s: Structure, from: number, to: number): number
The summed link lengths from from down to its descendant to.
Parameters
sStructurefromnumbertonumber
modules/rigStructure/effective
effective(s: Structure, q: any, overrides: any?): any
A qualification with an author's overrides laid over it. overrides.roles maps a
role to the bone that fills it, or to false to leave the role empty. An override
naming a bone the skeleton does not have keeps the detected bone and is listed in
report.stale. The qualification passed in is left as it was.
Parameters
sStructure— The structure the qualification was made on.qany(optional) — A qualification (from an avatar type'squalify).overridesany?(optional) —{ roles = { [role] = boneName | false } }, or nil.
modules/rigStructure/extent
extent(s: Structure, dir: { number }): (number, number)
The extent of the skeleton along dir: lowest and highest projections of any bone.
Parameters
sStructuredir{ number }
modules/rigStructure/extremity
extremity(s: Structure, i: number, origin: { number }): number
The bone of the subtree rooted at i farthest from origin.
Parameters
sStructureinumberorigin{ number }
modules/rigStructure/fromBones
fromBones(bones: { any }): Structure
The structure of a live Skeleton's bone list (ecs.Skeleton.bones: name,
parent, t, r, s), memoized the same way as fromDoc.
Parameters
bones{ any }— The Skeleton's bones.
modules/rigStructure/fromDoc
fromDoc(doc: any): Structure
The structure of a rig document, memoized by its content hash.
Parameters
docany(optional) — A rig document:{ bones = { { name, parent (0-based, -1 for a root), rest = { t = {x,y,z}, r = {x,y,z,w}, s = {x,y,z} } } } }.
modules/rigStructure/hash
hash(doc: any): string
The content hash of a skeleton: its bones' names, parents, rest transforms and inverse-bind matrices. Two documents with the same hash have the same structure, whatever else they carry.
Parameters
docany(optional) — A rig document ({ bones = { { name, parent, rest = { t, r, s } } } }) or a live Skeleton's bone list.
modules/rigStructure/lca
lca(s: Structure, a: number, b: number): number
The deepest bone that is an ancestor of both a and b (a bone counts as its own
ancestor), or 0 when they share no root.
Parameters
sStructureanumberbnumber
modules/rigStructure/leaves
leaves(s: Structure, i: number): { number }
The leaves of the subtree rooted at i.
Parameters
sStructureinumber
modules/rigStructure/longest
longest(s: Structure, i: number): (number, number, number)
The longest chain below i along its links: the leaf it ends at, its length, and how
many bones it holds (i included). Independent of pose.
Parameters
sStructureinumber
modules/rigStructure/longestChild
longestChild(s: Structure, i: number): number?
The child of i whose chain runs longest (a limb's next joint, whatever the pose),
or nil for a leaf.
Parameters
sStructureinumber
modules/rigStructure/mirrorScore
mirrorScore(s: Structure, a: number, b: number, origin: { number }, side: { number }): number
How well the subtrees rooted at a and b mirror each other across the plane
through origin whose normal is side: 1 when b's farthest point reflects onto a's
and their chains are the same length, falling toward 0 as either differs.
Parameters
sStructureanumberbnumberorigin{ number }— The point the mirror plane passes through.side{ number }— The mirror plane's normal (need not be unit length).
modules/rigStructure/path
path(s: Structure, from: number, to: number): { number }?
The bones from from down to its descendant to, both included, or nil when to
is not below from.
Parameters
sStructurefromnumbertonumber
modules/rigStructure/reach
reach(s: Structure, i: number, dir: { number }): number
How far the subtree rooted at i reaches along dir: the largest projection of any
of its bones' positions onto dir.
Parameters
sStructureinumberdir{ number }
modules/rigStructure/sameSkeleton
sameSkeleton(a: Structure, b: Structure): boolean
Whether two structures are one skeleton: every bone both carry has the same parent and the same link length as a share of the links they share (within 1%), and every bone only one of them carries is a leaf (a prop socket, an end marker). No pose and no bone roll changes the answer, so a body and the clips authored on it match.
Parameters
aStructure— A structure.bStructure— A structure.
modules/rigStructure/shapeScore
shapeScore(s: Structure, a: number, b: number): number
How alike the subtrees at a and b are in shape, 0..1, independent of pose: the
length of their longest chains, the bones along them, and their leaf counts. Two limbs
of a mirrored pair score near 1 in any pose.
Parameters
sStructureanumberbnumber
modules/rigStructure/size
size(s: Structure): number
The length of the longest root-to-leaf chain: a size for the skeleton that no pose changes.
Parameters
sStructure
modules/rigStructure/subtree
subtree(s: Structure, i: number): { number }
Every bone in the subtree rooted at i, i first.
Parameters
sStructureinumber
modules/rigs/README
require("@builtin::tests.fixtures.rigs") -- rigs
Rig documents built in code for the rig structure, avatar type and retarget suites: a 1.8 m biped in six bone-naming conventions, with pose, orientation, spine-length, twist-bone, mirrored-name and extra-chain variants, plus three bodies that are not humanoids. Bones are laid out as world positions (facing +Z, up +Y, the character's left +X) and written as rest translations under identity rotations, so every fixture is exact and readable.
Usage: local rigs = require("@builtin::tests.fixtures.rigs")
modules/rigs/bend
bend(bones: { Bone }, key: string, axis: { number }, deg: number)
A 1.8 m biped rig document.
Parameters
bones{ Bone }keystringaxis{ number }degnumber
modules/rigs/fox
fox(): any
A four-legged body: a horizontal spine, two leg pairs to the ground, a neck and head forward, and a tail.
modules/rigs/nameOf
nameOf(conv: string, role: string, opts: any?): string?
The bone name a convention gives a humanoid role, as the fixture builds it.
Parameters
convstring— mixamo | cats | vrm | unreal | synty | unnamedrolestring— A humanoid role (hips,lefthand,righttoebase, ...).optsany?(optional) — The same options passed tobiped, when they change names (spine count).
modules/rigs/oneArmed
oneArmed(): any
A torso with one arm and one leg: not a humanoid, since it has no leg pair.
modules/rigs/plant
plant(): any
A plant: a trunk rising from the ground with mirrored branches.
modules/rt_ao/README
require("@builtin::modules.rt_ao") -- rt_ao
Ray-traced ambient occlusion — the settings the rt_ao render feature runs on, and the lifetime of the pass that draws it. A hemisphere of short rays per pixel is traced against the scene acceleration structure, and the fraction that hits nearby geometry darkens the frame.
Usage: local rt_ao = require("@builtin::modules.rt_ao")
modules/rt_ao/active
active(): boolean
Whether the occlusion pass is running. Read from the live feature
registry, so a feature created directly through renderer.feature.create
counts the same as one this module started.
if rt_ao.active() then print(rt_ao.stats().raysPerFrame) end
modules/rt_ao/clear
clear()
Turn occlusion off and release the pass. The other settings are kept, so
a later set({ strength = ... }) brings back the same look.
rt_ao.clear()
modules/rt_ao/get
get(): RtAoState
The occlusion settings currently in force.
local rays = rt_ao.get().rays
modules/rt_ao/publish
publish(built: { traceWidth: number, traceHeight: number, dispatches: number, traceTarget: string? })
Record the grid the feature allocated and the dispatches it enqueues.
The feature calls this as it builds, which is what gives stats the shape
of the chain that is running.
Parameters
built{ traceWidth: number, traceHeight: number, dispatches: number, traceTarget: string? }— The grid and dispatch count the feature just created.
rt_ao.publish({ traceWidth = 960, traceHeight = 540, dispatches = 9, traceTarget = rt.guid })
modules/rt_ao/qualityLevels
qualityLevels(): { [string]: { rays: number, resolution: number } }
What each quality level costs: rays hemisphere rays per pixel, cast
from a grid resolution of the frame's own. The rays a frame traces is
those two multiplied by the frame's pixels, and the trace pass's cost is
linear in it.
local shape = rt_ao.qualityLevels().ultra
modules/rt_ao/set
set(opts: RtAoOpts?): RtAoState
Set how the occlusion is traced. Any omitted field keeps its current
value, so a call can move one knob without restating the rest. A strength
of 0 turns occlusion off and releases the pass.
Parameters
optsRtAoOpts?(optional) — Occlusion settings — seeRtAoOpts.
rt_ao.set({ quality = "low", radius = 1.5 })
modules/rt_ao/stats
stats(): RtAoStats
What the running feature built — the grid it traces from, the rays that
grid costs each frame, and the dispatches it enqueues. The feature writes
these as it allocates its targets, so they describe the pass that exists
this frame; traceTarget is that grid as a resource, for a reader that
wants to measure it.
local s = rt_ao.stats(); print(s.traceWidth, s.traceHeight, s.raysPerFrame)
modules/runtime_participation/README
require("@builtin::modules.api.engine.runtime_participation") -- runtime_participation
Reads and writes the RuntimeParticipation lifecycle axis for an entity, and answers the save / edit-liveness / play-liveness questions that follow from a mode. One source of truth for the four modes (WorldEntity, PrototypeOnly, EditorOnly, RuntimeOnly) so save and play-mode code agree on what each mode means.
Usage: local runtime_participation = require("@builtin::modules.api.engine.runtime_participation")
modules/runtime_participation/isSaved
isSaved(mode: string): boolean
Whether an entity with this mode is written to the persisted world. True for WorldEntity, PrototypeOnly, and EditorOnly; false for RuntimeOnly.
Parameters
modestring— A RuntimeParticipation mode string.
modules/runtime_participation/liveInEdit
liveInEdit(mode: string): boolean
Whether an entity with this mode is live while authoring in edit mode. True for WorldEntity, PrototypeOnly, and EditorOnly; false for RuntimeOnly.
Parameters
modestring— A RuntimeParticipation mode string.
modules/runtime_participation/liveInPlay
liveInPlay(mode: string): boolean
Whether an entity with this mode is live during play. True for WorldEntity and RuntimeOnly; false for PrototypeOnly and EditorOnly.
Parameters
modestring— A RuntimeParticipation mode string.
modules/runtime_participation/modeOf
modeOf(entityId: string): string
The entity's RuntimeParticipation mode. Defaults to "WorldEntity".
Parameters
entityIdstring— Entity id to read.
modules/runtime_participation/set
set(entityId: string, mode: string)
Sets the RuntimeParticipation mode on an entity. A mode that is not saved marks the entity temporary so the scene-save exclusion drops it.
Parameters
entityIdstring— Entity id to write.modestring— The mode to store.
modules/runtime_participation/standsDown
standsDown(mode: string, engineMode: string): boolean
Whether an entity with this mode stands down — stops rendering and
ticking — when an EDITOR session is in engineMode. This is the question a
mode flip actually asks, and it is not liveInPlay: that answers which
entities a SHIPPED RUNTIME contains, where there is no authoring surface at
all. A session able to flip modes is an editor session by construction (the
runtime profile forbids mode swaps), so the editor's own cameras, panels and
gizmos are present in both of its modes and stand down in neither. What
stands down in play is a template, whose clones are what runs; what stands
down in edit is a runtime entity.
Parameters
modestring— A RuntimeParticipation mode string.engineModestring— The engine mode the session is in, "play" or "edit".
local rp = require("@builtin::modules.api.engine.runtime_participation")
if rp.standsDown(entity(id).participation, tostring(engine.mode)) then ... end
modules/sceneProxy/README
require("@builtin::systems.sceneProxy.sceneProxy") -- sceneProxy
A coarse volumetric stand-in for the scene's geometry: a grid that answers how far the nearest surface is from any point, cheaply enough to ask along a whole ray.
Usage: local sceneProxy = require("@builtin::systems.sceneProxy.sceneProxy")
modules/sceneProxy/build
build(opts: ProxyOpts?): ({ [string]: any }?, string?)
Build the proxy over the scene as it currently stands. Allocates the grid, scatters the scene's triangles into it, and floods the result into a distance field.
Parameters
optsProxyOpts?(optional) — Grid settings — see the fields below. All are optional.
sceneProxy.build({ resolution = 64 })
modules/sceneProxy/building
building(): boolean
Whether a build or refresh is running right now. Both yield while the GPU answers, so this is what a caller checks before starting one of its own over the same scene.
if not sceneProxy.building() then sceneProxy.build() end
modules/sceneProxy/built
built(): boolean
Whether a field is built.
if sceneProxy.built() then ... end
modules/sceneProxy/claim
claim(key: string, opts: TrackOpts?): boolean
Ask for the field to be kept current, on behalf of something that will say when it no longer wants it. Tracking follows the claims that stand: it is on while there is at least one, and the settings in force are those of the claim made most recently. Two scene objects each wanting a proxy therefore share one grid, and neither turns the other's off.
Parameters
keystring— What is asking — anything that names the claimant, an entity id for a component.optsTrackOpts?(optional) — What to follow and how closely, astracktakes them.
sceneProxy.claim(entityId, { resolution = 64 })
modules/sceneProxy/claimed
claimed(key: string): boolean
Whether a claim made under this key still stands. A release from
elsewhere — destroy drops every claim there is — is what this answers
false after, so something whose presence IS the request for a proxy can
make it again.
Parameters
keystring— The key the claim was made under.
if not sceneProxy.claimed(id) then sceneProxy.claim(id, opts) end
modules/sceneProxy/destroy
destroy()
Release the proxy's grid and its working volumes, and with them every claim on it and any build or refresh still in flight — what that work was making is a grid nothing asked for any more.
sceneProxy.destroy()
modules/sceneProxy/distanceAt
distanceAt(point: { [string]: number }): number?
The world-space distance from point to the nearest surface. Reads the
field the way a shader does — interpolated between voxel centres, and far
outside the extent the grid covers. Yields while the GPU answers, so call
it from a task or execute; a shader samples the field directly instead.
Parameters
point{ [string]: number }—{ x, y, z }world position.
local d = sceneProxy.distanceAt({ x = 0, y = 2, z = 0 })
modules/sceneProxy/gridParams
gridParams(): { number }?
The grid a shader needs to read the field: the two vec4 that
scene_proxy.shaderModule's spGridFrom unpacks, as eight floats ready to
write into a consuming pass's own parameter buffer.
local p = sceneProxy.gridParams(); myParams:write(p)
modules/sceneProxy/maintain
maintain(): boolean
One maintenance tick: build the field when tracking is armed and nothing
is built yet, otherwise walk a slice of the scene and start a refresh once a
whole walk has found that the geometry the proxy covers moved. Cheap on a
scene standing still, bounded on a big one, and never yields — the work it
starts runs as its own task, which is what lets a component update drive
it.
function update() sceneProxy.maintain() end
modules/sceneProxy/refresh
refresh(): (boolean, string?)
Rebuild the field from the scene's current geometry, over the grid the proxy already has. What to call after something moves.
sceneProxy.refresh()
modules/sceneProxy/release
release(key: string): boolean
Drop a claim. The grid is released when it was the last one standing; otherwise the claim made most recently before it takes the settings back.
Parameters
keystring— The key the claim was made under.
sceneProxy.release(entityId)
modules/sceneProxy/sampleAt
sampleAt(points: { any }): ({ { distance: number, normal: { number } } }?, string?)
Ask the field about a batch of world points in one dispatch. Yields
while the GPU answers, so call it from a task or execute.
Parameters
points{ any }— A list of world positions, each{ x, y, z }or{ X, Y, Z }.
local s = sceneProxy.sampleAt({ { x = 0, y = 2, z = 0 } })
modules/sceneProxy/settings
settings(): { [string]: any }?
The grid in force, the world extent it covers, and what it cost.
boundsMin and boundsMax are the corners of the box the grid spans —
resolution voxels along each axis from boundsMin, and what a point has
to fall inside to have an answer. The geometry the grid was fitted to sits
one voxel inside them at each end. gridParams() is what a consuming
shader wants — the same numbers in the layout spGridFrom reads.
local s = sceneProxy.settings(); print(s.voxelSize, s.memoryBytes)
modules/sceneProxy/track
track(opts: TrackOpts?): boolean
Keep the field current by itself: from here on the proxy watches the
geometry it covers and refreshes when that geometry moved. Returns at once
— it records what to follow and leaves the work to maintain, which
something has to drive each frame; SceneProxy.component is that driver for
an authored scene. A proxy that is not built yet is built by the first tick,
at resolution.
Parameters
optsTrackOpts?(optional) — What to follow and how closely — see the fields below. All are optional.
sceneProxy.track({ resolution = 64, interval = 0.2 })
modules/sceneProxy/tracking
tracking(): boolean
Whether the proxy is following the scene.
if not sceneProxy.tracking() then sceneProxy.track() end
modules/sceneProxy/trackingStats
trackingStats(): { [string]: any }
What tracking is set to follow, what it has done, and what it costs: the settings in force, how many claims stand, how many entities the last completed walk over the scene looked at and how long the last slice of one took, how many GPU-driven populations the field standing in the grid covers, how many builds, refreshes and refitting rebuilds it has started, how many ticks it stood aside for work already running, and the last error a walk or a refresh reported.
print(sceneProxy.trackingStats().refreshes)
modules/sceneProxy/untrack
untrack()
Stop keeping the field current. The grid stays built and readable; it simply stops following the scene.
sceneProxy.untrack()
modules/scene_instantiable/README
require("@builtin::assetTypes.assetType.shared.instantiable") -- scene_instantiable
The instantiation contract's shared half. An asset type opts into scene instantiation by defining instantiate(self, target?, opts?) on its behaviour ref table. Both halves of that call are shared, so a caller writes the same code against every type. IN — the base opts position, rotation, scale, name, temporary mean the same thing for every type, so their implementation lives here. rotation takes three numbers as pitch/yaw/roll in DEGREES, or four as a quaternion. root stands the root entity (parented, born temporary, named, placed) and place applies the placement opts to a root the type adopted (a bundle exploding onto its target). OUT — every type returns (root, idMap) through result: the composed root as a LIVE EntityRef, and the originalId -> runtimeId map naming what the composition spawned ({} for a type with no addressable children). Composition is synchronous — the root is usable the moment the call returns. AssetRef.instantiate is dispatched through this same check whether or not the type called it, so the two values a caller gets back never depend on which asset it held. Also registers the sceneInstantiable field-constraint validator: a constrained value must be an asset whose type defines instantiate (ref:canInstantiate()), which is what makes Field.instantiableRef accept by CAPABILITY instead of a hardcoded type list. nil (no asset) passes — the field is optional.
Usage: local scene_instantiable = require("@builtin::assetTypes.assetType.shared.instantiable")
modules/scene_instantiable/isOwned
isOwned(opts: { [string]: any }?): boolean
Whether this instantiate call already has an owner. The Asset /
SceneModule components drive instantiate themselves and tag the call
with sourceTag; they hold the asset reference, persist the composition's
idMap, and re-run the composition on every load. A call with no tag came
straight from ref:instantiate(...) and has no such owner, so a type whose
composition must survive a reload composes, then hands the result one.
Parameters
opts{ [string]: any }?(optional) — Theinstantiateopts table (nil-safe).
if not Instantiable.isOwned(opts) then ... end
modules/scene_instantiable/own
own(root: any, self: any, idMap: { [string]: string }?): any
Hand an ALREADY-COMPOSED root to an Asset component pointing at
self. The type composes first and calls this last: the component adopts
the composition standing on root rather than building a second one, and
from then on owns the reference — it keeps idMap in a persisted field
and re-composes with those same ids on the next load, so cross-entity
references into the composition (SkinnedModel.skeletonRoot) stay valid.
Composed children never reach scene.json; the scene stores the reference
and re-composes from it.
Parameters
rootany(optional) — The root entity, as anEntityRefproxy, with the composition live.selfany(optional) — The asset ref being instantiated.idMap{ [string]: string }?(optional) — Theoriginal_id -> runtime idmap naming that composition.
if not Instantiable.isOwned(opts) then Instantiable.own(root, self, freshMap) end
modules/scene_instantiable/place
place(root: any, opts: { [string]: any }?): any
Apply the base placement opts to a root the type already has — the
adopt path (a bundle exploding onto its target, a sceneModule
reconciling under one). position / rotation / scale land on the
root's local transform; name renames it. rotation takes three numbers
as pitch/yaw/roll in DEGREES, or four as a quaternion.
Parameters
rootany(optional) — The root entity, as anEntityRefproxy.opts{ [string]: any }?(optional) — Theinstantiateopts table (nil-safe).
return Instantiable.place(target, opts), idMap
Instantiable.place(root, { rotation = { 0, 90, 0 } }) -- yaw 90°
modules/scene_instantiable/result
result(self: any, root: any, idMap: { [string]: string }?): (any, { [string]: string })
Return an instantiate through the contract — the OUT half, the
counterpart of root / place. Checks that root is a live entity ref
and normalises a missing map to {}, so every type hands its caller the
same two values: the composed root, live on return, and the
originalId -> runtimeId map naming what it spawned. AssetRef runs
every instantiate through this on the way out, so a type that returns
something else fails at its own call rather than handing a caller a nil
root or a map that is sometimes absent.
Parameters
selfany(optional) — The asset ref being instantiated — named in the error.rootany(optional) — The composed root, as anEntityRefproxy.idMap{ [string]: string }?(optional) — Theoriginal_id -> runtime idmap, or nil for a type that spawns no addressable children.
return Instantiable.result(self, root, freshMap)
return Instantiable.result(self, Instantiable.root(self, target, opts))
modules/scene_instantiable/root
root(self: any, target: any?, opts: { [string]: any }?): any
Stand the root entity for an asset type's instantiate — the whole
base contract in one call. Validates target (an owning entity ref, or
nil), spawns the root as its child (born temporary when opts.temporary,
named opts.name else the asset's own name), and applies the placement
opts. The type adds its components to the returned root; what it returns
from instantiate is (thisRoot, idMap).
Parameters
selfany(optional) — The asset ref being instantiated.targetany?(optional) — Optional owning entity ref — the root spawns as its child.opts{ [string]: any }?(optional) — Theinstantiateopts table (nil-safe).rotationtakes three numbers as pitch/yaw/roll in DEGREES, or four as a quaternion.
local root = Instantiable.root(self, target, opts)
modules/scene_loader/README
require("@builtin::assetTypes.scene.shared.loader") -- scene_loader
Luau-side scene loader. Reads scene.json v6 and v7, refuses versions outside that range with a typed error, dispatches to entity.spawn / component.add / lights.setup, auto-discovers the sibling entrypoint.luau via vfs.exists. v6 attaches the declarative player + camera blocks to the Scene proxy for procedural resolution; v7 stashes the string player intent and does no procedural player/camera spawn. Replaces the legacy Rust __layers.load FFI path; the Rust FFI remains for one release as a safety net but is no longer invoked by any in-tree caller. Delta-overlay aware: when a scene_dirty/ directory exists next to canonical scene.json, the loader hands the merge off to scene_saver.composeMerged — canonical scene.json + dirty manifest overrides + per-entity overlay files = the assembled body. Single merge point so the load + promote paths can never disagree. See § 10 of the player-camera-unification integration design for the architecture rationale (pure Luau, performance budget ~5 ms per 1k-entity scene, ECS FFI is sufficient without new primitives).
Usage: local scene_loader = require("@builtin::assetTypes.scene.shared.loader")
modules/scene_loader/afterRecordsApplied
afterRecordsApplied(fn: () -> ()): boolean
Run fn once every record of the scene load that is applying records
right now has landed: every entity it states spawned, parented and
carrying the components and attributes its record states. A component
waking as one of those records is applied reads the entities beneath it in
whatever state the records before it left them, and a record after it puts
back what its own record says; work that reconciles those entities against
something else (a placement rebuilding what its module now states) belongs
after the last record, where nothing the load applies comes after it.
Outside such a load, or once the load's records have all landed, there is
nothing to wait for: fn runs before this returns, and an error it raises
reaches the caller. Work that waits runs after the last record, in the
order it was handed in, each function in its own protected call, so one
that raises is logged and the rest still run.
Parameters
fn() -> ()— The work to run.
Loader.afterRecordsApplied(function() print(#entity.findAll(), "entities applied") end)
modules/scene_loader/applyPeerRecords
applyPeerRecords(fn: () -> ())
Apply records another session wrote: run fn, reading
applyingPeerRecords() as true for as long as it runs. An error fn
raises reaches the caller once the state is put back.
Parameters
fn() -> ()— The application.
Loader.applyPeerRecords(function() applyBody(eid, body) end)
modules/scene_loader/applySceneFields
applySceneFields(sceneProxy: any, body: any, opts: any?): (boolean, { string })
Take a loaded scene to the scene-level fields a scene.json body
states. A v7 body carries player as the string intent "spawns" or
"none" (a missing or empty one reads "spawns"), which lands as
sceneProxy.playerIntent; a v6 body carries player and camera as
setting blocks instead, which land under sceneProxy.settings. A root
scene's lighting block lands under sceneProxy.settings.lighting; an
additive one leaves the host scene's lighting alone.
A load applies every field. A write to the file of a scene already loaded
passes opts.previous, the body the file held before it, and a field
lands only where the two bodies differ, so a write that edits one field
leaves a live change to another standing until the file states it. A
write also leaves alone a field the scene already holds as the body
states it, so the scene's own save, which writes what the scene holds,
lands nothing and reports nothing.
Parameters
sceneProxyany(optional) — The loaded scene's proxy.bodyany(optional) — The decodedscene.jsonbody.optsany?(optional) —{ additive: boolean?, source: string?, previous: table? }: whether the scene is an additive layer, the path a warning names, and the body the file held before this one.
local Json = require("@builtin::modules.json")
Loader.applySceneFields(layers.active, Json.decode(assert(vfs.read(path))), { previous = before })
modules/scene_loader/applyingPeerRecords
applyingPeerRecords(): boolean
Whether the records being applied to a loaded scene right now were written by another session sharing this world: a peer's edit, or what a peer's build placed, arriving as that peer's records. A build is run by the session the change that asks for it was made in, and what it places reaches every other session as the records it writes, so a placement waking while this reads true is one a peer's records put here, holding what that peer already built.
if Loader.applyingPeerRecords() then return end
modules/scene_loader/applyingRecords
applyingRecords(): boolean
Whether a scene load is applying its records, or running the work components handed in to run after them, right now. A build that runs inside such a load reruns on every load.
if Loader.applyingRecords() then log.info("inside a load") end
modules/scene_loader/handBackHere
handBackHere(): boolean
Hand the frame back from inside the scene load the calling code runs
in, on the terms the load hands it back between its own records: the code
runs on the coroutine of a direct load outside any component's context,
gameplay is paused, and this frame's slice (FrameBudget) is spent. The
load then goes on with the caller on the next frame, reading as partly
applied (M.partlyApplied) across the frames in between. Work a load
runs as one piece (a placement that wakes in it building what its module
states, run after the records) calls this between its own units, so it
spreads across frames the way the records do. Anywhere else it returns at
once.
if Loader.handBackHere() then print("this load hands the scene back here") end
modules/scene_loader/partlyApplied
partlyApplied(): string?
The scene a load is applying part way through its records while it has handed the frame back between two of them, or nil when no load is. Such a scene's layer holds only the records applied so far; the load goes on with the next record on a later frame. A load whose task has ended (cancelled with its records part applied) no longer counts.
while Loader.partlyApplied() ~= nil do task.wait() end
modules/scene_saver.recordDiff/README
require("@builtin::assetTypes.scene.shared.saver.recordDiff") -- scene_saver.recordDiff
The comparisons the saver's record diffs are built from: numeric-tolerant equality, the component name a record matches by, a record's component list read the way the comparison needs it, the fields a component wrote about its own runtime, and the attribute differences between two records.
Usage: local scene_saver.recordDiff = require("@builtin::assetTypes.scene.shared.saver.recordDiff")
modules/scene_saver.serialize/README
require("@builtin::assetTypes.scene.shared.saver.serialize") -- scene_saver.serialize
One live entity as the record a scene file carries: its transform, its components (each field value serialized, a runtime GPU handle reported once and left out), its name, parent, participation, network scope, render layer and attributes, and the reads the saver asks of an entity while it decides what to record.
Usage: local scene_saver.serialize = require("@builtin::assetTypes.scene.shared.saver.serialize")
modules/scene_saver/README
require("@builtin::assetTypes.scene.shared.saver") -- scene_saver
Luau-side scene saver. Persists scene state via a delta-overlay model: Canonical (committed work) canonical.entities[] plus a filesystem listing of entities/. Concurrent writes to per-entity files therefore never produce manifest-conflict orphans (the conflict surface is one entity at a time, not the whole-scene index). Tombstones survive in dirty until the next save (when clearDirty wipes the directory). An orphan tombstone — one targeting an entity that wasn't in canonical either (i.e. the entity was spawned and deleted inside the same edit session before save) — is a no-op at compose time, so the file shape is robust regardless of operation order. The composer (composeMerged) is the canonical merge point used by both this saver's promote/save paths AND scene_loader.M.load, so there's exactly one place that knows how to combine canonical with the overlay. Captures authored intent only: no spawner-managed entities (player identities, primary camera), no temporary entities, no runtime player position. FFI shapes (discovered at runtime — differ from plan): - entity.findAll() → array of {id: string, name: string} tables. - localPosition / localScale expose number components .x/.y/.z. - localRotation exposes quaternion components .x/.y/.z/.w. - entity(id).getParent() → parent entity proxy or nil; its .id is the id string. - entity(id).name → string name (direct field, no function call). - lighting snapshot is read directly from settings.lighting.
Usage: local scene_saver = require("@builtin::assetTypes.scene.shared.saver")
modules/scene_saver/buildOutputOf
buildOutputOf(savedRec: any?, pendingRec: any?): string?
The scene build whose output a pending edit is, or nil when an author
made it. A scene build (a scene's build.luau, a SceneModule
placement) writes its name, the record each entity stands for and what it
stated onto every entity it places, and a rebuild that states something new
restates that last part; those attributes travel in the records, so the
answer is read off the two records alone. An edit is the build's output
when the build placed the entity, the pending record holds exactly what the
build stated (SceneBuild.recordDrift finds nothing an author changed or
added), and, for an update, the build's statement is not the one the saved
record holds. A removal is the build's when the build that placed the
entity has run in this session and no longer states it
(SceneBuild.states); an entity its build still states was taken away by
an author, and the build's next run puts it back.
Parameters
savedRecany?(optional) — The record the scene's saved file holds for the entity, nil for an addition.pendingRecany?(optional) — The record the scene's unsaved edits hold for it, nil for a removal.
local by = require("@builtin::assetTypes.scene.shared.saver").buildOutputOf(saved, pending)
modules/scene_saver/componentDrivenFields
componentDrivenFields(id: any): { [string]: { [string]: boolean } }
The component fields on a live entity whose current value a component
callback wrote while the engine was in play, keyed by SHORT component
name. A lamp component writing Light.intensity every frame reports
Light = { intensity = true }; an authoring call writing that same field
takes it back off. These name the running simulation's state rather than
authored intent, so the record comparison passes over them.
Parameters
idany(optional) — The live entity's id.
require("@builtin::assetTypes.scene.shared.saver").componentDrivenFields("ent_0")
modules/scene_saver/componentShortName
componentShortName(t: string): string
The component type's short name: the leaf of the identity every
spelling of the component resolves to, so a saved record (Model, Door)
and a live one (@builtin::components.Model, doors.Door) read alike.
Parameters
tstring— A component type name in any form.
require("@builtin::assetTypes.scene.shared.saver").componentShortName("@builtin::components.Model")
modules/scene_saver/discardSceneEdits
discardSceneEdits(name: string, select: (string | { string })?): SceneEditDiscard
Take a scene's unbaked overlay edits back out, leaving the canonical
file as what the scene carries. This is the second verdict on the edits
pendingSceneEdits reports and a publication call refuses over: staging
bakes them into the scene, this drops them. Each edit's overlay record is
deleted and its entity withdrawn so no writer re-states it, whichever
session wrote the record and however long it has stood.
Parameters
namestring— The scene — a.scenefolder path, ascene.jsonpath, or a bare scene name.select(string | { string })?(optional) — Which edits to drop: an entity id or entity name, or a list of them. Omitted, every edit the scene has pending.
require("@builtin::assetTypes.scene.shared.saver").discardSceneEdits(layers.active.name)
require("@builtin::assetTypes.scene.shared.saver").discardSceneEdits("/zero/source/scenes/main.scene", "look")
modules/scene_saver/filesSignature
filesSignature(target): string
What a scene's files hold, as one string: its canonical scene.json
and every file of its dirty overlay, each with its bytes. Two reads give
the same string exactly when neither the canonical file nor any overlay
file changed between them, which is how a caller that rewrites files
underneath a loaded scene tells whether it moved that scene.
Parameters
targetany(optional) — The scene's authoring target: a.scenefolder path, itsscene.jsonpath, or a bare scene name.
local before = require("@builtin::assetTypes.scene.shared.saver").filesSignature(layers.active.asset.path)
modules/scene_saver/flushDirtyAcrossFrames
flushDirtyAcrossFrames()
Put every pending edit-mode mark into the dirty overlay the way the continuous writer does: one frame's
budget of records at a time, with the frame handed back between shares, so the time the calling frame spends is
set by the budget however many entities the marks name. Returns once the overlay holds every mark taken. Where the
caller cannot yield the whole backlog is written in the one frame, as M.flushDirty does. The edit to play flip
calls this before it takes the write lock.
saver.flushDirtyAcrossFrames()
modules/scene_saver/hasPendingSceneEdits
hasPendingSceneEdits(name: string): boolean
Whether baking the scene's dirty overlay into its canonical file would change the scene. False when the overlay is absent, and false when it holds only records the canonical file already states.
Parameters
namestring— The scene — a.scenefolder path, ascene.jsonpath, or a bare scene name.
require("@builtin::assetTypes.scene.shared.saver").hasPendingSceneEdits(layers.active.name)
modules/scene_saver/noteBuildRemoved
noteBuildRemoved(eid: string)
Say that a scene build took the entity eid out of the world. A save of the scene then states the
removal of the record the scene holds for it, however the build ran. A build that runs as its scene loads
reaches scene.json this way and records nothing in the scene's unsaved edits.
Parameters
eidstring— The entity id the build despawned.
require("@builtin::assetTypes.scene.shared.saver").noteBuildRemoved(id)
modules/scene_saver/overlayEmptiesScene
overlayEmptiesScene(name: string): { entities: number, tombstones: number, path: string }?
Whether the scene's dirty overlay carries a tombstone for every entity its saved scene.json holds, which
composes the scene to nothing it was saved with. An overlay of a scene that is being edited removes some of its
entities; one that removes all of them is a record of something other than an author's edits (a build that stated
nothing, a damaged journal), so the loader loads the saved scene instead and the pending-edit verdict names it.
Parameters
namestring— The scene: its path or identity.
local emptied = Saver.overlayEmptiesScene("/source/scenes/arena.scene")
modules/scene_saver/pendingRecords
pendingRecords(): number
How many entity records the writer holds to write: the marks the engine has noticed, taken into the backlog, plus the records already waiting there. A caller about to wait for the writer reads this to know how long the wait is.
if saver.pendingRecords() > 64 then log.info("the writer is behind") end
modules/scene_saver/pendingSceneEdits
pendingSceneEdits(name: string): ({ PendingSceneEdit }, string?)
Every edit a scene's dirty overlay holds that baking it would write into the canonical scene file: an added entity, an updated one, a removed one, or a change to the scene's own lighting / player / camera config. An EMPTY result is the verdict that the canonical scene already says what the overlay says, whatever rows the overlay carries. Each entry names the entity and describes the difference.
Parameters
namestring— The scene — a.scenefolder path, ascene.jsonpath, or a bare scene name.
require("@builtin::assetTypes.scene.shared.saver").pendingSceneEdits("/zero/source/scenes/main.scene")
modules/scene_saver/recordDiffLines
recordDiffLines(oldRec: any, newRec: any, maxLines: number?): { string }
Human lines describing how a live entity record differs from the record the scene carries: transform channels, component fields, component additions and removals, and attribute additions, changes and removals. Compares authored intent: a component field participates where either record states it and while its live value is an author's (a field only the live record states was set after the scene's record was made, and one the instance wrote about its own runtime is left out), numbers compare within a float-noise epsilon, and asset references compare by the asset they name rather than by the shape they are written in. A field or transform channel a component drove in play holds the running simulation's state, which the scene's record puts back, so it states no difference. An EMPTY result is the "unchanged" verdict.
Parameters
oldRecany(optional) — The scene's entity record.newRecany(optional) — The live entity record.maxLinesnumber?(optional) — How many lines to report before summarizing the rest as "…".
local ss = require("@builtin::assetTypes.scene.shared.saver"); ss.recordDiffLines(saved, ss.serializeEntity(id))
modules/scene_saver/recordFieldValue
recordFieldValue(v: any): (any, string?)
The durable form of one component field value — what a record states for it. An asset reference keeps the identity a later session re-resolves it from; a live GPU resource handle names a slot in this session's GPU registry, so it is left out and named in the second return instead. Reading a live field through this is what lets a consumer of a record compare what it holds against what the record says in one form.
Parameters
vany(optional) — A field value read off a live component.
require("@builtin::assetTypes.scene.shared.saver").recordFieldValue(model.material) -- { __ref = "..." }, nil
modules/scene_saver/recordsWritten
recordsWritten(): number
How many entity records this session has written into a scene's dirty overlay, counted as each one lands. A record already holding the bytes it would be written with is left as it is and not counted. Read twice, the difference is the record writing done between the two reads, which is how a frame's share of a save or of the continuous writer is seen.
local before = Saver.recordsWritten()
modules/scene_saver/respawnFromFiles
respawnFromFiles(layer: any, target: string, change: (() -> any)?): any
Take a loaded scene's live layer to what its files hold: the layer is
respawned from the canonical scene.json composed with the overlay records
standing beside it, with the scene-load gate held so the entities that come
back are not marked as edits. change, when given, runs first inside the
same gate: it is the act that changes the files, such as a discard deleting
the overlay. Once the overlay holds nothing, what this session keeps about
the overlay's records is let go, as clearing the overlay lets it go.
Returns once the respawn's detached work (player, camera, avatar) has
settled. Raises when the respawn raises.
Parameters
layerany(optional) — The layer holding the scene (aSceneProxyfromlayers.list()).targetstring— The scene's authoring target, the path its overlay is filed under.change(() -> any)?(optional) — Optional function run inside the gate before the respawn.
local Saver = require("@builtin::assetTypes.scene.shared.saver")
Saver.respawnFromFiles(layers.active, layers.active.asset.path)
modules/scene_saver/save
save(name, opts)
Write the live layer of scene name into its canonical scene.json: the overlay of the session's edits
merged over what the file holds. A record waiting for a parent that no record and no entity provides stays in
the overlay, where it is built once its parent arrives, so scene.json carries no record a load of it cannot
place; such a record that is a build's output, when the build has since placed its record identity on a new
entity or places it no longer, is taken out of the scene instead. opts.layer names the source layer (default: name), opts.sourceGuid and
opts.sourcePath the scene it was loaded from. opts.bake = true is a build baking what it placed: an
additive layer, which records no edits of its own, is then recorded into the scene's own folder for the save.
Parameters
nameany(optional) — The scene to write: its path or identity.optsany(optional) —{ layer?, sourceGuid?, sourcePath?, bake? }.
saver.save("/source/scenes/arena.scene", { layer = "arena" })
modules/scene_saver/sceneBodyForReading
sceneBodyForReading(name: string): any
The body a scene composes to, for a caller that only reads it. A scene with no dirty state composes to its saved
scene.json, so the body is the one decoded for the file's current bytes and shared with every other reader of
them: asking again costs no decode while the file holds still. A scene with dirty state is composed afresh, as
composedSceneBody does. The tracker of canonical ids is left where the last load put it. The table belongs to
its readers and is never written to; composeMerged is the call for a body the caller edits. A saved file that
exists and that this engine cannot read (its bytes are not on this engine, or the caller cannot wait for them)
raises, naming the file and why, as composeMerged does.
Parameters
namestring— The scene: its path or identity.
local body = Saver.sceneBodyForReading("/source/scenes/arena.scene"); print(#body.entities)
modules/scene_saver/sceneRemoved
sceneRemoved(layerName: string)
Stop writing anything for the loaded layer layerName: the scene it was
loaded from was removed from the world, so its dirty overlay has no scene
left to belong to. The marks it holds and every mark it takes until it
loads again are dropped, and nothing is written into the removed scene's
folder, which would otherwise bring that folder back.
Parameters
layerNamestring— The layer's name, aslayers.list()names it.
Saver.sceneRemoved(proxy.name)
modules/scene_saver/sceneReturned
sceneReturned(layerName: string)
Write the loaded layer layerName's edits again: a scene of that name
loaded, so the layer has a scene to write into. Undoes M.sceneRemoved.
Parameters
layerNamestring— The layer's name, aslayers.list()names it.
Saver.sceneReturned(proxy.name)
modules/scene_saver/trackingReason
trackingReason(): string?
Why an authored scene edit made from THIS call's own context would not
be recorded right now, or nil while it would be. A scene records its edits
in edit mode, outside a scene load, outside the world entrypoint's respawn
pass, and outside a component or entrypoint callback tick; inside any of
those a spawn or a change reaches the live session and no file. This is the
question an empty pendingSceneEdits list cannot answer on its own — the
same list stands for "the scene is saved" and for "nothing is watching it".
require("@builtin::assetTypes.scene.shared.saver").trackingReason()
modules/scene_saver/transformDiffLines
transformDiffLines(oldRec: any, newRec: any, driven: { [string]: boolean }?): { string }
Diff lines for an entity's transform channels (position / rotation /
scale), comparing the live record against the record the scene carries. A
channel the saved record OMITTED defaults to the identity transform, so a
move away from origin registers even for an entity saved at identity (which
carries no transform block) — while an unmoved entity whose live record
materializes the identity transform produces no line. A channel named in
driven holds the running simulation's state and takes no part.
Parameters
oldRecany(optional) — The scene's entity record (may omittransformor channels).newRecany(optional) — The live entity record.driven{ [string]: boolean }?(optional) — Channel names (position/rotation/scale) a component drove in play, as a set; nil compares every channel.
require("@builtin::assetTypes.scene.shared.saver").transformDiffLines({}, { transform = { position = { 0, 1, 0 } } })
modules/scene_saver/transformDrivenChannels
transformDrivenChannels(id: any): { [string]: boolean }
The transform channels of a live entity whose current value a component
callback wrote while the engine was in play, as a set. A camera rig turning
its camera every frame reports { rotation = true }; an authoring call
writing that same channel takes it back off. These name the running
simulation's state rather than authored intent, so the record comparison
passes over them.
Parameters
idany(optional) — The live entity's id.
require("@builtin::assetTypes.scene.shared.saver").transformDrivenChannels("ent_0")
modules/scene_saver/withoutDrivenState
withoutDrivenState(rec: any, base: any?): any
An entity record with the running simulation's state taken out:
every transform channel and component field a component drove in play on
the entity the record names carries the value base states for it, and is
left out where base states none. With the scene's record as base, it is
what a verdict writes into the scene for a live entity: accepting an
author's change records that change and leaves the value a running
component happened to hold that frame where the scene had it. With no
base, it is what a write to the scene applies to a live entity in play,
leaving each channel and field a running component drives to that
component.
Parameters
recany(optional) — The entity record; itsidnames the entity whose driven state is read.baseany?(optional) — The record whose values the driven channels and fields take; nil leaves them out.
local ss = require("@builtin::assetTypes.scene.shared.saver"); ss.withoutDrivenState(ss.serializeEntity(id), saved)
modules/scene_swap_orchestrator/README
require("@builtin::assetTypes.scene.shared.swapOrchestrator") -- scene_swap_orchestrator
Drives multiplayer room transitions + the scene-swap gate around scene load/unload events. Subscribes to layers.onUnload + layers.onBeforeLoad and translates them into a leaveRoom -> gate.begin -> teardown -> gate.finish -> joinRoom sequence. Room key is {worldGuid}/{profile}/{mode}/{sceneGuid} — never name-based; world and scene segments are always GUIDs (stable across renames and collaborators), and {profile} (runtime/editor) keeps published and live peers apart. Without this orchestrator, scene swaps world would broadcast EntityDespawn to peers still subscribed to the old room, and transient teardown state would land in the dirty file.
Usage: local scene_swap_orchestrator = require("@builtin::assetTypes.scene.shared.swapOrchestrator")
modules/scopes/README
require("@builtin::modules.scopes") -- scopes (also available as global 'scopes')
Scopes: work you start together and that ends together, tied to what started it (an entity, a component, a scene, another scope), and the owning contexts every live resource is registered under. -- Load two things at once; neither outlives the load. task.spawn(function() scopes.run(function(s) s:spawn("terrain", function() task.wait(2) end) s:spawn("props", function() task.wait(1) end) end) print("both are done") end) -- What is live, and what will never be reached by a seam? for _, r in scopes.list() do if not r.endsAtASeam then print(r.kind, r.handle, r.scope, r.detail) end end
Start several pieces of work that must not outlive the thing that started
them, and wait for all of them:
scopes.run(function(s)
s:spawn("load-terrain", function() ... end)
s:spawn("load-props", function() ... end)
end)
-- returns once both are finished or cancelled; the first error either
-- raised is raised again here, after the other one was cancelled
Start work tied to an entity, without waiting for it:
local s = scopes.open({ entity = npc })
s:spawn("patrol", function() while true do ... task.wait(1) end end)
s:spawn("bark", function() ... end)
-- despawning npc cancels both; so does s:cancel()
Everything a task in a scope starts belongs to the scope too: a
task.spawn inside it, a job it registers, a scope it opens. A scope is
lived inside what the code opening it belongs to, so a scope opened in a
component's hook ends with the component (destroyed or hot-reloaded), one
opened by a scene's entrypoint ends with that load of the scene, and one
opened in another scope's work ends with that scope.
When a scope ends, every task still running in it is cancelled, and
unwinds: the cancellation is raised at the wait it is suspended in, so a
pcall or cleanup around that wait runs (task.isCancellation(err)
recognises it). A scope ends when:
- its
scopes.runis over; - work in it raises: the rest of its work is cancelled, and
join(and soscopes.run) raises that first error again where it is called.s.onError = function(name, err) endobserves every error as it is raised. The VM-widetask.onErroris not told while ascopes.runor ajoinwaits for the scope oronErrorobserves it; an error in a scope nothing waits for or observes is reported as any task's error is; s:cancel(),scopes.release(s.tag), or cancelling the task waiting inscopes.run;- what it is lived inside ends: the entity it is tied to despawns, the
component is destroyed or hot-reloaded, the scene load ends, the
enclosing scope ends.
s:why()says which ended it first, and is nil while the scope is open. Ascopes.runwhose scope something else ended returns once the work it started is cancelled, ands:why()names what ended it. The registry: a resource reached through a handle (a task, a substrate job, a camera feed, an input-map activation, an input subscription) outlives the call that made it. Each one records the context it was registered from, and the engine ends what a context left behind once that context's run is over. The contexts, by scope tag: scope:<n>: a task scope, as above.entity:<id>: an entity. Ends when it is despawned.scene:<guid>#<n>: one load of a scene layer. Ends when the load ends: the layer is reloaded or unloaded, the scene is swapped, the mode flips.chunk:<identity>: a module. Ends when the module runs again (a VFS write to its source) or is dropped from the require cache (vfs.reload). The next run registers its own.component:<instanceId>: one component instance. Ends when that instance is destroyed: its entity despawned, its scene cleared, the component removed. A hot reload of the component ends its tasks and the resources Luau code holds for it (listed with kindluau), and the new life'sawaketakes its own.exec:<chunk>: a chunk submitted for a single run, such as anexecutecall. It is never re-entered, so nothing ends it on its own. Aluauresource (an input-map activation, an input subscription) taken by work in a task scope, such as afuture.spawnbody or a future's handler, follows what that scope runs inside rather than the scope: the holder keeps it after the work is over.list()shows every live resource by the context it follows, andrelease(scope)ends everything under one. That last is what reaches a resource no variable names any more: a task anexecutecall started and lost the handle of is listed underexec:<chunk>, and releasing that tag cancels it.
Usage: local scopes = require("@builtin::modules.scopes") Also available as global: scopes
modules/scopes/cancel
cancel(self: Scope, name: string?): number
Cancel the work named name, or end the whole scope when name is
omitted. Cancelled work unwinds: its cleanup runs at the wait it is
suspended in. Returns how many tasks this cancelled.
Parameters
selfScopenamestring?(optional) — A child's name; omit to end the scope.
s:cancel("patrol")
modules/scopes/children
children(self: Scope): { ScopeChild }
What this scope started with spawn, in the order started, each with
its current task.status: every child still running, and the 32 that
ended most recently.
Parameters
selfScope
for _, c in s:children() do print(c.name, c.status) end
modules/scopes/current
current(): string?
The scope the calling code registers a resource under right now: the module whose body is running, the task scope its work runs in, the component instance whose lifecycle hook is on the stack, or the chunk of this call. Nil when the caller registers under no context.
print("resources I register follow", scopes.current())
modules/scopes/join
join(self: Scope, name: string?)
Wait until the work named name (all of the scope's work when omitted)
is finished or cancelled, its cleanup included. Raises the first error
that work raised, as it was raised. Called from work in the scope (the
function scopes.run runs, say), it waits for the rest of the work and
not for the calling task. Waits, so call it from a task.
Parameters
selfScopenamestring?(optional) — A child's name; omit to wait for everything in the scope.
s:join()
modules/scopes/list
list(): { LiveResource }
Every live resource that follows an owning context, across every subsystem holding them. A resource registered with no context above it, the engine's own, is not listed, because no scope reaches it.
for _, r in scopes.list() do print(r.scope, r.kind, r.detail) end
modules/scopes/open
open(options: ScopeOptions?): Scope
Open a task scope without waiting for it: start work in it with
s:spawn, end it with s:cancel(), or let what it is lived inside end it
({ entity = id } ties it to an entity). Wait for its work with
s:join() from a task.
Parameters
optionsScopeOptions?(optional) —{ entity = id }ties the scope to an entity;{ name = "..." }names it.
local s = scopes.open({ entity = npc }); s:spawn("patrol", patrol)
modules/scopes/release
release(scope: string): { Released }
End every resource registered under scope, across every subsystem:
tasks are cancelled, jobs dropped. Reaches contexts no seam does, such as
the chunk of an execute call that started something and ended without
ending it. An execute call runs as a task listed under its own exec:
scope, so releasing that scope from the same call cancels the call too:
release it from a later call.
Parameters
scopestring— A scope tag, as thescopefield of alist()row carries it.
local ended = scopes.release("exec:__exec_12")
modules/scopes/run
run(fn: (Scope) -> ...any, options: ScopeOptions?): ...any
Run fn(s) in a new task scope and wait until every piece of work
started in it is finished or cancelled. Returns what fn returned. The
first error raised by fn or by any work in the scope cancels the rest,
and is raised again here, as it was raised, once their cleanup has run.
Waits, so it must be called from a task: in code that cannot wait (a
component hook called directly, a callback) it raises, naming that.
Parameters
fn(Scope) -> ...any— The function to run; it receives the scope, and starts work withs:spawn.optionsScopeOptions?(optional) —{ entity = id }ties the scope to an entity;{ name = "..." }names it.
scopes.run(function(s) s:spawn("a", fa); s:spawn("b", fb) end)
modules/scopes/spawn
spawn(self: Scope, name: string, fn: (...any) -> ...any, ...: any): number
Start fn(...) as a task in this scope, named name, and return its
task handle. The task, and everything it starts, belongs to the scope: it
is cancelled (and unwinds) when the scope ends. Raises when the scope has
already ended, naming why.
Parameters
selfScopenamestring— What the work is called, inchildren(),join(name), errors and listings.fn(...any) -> ...any— The function to run.argsany(optional)
s:spawn("props", function() task.wait(1) end)
modules/scopes/why
why(self: Scope): string?
Why the scope ended: its run finished, it was cancelled, a named
child raised, or what it was lived inside ended (entity:<id> ended,
component:<id> ended, ...). Nil while the scope is open.
Parameters
selfScope
print(s:why())
modules/screenSpaceGI/README
require("@builtin::systems.screenSpaceGI.screenSpaceGI") -- screenSpaceGI
Indirect diffuse light gathered from the scene that was just drawn, so anything on screen bounces light onto its neighbours — including geometry that moved this frame, which a baked lightmap cannot follow.
Usage: local screenSpaceGI = require("@builtin::systems.screenSpaceGI.screenSpaceGI")
modules/screenSpaceGI/active
active(): boolean
Whether the screen-space GI pass is running this frame.
if screenSpaceGI.active() then ... end
modules/screenSpaceGI/clear
clear()
Turn screen-space GI off and release the pass. The other settings are
kept, so a later set({ intensity = ... }) brings back the same look.
screenSpaceGI.clear()
modules/screenSpaceGI/get
get(): SSGIState
The screen-space GI settings currently in force.
local r = screenSpaceGI.get().radius
modules/screenSpaceGI/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = screenSpaceGI.paramsBuffer()
modules/screenSpaceGI/set
set(opts: SSGIOpts?): SSGIState
Set the scene's screen-space GI. Any omitted field keeps its current
value. An intensity of 0 turns it off and releases the pass.
Parameters
optsSSGIOpts?(optional) — Screen-space GI settings — seeSSGIOpts.
screenSpaceGI.set({ intensity = 1.0, radius = 2.0 })
modules/service/README
require("@builtin::modules.api.engine.service") -- service (also available as global 'service')
Credit-metered service invoke, buffered or streamed. Public Luau surface over the __service Internal FFI namespace.
Usage: local service = require("@builtin::modules.api.engine.service") Also available as global: service
modules/service/authenticated
authenticated(): boolean
Whether a platform identity (JWT) is available to attach to service calls. Returns only a boolean — never the token.
if not service.authenticated() then error("link ZeroMind") end
modules/service/balance
balance(): PromiseHandle?
Read the caller's credit balance from ZeroMind. Returns a
promise handle for task.await() resolving the balance JSON, or nil
when the gateway is unconfigured or no caller identity is available.
local h = service.balance(); local raw = h and task.await(h)
modules/service/configureGateway
configureGateway(baseUrl: string, tokenIssuer: string?): boolean
TRUSTED ONLY. Set the ZeroMind base URL that service.invoke,
service.balance and a trusted plugin's service calls target, and
the issuer the JWTs it mints name as iss. The trusted-VM auth
bootstrap calls this with the resolved issuer and token issuer.
Parameters
baseUrlstring— ZeroMind base URL (e.g. "https://origozero.ai").tokenIssuerstring?(optional) — Theissthe base URL's JWTs carry (optional; e.g. "https://api.origozero.ai"). Omitted, the base URL signs its own.
service.configureGateway("https://origozero.ai", "https://api.origozero.ai")
modules/service/configureWorld
configureWorld(guid: string): boolean
TRUSTED ONLY. Set the bound world guid attached to metered service invocations, so the credit ledger attributes each charge to the world it happened in. The trusted-VM world-load hook calls this on every bind so a runtime world switch re-points attribution.
Parameters
guidstring— The bound world's guid.
service.configureWorld(world.guid())
modules/service/gatewayConfigured
gatewayConfigured(): boolean
Whether the ZeroMind service gateway has been configured.
Service handlers use this to distinguish "gateway not configured"
from "not signed in" when invoke returns nil.
if not service.gatewayConfigured() then error("no gateway") end
modules/service/invoke
invoke(offering: string, endpoint: string, opts: InvokeOpts?): PromiseHandle?
Invoke a provider offering's logical endpoint through ZeroMind.
Returns a promise handle for task.await() resolving the
InvokeResponse JSON, or nil when the gateway is unconfigured or no
caller identity is available. The JWT and real upstream URL are
never exposed to Luau.
Parameters
offeringstring— Fully-qualified offering identityprovider/name(e.g. "origozero/mesh_gen").endpointstring— Logical endpoint name (e.g. "create_preview").optsInvokeOpts?(optional) —{ params?, headers?, body?, max_credits?, idempotency_key? }.
local h = service.invoke("origozero/mesh_gen", "create_preview", { body = { prompt = p } })
modules/service/invokeStream
invokeStream(offering: string, endpoint: string, opts: StreamOpts): ServiceStream?
Invoke a provider offering's logical endpoint as a stream. ZeroMind
relays the upstream's server-sent events as they arrive, then ends with
a zeromind.settled event whose data is {"charged":N,"balance":M}, or
a zeromind.failed event whose data is {"reason":...} when the relay
stopped early. A call it refuses before the stream starts arrives as one
zeromind.refused event carrying the HTTP status and the JSON answer
as data; a call that could not be made, or a stream that broke or went
quiet, arrives as zeromind.failed. Returns a stream at once, or nil
when the gateway is unconfigured or no caller identity is available,
exactly as invoke. Take events with stream:poll() (never waits) or
stream:read() (waits for the next event; nil at the end), and release
the connection with stream:close(). opts takes what invoke takes,
plus a required idempotency_key that is unique to this call (ZeroMind
refuses a key a streamed call already used) and an optional timeout_ms
bounding the wait for the response head and for each next chunk (default
120000). The JWT and the real upstream URL are never exposed to Luau.
Parameters
offeringstring— Fully-qualified offering identityprovider/name(e.g. "origozero/llm").endpointstring— Logical endpoint name (e.g. "chat").optsStreamOpts—{ params?, headers?, body?, idempotency_key, timeout_ms? }.
local s = service.invokeStream("origozero/llm", "chat", { body = { messages = msgs }, idempotency_key = id })
while s do local ev = s:read(); if ev == nil then break end; print(ev.event, ev.data) end
modules/service/jobStatus
jobStatus(jobId: string): PromiseHandle?
Poll a submitted service job. Returns a promise handle for
task.await() resolving the JobStatusResponse JSON { job_id, status, result?, error? }: status walks pending/running -> succeeded
(with result, the same InvokeResponse invoke returns) or failed
(with error). nil when the gateway is unconfigured or no caller
identity is available.
Parameters
jobIdstring— Job id returned bysubmitJob.
local h = service.jobStatus(jobId); local raw = h and task.await(h)
modules/service/quote
quote(offering: string, endpoint: string, opts: InvokeOpts?): PromiseHandle?
Read an exact tier price without charging or calling a provider.
Parameters
offeringstringendpointstringoptsInvokeOpts?(optional)
modules/service/submitJob
submitJob(offering: string, endpoint: string, opts: InvokeOpts?): PromiseHandle?
Submit a durable async invocation of an offering endpoint. Same
arguments as invoke, but the provider round-trip runs server-side
(off this connection), so a slow synchronous provider or a dropped
link no longer loses the result. Returns a promise handle for
task.await() resolving { job_id, status }; poll it with
jobStatus. nil when the gateway is unconfigured or no caller
identity is available.
Parameters
offeringstring— Fully-qualified offering identityprovider/name(e.g. "origozero/mesh_gen").endpointstring— Logical endpoint name (e.g. "create_preview").optsInvokeOpts?(optional) —{ params?, headers?, body?, max_credits?, idempotency_key? }.
local h = service.submitJob("origozero/mesh_gen", "create_preview", { body = { prompt = p } })
modules/shader/README
require("@builtin::modules.api.engine.shader") -- shader (also available as global 'shader')
Shader compilation — turning authored WGSL into registered GPU programs, and the reusable modules those programs include. Public Luau surface over the __shader Internal FFI namespace.
Usage: local shader = require("@builtin::modules.api.engine.shader") Also available as global: shader
modules/shader/compile
compile(keys: string | { string }, opts: { [string]: any }): boolean
Compile a zero-scaffolding SURFACE shader: the author wrote only
vertex() / fragment() and declared its material properties, and the
engine generates the group(1) material interface plus every render-mode
entry point. Compiles once and registers the result under its key.
Parameters
keysstring | { string }— The shader key (guid@checksumof the version compiled), alone or as a one-element array.opts{ [string]: any }—{ source, domain?, properties?, replaces? }— the author's WGSL, its@domain, the declared property schema, and the key this shader compiled under before its source changed, whose materials move to the new key.
local m = asset.meta(ref); shader.compile(m.guid .. "@" .. m.checksum, { source = wgsl, properties = props })
modules/shader/forget
forget(keys: string | { string }): boolean
Drop what a removed shader registered under its key: its programs and their variants, the composed WGSL, the compile status and the diagnostic. The pipelines built from those programs are evicted and the materials drawing through them re-prepare.
Parameters
keysstring | { string }— The shader key (guid@checksum), alone or in an array.
local m = asset.meta(ref); shader.forget(m.guid .. "@" .. m.checksum)
modules/shader/registerModule
registerModule(keys: string | { string }, source: string): boolean
Register a block of WGSL other shaders include. Every key names the same source, so a shader includes it by whichever name it holds — its guid, its identity, or an alias. Registering again replaces it, and the shaders that include it recompile.
Parameters
keysstring | { string }— One key, or the array of keys this module answers to.sourcestring— The module's WGSL.
shader.registerModule({ ref.guid, ref.identity }, wgsl)
modules/shader/status
status(name: string): (string, string?)
A shader's latest compile outcome, without reading the engine log:
"compiled", "failed" (with the compiler error second), or "pending".
Compilation is async, so a "pending" straight after a write means ask
again next frame.
Parameters
namestring— The key it compiled under (guid@checksum), or a reference to a shader asset (identity, path, guid), which reaches the key of the version that reference resolves to now.
local status, err = shader.status("myShader")
modules/shader_includes/README
require("@builtin::modules.shader_includes") -- shader_includes
Resolves the #include lines of a WGSL source against the asset system, so a shader includes a .shaderModule by every name form require and asset.resolve accept.
Usage: local shader_includes = require("@builtin::modules.shader_includes")
modules/shader_includes/canonicalize
canonicalize(source: string, base: string): string
Rewrite every #include in source whose literal names a
.shaderModule to that module's guid, resolved against base, and bring
every module the source reaches up to date with what the VFS serves. A
literal that resolves to no asset is left as it was written, so a framework
name reaches the expander unchanged.
Parameters
sourcestring— The WGSL as authored.basestring— VFS path of the asset the source belongs to — what a~/~.tail/.relative.tailliteral expands against.
local wgsl = ShaderIncludes.canonicalize(vfs.read(path .. "/shader.wgsl"), path)
modules/shader_includes/settle
settle(): { string }
Compile again every shader whose last compile named a module that no
asset answered to and that one now does — a shader written before the
module it includes. Called when a .shaderModule registers. Each such
shader is sent a dependency change, which its type answers by compiling.
ShaderIncludes.settle()
modules/sharpening/README
require("@builtin::systems.sharpening.sharpening") -- sharpening
Contrast-adaptive sharpening. Restores local acuity to the finished frame, backing off wherever the neighbourhood has no headroom left, which is what keeps a bright fringe from forming along high-contrast edges.
Usage: local sharpening = require("@builtin::systems.sharpening.sharpening")
modules/sharpening/active
active(): boolean
Whether the sharpening pass is running this frame.
if sharpening.active() then ... end
modules/sharpening/disable
disable()
Turn sharpening off and release the pass.
sharpening.disable()
modules/sharpening/enable
enable(sharpness: number?): State
Turn sharpening on at a given strength.
Parameters
sharpnessnumber?(optional) — Strength in [0, 1]. Omit to keep the current value.
sharpening.enable(0.5)
modules/sharpening/get
get(): State
The sharpening settings currently in force.
local s = sharpening.get().sharpness
modules/sharpening/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = sharpening.paramsBuffer()
modules/sharpening/set
set(opts: SharpenOpts?): State
Set the sharpening strength. Any omitted field keeps its current value.
Parameters
optsSharpenOpts?(optional) — Sharpening settings — seeSharpenOpts.
sharpening.set({ sharpness = 0.6 })
modules/shell/README
require("@builtin::modules.api.engine.shell") -- shell (also available as global 'shell')
Engine emulated Unix shell — same shell that powers the MCP bash tool. Public Luau surface over the __shell Internal FFI namespace.
Usage: local shell = require("@builtin::modules.api.engine.shell") Also available as global: shell
modules/shell/run
run(command: string, sessionKey: string?): ShellResult
Execute a command in the engine's emulated Unix shell and
return once it has completed. This is the same shell as the MCP
bash tool — 60+ builtins (ls, cat, grep, find, echo, ...)
operating on the virtual scene filesystem. A command that runs
Luau (run, luau, zm, zero) needs the engine's frame loop,
and a command whose work is a wait (sleep) cannot take its
interval while holding it, so from a coroutine the whole line is
queued to run off the frame loop and this yields until it
finishes; everything else runs inline. The queued run starts the
line again from the top, so a line that had already written a
file, sent a request, read input or started a background job
comes back with the explanation in stderr and shell.runAsync
as the way to run it whole. A command reaches the files the code
running it reaches, the jobs it starts and the Luau it runs
included: run for code a world ships, it is refused the home folder
(/zero/home) the way vfs refuses that code.
Parameters
commandstring— Shell command to execute.sessionKeystring?(optional) — Which caller's shell session the command runs in. A session holds what a command leaves behind: the directorycdmoved to, exports, shell functions,set -e. It hands that to the next command run under the same key. Omit it and the command runs in the session of the caller this code runs on behalf of, the one that caller'sbashcommands also use; code with no attested caller behind it runs in the session every caller that names none shares. A command run for code a world ships keeps what it leaves behind in a session of that code's own under the key: it reaches that code's next command and never a command of the caller's own.
local r = shell.run("ls /zero/source")
modules/shell/runAsync
runAsync(command: string, sessionKey: string?): string
Asynchronous version of shell.run. Returns a promise ID that
resolves to a JSON-encoded result string. Use with
task.await().
Parameters
commandstring— Shell command to execute.sessionKeystring?(optional) — Which caller's shell session the command runs in. A session holds what a command leaves behind: the directorycdmoved to, exports, shell functions,set -e. It hands that to the next command run under the same key. Omit it and the command runs in the session of the caller this code runs on behalf of, the one that caller'sbashcommands also use; code with no attested caller behind it runs in the session every caller that names none shares. A command run for code a world ships keeps what it leaves behind in a session of that code's own under the key: it reaches that code's next command and never a command of the caller's own.
local json = task.await(shell.runAsync("find /zero -name '*.luau'"))
modules/skeleton/README
require("@builtin::modules.api.engine.skeleton") -- skeleton (also available as global 'skeleton')
The skeleton pose-data pipeline: sample a clip into a pose buffer, and bind/apply a pose buffer onto a Skeleton + Model entity. Public Luau surface over the __skeleton and __clip Internal FFI namespaces.
Usage: local skeleton = require("@builtin::modules.api.engine.skeleton") Also available as global: skeleton
modules/skeleton/applyPose
applyPose(sinkHandle: number, poseBuffer: Substrate.TypedBuffer): boolean
Snapshot the buffer's first layout.total_floats values and
queue a pending apply for the next ECS drain. Returns false on
unknown sink/buffer or buffer too small for the layout. The
Buffer is unchanged.
Parameters
sinkHandlenumber— Sink handle frombindPose.poseBufferSubstrate.TypedBuffer— The pose buffer to apply.
modules/skeleton/bindClip
bindClip(zanimBytes: buffer | string, boneOrder: { string }): ClipBindInfo?
Decode a zanim payload and bind it to boneOrder,
precomputing which of the clip's channels feed each bone so
per-frame sampleClip is allocation-free. Returns
{ handle, matched, total, duration }, or nil on a malformed
payload / empty bone order. Check matched: 0 means the clip
drives none of these bones.
Parameters
zanimBytesbuffer | string— The clip'sdata.zanimpayload bytes (binary-safe).boneOrder{ string }— Output bone names — one stride-10 record per bone.
modules/skeleton/bindPose
bindPose(entityId: (string | entityRef)?, opts: SkeletonLayout): number?
Register a pose sink targeting entityId. The opts table
carries the layout: boneOrder is the bone-name array
({"hip", "spine", ...}), stride defaults to 10
(translation.xyz + rotation.xyzw + scale.xyz). Pass entityId
as nil to use the current component's owning entity.
Parameters
entityId(string | entityRef)?(optional) — Engine entity id or proxy, or nil for the current entity.optsSkeletonLayout—{ boneOrder, stride }.
local h = skeleton.bindPose(nil, { boneOrder = bones, stride = 10 })
modules/skeleton/clipBones
clipBones(zanimBytes: buffer | string): { string }?
Decode a zanim payload and return its bone-name array. Pure:
build a bind order or a retarget map from a clip without binding a
sampler. Returns nil on bytes that aren't a valid zanim payload.
Parameters
zanimBytesbuffer | string— The clip'sdata.zanimpayload bytes (binary-safe).
local names = skeleton.clipBones(assert(vfs.read(path .. "/data.zanim")))
modules/skeleton/clipDecode
clipDecode(zanimBytes: buffer | string): string?
Decode a zanim payload to its readable JSON form
({ name, duration, channels, bone_names }), the clip as text to
read, store or diff. The binary parse is the engine's. Code that
transforms a clip's channels in Luau (e.g. the retarget bake) reads
the same clip as a table with clipToTable, which skips the text.
Returns nil on bytes that aren't a valid zanim payload. Inverse of
clipEncode.
Parameters
zanimBytesbuffer | string— The clip'sdata.zanimpayload bytes (binary-safe).
local json = require("@builtin::modules.json")
local clipJson = skeleton.clipDecode(bytes)
local clip = if clipJson then json.decode(clipJson) else nil
modules/skeleton/clipEncode
clipEncode(jsonString: string): string?
Encode a clip's JSON form (the shape clipDecode returns) back
to a zanim payload — the bytes a .animation stores and
bindClip/sampleClip consume. Inverse of clipDecode. A clip
held as a table encodes with clipFromTable, which skips the text.
Returns nil on invalid JSON.
Parameters
jsonStringstring— A clip JSON document.
local json = require("@builtin::modules.json")
local bytes = skeleton.clipEncode(json.encode(clip))
modules/skeleton/clipFromTable
clipFromTable(clip: { [string]: any }): (string?, string?)
Encode a clip table (the shape clipToTable returns) to a zanim
payload, the bytes a .animation stores and bindClip/sampleClip
consume. Every field is required and every number finite. Inverse of
clipToTable. Returns nil and the reason, naming the field, when the
table is not a clip.
Parameters
clip{ [string]: any }— A clip table:{ name, duration, channels, bone_names }.
local bytes = skeleton.clipFromTable(clip)
modules/skeleton/clipPack
clipPack(packed: PackedClip): (string?, string?)
Encode a clip in packed form (the shape clipUnpack returns) into
zanim bytes. Channels may share one run of times by naming the same
keyOffset; interpolation defaults to Linear; with no boneNames the
clip names its bones in the order its channels first drive them.
times and values take a compute readback's resultBytes()
directly. Returns nil and the reason, naming the channel, when a
channel's keys fall outside the runs or its times run backwards.
Parameters
packedPackedClip— The packed clip.
local bytes = skeleton.clipPack(packed)
modules/skeleton/clipToTable
clipToTable(zanimBytes: buffer | string): { [string]: any }?
Decode a zanim payload to a table: { name, duration, channels = { { target_bone, path, keyframes_in, keyframes_out, interpolation } }, bone_names }, the shape clipDecode writes as JSON, built by the engine
in place. path is Translation, Rotation or Scale; interpolation
is Linear, Step or CubicSpline. Inverse of clipFromTable.
Returns nil on bytes that aren't a valid zanim payload.
Parameters
zanimBytesbuffer | string— The clip'sdata.zanimpayload bytes (binary-safe).
local clip = skeleton.clipToTable(bytes)
modules/skeleton/clipUnpack
clipUnpack(zanimBytes: buffer | string): PackedClip?
Decode a zanim payload into its packed form: a channel table
({ bone, path, interpolation, keyOffset, keyCount, valueOffset },
offsets 0-based element indices) and two buffers of little-endian
f32s, times and values, holding every channel's keys channel after
channel (3 floats a key for Translation and Scale, 4 for Rotation, three
times that for CubicSpline). The runs go straight into a typed buffer
(buf:writeBytes(packed.values)) for a compute pass. Returns nil on
bytes that aren't a valid zanim payload. Inverse of clipPack.
Parameters
zanimBytesbuffer | string— The clip'sdata.zanimpayload bytes (binary-safe).
local packed = skeleton.clipUnpack(bytes)
modules/skeleton/jointTransforms
jointTransforms(entityId: string | entityRef): table
Read a skinned entity's per-joint world transforms for the current animated pose.
Parameters
entityIdstring | entityRef— Engine entity id or proxy of a skinned entity.
local joints = skeleton.jointTransforms(meshId)
modules/skeleton/sampleClip
sampleClip(handle: number, time: number, poseBuffer: Substrate.TypedBuffer): boolean
Sample the bound clip at time (clamped to [0, duration])
and write one stride-10 pose record per bound bone into the
Buffer, starting at index 0. Bones the clip does not drive are
written as identity. Returns false on unknown handle/buffer or a
buffer too small for the bone count.
Parameters
handlenumber— Sampler handle frombindClip.timenumber— Sample time in seconds.poseBufferSubstrate.TypedBuffer— The stride-10 pose buffer written into.
modules/skeleton/unbindClip
unbindClip(handle: number): boolean
Drop the bound clip sampler from the registry.
Parameters
handlenumber— Sampler handle to remove.
modules/skeleton/unbindPose
unbindPose(sinkHandle: number): boolean
Remove the sink from the registry.
Parameters
sinkHandlenumber— Sink handle to remove.
modules/sky/README
require("@builtin::modules.api.engine.sky") -- sky (also available as global 'sky')
Sky configuration — type, time of day, day/night cycle, procedural parameters, presets, explicit sun direction. Public Luau surface over the __sky Internal FFI namespace.
Usage: local sky = require("@builtin::modules.api.engine.sky") Also available as global: sky
modules/sky/get
get(): { [string]: any }
Get all current sky configuration as a table. Returns the
same fields as sky.set accepts, plus read-only fields like
material_name and type. Color values are returned as
positional arrays [r, g, b].
local cfg = sky.get(); print(cfg.time_of_day)
modules/sky/getTimeOfDay
getTimeOfDay(): number
Get the current time of day in hours (0-24).
local t = sky.getTimeOfDay()
modules/sky/installFallback
installFallback()
Register the engine fallback sky material and install it as the engine-level fallback (rendered when a scene has no sky entity). Idempotent; requires a live renderer — the scene loader calls it.
sky.installFallback()
modules/sky/preset
preset(name: string)
Apply a named sky preset. Available: clear_day, sunset,
sunrise, overcast, night, studio, none. Raises a Luau
error for unrecognized names — wrap in pcall if uncertain.
Parameters
namestring— Preset name (case-sensitive).
sky.preset("sunset")
modules/sky/set
set(opts: SkyOpts)
Configure the sky system. All fields are optional — only
provided fields are updated. Color fields accept both named
{x=r, y=g, z=b} and positional {r, g, b} forms. color is
an alias for solid_color.
Parameters
optsSkyOpts— Sky configuration properties.
sky.set({ type = "procedural", time_of_day = 14, sync_sun_to_light = true })
modules/sky/setSunDirection
setSunDirection(dir: SkyColor)
Set an explicit sun direction and disable time-based sun positioning. The directional light is updated to match.
Parameters
dirSkyColor— Normalized sun direction vector.
sky.setSunDirection({ 0.5, -1, 0.3 })
modules/sky/setTimeOfDay
setTimeOfDay(time: number)
Set the time of day (0-24 hours). 0 = midnight, 6 = sunrise, 12 = noon, 18 = sunset.
Parameters
timenumber— Time of day in hours.
sky.setTimeOfDay(18.5)
modules/spatialStreaming/README
require("@builtin::systems.spatialStreaming.spatialStreaming") -- spatialStreaming
Usage: local spatialStreaming = require("@builtin::systems.spatialStreaming.spatialStreaming")
modules/spatialStreaming/add
add(records: { Record }, opts: { [string]: any }?): string
Register a group of records for content that is not spawned. This is
the path that lets a world hold more than it can spawn at once: with
store = "vfs" the records are written to a file under the configured
directory and only the cell's manifest stays in memory until a source
arrives.
Parameters
records{ Record }— Array of records, root first. A record'sparentindexes another record of the same array.opts{ [string]: any }?(optional) —{ layer = "default", store = "memory" | "vfs" }.
spatialStreaming.add({ { name = "rock", position = { x = 300, y = 0, z = 0 }, components = { Model = { model = "@builtin::meshes.cube" } } } }, { store = "vfs" })
modules/spatialStreaming/addSource
addSource(target: any, opts: { [string]: any }?): number
Add a streaming source. A cell is resident while ANY source wants it resident and released only once every source wants it released, so several sources — a player and a spectator camera, two split-screen players — each keep the region they stand near.
A source carries its own radii, which is what lets a distant spectator stream a thin shell while the player streams a deep one. Radii left out follow the layer's, and the layer's follow the configuration.
Parameters
targetany(optional) — An entity id, an entity proxy, an entity name, or a fixed world position{ x, y, z }.opts{ [string]: any }?(optional) —{ loadRadius, unloadRadius, proxyRadius, proxyUnloadRadius }— this source's own radii, for the content and for the far field it sees proxies in. A source that names an unload radius of its own sees a far field measured from it unless it names that too.
spatialStreaming.addSource(entity.find("Player"), { loadRadius = 90, unloadRadius = 140 })
modules/spatialStreaming/capture
capture(targets: any, opts: { [string]: any }?): { [string]: any }
Hand live entities to the streaming store. Each target is the ROOT of a group: it and its descendants are serialized together and placed in the cell the root stands in. The entities are left standing — residency passes to the streaming rule, which releases them on the first tick that puts them past the unload radius.
A target that is replicated to other peers is refused: residency is a local decision, and despawning a replicated entity on one client would reach the others. A target that already has a parent is refused too — its root is the group, and capturing a branch of one would leave the rest behind. A target the store already holds is refused as well, and counted: a second group over the same live entities would despawn them on the first release and leave the second group naming content that is gone.
Parameters
targetsany(optional) — Array of entity ids, proxies, or names, or a single name glob.opts{ [string]: any }?(optional) —{ layer = "default", store = "memory" | "vfs" }.
spatialStreaming.capture(entity.findAll("rock_*"), { layer = "props" })
modules/spatialStreaming/cellBounds
cellBounds(key: string, cellSize: number): { minX: number, minZ: number, maxX: number, maxZ: number }
Ground footprint of a cell.
Parameters
keystring— Cell key.cellSizenumber— Edge length of a cell in world units.
local b = spatialStreaming.cellBounds("2:-1", 64)
modules/spatialStreaming/cellCoords
cellCoords(key: string): (number, number)
Grid coordinates a cell key names.
Parameters
keystring— Cell key fromcellKeyAt.
local cx, cz = spatialStreaming.cellCoords("2:-1")
modules/spatialStreaming/cellDistance
cellDistance(key: string, cellSize: number, x: number, z: number): number
Distance from a point to the nearest edge of a cell's footprint, zero when the point stands inside it. Measuring to the centre instead would put a cell's near corner inside the load radius while the cell itself reads as far, so a source walking along a boundary would see the ground it is on released.
Parameters
keystring— Cell key.cellSizenumber— Edge length of a cell in world units.xnumber— World-space X of the point.znumber— World-space Z of the point.
local d = spatialStreaming.cellDistance("2:-1", 64, 10, 10)
modules/spatialStreaming/cellKeyAt
cellKeyAt(x: number, z: number, cellSize: number): string
Key of the cell a world-space point stands in. Cells are square columns on the ground plane: height never enters, because a world's content is spread over its ground rather than through its air, and a column keeps a tower and its foundation in one cell.
Parameters
xnumber— World-space X.znumber— World-space Z.cellSizenumber— Edge length of a cell in world units.
local key = spatialStreaming.cellKeyAt(130, -40, 64)
modules/spatialStreaming/cells
cells(): { any }
Per-cell view of the store, for inspection and for tests.
local c = spatialStreaming.cells()
modules/spatialStreaming/clearProxy
clearProxy(target: any, opts: { [string]: any }?): boolean
Take a cell's proxy away, despawning it if it is standing.
Parameters
targetany(optional) — A cell key or a{ x, y, z }world position.opts{ [string]: any }?(optional) —{ layer = "default" }.
spatialStreaming.clearProxy("4:0")
modules/spatialStreaming/clearSources
clearSources()
Drop every streaming source. Cells hold whatever residency they have — nothing loads or releases while no source stands anywhere.
spatialStreaming.clearSources()
modules/spatialStreaming/config
config(): { [string]: any }
The configuration now in force. The far field is reported as the distances it is measured at, whether they were given or follow the content radii.
local c = spatialStreaming.config()
modules/spatialStreaming/configure
configure(opts: { [string]: any }?): { [string]: any }
Set the grid and the radii every layer inherits. Keys left out keep their current value.
A new cellSize re-buckets everything the store already holds, by each
group's own root position. A cell key means nothing without the size it was
measured with, so content filed under the old grid would otherwise be
measured against footprints it never stood in.
Parameters
opts{ [string]: any }?(optional) —{ cellSize, loadRadius, unloadRadius, proxyRadius, proxyUnloadRadius, budget, dir }.budgetis how many entity records one tick may spend on loading and releasing; the proxy pair is the far field a released cell's stand-in covers, and followsunloadRadiusunless it is given — passing 0 for either hands it back to that;diris the VFS directory a file-backed cell writes under.
spatialStreaming.configure({ cellSize = 50, loadRadius = 100, unloadRadius = 160 })
modules/spatialStreaming/decide
decide(distance: number, loadRadius: number, unloadRadius: number): string
Residency a cell whose nearest edge is distance from the closest
source should be in. Inside loadRadius it is wanted resident, past
unloadRadius it is wanted released, and between the two it keeps whatever
it already is — the band is what stops a source resting on a boundary from
loading and releasing the same cell every frame.
Parameters
distancenumber— Distance from the nearest source to the cell's nearest edge.loadRadiusnumber— Distance within which a cell is wanted resident.unloadRadiusnumber— Distance past which a cell is wanted released.
local want = spatialStreaming.decide(140, 128, 192)
modules/spatialStreaming/deriveProxies
deriveProxies(opts: { [string]: any }?): { [string]: any }
Build bounding-silhouette proxies from the content the store already
holds — one box over a whole cell, or one over each group in it. This is
the automatic path; setProxy is the one that takes an authored mesh or
impostor.
Each record is measured as a box of its own scale, placed through the
whole of its parent's transform, so a group standing rotated and scaled is
enclosed where it actually stands. A record whose mesh is larger than one
unit at scale 1 is measured as the unit box it is scaled from — padding
is what covers the difference, and setProxy is what takes an authored
silhouette instead.
A file-backed cell's records are read to measure them and dropped again, so deriving over a world that is held in files costs one read per cell and leaves the store as it found it.
Parameters
opts{ [string]: any }?(optional) —{ layer, mesh = "@builtin::meshes.cube", material, granularity = "cell" | "group", padding = 0, replace = false }.layerlimits the walk to one layer;replaceoverwrites a proxy a cell already has.
spatialStreaming.deriveProxies({ granularity = "group", material = "@builtin::materials.default" })
modules/spatialStreaming/flush
flush(): number
Write every file-backed cell that has no group standing out to its file
and drop its records. A cell already written is left alone. This is what
bounds memory while a world's content is being registered; tick calls it
each step, so a world that streams needs it only to measure the store
between an add batch and the first step.
spatialStreaming.flush()
modules/spatialStreaming/layers
layers(): { [string]: any }
Settings of every configured layer, keyed by name.
local l = spatialStreaming.layers()
modules/spatialStreaming/proxies
proxies(): { any }
Per-cell view of the proxies the store holds. records is what the
stand-in is made of; entities is how much of it is standing right now,
which is zero while the cell's content covers it.
local p = spatialStreaming.proxies()
modules/spatialStreaming/proxyDecide
proxyDecide(distance: number, proxyRadius: number, proxyUnloadRadius: number): string
Residency a cell's PROXY should be in, for a cell whose content is not
standing. Same shape as decide and for the same reason: the band between
the two radii is what keeps a source resting at the far edge from spawning
and despawning the same stand-in every frame.
The rule reads a distance and the far-field radii alone. Whether the cell's own content is standing is the tick's question, and the tick lets the content's answer win: a proxy stands where the content does not.
Parameters
distancenumber— Distance from the nearest source to the cell's nearest edge.proxyRadiusnumber— Distance within which a released cell's proxy stands.proxyUnloadRadiusnumber— Distance past which the proxy is dropped too.
local want = spatialStreaming.proxyDecide(560, 512, 640)
modules/spatialStreaming/proxyIds
proxyIds(): { string }
Entity ids the proxies currently have standing, across every cell.
local ids = spatialStreaming.proxyIds()
modules/spatialStreaming/removeSource
removeSource(target: any): boolean
Remove a streaming source by the entity it follows.
Parameters
targetany(optional) — Entity id, proxy, or name the source was added with.
spatialStreaming.removeSource(entity.find("Player"))
modules/spatialStreaming/reset
reset()
Release every resident group, forget the store, and drop every source. Live entities the store owns are despawned; nothing else in the scene is touched.
spatialStreaming.reset()
modules/spatialStreaming/residentIds
residentIds(): { string }
Entity ids the store currently has standing, across every cell.
local ids = spatialStreaming.residentIds()
modules/spatialStreaming/setLayer
setLayer(name: string, opts: { [string]: any }?): { [string]: any }
Configure a content layer. A layer streams on its own radii and can be switched off entirely, so decorative content can be released long before the content a player interacts with. Each layer keeps its own grid, so two layers standing in the same square still stream apart.
Parameters
namestring— Layer name. Content lands in "default" unlesscapture/addsay otherwise.opts{ [string]: any }?(optional) —{ enabled, loadRadius, unloadRadius, proxyRadius, proxyUnloadRadius }. A nil radius follows the global configuration, and a layer that names an unload radius of its own gets a far field measured from it. A disabled layer holds nothing standing — neither its content nor its proxies.
spatialStreaming.setLayer("props", { loadRadius = 60, unloadRadius = 90 })
modules/spatialStreaming/setProxy
setProxy(target: any, records: { Record }, opts: { [string]: any }?): string
Give a cell the stand-in it is drawn as while its content is released. The proxy is a group of records like any other, so what it represents is the caller's: a merged low-detail mesh, a billboard impostor, a bounding silhouette. It stands whenever the cell's content does not and the cell is inside the proxy radius, and it is exchanged for the content in an order that leaves no frame with neither standing.
A cell that has no content yet takes a proxy too, which is what lets a skyline be registered before — or instead of — the content it stands for.
Parameters
targetany(optional) — A cell key fromcellKeyAt/cells(), or a{ x, y, z }world position the cell is looked up from.records{ Record }— Array of records, the same shapeaddtakes. Positions are world-space for a record with no parent.opts{ [string]: any }?(optional) —{ layer = "default" }.
spatialStreaming.setProxy("4:0", { { name = "skyline", position = { x = 288, y = 8, z = 32 }, scale = { x = 64, y = 16, z = 64 }, components = { Model = { model = "@builtin::meshes.cube" } } } })
modules/spatialStreaming/sourcePositions
sourcePositions(): { Vec3 }
World positions of the live sources. An entity source that has been despawned is dropped here rather than reporting a stale position.
local p = spatialStreaming.sourcePositions()
modules/spatialStreaming/stats
stats(): { [string]: any }
What the store holds and how much of it is standing. bytesResident is
the encoded size of the groups that are live; bytesStored is the encoded
size of everything the store knows about, resident or not. The gap between
the two is what streaming bought.
The proxy figures stand apart from the content's: entitiesProxy and
bytesProxy are what the far field costs right now, against the
entitiesTotal / bytesStored it stands in for.
local s = spatialStreaming.stats()
modules/spatialStreaming/tick
tick(_dt: number?): { [string]: any }
Advance streaming by one step. Loads and releases at most budget
entity records, so crossing a cell boundary spreads its cost over frames
instead of spending it all in one. A group is atomic: a group larger than
the whole budget still moves in one piece, so the budget is the floor a
step stops at rather than a ceiling it never passes.
Releases are spent before loads, which keeps the peak residency at what the radius bought rather than at the sum of the cells on both sides of a boundary.
A cell that has a proxy raises it before the first of its groups is released and drops it once the cell's own content has landed, so the exchange between the two representations leaves neither a gap nor a silhouette standing over the content it covered for.
One step belongs to the frame, not to the caller: a second call inside the
same engine frame reports stepped = false and changes nothing, so a world
carrying several StreamingSource components spends one budget rather than
one per source. Waiting a frame is what advances it again.
Parameters
_dtnumber?(optional) — Frame delta, accepted so a component can pass its own and ignored — the step is driven by distance, not by time.
spatialStreaming.tick(dt)
modules/ssr/README
require("@builtin::systems.reflections.ssr") -- ssr
Screen-space reflections — polished floors reflect what is standing on them, and wet ground reflects what is above it, from the frame the engine has already drawn.
Usage: local ssr = require("@builtin::systems.reflections.ssr")
modules/ssr/active
active(): boolean
Whether the reflection passes are currently running.
if ssr.active() then print("reflecting") end
modules/ssr/clear
clear()
Take the reflection passes down. The next set brings them up again
at the feature's declared defaults laid under whatever it passes.
ssr.clear()
modules/ssr/get
get(): { [string]: any }
The reflection settings currently in force: every knob the feature declares at its value, or the declared defaults while none is live.
local d = ssr.get().maxDistance
modules/ssr/set
set(opts: SsrOpts?): { [string]: any }?
Set the scene's screen-space reflections. Any omitted field keeps its
current value, so a call can adjust one knob without restating the rest.
Brings the feature up when none is live; an intensity of 0 takes it
down. A knob the feature does not declare is refused by name.
Parameters
optsSsrOpts?(optional) — Reflection settings — seeSsrOpts.
ssr.set({ intensity = 1, maxDistance = 40, quality = "high" })
modules/state
modules.state(path?) -> table
The calling module's durable state table — the same table on every call for the life of the VM, kept across an in-place hot reload of that module and across the re-run a reloaded dependency triggers in it. A module-level local is an upvalue of the chunk that declared it, so it starts again from its initial value each time that chunk runs; a field on this table is held by the engine and does not. Put here what a reload has to survive: a built flag, the entities and particle systems a build owns, an unsubscribe list, a generation counter. Pass a module require path to read another module's table.
Parameters
pathstring(optional) — Module require path. Omit inside a module to get that module's own table.
Returns table — The module's durable state table
modules/stream/README
require("@builtin::modules.api.engine.stream") -- stream (also available as global 'stream')
Named byte streams by URL scheme — TCP, tty, Bluetooth Low Energy and loopback transports, dialled out or listened for, with a common read/write/status/close surface over every one of them. Public Luau surface over the __stream Internal FFI namespace.
Usage: local stream = require("@builtin::modules.api.engine.stream") Also available as global: stream
modules/stream/accept
accept(listener: string): string?
Take the connection that has waited longest on the listener, as a
stream handle that reads, writes, and closes exactly like one
stream.open returned. Returns nil when nothing is waiting, so call
it in a loop each tick to take every peer that arrived.
stream.listenerStatus(listener).pending is how many are still
waiting.
Parameters
listenerstring— Listener handle from stream.listen.
while true do local h = stream.accept(listener); if not h then break end; table.insert(peers, h) end
modules/stream/close
close(handle: string): boolean
Finish whatever handle names — a stream or a listener — and
drop it from the registry.
Closing a stream refuses every later write and carries the bytes
already queued to the peer before the connection ends, so a write and
a close in the same tick deliver — the shape a request answered with
one response has. A peer that has stopped reading altogether holds
that finish for thirty seconds; past that the connection ends and
what is still queued ends with it, so a caller that must know its
bytes went out watches stream.status(handle).pending reach zero
before it closes.
Closing a listener stops it answering new peers and closes the
connections nobody took; the connections stream.accept already
handed over keep running until they are closed themselves.
Parameters
handlestring— Stream handle from stream.open or stream.accept, or listener handle from stream.listen.
stream.write(peer, response); stream.close(peer)
modules/stream/listen
listen(url: string, opts: StreamListenOpts?): PromiseHandle
Hold the address url names and answer the peers that dial it —
the other direction from stream.open, for when the thing you are
talking to starts the conversation and restarts on its own schedule.
Returns a promise handle: task.await() it to get the listener
handle once the address is held, or it raises the reason a malformed
url, a scheme that cannot listen, or a failed bind was refused with.
Take the connections with stream.accept.
The host in the url is the interface bound, and the whole of what
decides who can reach it. tcp://127.0.0.1:9000 answers only
programs on this same machine. tcp://0.0.0.0:9000 answers any host
that can route to this machine on that port — every device on the
wifi, and anything beyond it the network lets through. Write the one
you mean; there is no default, and stream.listenerStatus reports
which of the two you got. A port of 0 asks the operating system to
choose one, which that same status then reports.
opts.inboundCapacity and opts.outboundCapacity bound each
answered connection (65536 bytes each by default);
opts.backlog bounds the connections held for stream.accept
before the listener stops taking them from the operating system,
which leaves the rest queued in the kernel rather than answered and
forgotten (16 by default, and at least 1).
The listener belongs to the chunk that opened it — the chunk whose
own code called stream.listen, which is the module holding that
line even when something else called into it. When that chunk runs
again — a module hot-reload, a cleared require cache — the listener
and the connections it answered are closed, and the new run binds the
address for itself. Peers see the connection close and dial again.
stream.listeners() names that chunk as each entry's owner.
Parameters
urlstring— Listen URL — scheme://host:port.optsStreamListenOpts?(optional) — Per-connection capacities and the accept backlog (optional).
local pending = stream.listen("tcp://127.0.0.1:9000"); local listener = task.await(pending)
modules/stream/listenerStatus
listenerStatus(listener: string): ListenerStatus?
Report what the listener holds and has handed over. address is
the address the operating system resolved the bind to, port
included — the one to hand a peer. reach says who can connect to
it: "thisMachine" when it is a loopback address and only programs
on this machine can, "network" when any host that can route here
can. accepted counts the connections stream.accept handed over,
pending the ones still waiting, and capacity the value pending
may reach before the listener stops taking connections from the
operating system. nil when handle names no open listener.
Parameters
listenerstring— Listener handle from stream.listen.
local s = stream.listenerStatus(listener); print(s.address, s.reach, s.pending)
modules/stream/listeners
listeners(): { OpenListener }
Every listener this engine currently holds an address for, in the
order they were opened. Each entry is what stream.listenerStatus
reports about it, plus the handle it is addressed by and the owner
chunk its life follows.
This is how an address is reached again once nothing holds its handle:
filter on address for the port you want and close the entry by its
handle, rather than guessing at handles.
for _, l in stream.listeners() do if l.address == want then stream.close(l.handle) end end
modules/stream/open
open(url: string, opts: StreamOpenOpts?): PromiseHandle
Open a byte stream at url (scheme://target[?k=v]). loopback
carries written bytes back out of the same stream and works on
every platform; tcp dials host:port; tty opens a serial
device node — /dev/ttyACM0 or /dev/ttyUSB0 for a USB CDC board
such as an ESP32, /dev/rfcomm0 for a Bluetooth controller paired
over classic SPP (both present as a tty on Linux, so one transport
serves either peer), COM5 on Windows. tty query parameters:
baud (default 115200), dataBits (5-8, default 8), parity
(none | odd | even, default none), stopBits (1 or 2,
default 1).
ble connects to a Bluetooth Low Energy device over GATT, on a
desktop engine and in a browser alike — the wireless transport a
web world reaches a device through:
ble://<device>?service=<uuid>&write=<uuid>¬ify=<uuid>. The
device is the name it advertises, * any device offering the
service, a trailing * a name prefix (Paw*). write is the
characteristic this engine writes to and notify the one it
subscribes to, which on a Nordic UART peripheral are that
peripheral's RX and TX; a module with one bidirectional
characteristic names it for both. UUIDs may be 16-bit (ffe0),
32-bit, or full. Optional: chunk (bytes per packet, 1-512 —
otherwise what the connection carries), writeMode
(withResponse | withoutResponse, default withResponse),
timeout (seconds to find and connect to the device, default
15).
opts bounds the stream's undrained inbound buffer
and in-flight outbound bytes (default 65536 each). Returns a
promise handle: task.await() it
to get the stream handle once the transport is open, or it raises
the reason a malformed url, an unknown or unsupported scheme, or a
failed connect was refused with. A ble stream resolves as soon as
it exists and reports the rest as state — watch
stream.status(handle).state go opening, permissionPending
while the browser asks the person at the machine to pick a device,
then open; writes made meanwhile are queued and go out when it
connects. Check stream.transports() first
to tell a mistyped scheme from one this build does not carry.
Parameters
urlstring— Stream URL — scheme://target[?k=v&k=v].optsStreamOpenOpts?(optional) — Buffer capacities (optional).
local pending = stream.open("loopback://echo"); local handle = task.await(pending)
local paw = task.await(stream.open("ble://Paw*?service=ffe0&write=ffe1¬ify=ffe1"))
modules/stream/read
read(handle: string, max: number?): string
Drain up to max buffered inbound bytes from the stream.
Parameters
handlestring— Stream handle from stream.open.maxnumber?(optional) — Maximum bytes to drain (optional). Omit to drain everything buffered.
local chunk = stream.read(handle)
modules/stream/serialPorts
serialPorts(): SerialPorts
Every serial device this machine has, for picking the one to open.
ports is an array ordered by path. Each entry carries the path the
device is at (/dev/ttyACM0 on Linux, COM3 on Windows), the url
that opens it, the kind of bus it attaches by, and — for a USB
device — the vendorId, productId, serialNumber, manufacturer
and product it advertises.
A device's path moves with enumeration order: a board that came up at
/dev/ttyACM0 is at /dev/ttyACM1 once something else is plugged in
first, and moves across COM3-COM5 on Windows. What the device
advertises holds still across those moves, so match on
vendorId/productId — or on serialNumber to tell two of the same
board apart — and open the url that entry carries, appending the
port settings stream.open documents.
Three answers are distinct. supported false with a reason means
this platform has no serial bus to enumerate at all. error set means
it has one and the operating system refused this enumeration, so a
later call may answer. An empty ports with neither means the machine
has no serial device attached, which is an ordinary result.
for _, p in stream.serialPorts().ports do if p.vendorId == 0x303A then print(p.url, p.product) end end
modules/stream/status
status(handle: string): StreamStatus?
Report what the stream has carried and lost. state is where
the stream is in its life: opening, permissionPending while the
platform asks the person at the machine to allow the connection,
open, denied when that permission was refused, and closed
when it is finished. pending is bytes
accepted and not yet handed to the peer; capacity is the value
pending may reach before a write is refused. error holds the
most recent transport failure and the refusal a denied stream
carries, retained for the life of the
stream. nil when handle names no open stream.
Parameters
handlestring
local s = stream.status(handle); print(s.pending, s.capacity)
modules/stream/streams
streams(): { OpenStream }
Every open stream, dialled or answered, in the order they were
opened. Each entry is what stream.status reports about it, plus the
handle it is addressed by and the owner chunk its life follows —
a connection stream.accept handed over carries the owner of the
listener that answered it.
for _, s in stream.streams() do print(s.handle, s.transport, s.pending, s.owner) end
modules/stream/transports
transports(): { [string]: TransportSupport }
Every stream scheme this build knows about — a capability
probe, in both directions. supported answers stream.open and
listen answers stream.listen, since a scheme can carry one and
not the other. Each reason is nil when its direction works,
otherwise it names why not: an unbuilt transport names its own
absence, a transport this platform lacks (tcp and tty on wasm;
ble in a browser without Web Bluetooth or with the radio off,
which the page itself answers) names that, and a loopback stream,
whose peer is itself, names that nothing dials it. A typo'd scheme
is absent from this table entirely, which is what tells it apart
from a real transport this build lacks.
local t = stream.transports(); if not t.tcp.listen then warn(t.tcp.listenReason) end
modules/stream/write
write(handle: string, bytes: string): WriteOutcome
Queue bytes for the stream's peer. Never blocks. "accepted"
means the bytes were queued. "full" means the outbound queue has
no room right now — backpressure, not failure: the peer is alive
and draining slower than this call is producing, so a retry after
it catches up can succeed. Compare pending against capacity on
stream.status() to see it coming before a write is refused.
"closed" means the stream is finished, or handle names no open
stream — reopen to continue, retrying never succeeds. "tooLarge"
means bytes is bigger than the stream's whole outbound capacity, so
it can never fit at any queue depth — retrying the same write
returns this again.
Parameters
handlestring— Stream handle from stream.open.bytesstring— Bytes to queue, byte-safe.
local outcome = stream.write(handle, data)
modules/streaming/README
require("@builtin::modules.api.engine.streaming") -- streaming (also available as global 'streaming')
What the engine has resident of a world's detail right now, and why a piece of it is not on screen. Covers the four systems that decide how much of a world stands at any moment: terrain's LOD cut, a voxel world's chunk meshes, spatial streaming's cell store, and mesh LOD's level selection. Reading a Terrain, VoxelWorld, StreamingSource or MeshLod component's fields back tells you what was asked for. streaming.observe() answers the other question: what is standing, what it costs, and for a chunk that is not drawn, which of a closed set of reasons it is not drawn for. The same reading is served at /zero/runtime/observations/streaming. It is built by the call and published as its last act, so both transports carry the document one pass produced.
Usage: local streaming = require("@builtin::modules.api.engine.streaming") Also available as global: streaming
modules/streaming/cells
cells(): { [string]: any }
What the spatial-streaming store has resident: the configured radii and budget, the counters the store keeps, and one row per cell with how many of its groups are standing, what it costs, and whether a release wrote it to a file it now reads back from.
local s = streaming.cells()
modules/streaming/levels
levels(scene: any?): { [string]: any }
Which level every mesh-LOD receiver is drawing at, and the screen
fraction that selection was measured from.
A receiver whose entity the scene no longer holds is reported as
standing = false: the chain is registered and there is nothing left for
it to draw.
Parameters
sceneany?(optional) — The scene walk to read against. Omitted, the call takes its own.
local l = streaming.levels()
modules/streaming/observe
observe(): { [string]: any }
The whole reading in one document: terrain, voxel, streaming cells and mesh LOD, plus the totals those rows sum to.
Built by this call and published as its last act, so
/zero/runtime/observations/streaming serves the same document rather
than a second derivation of it.
local r = streaming.observe()
modules/streaming/reasons
reasons(): { string }
Every reason whyNotDrawn can answer with, so a caller can enumerate
the set rather than meeting it one failure at a time.
local r = streaming.reasons()
modules/streaming/terrain
terrain(scene: any?): { [string]: any }
What each terrain entity is drawing: whether a heightfield is bound to it, the LOD cut it settled on, what that cut costs in indices and in the vertex pool, and the eye the cut was refined under: the camera in the entity's own coordinates, where its ground's vertices stand.
Parameters
sceneany?(optional) — The scene walk to read against. Omitted, the call takes its own, which is what makes a whole reading one walk rather than four.
local t = streaming.terrain()
modules/streaming/voxel
voxel(scene: any?): { [string]: any }
What became of every chunk of every voxel world: how many are meshed, queued, failed or empty, and one row per chunk carrying the state, the engine's reason when a build failed, and what the build reserved on the device.
Parameters
sceneany?(optional) — The scene walk to read against. Omitted, the call takes its own.
local v = streaming.voxel()
modules/streaming/whyNotDrawn
whyNotDrawn(subject: any): { [string]: any }
Why a piece of a world's detail is not on screen, as one reason from
the closed set streaming.reasons() enumerates, with a detail line naming
what that reason is about.
The subject picks which system answers:
- an entity ref, id or name — whichever of the four systems holds it
{ entity = ..., chunk = "cx_cy_cz" }— one chunk of a voxel world{ entity = ..., level = n }— one level of a mesh-LOD chain{ cell = "x_z" }— one cell of the spatial-streaming store
Parameters
subjectany(optional) — The entity, chunk, level or cell to answer about.
local w = streaming.whyNotDrawn({ entity = "Vox", chunk = "0_0_0" })
modules/stringx/README
require("@builtin::modules.api.engine.stringx") -- stringx (also available as global 'stringx')
Batch text-scanning kernels — read a whole run of numbers out of a string in one call. Public Luau surface over the __stringx Internal FFI namespace.
Usage: local stringx = require("@builtin::modules.api.engine.stringx") Also available as global: stringx
modules/stringx/decodeJson
decodeJson(s: string): (boolean, any)
Decode a JSON document in one call, when the document is one the
engine's Luau JSON decoder reads the same way. ok is true and value
holds the decoded value (nil for a document that is null); ok is false
for text this leaves to that decoder: malformed text, nesting past 96
levels, escapes or control bytes the two could read differently, and text
after the value. modules.json calls this first and falls back to its own
scanners on false.
Parameters
sstring— The JSON text.
local ok, value = stringx.decodeJson('{"a":[1,2,3]}')
modules/stringx/encodeJson
encodeJson(value: any): (boolean, string?)
Encode a value as compact JSON in one call, when the value is one the
engine's Luau JSON encoder writes the same way. ok is true and text
holds the JSON; ok is false for a value this leaves to that encoder: a
table with a metatable, a table that contains itself, a number key that is
not finite, and nesting past 192 levels. modules.json calls this first
and falls back to its own walk on false.
Parameters
valueany(optional) — The value to encode.
local ok, text = stringx.encodeJson({ a = { 1, 2, 3 } })
modules/stringx/scanNumbers
scanNumbers(s: string, pos: number?): ({ number }, number)
Read the run of numbers starting at pos — separated by commas and/or
whitespace — and report where the run ended.
The run stops at the first character that neither continues a number nor
separates two of them (], }, a quote, a letter), and nextPos is that
character's index, so the caller's own parser resumes exactly there. A
token that is not a valid number also ends the run, with nextPos left ON
it rather than past it, so nothing is skipped without the caller seeing it.
Parameters
sstring— The text to read.posnumber?(optional) — 1-based index to start at. Defaults to 1.
-- A JSON array of numbers, in one crossing instead of one per token.
local values, nextPos = stringx.scanNumbers(payload, afterBracket)
-- A whitespace-separated block (OBJ, PLY, a matrix dump).
local m = stringx.scanNumbers("1 0 0 0 0 1 0 0", 1)
modules/subscriptions/README
require("@builtin::modules.api.engine.subscriptions") -- subscriptions (also available as global 'subscriptions')
Runtime inspection and cancellation of component-event subscriptions. Public Luau surface over the __event_inspect_* / __event_track_* Internal FFI globals; the same data is browsable at /zero/runtime/events/.
Usage: local subscriptions = require("@builtin::modules.api.engine.subscriptions") Also available as global: subscriptions
modules/subscriptions/cancel
cancel(id: string): boolean
Cancel a subscription by id: disconnects the live connection immediately and marks the row cancelled. Returns true when a live subscription was cancelled, false for an unknown or already-disconnected id.
Parameters
idstring— Subscription id to cancel.
subscriptions.cancel(conn.id)
modules/subscriptions/get
get(id: string): SubscriptionRow?
One subscription row by id, or nil when the id is unknown (never tracked, or evicted after its publisher was destroyed).
Parameters
idstring— Subscription id (conn.id, or a/zero/runtime/events/subscriptions/entry).
local row = subscriptions.get(conn.id); print(row and row.deliveries)
modules/subscriptions/list
list(filter: SubscriptionFilter?): { SubscriptionRow }
Every tracked subscription row, optionally filtered by publisher instance id, publisher entity id, event name, and/or connected state.
Parameters
filterSubscriptionFilter?(optional) — Optional filter table.
for _, s in ipairs(subscriptions.list({ connected = true })) do print(s.id, s.event, s.deliveries) end
modules/subscriptions/publishers
publishers(): { PublisherRow }
Every live event publisher: component instance, entity, and per-event fire stats (fires happen whether or not anyone subscribes) plus current subscriber ids.
for _, p in ipairs(subscriptions.publishers()) do print(p.component, p.entityName) end
modules/substrate/README
require("@builtin::modules.api.engine.substrate") -- substrate (also available as global 'substrate')
Typed data buffers, on the CPU or the GPU — the engine's one buffer primitive. Public Luau surface over the __substrate Internal FFI namespace.
Usage: local substrate = require("@builtin::modules.api.engine.substrate") Also available as global: substrate
modules/substrate/await
await(self): ({ number }?, string?)
Wait for this read to arrive and drain it as f32 values. The wait runs on every frame the renderer draws, a frame drawn while pipeline builds are still landing among them, since the render system delivers a read on each of those frames. It ends on the read's own terminal state: the values once it delivered, or nil and the reason once the engine has given it up (a buffer that was not there, a device that was lost). A read that is still on its way is waited for, however long the GPU takes to answer it.
Parameters
selfany(optional)
local values, why = pending:await()
modules/substrate/bindFrames
bindFrames(key: string, id: string, slots: { any }): (boolean, string?)
Bind the play key to the sequence id through slots, so
showFrame(key, f) places its elements from frame f. slots[s] is
{ kind = "instances", key, transforms, data?, capacity, draw, interval? }
for elements an instanced draw copies from transforms — the scatter
binding key places up to capacity of them there and the draw draw
draws the frame's count — or { kind = "entities", key, binding?, interval? } for elements standing in entities: the scatter binding key,
whose entities scatterTransforms has already set, places them, and the
frame's fields are written across the entity binding binding.
Parameters
keystring— The play's name.idstring— The sequence the play shows.slots{ any }— What each numbered slot places, for this play.
substrate.bindFrames("spark#1", "spark", { { kind = "instances", key = "spark#1", transforms = "spark#1.xf", capacity = 64, draw = drawId } })
modules/substrate/bufferSource
bufferSource(name: string): string?
The chunk that created the GPU buffer name holds, as debug.info
names a chunk — a module's identity, a test suite's, an execute body's.
The record is the name's for as long as a buffer holds the name, across a device rebuilt underneath it. A name created again after its buffer went answers for the call that created it again. A buffer the engine made itself, or one made through another surface, has no record.
Parameters
namestring— The name the buffer was created under.
if substrate.bufferSource("debug_viz.vtx") then print("made through the substrate") end
modules/substrate/clearScatterTransforms
clearScatterTransforms(key: string): boolean
Drop the device transform binding under key. Its entities go back to
being placed by whatever writes their Transform. Queued.
Parameters
keystring— The key the binding was made under.
substrate.clearScatterTransforms("wave")
modules/substrate/createBuffer
createBuffer(opts: BufferOpts): TypedBuffer?
Allocate a typed buffer and return its handle.
A "gpu" buffer is storage a compute shader binds; usage adds
"vertex", "index", "indirect" or "readback" on top of the storage
it always has. A "cpu" buffer is storage the engine holds outside the
Luau heap, and reads back as a flat array of floats. Reading its bytes into
Luau (:bytes(), :read():resultBytes()) makes a copy in the Luau heap.
The handle's write answers whether the words landed: a payload whose end
falls past the end of the buffer is refused whole on both kinds, so the
buffer keeps what it held and the call answers false. writeU32 and
writeBytes answer the same way, against the same extent.
A "cpu" buffer holds at most 1 GiB of storage: 268435456 f32 words,
16777216 mat4 records. A len past that raises an error naming the
bytes it needs and the limit, and a len within it whose storage the heap
cannot supply raises an error naming the bytes. Neither allocates
anything.
A "gpu" buffer holds at most what the device creates in one buffer, its
max_buffer_size. A len whose bytes pass it raises an error naming the
records, the bytes they need, that limit and the most records of the type
one buffer holds; nothing is allocated and the name stays free.
class makes a "gpu" buffer a run: it stands in a range of a page the
engine's device arenas share among many runs of the class, rather than in
an allocation of its own, so thousands of short-lived buffers cost a
handful of device allocations. "effect" is for runs made and let go of
as an effect plays, "persistent" for runs held until let go of. A run
binds, writes, reads and frees like any "gpu" buffer under the name its
handle carries, which the engine mints, so a run takes no name; a
compute program declared with ranges = true binds any number of runs of
one page through one bind group. A run carries "readback" usage and no
other: a vertex, index or indirect buffer is one of its own. owner names
whom a run is held for, and substrate.releaseOwner(owner) lets go of
every run created with it at once.
A job on a worker thread makes a run the same way. The handle answers at
once, with the type and length asked for and a name the worker mints;
substrate.listBuffers lists the run at once; and the engine thread
places it in its arenas ahead of every write, dispatch and read the job
makes over it afterwards, so one job can make a run, fill it, dispatch
over it and read it back. A class, usage or len the engine thread
refuses raises at the call in the job too. When the engine thread cannot
place the run, the handle's next method call raises why.
substrate.setOwner and substrate.releaseOwner answer in a job as they
do on the engine thread, counting the job's own changes at once.
Parameters
optsBufferOpts—{ type, len, kind?, usage?, name?, class?, group?, owner? }—typeis"f32","vec3","vec4","quat"or"mat4";kindis"cpu"(the default) or"gpu".nameis the name a dispatch binds a"gpu"buffer by, and the namesubstrate.getBufferandsubstrate.destroyBufferreach it under.class("effect"or"persistent") makes a"gpu"buffer a run;ownernames whom the run is held for.
local pose = substrate.createBuffer({ type = "mat4", len = boneCount })
local field = substrate.createBuffer({ type = "vec3", len = 4096, kind = "gpu" })
local column = substrate.createBuffer({ type = "f32", len = n, kind = "gpu", class = "effect", owner = "burst:" .. id })
local values = pose:read(0, 16):result()
modules/substrate/defineFrames
defineFrames(id: string, frames: { any }): (boolean, string?)
Hold a sequence of frames on the engine under id, for plays bound to
it (bindFrames) to show by index (showFrame) with no script running
per frame. frames[f] is { scatters = {...}, fields = {...} }. A
scatter { slot, positions, rotations?, scales?, lanes?, identities?, count } names the buffers the slot's elements are placed from in that
frame and how many elements they hold; lanes[k] is a buffer name or
false. A field { slot, component, field, values } gives the value the
field takes on each of the slot's entities, in binding order. Slots are
numbered from 1. The buffers stay the caller's and must stand for as long
as the sequence is held. Defining id again replaces it.
Parameters
idstring— The sequence's name.frames{ any }— The frames, in order.
substrate.defineFrames("spark", { { scatters = { { slot = 1, positions = P:bufferName(), count = 64 } } } })
modules/substrate/destroyBuffer
destroyBuffer(name: string): boolean
Free the GPU buffer name denotes, whatever else still holds a handle
to it.
The allocation goes and the name is free to be created again at any type
and length; every handle that pointed at it answers :alive() false. This
is what releases a name whose creating handle is gone, so a build that
re-runs at a different size gets its name back.
Parameters
namestring— The name the buffer was created under.
substrate.destroyBuffer("env.town.xf")
modules/substrate/forgetFrames
forgetFrames(id: string): boolean
Drop the sequence held under id. A play still bound to it shows
nothing further.
Parameters
idstring— The sequence's name.
substrate.forgetFrames("spark")
modules/substrate/getBuffer
getBuffer(name: string): TypedBuffer?
The GPU buffer name denotes, as a handle you now hold.
A name is how a dispatch binds a buffer, so the name is what an owner asks
by once the handle it created with has gone out of scope — a .module
that hot-reloaded, a build that ran in an earlier execute. The handle
carries everything createBuffer's does and releases its reference with
:destroy().
Parameters
namestring— The name the buffer was created under.
local xf = substrate.getBuffer("env.town.xf")
local shape = xf and { xf:type(), xf:length() }
modules/substrate/gpuReadback
gpuReadback(key: string?): Readback?
Wrap the key an FFI read handed back as the Readback that polls it.
Every GPU→CPU read reaches the caller through this, so a texture's read
and a buffer's read answer with the same thing.
Parameters
keystring?(optional) — The key the read returned.
local pending = substrate.gpuReadback(compute.readTexture3D(handle))
modules/substrate/listBuffers
listBuffers(): { NamedBuffer }
Every named GPU buffer the engine holds, in name order.
Each record states id, name, type ("F32", "Vec3", "Vec4",
"Quat", "Mat4"), len in records, refs — how many holders it
has — holder, the owner a run is held for when one was named
(createBuffer's owner), class, the lifetime class of a run
("effect" or "persistent"; absent for a buffer of its own), and
bytes, the device bytes it takes: the range a run stands in, or the
extent of a buffer of its own. This is what states which names are taken,
at what shape, and what an owner holds.
for _, b in ipairs(substrate.listBuffers()) do print(b.name, b.type, b.len) end
modules/substrate/losses
losses(): number
How many times a buffer has been freed by name or by owner: destroyBuffer, releaseOwner and the reset to
a baseline. A holder that checked that the buffers it names exist at one count knows they still do while the
count is the same, whatever else it asks.
local at = substrate.losses()
modules/substrate/markBaseline
markBaseline(): number
Record which named GPU buffers the engine holds right now, and make that
the point substrate.resetToBaseline returns to.
A caller running work in an engine it shares — a sweep of test suites, a tool driving a session — leaves buffers behind under the names the work chose: a view's geometry built on its first capture, a kernel's storage. This is how such a caller says where its own allocations start.
local mark = substrate.markBaseline() -- then run, then substrate.resetToBaseline(mark)
modules/substrate/mintName
mintName(prefix: string): string
prefix followed by a number no VM of this engine was handed before. The engine thread and every worker VM
draw from one count, so a name minted in one VM is never one another VM minted: what names a buffer, a run's owner
or anything else found by name when several VMs make them at once.
Parameters
prefixstring— What the name starts with.
local name = substrate.mintName("cook.points.")
modules/substrate/placement
placement(name: string): BufferPlacement?
Where the GPU buffer name names stands on the device.
A run stands in a range of an arena page that many runs share: page is
the buffer a dispatch binds to reach it, offset the byte it starts at in
that buffer (a multiple of 256) and bytes the bytes it holds. A buffer of
its own is its own page at offset 0. A kernel that binds a page once and
addresses every run of it by offset reads this to state each run's base.
A job on a worker thread is answered by the engine thread, after it has
placed every run the job created before the call.
Parameters
namestring— The name the buffer binds under (its handle'sname).
local at = substrate.placement(column.name)
modules/substrate/ready
ready(self): boolean
Whether this read has arrived.
Parameters
selfany(optional)
modules/substrate/releaseBaseline
releaseBaseline(generation: number): boolean
Drop the mark generation names, and every mark taken after it, once
the caller that took it is done resetting to it. It touches the
marks alone.
Parameters
generationnumber— The mark to drop, assubstrate.markBaselinereturned it.
substrate.releaseBaseline(mark) -- the run is over
modules/substrate/releaseOwner
releaseOwner(owner: string): number
Let go of every run created with owner (createBuffer's class and
owner), whatever else still holds a handle to it.
Each run's range goes back to its arena and every handle to it answers
:alive() false. This is what something that makes runs as it plays — an
effect, a cook, a cache — calls when it ends, so everything it made goes
with it at once, runs it handed on to others included.
Parameters
ownerstring— The owner the runs were created with.
substrate.releaseOwner("burst:" .. id)
modules/substrate/resetToBaseline
resetToBaseline(generation: number?): number
Free every named GPU buffer created since substrate.markBaseline,
leaving the ones it recorded where they are.
A module that created one of these holds its own handle to it. Put that
module's state back alongside this (engine.restoreModuleState) or it
goes on addressing storage this freed.
is touched.
Parameters
generationnumber?(optional) — The mark to restore to, assubstrate.markBaselinereturned it; the newest mark when omitted. The marks taken after it go with the reset.
local freed = substrate.resetToBaseline(mark)
modules/substrate/result
result(self): { number }?
Drain this read as f32 values, nil while it is still on its way. Every later call on this handle answers the same values.
Parameters
selfany(optional)
modules/substrate/resultBytes
resultBytes(self): buffer?
Drain this read as a Luau buffer, nil while it is still on its way.
Every later call on this handle answers the same buffer.
Parameters
selfany(optional)
modules/substrate/resultU32
resultU32(self): { number }?
Drain this read as u32 values, nil while it is still on its way. Every later call on this handle answers the same values.
Parameters
selfany(optional)
modules/substrate/scatterTransforms
scatterTransforms(key: string, entityIds: { string }?, positions: string, rotations: string?, scales: string?, lanes: { string? }?, interval: number?, identities: string?): boolean
Place entities from the buffers that already hold their transform, on
the device, instead of from a Transform written per entity.
entityIds[i] is placed from row i of every named buffer, so the order
is the buffers' own. Pass nil for entityIds to keep the entities a
binding already has and replace only the buffers — what a re-cook does,
since a field chain mints a fresh run each time while its membership stands
still, and sending the element list again each time would put back the
per-element crossing the binding exists to remove.
Re-binding the same key with a list replaces the previous binding.
Queued: it takes effect on the next frame, and an entity whose renderable
has not landed yet is placed on the frame it does.
Parameters
keystring— Stable identity of the binding.entityIds{ string }?(optional) — The entities in buffer order, or nil to rebind the buffers alone.positionsstring— Name of a buffer holding three f32 per element.rotationsstring?(optional) — Name of a buffer holding four f32 per element.scalesstring?(optional) — Name of a buffer holding three f32 per element.lanes{ string? }?(optional) — Per-instance shader data, by lane:lanes[k + 1]names a buffer holding one vec4 per element, written into lanekof each element's block — what its material reads back asinput.shader_data[k]. A lane left out is left to whatever else writes it.intervalnumber?(optional) — Seconds between the presents of the domain the buffers hold. Given, every frame draws each element between the last two presents — position, rotation, scale and lanes blended — the way a fixed-rate simulation is drawn between its ticks, so its motion is continuous at any frame rate while the domain presents at its own. An element new to a slot starts where it was presented. Omitted or 0, each present is drawn as it lands.identitiesstring?(optional) — Name of a buffer holding one f32 per element naming which element stands in that row at each present — for a domain whose rows are taken by different elements over time, as a particle's slot is when it dies and another is born into it. A row whose identity moved since the last present starts where it was presented rather than blending from the element that held it before. -1 names a row no element stands in. Omitted, each row's element is the entity placed from it.
substrate.scatterTransforms("wave", ids, positions:bufferName())
substrate.scatterTransforms("wave", nil, positions:bufferName())
substrate.scatterTransforms("wave", nil, positions:bufferName(), nil, nil, { colors:bufferName() })
substrate.scatterTransforms("sparks", ids, positions:bufferName(), nil, nil, nil, 1 / 30)
substrate.scatterTransforms("sparks", nil, positions:bufferName(), nil, scales:bufferName(), nil, 1 / 30, ids:bufferName())
modules/substrate/scatterTransformsInto
scatterTransformsInto(key: string, into: { transforms: string, data: string?, count: number }, positions: string, rotations: string?, scales: string?, lanes: { string? }?, interval: number?, identities: string?): boolean
Place elements that stand in no entity from the substrate buffers that
hold their transform, on the device: row i of the columns is composed into
matrix i of into.transforms, and lane k of block i of into.data — the
two buffers an instanced draw (renderer.mesh.drawInstanced with
transformBuffer and instanceDataBuffer) copies into its slots every
frame. It is scatterTransforms for a population: the same columns, the
same blend between presents when interval is given, the same
identities. Binding the same key into the same buffers again replaces
only the columns it reads. Queued: it takes effect on the next frame, ahead
of the instanced copies that frame records.
Parameters
keystring— Stable identity of the binding.into{ transforms: string, data: string?, count: number }—{ transforms, data?, count }: a buffer ofcountcolumn-major mat4, a buffer ofcount64-byte blocks of four vec4 lanes when lanes are bound, and how many elements there are.positionsstring— Name of a buffer holding three f32 per element.rotationsstring?(optional) — Name of a buffer holding four f32 per element.scalesstring?(optional) — Name of a buffer holding three f32 per element.lanes{ string? }?(optional) —lanes[k + 1]names a buffer holding one vec4 per element, written into lanekof each element's block ininto.data.intervalnumber?(optional) — Seconds between the domain's presents; given, each element is drawn between the last two presents.identitiesstring?(optional) — Name of a buffer holding one f32 per element naming which element stands in that row at each present; -1 names a row no element stands in.
substrate.scatterTransformsInto("sparks", { transforms = "sparks.xf", count = 4096 }, P:bufferName())
modules/substrate/scatterWorlds
scatterWorlds(key: string): any
Read back where the device drew the elements of the transform binding
under key in the last frame drawn — the device's own answer, since the
CPU never learns where an element it places stands. 16 floats per placed
element, column-major world matrices, in the binding's element order,
leaving out elements whose renderable has not landed. A binding drawn
between its presents answers the blended pose that frame drew.
Parameters
keystring— The key the binding was made under.
local pending = substrate.scatterWorlds("sparks")
while not pending:ready() do task.wait() end
local x = pending:result()[13]
modules/substrate/setOwner
setOwner(name: string, owner: string?): boolean
Hold the run name names for owner from now on, in place of the
owner it was created with, or for no one when owner is nil.
substrate.releaseOwner(owner) then lets go of it with the rest of what
owner holds, and releasing the owner it was made for leaves it standing.
What hands a run on to whatever keeps it longer than the one that made it
— a cache several makers read from.
Parameters
namestring— The name the run binds under (its handle'sname).ownerstring?(optional) — The owner to hold it for, or nil.
substrate.setOwner(column.name, "cache#3")
modules/substrate/settled
settled(self): string
Wait until this read leaves "pending", without draining it, and answer
its state. The wait is on the read itself: where the engine can wait on the
device the task resumes in the frame the device answered, so a task that
reads, uses the answer and reads again does all of it in one frame.
Parameters
selfany(optional)
if pending:settled() == "ready" then print(#pending:resultBytes(), "bytes read back") end
modules/substrate/showFrame
showFrame(key: string, frame: number): boolean
Show frame frame (from 1) of the sequence the play key is bound
to: each slot is placed from that frame's buffers, each instanced draw
draws that frame's count, and that frame's fields are written. Showing the
frame already shown changes nothing. Queued.
Parameters
keystring— The play's name.framenumber— The frame, from 1.
substrate.showFrame("spark#1", 12)
modules/substrate/state
state(self): string
Where this read stands, without draining it and without raising:
"pending", "ready", "failed" (given up on, with the reason as a
second return), or "unknown" (already drained). Every read leaves
"pending" — one the GPU does not answer inside the bound the engine
holds it to reaches "failed" naming the buffer — so a wait on
state() ~= "pending" ends on what the read did.
Parameters
selfany(optional)
modules/substrate/unbindFrames
unbindFrames(key: string): boolean
Drop the play key's binding to its sequence. What it placed stays as
the last frame shown left it.
Parameters
keystring— The play's name.
substrate.unbindFrames("spark#1")
modules/subsurface/README
require("@builtin::systems.subsurfaceScattering.subsurface") -- subsurface
Light that enters a surface at one point and leaves at another — the transport that softens and reddens the terminator on skin, and that a per-pixel shading model cannot produce.
A surface shaded per-pixel answers only for the light that arrived at that pixel. Skin does not work that way: light entering the lit side keeps travelling beneath the surface and emerges past where a cosine has already reached zero, and it emerges red, because red travels furthest through flesh. That is what makes the terminator on a face soft and warm instead of a hard line, and it is why a face with no scattering reads as plastic. The transport is a spread of exitant light across the surface, so it is computed on the drawn frame: marked meshes write their scattering into a mask, and the lit colour is spread along that mask. This module owns which entities are marked and what they scatter, and ties the pass's lifetime to whether anything is marked at all.
Usage: local subsurface = require("@builtin::systems.subsurfaceScattering.subsurface")
modules/subsurface/active
active() -> boolean
Returns boolean
modules/subsurface/clear
clear()
modules/subsurface/groups
groups() -> table
Returns table
modules/subsurface/list
list() -> { string }
Returns { string }
modules/subsurface/mark
mark(entityRef: string, opts: MarkOpts?) -> table
Give an entity's meshes a scattering tint and radius.
Parameters
entityRefstringoptsMarkOpts?(optional)
Returns table
modules/subsurface/marked
marked(entityRef: string) -> table?
Parameters
entityRefstring
Returns table?
modules/subsurface/paramsBuffer
paramsBuffer(): any?
The buffer this system's passes read. The render feature binds what this hands it, so the pass has the values this module packed.
local p = subsurface.paramsBuffer()
modules/subsurface/setStrength
setStrength(strength: number) -> number
Parameters
strengthnumber
Returns number
modules/subsurface/strength
strength() -> number
Returns number
modules/subsurface/unmark
unmark(entityRef: string) -> boolean
Parameters
entityRefstring
Returns boolean
modules/surfaceLight/README
require("@builtin::systems.areaLights.surfaceLight") -- surfaceLight
Rectangular area lights — a screen, a window or a strip that emits from its whole surface, so its highlight is a shape rather than a dot.
Usage: local surfaceLight = require("@builtin::systems.areaLights.surfaceLight")
modules/surfaceLight/active
active(): boolean
Whether the area-lighting pass is currently running.
if surfaceLight.active() then print("emitting") end
modules/surfaceLight/buffers
buffers(): { [string]: any }?
The buffers the area-lighting pass reads: the settings and the packed light records. The render feature binds what this hands it.
local b = surfaceLight.buffers()
modules/surfaceLight/clear
clear()
Drop every area light and release the pass. The scales are kept.
surfaceLight.clear()
modules/surfaceLight/configure
configure(opts: SurfaceLightOpts?): SurfaceLightState
Adjust how the two terms are weighted. Any omitted field keeps its current value.
Parameters
optsSurfaceLightOpts?(optional) — Settings — seeSurfaceLightOpts.
surfaceLight.configure({ specular = 0.5 })
modules/surfaceLight/count
count(): number
How many area lights are registered.
print(surfaceLight.count())
modules/surfaceLight/remove
remove(key: string): boolean
Remove the area light registered under key.
Parameters
keystring— The identifier the light was registered with.
surfaceLight.remove("tv")
modules/surfaceLight/set
set(key: string, shape: SurfaceLightShape): number
Add or replace the area light registered under key. Re-submitting the
same key moves that light rather than adding another, which is what lets a
component push its rectangle every frame as its entity moves.
Parameters
keystring— Stable identifier — an entity id works well.shapeSurfaceLightShape— The emitting rectangle — seeSurfaceLightShape.
surfaceLight.set("tv", { position = { 0, 2, 0 }, right = { 1, 0, 0 }, up = { 0, 1, 0 }, width = 2, height = 1.2 })
modules/surfaceLight/settings
settings(): SurfaceLightState
The settings currently in force.
local d = surfaceLight.settings().diffuse
modules/systemSettings/README
require("@builtin::modules.systemSettings") -- systemSettings
Which of several components stating one scene-wide system's settings is in force, so a component going away never takes down a system another live component still states.
Usage: local systemSettings = require("@builtin::modules.systemSettings")
modules/systemSettings/claim
claim(key: string, spec: ClaimSpec): Claim
A claim on the scene-wide system named key. Every claim made with
the same key shares one registry, so a component makes one per instance,
at the top of its script, keyed by the path of the module that drives the
system.
Parameters
keystring— The system's name: the path of the module that drives it.specClaimSpec— How to put settings in force, take the system down and read whether it is up.
local claim = systemSettings.claim("@builtin::systems.reflections.ssr", { push = Ssr.set, release = Ssr.clear, live = Ssr.active })
modules/systemSettings/count
count(key: string): number
How many live claims state the system named key.
Parameters
keystring— The system's name, as given toclaim.
modules/systemSettings/inForce
inForce(self: any): boolean
Whether this claim's settings are the ones in force.
Parameters
selfany(optional)
modules/systemSettings/release
release(self: any)
Let the system go; call it from the component's onDestroy. The
newest other live claim on the system takes over, and the system is taken
down only when this was the last one.
Parameters
selfany(optional)
modules/systemSettings/state
state(self: any, sig: string, opts: any)
State this claim's settings for the frame. Call it every frame the component runs; it pushes only when this claim is in force and the settings changed, or the system it brought up is no longer up.
Parameters
selfany(optional)sigstring— A string that differs wheneveroptsdiffers.optsany(optional) — The settings, handed to the spec'spushwhen they are pushed.
modules/temporalAntiAliasing/README
require("@builtin::systems.antiAliasing.temporalAntiAliasing") -- temporalAntiAliasing
Antialiasing that accumulates one sample per pixel per frame. The projection samples a different point inside each pixel every frame, and the frames are carried forward through the scene's own motion, so edges, highlights and fine texture settle instead of crawling.
Usage: local temporalAntiAliasing = require("@builtin::systems.antiAliasing.temporalAntiAliasing")
modules/temporalAntiAliasing/active
active(): boolean
Whether the temporal pass is running this frame.
if temporalAntiAliasing.active() then ... end
modules/temporalAntiAliasing/buffers
buffers(): { [string]: any }?
The parameter buffer the accumulation reads, carrying the settings this module packs. The render feature binds what this hands it.
local b = temporalAntiAliasing.buffers()
modules/temporalAntiAliasing/disable
disable()
Turn temporal antialiasing off and release the pass. The projection goes
back to sampling pixel centres. The settings are kept, so a later enable()
brings back the same tuning.
temporalAntiAliasing.disable()
modules/temporalAntiAliasing/enable
enable(opts: TemporalAntiAliasingOpts?): TemporalAntiAliasingState
Turn temporal antialiasing on and set it. Any omitted field keeps its current value.
Parameters
optsTemporalAntiAliasingOpts?(optional) — Temporal antialiasing settings — seeTemporalAntiAliasingOpts.
temporalAntiAliasing.enable({ historyWeight = 0.9 })
modules/temporalAntiAliasing/get
get(): TemporalAntiAliasingState
The temporal antialiasing settings currently in force.
local w = temporalAntiAliasing.get().historyWeight
modules/temporalUpscale/README
require("@builtin::systems.temporalUpscale.temporalUpscale") -- temporalUpscale
Reconstruction of a display-resolution image from a lower-resolution render. The projection samples a different point inside each pixel every frame and the frames are carried forward through the scene's own motion, so a scene rasterized at a fraction of the display's pixels resolves detail no single one of those frames holds. enable's backend field chooses what fills the upscale seam this reconstruction sits after — "auto", "dlss", "taau" or "none" — and whether this module's own reconstruction runs alongside it; see TemporalUpscaleOpts.
Usage: local temporalUpscale = require("@builtin::systems.temporalUpscale.temporalUpscale")
modules/temporalUpscale/active
active(): boolean
Whether the reconstruction is running this frame.
if temporalUpscale.active() then ... end
modules/temporalUpscale/buffers
buffers(): { [string]: any }?
The parameter buffer the reconstruction reads, carrying the settings this module packs. The render feature binds what this hands it.
local b = temporalUpscale.buffers()
modules/temporalUpscale/disable
disable()
Turn temporal upsampling off and release the pass. The projection goes
back to sampling pixel centres, the upscale seam returns to the blit, and
the render scale returns to what it was before this module first moved
it — unless something else has steered it since, which keeps that number.
The settings are kept, so a later enable() brings back the same tuning.
temporalUpscale.disable()
modules/temporalUpscale/enable
enable(opts: TemporalUpscaleOpts?): TemporalUpscaleState
Turn temporal upsampling on and set it. Any omitted field keeps its
current value. backend chooses what fills the upscale seam and whether
this module's own reconstruction runs alongside it — see
TemporalUpscaleOpts. Passing renderScale also moves the resolution
the scene rasterizes at, and disable puts back the scale that was in
force before the first such move.
Parameters
optsTemporalUpscaleOpts?(optional) — Temporal upsampling settings — seeTemporalUpscaleOpts.
temporalUpscale.enable({ backend = "auto", quality = "balanced" })
modules/temporalUpscale/get
get(): TemporalUpscaleState
The temporal upsampling settings currently in force.
local s = temporalUpscale.get().renderScale
modules/text/README
require("@builtin::modules.api.engine.text") -- text (also available as global 'text')
Text rasterisation resource — create a text handle, set its content and style, then rasterise it to a texture for display, and observe what the text system is holding. Public Luau surface over the __text and __textObserve Internal FFI namespaces.
Usage: local text = require("@builtin::modules.api.engine.text") Also available as global: text
modules/text/alive
alive(handle: any): boolean
Whether the text system still holds this handle — true between
text.create and the text.destroy that released it.
Parameters
handleany(optional) — Text handle fromtext.create.
if not text.alive(h) then h = text.create({ content = "again" }) end
modules/text/count
count(): number
How many text objects the text system is holding — the number that
moves when text.create and text.destroy are called.
local before = text.count()
modules/text/create
create(options: table): any
Create a text handle from an initial content + style table. The handle
owns a runtime GPU texture (see text.textureGuid); pass it to every other
call.
Parameters
optionstable— Table ofcontentplus style fields (fontSize, color, alignment, richText, maxWidth, ...).
local h = text.create({ content = "Hello", fontSize = 48 })
modules/text/destroy
destroy(handle: any): boolean
Destroy a text handle and release its raster + glyph layout.
Parameters
handleany(optional) — Text handle fromtext.create.
text.destroy(h)
modules/text/face
face(handle: any): any
Which font face one handle actually shaped with, and whether that is
the family its style selects. requested is the name the style wrote,
selected is the family that name selects — itself for a family the
shaper's own database carries, and the family a font file declares for a
name registered onto it — resolved is the face that answered, matched
says whether the face is the family the name selected and reason
says why when it is not — one of text.faceReasons(). A style that named
no family reports noFamilyRequested: it got the default because it asked
for nothing, so reason rather than matched is what an alert switches
on. faces lists
every face the shaper used, most glyphs first, so a fallback that covered
part of the string is visible alongside the face that covered the rest.
missing lists the characters no face drew (the missing glyph stood in);
a character an on-demand face covers requests it, and the object is shaped
again once the face is installed (font.onDemand()).
Parameters
handleany(optional) — Text handle fromtext.create.
local r = text.face(h).reason; if r == "familyUnknown" or r == "familyNotSelectable" then print(r) end
modules/text/faceReasons
faceReasons(): { string }
Every reason the face readings give for a label or a family not being
in the family a style named, nearest cause first. text.face gives them
for one label; font.reconcile() also gives familyCoveredNoGlyph, which
it can only reach by laying the family out under its own weights and over
several scripts.
for _, r in ipairs(text.faceReasons()) do print(r) end
modules/text/isDirty
isDirty(handle: any): boolean
Whether the handle was laid out again since it was last rasterised: its content or style changed, or a font arriving, leaving or changing the names it answers to changed the face it draws with. Rasterise it again when this answers true to show what it now says.
Parameters
handleany(optional) — Text handle fromtext.create.
if text.isDirty(h) then text.rasterize(h, text.textureGuid(h)) end
modules/text/listFonts
listFonts(): { string }
List the font families currently available to the text system.
local fonts = text.listFonts()
modules/text/loadFont
loadFont(ref: any): any
Load a font from an asset reference so it becomes available to
setStyle's fontFamily.
Parameters
refany(optional) — Font asset reference or path.
text.loadFont(asset.ref("fonts.inter", "font"))
modules/text/measure
measure(handle: any): any
Measure the rasterised text in pixels without producing a texture.
Parameters
handleany(optional) — Text handle fromtext.create.
local size = text.measure(h)
modules/text/observe
observe(): any
Everything the text system is holding right now. count is the live
text objects; objects is one row each, carrying its content, the style
it was laid out with, its measured extent, whether it is dirty, the face
the shaper actually used, the owner entity whose component created it
with whether that entity is still there, and the raster texture its last
rasterisation landed in with the bytes it costs. orphans is the subset
whose owning entity is gone, fonts the families the shaper can resolve,
and raster the glyph-raster bytes with the pool they belong to named.
Built when you ask, so it costs nothing per frame and reads the same in
edit mode as in play.
local live = text.observe().count
modules/text/orphans
orphans(): { any }
The text objects whose owning entity no longer exists — a quad the
engine is still holding for something that has been despawned. Each row is
the same shape text.observe().objects carries.
print(#text.orphans() .. " labels outlived their entity")
modules/text/rasterMemory
rasterMemory(): any
The glyph-raster bytes, broken out of the runtime GPU texture pool.
bytes is summed off the same map renderer.gpuMemory().textures is
totalled from, so shareOfPool is a share of that number rather than a
second count of the same memory.
local r = text.rasterMemory(); print(r.bytes .. " of " .. r.poolBytes)
modules/text/rasterize
rasterize(handle: any, texture: any, scale: number?): any
Rasterise the handle's current text + style into the given runtime GPU
texture. Bind that texture's guid as a material's base_color_texture to
display the text; re-rasterising the same texture overwrites it in place.
Parameters
handleany(optional) — Text handle fromtext.create.textureany(optional) — Destination GPU texture handle (renderer.texture.create) or its guid string — WHERE the raster lands.scalenumber?(optional) — World/pixel scale factor for the raster (default 1.0).
local tex = renderer.texture.create({ width = 256, height = 64 })
local r = text.rasterize(h, tex, 1.0)
modules/text/setStyle
setStyle(handle: any, style: table): boolean
Replace the handle's style. Fields not present keep their current value.
Parameters
handleany(optional) — Text handle fromtext.create.styletable— Style table (fontSize, color, alignment, outline, ...).
text.setStyle(h, { fontSize = 64, color = "yellow" })
modules/text/setText
setText(handle: any, content: string): boolean
Replace the handle's text content.
Parameters
handleany(optional) — Text handle fromtext.create.contentstring— New text string.
if not text.setText(h, "HP: 100") then h = text.create({ content = "HP: 100" }) end
modules/text/textureGuid
textureGuid(handle: any): string?
The runtime GPU texture guid this handle rasterises into — bind it as a
material texture (base_color_texture) to display the text.
Parameters
handleany(optional) — Text handle fromtext.create.
entity(id).component.get("Material"):setTexture("base_color_texture", text.textureGuid(h))
modules/trusted/README
require("@builtin::modules.trusted_client") -- trusted
User-space client for the trusted -> user call bridge (trusted.call).
Lets user-space scripts TRIGGER orchestration that lives in the engine's
trusted VM (auth / connection / service flows we author in trusted Luau)
WITHOUT exposing the trusted source or the privileged primitives those
flows use. Backed by the single __trustedBridge.invoke Rust transport:
the named call is marshalled into the trusted VM, run against its
__TRUSTED_EXPORTS registry, and the result marshalled back as plain data.
Trusted methods are registered on the other side by the trusted module
/zero/trusted/exports (its expose(name, handler)). This module is
auto-injected as the global trusted by the prelude.
Usage: local trusted = require("@builtin::modules.trusted_client")
modules/ui/README
require("@builtin::modules.api.engine.ui") -- ui (also available as global 'ui')
UI system — screens, styles, themes, widget responses, focus, custom-widget builders, per-widget state. Public Luau surface over the __ui Internal FFI namespace.
Usage: local ui = require("@builtin::modules.api.engine.ui") Also available as global: ui
modules/ui/blur
blur()
Surrender keyboard focus from whichever widget currently holds it, in the editor's UI and the game's alike.
modules/ui/bringAreaToFront
bringAreaToFront(id: string)
Raise a movable area to the top of the window stacking order —
the programmatic equivalent of clicking it. Areas sharing a stacking
band order by interaction, so this is the call that brings one forward
from code: use it when a taskbar button, focus change, or app launch
should raise a window. Moving a screen to a higher layer band raises
it over the bands below.
Parameters
idstring— Area widget id.
modules/ui/captureWindow
captureWindow(screen: string, window: string, opts: CaptureOpts?): CaptureResult?
Render a single Window widget to its own offscreen texture
and write the result as PNG at
/runtime/render_surfaces/<rtHandle>.png. The screen does NOT
need to be visible. Returns { rtHandle, texturePath } or nil
on invalid inputs (width/height clamped to [1, 8192],
defaults 600x400).
Parameters
screenstring— Screen id containing the target Window.windowstring— Widget id of the Window.optsCaptureOpts?(optional) —{ width, height }(optional).
modules/ui/click
click(callbackId: string, value: any?): boolean
Simulate a widget click / interaction by its callback id. The call
carries no screen, so an id that names widgets on several screens reaches
every component that declared it, once each. The callback id is the one
a widget emits: the string its onClick / onChange / other on* prop
names, or its element id where it leaves that prop unnamed (a button
clicked without an onClick, a slider changed without an onChange).
Given the element id of a widget whose interactions emit other ids, it
raises an error naming those ids, and clicks nothing.
Parameters
callbackIdstring— Callback id the widget emits (itsonClick/onChange/on*prop).valueany?(optional) — Optional value the callback receives asdata.value: a number, a string, a boolean, or a table with the fields a structured interaction delivers (a code editor's{ token, line, col }, a canvas drag's deltas).
modules/ui/copyText
copyText(text: string)
Put text on the host clipboard — the operating system's clipboard
on a native build, the browser's in a web build. What a "Copy path" or
"Copy reference" action calls.
Parameters
textstring— The text to copy.
ui.copyText("/zero/source/scenes/main.scene")
modules/ui/defineStyle
defineStyle(name: string, style: StyleProps)
Define a named style. Style keys follow
<widgetType>.<className> (e.g. "label.h1", "button.primary")
or bare <className> to apply across widget types. Widgets
reference styles via the classes (or class) prop.
Parameters
namestring— Style name.styleStyleProps— Style properties table.
modules/ui/defineStyles
defineStyles(styles: { [string]: StyleProps })
Define multiple named styles at once.
Parameters
styles{ [string]: StyleProps }— Map of style name to style properties.
modules/ui/defineWidget
defineWidget(name: string, builderFn: (WidgetTree, { WidgetTree }) -> WidgetTree)
Register a custom widget kind. When a tree contains
{ type = name, props = ..., children = ... }, the decoder
calls builderFn(props, children) at register / update time and
substitutes the returned widget table in place. Errors surface
through ui.lastValidation() with codes widget-builder-error
/ widget-builder-bad-return / decode-recursion-depth-exceeded.
Parameters
namestring— Custom widget kind name.builderFn(WidgetTree, { WidgetTree }) -> WidgetTree— Builder closure(props, children) -> widgetTable.
modules/ui/diagnose
diagnose(widgetId: string): WidgetPaint?
Why one widget did or did not reach the last frame. Returns that
widget's row from ui.observe() — the same fields, resolved against the
same reading. An id no registered screen carries reads noSuchWidget,
which is how a misspelling separates from a widget whose screen is
hidden and from one the frame laid out no box for.
Parameters
widgetIdstring— The id the widget records layout under.
local row = ui.diagnose("hud-healthbar")
modules/ui/displayScale
displayScale(): DisplayScale
The physical scale the UI is sized at. density is the physical
pixels one density-independent point covers on a handheld display (a
phone, a tablet, a page in a touch browser): a point of the UI covers at
least that many pixels whatever the screen's width or orientation, so
text and buttons keep their physical size. It is nil on a desktop
window, whose UI is sized by its width alone. textScale is the user's
text size setting, which multiplies every font size the UI typesets
(labels, buttons, inputs, editor chrome; canvas text is drawn at the
size it names). touchTarget is the smallest target, in points, a touch
reaches an interactive widget within: 48 on a handheld display, 0 on a
desktop. pixelRatio is ui.pixelRatio() of the same frame.
ui.simulateDisplayScale previews a phone's on any engine.
local scale = ui.displayScale()
local buttonHeight = math.max(32, scale.touchTarget)
modules/ui/dragState
dragState(): { payload: string, x: number, y: number, label: string?, ghost: boolean }?
The in-flight drag-and-drop payload while a dragPayload widget is
being dragged, else nil. x/y are the pointer's position in the
logical space ui.getLayoutInfo rects live in, so the reading resolves
directly against widget rects. label is the text the drag ghost beside
the pointer reads (dragLabel, else the source's text; nil for an
outline ghost), and ghost whether the engine draws one (dragGhost) —
a capture never shows the ghost, so this is how a drag's name-at-cursor
is checked. Poll during a drag to drive live feedback; the drop itself
still lands through the target's onDrop. Snapshotted each frame.
modules/ui/elementTree
elementTree(screenName: string): ElementNode?
Introspect a screen's rendered widget hierarchy with each
element's layout rect. Every node the renderer draws appears, nested
exactly as the widgets nest, under the id it records layout against:
the id set on the node when the author gave it one, otherwise
<screen>/<type>@<path>. bounds is that element's rect — the same
table ui.getLayoutInfo(id) returns — and appears once the element has
been measured. Kinds registered through ui.defineWidget appear
expanded into the primitives they build. Feeds the gui.captureElement
tool: list the tree, pick the ids to frame, capture their region.
Parameters
screenNamestring— Screen id passed toui.registerScreen.
modules/ui/focus
focus(widgetId: string)
Programmatically request keyboard focus on a widget. Queued
as a one-shot; the next render of the matching widget calls
response.request_focus().
Parameters
widgetIdstring— Widget id to focus.
modules/ui/focusedWidget
focusedWidget(): (string?, string?)
Return the widget id of whichever widget currently holds
keyboard focus, or nil, and the space it draws in: "window" for the
editor's UI around the game view, "camera" for the game's own UI in
the game view. Snapshotted post-render each frame.
local id, space = ui.focusedWidget()
modules/ui/getAreaPos
getAreaPos(id: string): AreaPos?
Read the current pivot position of an area widget,
including any user drag deltas. Returns { x, y } or nil if
the area didn't render this frame.
Parameters
idstring— Area widget id.
modules/ui/getAreaSize
getAreaSize(id: string): AreaSize?
Read the measured size of an area widget, including any user
resize-grip drags if the area is resizable. Returns { w, h }
or nil if the area didn't render this frame.
Parameters
idstring— Area widget id.
modules/ui/getDockLayout
getDockLayout(id: string): string?
Read the current serialized layout (split/tab arrangement) of
a dockArea widget as a JSON string. Returns nil if the dockArea
didn't render this frame. Persist the string and pass it back via
the dockArea's layout prop to restore the arrangement.
Parameters
idstring— DockArea widget id.
modules/ui/getLayoutInfo
getLayoutInfo(widgetId: string?): LayoutInfo?
Get layout info (position, size, content bounds) for UI
containers. If widgetId is given, returns info for that
widget only; otherwise returns all.
Parameters
widgetIdstring?(optional) — Optional widget id to query.
modules/ui/getPersistentDockLayout
getPersistentDockLayout(id: string): string?
Read a dockArea's arrangement as a JSON string with every tab
whose dockPanel is transient left out — the form to save and
restore across sessions. Returns nil if the dockArea didn't render
this frame.
Parameters
idstring— DockArea widget id.
modules/ui/getScreenTree
getScreenTree(screenName: string): WidgetTree?
Return the last widget tree table passed to
registerScreen / updateScreen for screenName.
Parameters
screenNamestring— Screen name to query.
modules/ui/getTheme
getTheme(): string
Get the name of the currently active theme.
modules/ui/getToken
getToken(name: string): string?
Look up a single design token value from the active theme.
Parameters
namestring— Token name (without$prefix).
modules/ui/getTokens
getTokens(): { [string]: string }
Get all design tokens from the active theme as a key-value map.
modules/ui/getWidgetProps
getWidgetProps(typeName: string): { WidgetPropDescriptor }?
Get the property definitions for a widget type.
Parameters
typeNamestring— Widget type name.
modules/ui/getWidgetTypes
getWidgetTypes(): { string }
Get all available widget type names that can be used in widget trees.
modules/ui/hideScreen
hideScreen(name: string): boolean
Hide a registered screen, and report whether a screen by that name
is registered. The engine applies the hide later in the frame;
listScreens reflects it from the next call onwards.
Parameters
namestring— Screen identifier to hide.
modules/ui/hitTest
hitTest(x: number, y: number): PaintHitTest?
Which widget a pointer at (x, y) reaches, and the stack beneath it.
Coordinates are logical points on the window, the space getLayoutInfo
and gui.bounds rects are in wherever a widget's screen draws (a screen
in the Scene view's picture included). A widget that takes no
pointer, a canvas declaring pointerEvents = "none", is passed over: the
answer is the widget beneath it.
Parameters
xnumber— Logical X.ynumber— Logical Y.
local hit = ui.hitTest(640, 360)
modules/ui/idCollisions
idCollisions(): { [string]: { string } }
Element ids more than one screen recorded, each mapped to the
screens that recorded it. An id addresses one element: two screens
sharing one leave ui.getLayoutInfo and the gui element tools
answering for whichever painted last, and the gui tools refuse such
an id. Empty while every id is unique.
for id, screens in ui.idCollisions() do print(id, table.concat(screens, ", ")) end
modules/ui/invisibilityReasons
invisibilityReasons(): { string }
Every verdict ui.diagnose can report, as a closed list.
modules/ui/lastRegistration
lastRegistration(): { name: string, layer: number? }?
The name and layer passed to the most recent ui.registerScreen
call, recorded synchronously at call time. A host that mounts a nested
app reads this immediately after the mount to learn which screen the
nested code registered, without intercepting the ui table.
modules/ui/lastValidation
lastValidation(screenName: string?): any
Validation diagnostics produced at the most recent
registerScreen / updateScreen, plus what the render stage
found while painting — unknown-font-family reports a
style.fontFamily that named no registered font family, once
per family per screen, wrap-label-no-width reports a
label with props.wrap whose box came out narrower than its
own longest word, once per label per screen, and
svg-not-as-declared reports an svg widget whose document
declared something the picture does not hold — a <text>
whose font-family selected no registered family, a <text>
the picture holds no glyph of, or a shape whose url(#id)
paint resolved to nothing — once per finding per widget per
screen. With no args
returns a
{ [screen] = entry } map; with a name returns that screen's
entry or nil. Validation gated by world setting
ui.validation = "off" | "warn" | "strict" (default "warn").
Parameters
screenNamestring?(optional) — Optional screen name.
modules/ui/listFonts
listFonts(): { FontFamilyInfo }
Every font family a style.fontFamily can select. Read from
the registry the UI text renderer resolves a family token
through, so a family this returns is one a label renders in.
family and every name in aliases are accepted as a
fontFamily, case-insensitively; aliases carries the
web-font names, CSS generic families and face names that
select the same group. faces names the concrete face in each
weight/style slot, so a fontWeight = 700 against a family
with no bold face gets a synthesised heavy. more lists the
other faces registered in the family's slots, each drawing the
codepoints the slot's face lacks: the installed chunks of an
on-demand face (font.onDemand() lists them all). system = true
marks a family taken from the host OS — present on this
machine, absent on one without it, and absent on WASM — so a
UI that must look the same everywhere picks a family with
system = false. A fontFamily naming nothing in this list
is reported as an unknown-font-family warning through
ui.lastValidation(screen) once the screen paints, and the
text renders in the default proportional face.
for _, f in ui.listFonts() do print(f.family) end
modules/ui/listScreens
listScreens(): { ScreenSummary }
List every registered screen with its current visibility,
z-order layer, renderLayer (the render-layer membership mask it
draws under: the mask setScreenRenderLayer stated, else the one the
surface setScreenSpace named implies, else the ui bit),
editorChrome (whether the mask setScreenRenderLayer stated carries
the EditorUI bit, which makes the screen the editor's own chrome; a
screen placed on the window without stating it is not chrome), whether
the screen has a populated root widget tree, and the space it draws in
("window" for the editor's UI, "camera" for the game's),
including the register / show / hide / unregister calls the running
script has already made. Sorted by layer ascending, then name.
modules/ui/listThemes
listThemes(): { string }
List all registered theme names.
modules/ui/lockOrientation
lockOrientation(lock: OrientationLock)
Hold the display to the orientations lock allows: "landscape"
(both landscape directions, so turning the device over turns the app
with it), "portrait" (both portrait directions) or "any" (the display
follows the device). A world states the orientation it plays in as
world.orientation, which the engine locks to in play mode and releases
in edit mode, so the editor follows the device; call this to change it
while the world runs. Android turns the app at once, a browser grants the
lock only to a page in fullscreen in most cases (the page asks again each
time it enters fullscreen), and a desktop window presents in the shape it
is given. ui.orientation() reports the lock and whether the platform
holds it from the next frame. Any other value is refused by name.
Parameters
lockOrientationLock—"any","landscape"or"portrait".
ui.lockOrientation("portrait")
ui.lockOrientation("any")
modules/ui/missingGlyphs
missingGlyphs(): { string }
The characters the UI is showing without a glyph: each appears in
text a UI surface (the window, the game view, a camera's UI overlay, a
screen drawn into a texture) drew in what it last painted, and no face of
the family it was drawn in has a glyph for it, so it shows as the
replacement box.
Every family falls back glyph by glyph to every face the UI holds, so a
character here is one no installed face covers. A character a declared
on-demand face covers (font.onDemand()) requests that face the frame
it is met, and leaves this list once the face is installed and the next
frame draws it.
if #ui.missingGlyphs() > 0 then print(table.concat(ui.missingGlyphs(), " ")) end
modules/ui/observe
observe(screenName: string?): PaintObservation?
What the last UI frame painted. Returns
{ generation, viewport, pointer, pointerOverUi, pointerWidget, widgets }
with one widgets row per widget any registered screen holds — its
layout box, the clip chain it painted under, the part of that box which
reached the frame (visible), the order it painted in (paintIndex),
and its reason from the closed set ui.invisibilityReasons() lists.
Every rect, the reading's viewport (the window) and pointer are in
logical points on the window; a row's viewport is the region the pass
that drew it paints into (the whole window, or the rect a Scene panel
presents the camera's picture in), and offViewport is judged against it.
generation advances once per re-rendered frame, so two calls reporting
the same number describe the same frame.
Parameters
screenNamestring?(optional) — Narrow the rows to one screen. Omit for every screen.
local reading = ui.observe("hud")
modules/ui/onOrientationChange
onOrientationChange(callback: (reading: OrientationReading) -> ()): () -> ()
Call callback with the new reading every time ui.orientation()
changes: the display turns between landscape and portrait or to another
rotation, the lock changes, or the platform starts or stops holding it.
Each listener is watched by a task of the context that registered it, so
a listener a component registered ends when that component is removed,
and every other listener goes on hearing changes.
Parameters
callback(reading: OrientationReading) -> ()— Receives the reading, asui.orientation()returns it.
Returns () — A function that removes this listener.
local off = ui.onOrientationChange(function(o) print(o.current, o.rotation) end)
modules/ui/orientation
orientation(): OrientationReading
The orientation the display presents the app in, and the lock it is
held to. current is "landscape" (wider than tall) or "portrait":
the shape of the window the app presents in. lock is what
ui.lockOrientation last asked, "any" when the display follows the
device. enforced is whether the platform holds the display to it:
Android always does, a browser does once it grants the Screen
Orientation lock, and a desktop window never does, presenting in the
shape it is given; reason names why when it does not. rotation is the
display's rotation from its natural orientation in degrees (0, 90, 180,
270) where the platform states one, and nil on a desktop window.
revision advances every time any of these changes; ui.onOrientationChange
calls back on each change.
if ui.orientation().current == "portrait" then print("lay the HUD out for a tall screen") end
modules/ui/paintOrder
paintOrder(a: string, b: string): number?
Which of two widgets paints later: -1 when a paints before b,
1 when after, 0 when level. This is what separates two widgets whose
rects are identical.
Parameters
astring— First widget id.bstring— Second widget id.
local order = ui.paintOrder("panel-a", "panel-b")
modules/ui/pixelRatio
pixelRatio(): number
Physical pixels per logical point — the factor between the logical
space ui.screenSize() / getLayoutInfo rects live in and the physical
space input.mousePosition, the camera viewport rect and
input.simulateMouse* coordinates live in. Multiply a layout coordinate
by this to aim a simulated pointer at a widget.
modules/ui/pointerWidget
pointerWidget(): PointerRead?
Whether the UI is consuming the pointer, and which widget holds it —
the pointer counterpart of ui.focusedWidget(). x, y are in logical
points on the window, the space getLayoutInfo rects are in.
modules/ui/refreshLiveText
refreshLiveText(): number
Read again the text of every screen this VM registered whose text
resolves when it is read: a text, title, header, placeholder,
tooltip or dropdown option given as a value with a __tostring
metamethod, such as an i18n.text value, rather than as a string. The
i18n module calls it whenever the player's language, the
pseudo-locale or a catalog changes, so a screen built from i18n.text
values follows them without being built again.
local tree = { type = "label", props = { text = i18n.text("hud.title") } }
modules/ui/registerBackgroundShader
registerBackgroundShader(shaderHandle: any, width: number?, height: number?)
Register a screen-domain .shader as a UI background, drawn
via the backgroundShader style. Takes the shader's asset handle
from asset.resolve. A shader whose compile failed
(shaderHandle:compileStatus() reads failed), or whose program
the compile gate refuses, is not registered: the call raises an
error naming the shader and the compiler's message, the one
compileStatus().error reads. A shader whose compileStatus()
still reads pending raises too: register it once it reads
compiled.
Parameters
shaderHandleany(optional) — The screen.shader's asset handle, fromasset.resolve.widthnumber?(optional) — Render target width (default 1280).heightnumber?(optional) — Render target height (default 720).
modules/ui/registerCallbackEnv
registerCallbackEnv(key: string, env: { [string]: any })
Register an environment table to receive widget-callback
broadcasts: its global onCallback(id, value) fires for any widget
callback not owned by a specific component instance — the same
broadcast a component's onCallback receives. Keyed by key;
re-registering the same key replaces the previous env. A component
instance is folded into the callback dispatch automatically, so reach
for this from a non-component context that hosts a UI surface (a scene
entrypoint registering its own screen). Pair with
ui.unregisterCallbackEnv(key) so the ref is released.
Parameters
keystring— Stable identifier for this registration (re-register replaces).env{ [string]: any }— Environment table whoseonCallbackreceives the broadcasts.
modules/ui/registerScreen
registerScreen(name: string, widgetTree: WidgetTree, layer: number?)
Register a named UI screen with a widget tree. Optional
layer controls z-ordering (higher = on top), in bands: below 0
behind everything, 0-99 ordinary app depth, 100-999 always-on-top
chrome, 1000+ menu and popup depth. A screen in a higher band
covers one in a lower band whatever their roots are; inside a band
a floating area or window root sits over ordinary content, and
a modal root sits over the whole stack. Tag-based
grouping lives in Z.tags (Z.tags.set(name, { "editor" })
after register). A screen belongs to the component instance whose
own code registers it (its hooks and methods, and any closure they
create, such as a listener it subscribes): that instance's
onCallback receives its callbacks, and the screen is unregistered
when the instance ends. Code that is not an instance's own (a scene
entrypoint, a module, a listener either subscribed) registers a
screen no instance owns, which stays until it is unregistered,
whichever component's hook ran that code. topics/ui has the rule.
Parameters
namestring— Unique screen identifier.widgetTreeWidgetTree— Root widget table.layernumber?(optional) — Z-order layer (optional).
ui.registerScreen("hud", tree)
modules/ui/registerTheme
registerTheme(name: string, theme: ThemeDefinition)
Register a theme from a flat Luau table. Most callers
should use Z.theme.register(name, table) which runs the
cascade for them.
Parameters
namestring— Theme name to register.themeThemeDefinition— Flat-resolved theme table.
modules/ui/removeScreen
removeScreen(name: string): boolean
Alias for ui.unregisterScreen.
Parameters
namestring— Screen identifier to remove.
modules/ui/resetAreaSize
resetAreaSize(id: string)
Clear a resizable area's remembered size (from a grip drag or
ui.setAreaSize) so its declared — or content — size takes over again.
Parameters
idstring— Area widget id.
modules/ui/response
response(widgetId: string): WidgetResponse?
Per-widget interaction snapshot for the most recent frame.
Returns { clicked, hovered, focused, changed, value } where
clicked / changed mark transitions and hovered / focused
mark current state.
Parameters
widgetIdstring— The widget id (NOT the onClick / onChange callback id).
modules/ui/safeArea
safeArea(): SafeArea
The part of the screen no system bar, display cutout or on-screen
keyboard covers, in the logical points ui.screenSize() reports.
top / right / bottom / left are how far in from each edge the
covered band reaches; x / y / width / height are the rect they
leave; cutouts lists each display cutout (a camera hole or a notch) as
{ x, y, width, height }. Screens lay out inside this rect, so anchors,
top-level % sizes and a window's default position already keep clear
of it; read it to place something by absolute pos, or to run a
background under the bars while its controls stay inside. revision
advances every time the area changes (a rotation, the system bars shown
or hidden, the keyboard opening, a window resize): compare it with the
one you last laid out against. All zero on a desktop window;
ui.simulateSafeArea lays the UI out as a phone would on any engine.
local safe = ui.safeArea()
ui.setAreaPos("hud", safe.x + 8, safe.y + 8)
modules/ui/screen
screen(name: string): { [string]: any }?
Get a screen proxy with methods like setResolution and
rasterize.
Parameters
namestring— Screen name.
modules/ui/screenSize
screenSize(): { width: number, height: number }
The UI coordinate space as { width, height } (logical points). This is
the space area pos, anchors, and getLayoutInfo rects use — and it is
NOT the pixel size of a capture screenshot, which may be downscaled. Use
this for absolute area positioning (e.g. pinning a menu above a bottom
taskbar) instead of guessing the size from a capture image.
It follows the size the engine draws at, and renderer.setViewportSize
changes that size for the task that asks, which is how a layout written
against this is checked at a second shape without rebooting the engine,
read in the call that set the size before the surface goes back. The pixel size
behind these points is renderer.surfaceSize() — the whole drawing
surface a screen is laid out over, which an editor layout makes larger
than the rect renderer.viewportSize() draws the scene into — and
ui.pixelRatio() is the factor between the two spaces.
modules/ui/scroll
scroll(deltaX: number, deltaY: number)
Simulate a mouse-wheel scroll event on the UI.
Parameters
deltaXnumber— Horizontal scroll delta.deltaYnumber— Vertical scroll delta.
modules/ui/setAreaPos
setAreaPos(id: string, x: number, y: number)
Programmatically move a movable area widget to (x, y).
Applied for one frame; subsequent frames let drag tracking
take over.
Parameters
idstring— Area widget id.xnumber— Target pivot x (screen coords).ynumber— Target pivot y (screen coords).
modules/ui/setAreaSize
setAreaSize(id: string, w: number, h: number)
Programmatically set a resizable area's size (the user-size
override) — for maximize / restore / tile. Persists until the area's
declared width/height changes or ui.resetAreaSize(id) clears it.
Parameters
idstring— Area widget id.wnumber— Target width (screen coords).hnumber— Target height (screen coords).
modules/ui/setDockWindowRect
setDockWindowRect(
Place the floating window of a dockArea panel at (x, y) with
size (width, height). Applies once the panel occupies a window —
a request made before then waits for it.
modules/ui/setScreenRenderLayer
setScreenRenderLayer(name: string, mask: number)
Set a screen's render-layer membership bitmask. A screen draws into a
camera or capture only when this mask intersects the camera's include
mask, the same rule geometry follows. Content UI carries the ui bit;
the editor places its chrome on EditorUI so agent captures can drop it,
and a screen carrying that bit is part of the window rather than the
camera's picture. Stating a mask here fixes the membership: a screen left
to itself takes the one the surface it is placed on implies, EditorUI
for the window and ui for the camera's picture. __renderLayers.bit(name)
answers with a layer's bit INDEX, so a mask sets the bit at that index and
__renderLayers.names(mask) reads it back as the names it holds.
Parameters
namestring— Screen identifier.masknumber— Render-layer membership bitmask — the OR ofbit32.lshift(1, __renderLayers.bit(name))over the layers the screen is on.
ui.setScreenRenderLayer("hud", bit32.lshift(1, __renderLayers.bit("ui")))
modules/ui/setScreenSpace
setScreenSpace(name: string, space: string)
Set which surface a screen is part of. "camera" is the picture the
viewport camera produces: the screen lays out over the camera's target
and is drawn into it, so it sits inside the Scene panel presenting the
scene and appears in every capture of the camera — the default for
content UI. "window" is the window itself, whatever presents the scene
— where the editor's chrome lives, and the default for a screen on the
EditorUI layer. The two are one statement made from either end, so a
screen placed on the window takes the EditorUI membership unless
setScreenRenderLayer states another: the window goes on drawing it while
a capture that drops the authoring layers, which is what an agent takes by
default, leaves it out. Where the scene presents on the window, the two
surfaces coincide. A name that is neither raises.
Parameters
namestring— Screen identifier.spacestring—"camera"|"window".
ui.setScreenSpace("agent-banner", "window")
modules/ui/setScrollPosition
setScrollPosition(widgetId: string, offsetY: number)
Set the scroll offset of a scrollArea widget.
Parameters
widgetIdstring— Scroll area widget id.offsetYnumber— Vertical scroll offset in pixels.
modules/ui/setShaderUniforms
setShaderUniforms(name: string, uniforms: { [string]: number })
Set uniform values on a registered background shader.
Parameters
namestring— Shader name identifier.uniforms{ [string]: number }— Map of uniform name to number value.
modules/ui/setTheme
setTheme(name: string)
Switch the active global theme by name.
Parameters
namestring— Theme name to activate.
modules/ui/showScreen
showScreen(name: string): boolean
Make a registered screen visible, and report whether a screen by
that name is registered. The engine applies the show later in the
frame; listScreens reflects it from the next call onwards.
Parameters
namestring— Screen identifier to show.
modules/ui/simulateDisplayScale
simulateDisplayScale(scale: DisplayScaleSpec?)
Size the UI as a display stating scale would, in place of what the
platform states. A density sizes it as a handheld display of that
many physical pixels per point (omit it for a desktop display sized by
its width), and textScale multiplies every font size the UI typesets
(1 when omitted). Previews a phone's UI on a desktop or headless engine,
and makes a layout test independent of the device it runs on.
ui.displayScale(), ui.screenSize() and ui.pixelRatio() report it
from the next frame. Call it with no argument (or nil) to return to
the platform's own scale. A value that is not a number above 0 and at
most 8 is refused by name.
Parameters
scaleDisplayScaleSpec?(optional) —{ density?, textScale? }; nil returns to the platform's scale.
ui.simulateDisplayScale({ density = 2.625, textScale = 1.3 })
ui.simulateDisplayScale()
modules/ui/simulateSafeArea
simulateSafeArea(area: SafeAreaSpec?)
Lay the UI out as if the system covered the screen by area
(logical points) in place of what the platform states: each inset
defaults to 0 and cutouts is a list of { x, y, width, height }.
Previews a phone's status bar, camera cutout and navigation bar on a
desktop or headless engine, and makes a layout test independent of the
device it runs on. ui.safeArea() reports it from the next frame. Call
it with no argument (or nil) to return to the platform's own safe
area. A negative or non-number inset is refused by name.
Parameters
areaSafeAreaSpec?(optional) —{ top?, right?, bottom?, left?, cutouts? }in logical points; nil returns to the platform's safe area.
ui.simulateSafeArea({ top = 40, bottom = 30, cutouts = { { x = 600, y = 0, width = 80, height = 40 } } })
ui.simulateSafeArea()
modules/ui/unregisterCallbackEnv
unregisterCallbackEnv(key: string)
Remove an environment registered with ui.registerCallbackEnv. Its
onCallback stops receiving broadcasts. No-op if key isn't registered.
Parameters
keystring— The key passed toui.registerCallbackEnv.
modules/ui/unregisterScreen
unregisterScreen(name: string): boolean
Remove a screen from the registry entirely. Unlike
hideScreen, this deletes the entry so it no longer appears in
listScreens or render iteration.
Parameters
namestring— Screen identifier to unregister.
modules/ui/unregisterWidget
unregisterWidget(name: string)
Drop a registered custom widget kind. Subsequent references
produce an unknown-widget-type diagnostic.
Parameters
namestring— Custom widget kind name.
modules/ui/updateScreen
updateScreen(name: string, widgetTree: WidgetTree)
Replace the widget tree of an already-registered screen.
Parameters
namestring— Screen identifier to update.widgetTreeWidgetTree— New root widget table.
modules/ui/useStyles
useStyles(themeName: string)
Apply a registered style file's classes additively without changing the active theme.
Parameters
themeNamestring— Name of the registered style / theme asset.
modules/ui/widgetState
widgetState(widgetId: string, key: string, default: any?): any
Read per-widget cross-frame state. Returns the value
previously written via widgetStateSet, or default (or nil).
State is keyed by widget id and persists across re-renders
within a screen's lifetime; cleared automatically when the
owning screen is unregistered.
Parameters
widgetIdstring— Widget id whose state to read.keystring— State key.defaultany?(optional) — Value to return when nothing has been written.
modules/ui/widgetStateClear
widgetStateClear(widgetId: string, key: string)
Remove a per-widget state entry.
Parameters
widgetIdstring— Widget id whose state to clear.keystring— State key.
modules/ui/widgetStateSet
widgetStateSet(widgetId: string, key: string, value: any)
Write per-widget cross-frame state. Replaces any existing
value under (widgetId, key). Tables are stored by reference.
Parameters
widgetIdstring— Widget id to scope the state under.keystring— State key.valueany(optional) — Value to store (must be non-nil).
modules/unwatch
modules.unwatch(watcherId) -> boolean
Remove a previously registered module source watcher by its ID.
Parameters
watcherIdnumber— Watcher ID returned by modules.watch()
Returns boolean — true if watcher was found and removed
modules/userfile/README
require("@builtin::modules.api.engine.userfile") -- userfile (also available as global 'userfile')
The files of the person at the screen, both ways. pick opens their own file picker (native OS dialog / Android / web browser) and brings the chosen file(s) into the engine; save puts a file the engine holds onto their device (a download in the browser). Public Luau surface over the __userfile Internal FFI namespace.
Usage: local userfile = require("@builtin::modules.api.engine.userfile") Also available as global: userfile
modules/userfile/pick
pick(opts: PickOpts?): PickResult
Open the user's system file picker and bring the chosen file(s)
into the engine. Yields until the user finishes (call from a coroutine /
task, like any task.await) and returns
{ cancelled, files = {{ name, mime, size, bytes?, vfsPath? }} }.
Without writeTo each file carries bytes (a binary-safe string);
with writeTo each carries vfsPath (read it with vfs.read).
Cancelling returns { cancelled = true, files = {} }; a genuine failure
(e.g. a lost browser user-activation gesture) raises an error.
Parameters
optsPickOpts?(optional) — Picker options (optional): multiple, folder, title, filters, writeTo.
local r = userfile.pick({ filters = {{ name = "Images", extensions = {"png","jpg"} }} })
if not r.cancelled then vfs.write("/source/textures/wall.png", assert(r.files[1].bytes)) end
modules/userfile/pickFolder
pickFolder(opts: PickOpts?): PickResult
Convenience for userfile.pick({ folder = true }) — pick a whole
directory tree. Yields until the user finishes and returns the same
result table as pick. On the web this degrades to a multi-file selection.
Parameters
optsPickOpts?(optional) — Picker options (optional);folderis forced true.
local r = userfile.pickFolder({ writeTo = "/source/imported/" })
modules/userfile/save
save(path: string, opts: SaveOpts?): (boolean, string, SaveReport?)
Save a file the engine holds onto the device of the person at the
screen: the way a person keeps a recording, a capture or an export.
The person decides where it lands. In the browser the file downloads at
once when the save rides a click or key press of the person at the
screen (call it from a button's click handler), and otherwise the page
shows them an offer they save with a click of their own, since a
browser starts a download only for a person who just acted. A native
engine opens the host's save dialog in their downloads folder, with the
name filled in, and writes the file where they choose. An engine with no
window has no person at its screen and refuses. The call waits for the
first answer, so run it where it can yield (task.spawn from a
callback). Returns true, a sentence saying where the file went, and the
report { state, detail, name, size, path } whose state
is "saved" (the file is on the device) or "offered" (it is in front
of the person, as the page's offer or the save dialog, and lands when
they act); or false and the reason the save was refused: no file at the
path, a folder, a name with a folder in it, no window, or a file too
large for the browser to hold (which the page also shows).
Parameters
pathstring— VFS path of the file to save.optsSaveOpts?(optional) —{ name }, the file name the device gets (the file's own when omitted).
local ok, where = userfile.save("/zero/runtime/recordings/take.mp4")
local ok, where, report = userfile.save("/zero/source/export/level.json", { name = "level-3.json" })
modules/values/README
require("@builtin::modules.api.engine.values") -- values (also available as global 'values')
Named values an entity holds: typed numbers, vectors and booleans (throttle, rpm, gear, headlights, doorOpen) that scripts and engine systems write and read cheaply, and that materials, audio voices, the UI and replication follow without a script copying them every frame. A value stays on this engine unless it is declared to replicate, at a rate in Hz.
Usage: local values = require("@builtin::modules.api.engine.values") Also available as global: values
modules/values/bind
bind(
A UI prop that follows a named value, with no script updating the
screen: put it where a widget takes text, value, visible,
checked or enabled, and the widget reads the value every frame.
format is a string.format pattern for text ("%d rpm"; the value
as it reads when absent); scale and offset map a number
(value * scale + offset) before it is shown. A value the entity does
not hold shows fallback (empty text, 0 or false when absent).
ui.registerScreen("dash", { type = "vertical", children = {
{ type = "label", props = { text = values.bind(car, "rpm", { format = "%.0f rpm" }) } },
{ type = "slider", props = { min = 0, max = 1, value = values.bind(car, "throttle") } },
} })
modules/values/clear
clear(target: string | entityRef): number
Drop every named value an entity holds. An entity's values also go when the entity leaves the world.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.
values.clear(car)
modules/values/declare
declare(target: string | entityRef, name: string, declaration: ValueDeclaration?)
State what a named value is: its type ("number", "vector" or
"boolean"), the default it starts at, and whether it replicates. A name
the entity already holds keeps its value. replicate is a rate in Hz (up
to 60): the owner of the entity sends the value to every other peer at
most that often while it changes, and always sends the latest one, and
the other peers read it like any value. A value with no replicate is
never sent anywhere.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.namestring— The value's name.declarationValueDeclaration?(optional) —{ type?, default?, replicate? }; givetypeordefaultfor a name the entity does not hold yet.
values.declare(car, "throttle", { type = "number", default = 0, replicate = 10 })
values.declare(car, "brake", { default = false, replicate = 20 })
modules/values/describe
describe(target: string | entityRef): { ValueRow }
Every named value an entity holds, sorted by name, each with its
type, its value, who wrote it last (writer: "script", "engine" or
"remote"), the store revision of its last change, its replicate rate
(absent for a value kept on this engine) and whether a declaration states
it. The same rows /zero/runtime/values/<entityId> and the values
toolbox list.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.
for _, row in values.describe(car) do print(row.name, row.type, row.value, row.writer) end
modules/values/entities
entities(): { string }
Every entity holding at least one named value, sorted by id.
for _, id in values.entities() do print(id, #values.describe(id)) end
modules/values/get
get(target: string | entityRef, name: string): Value?
Read a named value an entity holds, or nil when it holds none under
that name. Engine systems write values too: a WheelCollider writes its
own state (wheel.slipRatio, wheel.angularVelocity, ...), so a script
reads it here the way it reads a value a script wrote.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.namestring— The value's name.
local rpm = values.get(car, "rpm") or 0
modules/values/list
list(target: string | entityRef): { [string]: Value }
Every named value an entity holds, by name.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.
for name, v in values.list(car) do print(name, v) end
modules/values/onAnyChange
onAnyChange(callback: (Value?, string, string) -> ()): ValueConnection
Call callback(value, name, entityId) for every change of every named
value on every entity, once per frame in which it changed: what a debug
view or a recorder of a session's values follows.
Parameters
callback(Value?, string, string) -> ()—function(value, name, entityId).
local conn = values.onAnyChange(function(v, name, id) print(id, name, v) end)
modules/values/remove
remove(target: string | entityRef, name: string): boolean
Drop a named value from an entity.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.namestring— The value's name.
values.remove(car, "rpm")
modules/values/set
set(target: string | entityRef, name: string, value: Value?)
Write a named value on an entity: a number, a vector or a boolean;
nil removes it. A name takes the kind of its first value and keeps it:
writing another kind raises (remove the value first to change its kind).
The write is a store, with nothing replicated and nothing copied, and
every reader sees it from the next read: values.get, a material
property bound to the name, an Audio voice following it, a UI prop
values.bind made. Only a value values.declare gives a replicate
rate is ever sent to other peers.
Parameters
targetstring | entityRef— The entity: a proxy fromentity(...), or its id.namestring— The value's name.valueValue?(optional) — A number, a vector or a boolean;nilremoves the value.
values.set(car, "rpm", 3200)
values.set(car, "headlights", true)
values.set(car, "wheelSpin", vector.create(0, 12.5, 0))
modules/values/stats
stats(): { entities: number, values: number, revision: number, replication: ValueReplicationStats }
How many entities hold values, how many values there are, the
store's revision (which advances on every change), and what replication
has carried: a value with no replicate rate adds nothing to it.
print(values.stats().values, values.stats().replication.sentBytes)
modules/values/subscribe
subscribe(
Call callback(value, name, entityId) when a named value of an entity
changes, whoever changed it: a script, an engine system or another peer.
Give name to follow one value, or nil to follow every value of the
entity. The callback runs once for the writes a frame made, on the
engine's next pass over its tasks, with the value as it stands then:
three writes in one frame are one call with the last of them. A value
that went (values.remove, its entity left the world) arrives as nil.
A subscription made by a component ends with the component.
local conn = values.subscribe(car, "gear", function(gear) print("now in gear", gear) end)
conn:Disconnect()
modules/velocityDilation/README
require("@builtin::systems.velocityDilation.velocityDilation") -- velocityDilation
How far a moving surface's velocity reaches past its own silhouette in the frame's velocity buffer. Every temporal technique reads that buffer one texel per pixel, so widening it is what lets a reprojection and a blur follow a moving object over the pixels it is about to cover.
Usage: local velocityDilation = require("@builtin::systems.velocityDilation.velocityDilation")
modules/velocityDilation/active
active(): boolean
Whether the dilation passes are running this frame.
if velocityDilation.active() then ... end
modules/velocityDilation/clear
clear()
Set the radius to 0 and release the passes, leaving the velocity buffer as the geometry passes wrote it.
velocityDilation.clear()
modules/velocityDilation/get
get(): VelocityDilationState
The dilation settings currently in force.
local r = velocityDilation.get().radius
modules/velocityDilation/maxRadius
maxRadius(): number
The widest neighbourhood set accepts, in pixels.
local ceiling = velocityDilation.maxRadius()
modules/velocityDilation/paramsBuffer
paramsBuffer(): any
The parameter buffer the dilation pass reads, carrying the radius this module packs. The render feature binds what this hands it.
local b = velocityDilation.paramsBuffer()
modules/velocityDilation/set
set(opts: VelocityDilationOpts?): VelocityDilationState
Set how far velocity reaches past a silhouette. Any omitted field keeps
its current value. A radius of 0 releases the passes and leaves the
velocity buffer as the geometry passes wrote it.
Parameters
optsVelocityDilationOpts?(optional) — Dilation settings — seeVelocityDilationOpts.
velocityDilation.set({ radius = 2 })
modules/vfs/README
require("@builtin::modules.api.engine.vfs") -- vfs (also available as global 'vfs')
Virtual filesystem — read, write, list, watch. Public Luau surface over the __vfs Internal FFI namespace.
A write to authored /source WHILE PLAY IS RUNNING lands on the play
shadow: the bytes are live in the session immediately, and a guarded
play-exit puts the pre-play copy back unless they were kept. Where the
bound world syncs the path, the write is carried to it as it lands, so a
restart or crash before that exit keeps it; where nothing syncs the path,
a restart ends it.
vfs.durability(path) answers where any write's bytes went: durable,
whether a restart keeps them in survivesRestart, the state in warning, the routes out in playShadow, and which of the
paths you asked about the shadow holds in shadowed.
vfs.playShadowPaths() lists everything the session is holding, and
vfs.playShadowAuthors() says whose each one is.
Three routes keep a write, differing in what they cost the session:
vfs.promotePlayShadow(path) -- or a list of paths: THOSE
-- paths onto canonical source,
-- play keeps running, the rest
-- of the set untouched
vfs.write(path, bytes, { durable = true }) -- the write skips the
-- shadow, nothing to promote
tools.use("sceneAuthoring", "changes") -- then acceptChanges: reaches
-- ENTITY changes too, the
-- session keeps running
vfs.revertPlayShadow takes the same path or list and does the opposite.
A folder asset settles whole: a path carrying an asset-type suffix names
the asset, so one .component write shadows its entry file, its README
and its metadata together, and promoting or reverting any one of them
settles all three, naming each in its second return value. A play-exit
refuses over whatever is still shadowed; vfs.playShadowPaths() lists
it.
The core/vfs guide has the model and what each route costs.
Usage: local vfs = require("@builtin::modules.api.engine.vfs") Also available as global: vfs
modules/vfs/claimWalks
claimWalks(): number
Lifetime count of walks over every asset the world offers: the part of
an enumeration's cost that grows with how many assets exist. asset.list
reads a snapshot of every registered claim, built once for each change to
what the world offers and shared by every list after it;
asset.categories reads the category registry and walks nothing. Read it
around a burst to learn what that burst cost in walks, a number that reads
the same on a loaded machine and a quiet one.
local at = vfs.claimWalks()
vfs.write("/zero/source/probe.module/init.luau", "return {}")
asset.list("module")
print(vfs.claimWalks() - at)
modules/vfs/clearPlayShadow
clearPlayShadow(): boolean
Forget the entire play-shadow set after a bulk promote or discard. Tracking only — never touches the bytes.
vfs.clearPlayShadow()
modules/vfs/contentAddress
contentAddress(path: string, opts: VfsOpts?): string?
The content address (sha-256 hex) of the bytes vfs.read(path)
returns, for a path whose bytes the blob store holds, answered
synchronously and without the bytes. Two answers that agree name the
same bytes, and a write that changes them changes it. Nil for a path
whose bytes are held in memory (text under the inline size threshold,
a play shadow, a kept read), which a synchronous vfs.read already
returns, and for a path nothing is stored at. Keep it beside a copy of
a file you read to tell, from a caller that cannot yield, whether the
copy is still what the path holds.
Parameters
pathstring— VFS path.optsVfsOpts?(optional) —{ root = "/source/" }.
local address = vfs.contentAddress("/zero/source/scenes/main.scene/scene.json")
modules/vfs/contentVersion
contentVersion(path: string): number
A number that moves every time the file at path changes this
session: each write, and each move onto it, stamps it with a version no
file has held this session, and while nothing is stored at path (before
it is written, after it is removed or moved away) it reads 0. It moves
the moment any change lands, from every origin: a script's write, a
peer's, a dev-mode disk pickup, a world-load or branch-swap write made
before the world's content is ready, a world's unmount, both ends of a
move, and a directory removal. Keep the value you saw when you last read
the file, and read it again only when the number moved.
Parameters
pathstring— The file's path, in any formvfs.readtakes.
local seen = vfs.contentVersion("/zero/source/.world_settings")
modules/vfs/copy
copy(src: string, dst: string): (boolean, (WriteReport | string)?)
Copy a file OR directory from src to dst, cp -r style. A
directory recurses — every descendant is replicated at the same
relative path under dst, .refs sidecars included. .meta
sidecars are minted fresh, so a copy is a distinct asset with its
own identity. Both paths are absolute. The source may live in any
layer (writable, library mount, builtin, runtime-generated); the
destination must be a writable route.
Parameters
srcstring— Source absolute VFS path (file or directory).dststring— Destination absolute VFS path.
vfs.copy("/zero/runtime/recordings/take1.mp4", "/zero/source/clips/take1.mp4")
local ok, report = vfs.copy(mod, "/zero/source/game/Vent.component")
modules/vfs/currentAuthor
currentAuthor(): { id: string, stable: string, connection: string, agent: string?, name: string?, account: string? }?
The caller this call is attributed to: the author a /source write
made right now would be recorded under in the play shadow. id names the
calling session where the transport attested one, so two agent sessions
driving one engine read as two callers even when one linked ZeroMind
account minted both their tokens. stable is the key the caller had
before the world's roster named it, which a rename leaves where it was;
one of several agents sharing a connection, which names itself with the
as argument every tool takes, has a stable of its own. connection
is the key of the connection the caller called over, the one the
caller's staging area and the writer its dirty rows record are kept
under, so the agents of one connection stage and commit one another's
work. agent is the name the world's roster holds for the caller now;
name is its account's username, which every agent of the account
shares; account is that shared account. Nil
when the engine can name no caller at all, which is the case for
engine-authored work and for a caller that presented neither a session
nor a token. Compare its id against vfs.playShadowAuthors() to
separate your own pending edits from a co-author's.
local me = vfs.currentAuthor()
print(if me ~= nil then me.id else "unattributed")
modules/vfs/dirSink
dirSink(path: string, opts: DirSinkOpts): PluginHandle
A sink for new files under the folder at path, subfolders
included, to pass a plugin in a call. The plugin makes whatever files it
needs within opts.maxFiles files and opts.maxBytes bytes in all.
Only the world's own files take a sink.
Parameters
pathstring— The folder to write under.optsDirSinkOpts—{ maxFiles = <n>, maxBytes = <bytes>, extensions = { "png" }? }.
local frames = vfs.dirSink("/source/frames", { maxFiles = 240, maxBytes = 200 * 1024 * 1024, extensions = { "png" } })
modules/vfs/discardPlayShadow
discardPlayShadow(): { discarded: { string }, owed: { { path: string, reason: string } } }
Throw away every play-shadow edit: the discard a play-exit takes when
the play session's work is not kept. Each path reverts to its pre-play
copy, as vfs.revertPlayShadow does. Every path it throws away is
returned in discarded, posted as a notice and logged by name. A path
whose pre-play copy cannot be put back yet (the world's blob, still
being pulled; the world's manifest row, read once the manifest has taken
the update it is applying; or a copy whose write back is refused) leaves
the play shadow all the same and is OWED: it holds the play bytes until
the copy lands and its write is taken, and the copy is put back then,
unless the path has changed in the meantime. Every owed path is returned
in owed, posted as a notice and logged by name. Calling it again asks
for every owed restore again, pulling a copy whose pull failed.
local result = vfs.discardPlayShadow()
for _, path in ipairs(result.discarded) do
print("discarded", path)
end
for _, owed in ipairs(result.owed) do
print(owed.path, owed.reason)
end
modules/vfs/durability
durability(paths: string | { string }, opts: VfsOpts?): Durability
Did that write save to disk, and if not how is it kept? What became of
the bytes just written at paths — one path, or an array of them
answered as ONE write. durable is true when they are where
the call filed them and the next session reads them back, and false when
the play shadow took any of them (live in this session and undone by a
guarded play-exit unless kept) or any of them is in /source/tmp/ scratch
(this session's working space: it reads back while the engine runs and is
gone when it stops or restarts, in edit mode and in play alike).
/source/local/ is durable: the machine keeps it. durable is
present whatever the answer is, so its absence is never a reading. A
non-durable answer carries survivesRestart (true when a restart of this
engine keeps the bytes, because the bound world syncs them as they land;
false when a restart ends them, which it always does for scratch) and
warning (the state and what a restart does with it, for a reader
scanning values rather than checking a field; it opens with PLAY SHADOW
or SCRATCH). When the shadow holds a path the answer also carries
playShadow (the routes to disk and what each costs a session other
people are running in) and shadowed (which of the given paths the shadow
has, or under pending would take); when a path is in scratch it carries
scratch (which of them are in scratch).
This is the answer, off the same shadow set and in the same words, that the
write_file / edit_file / capture tools attach to their own results and
that asset.create reports as its second return value. Ask it here at any
other site that lands files, so every write surface states where the bytes
went in one set of terms.
Parameters
pathsstring | { string }— One VFS path, or an array of paths answered together as one write. A path resolves the wayvfs.writeresolves its own — absolute or@-rooted as it stands, a bare one under/source/— so the answer is about the file that write landed. A value that is not a path — an AssetRef, a record, a number, a string with nothing in it — raises rather than being answered off the empty set it reads as; a list with no entries names nothing and answers durable.optsVfsOpts?(optional) —{ root = "/source/", pending = false }.pending = trueasks the same question of a write that has NOT landed yet: where bytes written at these paths would go, read off the same play-lock verdict that will decide it. That is what a surface arranging a write it files later reports from —av.recordopens a take here and the film is written when the take ends — because until those bytes land the shadow is holding nothing under the path and the answer would be durable at the one moment the caller can still act on it. The fields and the words are the same either way; the state names the tense it is true in.
local ok = vfs.write(path, body)
local d = vfs.durability(path)
if not d.durable then log.warn(d.warning) end
local ahead = vfs.durability("/zero/source/clips/take.mp4", { pending = true })
modules/vfs/evict
evict(path: string, opts: VfsOpts?): boolean
Drop the in-memory bytes for path from the writable
MemFs layer without removing the asset. Use after processing
large binaries to reclaim RAM.
Parameters
pathstring— VFS path whose bytes should be evicted.optsVfsOpts?(optional) —{ root = "/source/" }.
vfs.evict("/zero/source/textures/imported_big.png")
modules/vfs/exists
exists(path: string, opts: VfsOpts?): boolean
Is the path known to the VFS? Checks the Stage-1 metadata
(.meta sidecar / ManifestView) — NOT "are the bytes locally
cached?". Use vfs.read(path) ~= nil to confirm bytes are
reachable.
Parameters
pathstring— VFS path to check.optsVfsOpts?(optional) —{ root = "/source/" }.
assert(vfs.exists("@builtin/models/Cube"))
modules/vfs/folderHashWalks
folderHashWalks(): number
Lifetime count of category-folder checksum walks — the part of a write's cost that grows with how much content already exists. A folder's checksum is the tree hash over the descendants that describe the asset, so deriving one reads every key under it, and a write re-derives it for each enclosing category folder whose bytes that write reaches. Content the checksum is made of therefore moves this once per enclosing folder per write; bytes that reach no checksum — a managed sidecar, a scene's autosave overlay — move it by nothing. Read it around a burst to learn what that burst cost in walks, a number that reads the same on a loaded machine and a quiet one.
local at = vfs.folderHashWalks()
vfs.write("/zero/source/scenes/probe.scene/scene_dirty/entities/e1.json", "{}")
print(vfs.folderHashWalks() - at)
modules/vfs/holdContentSync
holdContentSync(held: boolean)
Hold (true) or release (false) the content sync of the world this
engine binds. While it is held, a take of the world's content (the
initial sync a binding runs, or the one a session that lost its
connection runs when it subscribes again) applies no row: the rows the
backend sends wait unapplied, in order, and are applied the moment the
hold is released. The binding stands and writes to authored source are
taken and uploaded meanwhile, so the engine sits between binding a world
and being shown its content for as long as a test needs it there:
world.syncStatus() reads content_synced = false and
content_sync_held = true, and the world's load waits at its content
step. A take that already finished carries on applying live changes; the
hold stops the next take at its first row. A boot started with
--hold-content-sync (holdContentSync=1 in a browser launch) raises the
hold before the world binds, which is how the initial sync of a fresh
engine is held.
Parameters
heldboolean— True to hold the content sync, false to release it.
vfs.holdContentSync(true)
vfs.holdContentSync(false)
modules/vfs/installedFrom
installedFrom(path: string, opts: VfsOpts?): InstalledFrom?
Where the asset holding path comes from, when the library
carries it by reference. The library's source then holds an install
record naming the asset, the world that published it and the commit
its bytes are, and the engine serves the asset's files from those.
path is the asset's own folder or anything inside it. Nil for a
path whose bytes the library or the world holds itself.
Parameters
pathstring— VFS path of the asset or of anything inside it.optsVfsOpts?(optional) —{ root = "/source/" }.
local from = vfs.installedFrom(ref.path) if from then print(from.world, from.commit) end
modules/vfs/isDirectory
isDirectory(path: string, opts: VfsOpts?): boolean
Is ONE path a directory? Answers from reality — the writable
layer's children, a resolver-served folder listing, an explicit
empty-directory marker — so a loose file whose extension collides
with an assetType name (notes.json) reads as the file it is while
a real <name>.<type>/ folder reads as a folder. Costs the same
whatever the containing folder holds; use vfs.list when you want
every entry's kind, this when you hold one path.
Parameters
pathstring— VFS path to classify.optsVfsOpts?(optional) —{ root = "/source/" }.
if vfs.isDirectory("/zero/source/Goblin.dynamicAsset") then print("folder asset") end
modules/vfs/isSaveExcluded
isSaveExcluded(path: string, opts: VfsOpts?): boolean
Does this path hold content the machine keeps to itself?
/source/tmp/ is session scratch and /source/local/ is this
machine's own durable content — each directory itself included,
and everything under it. Both are writable, hot-reloadable and
enumerable like the rest of /source/; what separates them is
where they stop. The engine filters them out of every world save
and every peer broadcast, so they reach no world, carry no
manifest row there, and a staging verb handed one refuses it by
name. The match reads a whole path segment, so
/source/tmpfoo/ is ordinary content. Ask here whenever your
code has to agree with what a world can hold.
Parameters
pathstring— VFS path to classify.optsVfsOpts?(optional) —{ root = "/source/" }.
if not vfs.isSaveExcluded(p) then table.insert(publishable, p) end
modules/vfs/list
list(path: string?): { VfsListEntry }
List entries in a VFS directory. A directory whose current
listing the next frame assembles (/zero/runtime/sync/entities after a
stretch nothing read the replication surface) is waited for where the
calling code can yield (coroutine.isyieldable()), as vfs.read waits;
where it cannot, the listing raises VFS_READ_CANNOT_WAIT, naming the
path.
Parameters
pathstring?(optional) — Directory path (defaults to/zero).
for _, e in ipairs(vfs.list("/zero/source")) do print(e.name) end
modules/vfs/memResident
memResident(): { { path: string, bytes: number, kind: string } }
List the MemFs entries that are NOT resident-by-default — the writable
in-memory layer's binary blobs and its large text files (text at or above
the inline-text size threshold). These are the bytes vfs.evict can
reclaim: the ones kept in RAM rather than left to fall through to the
on-disk BlobStore cache. Small text (resident by default) is omitted. The
audit counterpart to vfs.evict and to reading with { keep = true } —
use it to see what encoded bytes are held in RAM, and why.
for _, e in ipairs(vfs.memResident()) do print(e.path, e.bytes, e.kind) end
modules/vfs/mkdir
mkdir(path: string, opts: VfsOpts?): boolean
Create a directory. mkdir -p semantics — idempotent.
Errors if a file already exists at the same path. While play is
running an authored /source directory waits for the lock to
lift and the refusal RAISES with the reason; writing a file under
the path creates it as part of that write, and scratch under
/source/tmp/ creates as in edit mode.
Parameters
pathstring— Directory path.optsVfsOpts?(optional) —{ root = "/source/" }.
vfs.mkdir("/zero/source/scenes/")
modules/vfs/move
move(src: string, dst: string, opts: { quiet: boolean? }?): (boolean, (WriteReport | string)?)
Move a file from src to dst. By default fires the destination's
write side effects; pass opts.quiet = true to suppress them. A quiet
move still returns the destination's report and still posts the resolve
rule the publish gate reads, which is what vfs.write does with the same
option: a publish takes no override, so the finding is stated at the line
that carries it.
While play is running a move takes the source away, so authored
/source content that predates play is refused and the refusal
RAISES with the reason; content this play session created moves and
stays tracked on the play shadow.
Parameters
srcstring— Source absolute VFS path.dststring— Destination absolute VFS path.opts{ quiet: boolean? }?(optional) — Optional{ quiet: boolean? }.
vfs.move("/zero/source/a.luau", "/zero/source/b.luau")
local ok, report = vfs.move(mod .. "/init.luau", comp .. "/init.luau")
modules/vfs/movedReferenceNames
movedReferenceNames(path: string?, opts: VfsOpts?): { MovedReferenceSource }
The world sources that spell a reference by a name its target no
longer has. A source records, beside each name it uses, the guid of the
asset the name reached; when that asset later sits at another path (it
was moved, or the engine's library files it elsewhere), the reference
keeps resolving through the guid while the text keeps the old name. This
lists those sources and changes nothing. Writing an entry's currentText
back with vfs.write(source, currentText) brings the text up to date
without changing what any reference resolves to.
Only sources the world authors are considered: the engine library and
/source/deps/ keep the text they were published with.
Parameters
pathstring?(optional) — One source to ask about; every source the world authors when absent.optsVfsOpts?(optional) —{ root = "/source/" }.
for _, s in ipairs(vfs.movedReferenceNames()) do print(s.source, #s.names) end
modules/vfs/mutationSeq
mutationSeq(): number
Lifetime count of VFS mutations the engine has APPLIED — the drain's
clock. A write queues its side effects (an asset's content reload, the
assetType's onChange, a component or scene registration) and a later
frame runs them; this number advances as each one completes. Read it,
write, then poll for a larger value to learn the queue has moved past the
point you wrote at — instead of waiting a guessed number of frames. It
counts every mutation kind, so it answers about the pipeline rather than
about one file; asset.reloadSeq(ref) is the per-asset reading.
local at = vfs.mutationSeq()
vfs.write("/zero/source/tmp/note.txt", "hi")
repeat task.wait() until vfs.mutationSeq() > at
modules/vfs/open
open(path: string, opts: VfsOpts?): PluginHandle
A reader of the file at path, to pass a plugin in a call. The
plugin reads it by range and reaches nothing else through it; it is
refused, raising the reason, where this script could not read. A
reader whose file leaves its path answers the plugin that the asset
is gone.
Parameters
pathstring— The file to read.optsVfsOpts?(optional) —{ root = "/source/" }.
local weights = vfs.open(asset.containing(__FILE__).path .. "/weights.gguf")
modules/vfs/openDir
openDir(path: string, opts: VfsOpts?): PluginHandle
A reader of the folder at path and everything under it, to pass
a plugin in a call. The plugin lists it and opens readers of its files,
by paths relative to the folder that cannot leave it.
Parameters
pathstring— The folder to read.optsVfsOpts?(optional) —{ root = "/source/" }.
local model = vfs.openDir(asset.containing(__FILE__).path .. "/model")
modules/vfs/pendingWrites
pendingWrites(): { string }
List the /source paths with a local write or removal the synced
manifest has not reflected yet: everything this client still owes the
server. A just-written or just-removed file appears here until its
upload round-trips and the synced dirty state catches up;
world.vcsStatus unions these so a fresh edit reads back as dirty
immediately, and world.syncStatus().owed_paths reports the same list.
Empty when fully synced.
for _, p in ipairs(vfs.pendingWrites()) do print(p) end
modules/vfs/playDiscardsOwed
playDiscardsOwed(): { { path: string, reason: string } }
The play edits a discard threw away whose pre-play copy has not been put back yet. Each of these paths holds the play session's bytes until its restore lands, which happens on its own once the copy arrives and its write is taken. A path that changes first keeps its new content and leaves this list.
for _, owed in ipairs(vfs.playDiscardsOwed()) do
print(owed.path, owed.reason)
end
modules/vfs/playHoldsInPlace
playHoldsInPlace(path: string, opts: VfsOpts?): boolean
Whether the running play session holds path where it stands:
vfs.move of it, and vfs.remove of it without durable = true, are
refused while play runs, because what they would take away is content
that predates play (or that a durable write made canonical). Content
only the play shadow holds (this play session wrote it) answers false and
moves freely, and so does every path once play ends or pauses, a path in
/source/tmp/ or /source/local/, and a path outside authored source.
Ask it before the first step of a change that ends by taking path
away, so a change the lock would refuse at its last step is not started:
the importers ask it before relocating a source into the asset they
produce, and owe the import until play ends.
Parameters
pathstring— The VFS path: absolute,@-rooted, or bare under/source/.optsVfsOpts?(optional) —{ root = "/source/" }.
if vfs.playHoldsInPlace(src) then log.warn(src .. " moves once play ends") end
modules/vfs/playShadowAuthors
playShadowAuthors(): { [string]: { id: string, stable: string, connection: string, agent: string?, name: string?, account: string? } }
The caller behind each currently-shadowed /source path, in the
shape vfs.currentAuthor() answers in: the id the write was attributed
to, the name the world's roster holds for that caller now (agent, the
one to show), its account's username, and the ZeroMind account it
authenticated as. Several agents drive one engine at once and
every one of their in-play source edits sits in the same shadow set, so
this is how a review, a refusal or a verdict tells one agent's pending
work from another's. id names the calling session where the call
carried one, so two agent sessions on a machine linked to one ZeroMind
account are two authors. A path written by a caller the engine could not
name carries no entry, because it belongs to nobody in particular, and
stays settleable by anyone.
local mine = vfs.currentAuthor()
for path, who in pairs(vfs.playShadowAuthors()) do
if mine == nil or who.stable ~= mine.stable then print(path, "belongs to", who.agent or who.name) end
end
modules/vfs/playShadowPaths
playShadowPaths(): { string }
Every source write made during play that is not durable yet — the set
to keep or discard before leaving play. Lists the /source paths edited
during running play that the play shadow holds, each beside the
pre-play copy a guarded discard puts back: the universal play
shadow-copy set. These are the in-play edits persist
promotes over the originals on confirm, or drops on a guarded discard.
Empty outside play or when nothing was edited.
for _, p in ipairs(vfs.playShadowPaths()) do print(p) end
modules/vfs/promotePlayShadow
promotePlayShadow(path: string | { string }): ((string | { string })?, { string }, { string })
KEEP a source write made while play was running — the call that saves a play-mode edit onto disk and makes it durable. Promotes play-shadow edits into canonical writes: re-asserts the live overlay bytes through the full write pipeline, then unmarks each path. The bytes stay in the engine end to end, so binary content promotes exactly. It answers while play is RUNNING and leaves the mode, the clock and every shadow entry it did not name exactly where they stood. Takes ONE path, or an ARRAY of them — a single folder-asset write shadows the entry file, the README and the metadata together, so a slice is tens of paths, and naming them keeps the call to the caller's own work on an engine other sessions are running in. Every named path is attempted; one that refuses does not stop the ones after it. A path with nothing on the play shadow at it or beneath it settles nothing and raises nothing, since no play edit stands there: the third return value names it. A promotion that cannot happen raises with the reason: the path is a plain folder covering shadowed edits (the refusal names the first five assets and loose files under it by the paths that settle them, and counts the rest), the workspace is read-only, or the write-through failed. A shadow entry whose bytes are gone is dropped as promoted, so the path comes back with nothing written for it.
A folder asset is kept whole: a file of one promotes with every other
shadowed file of the same asset, so the files its type requires reach
source with whichever of them was named, and naming the folder asset's
own path (Gold.material, controls.inputMap) promotes every shadowed
file of it, the assets nested in it included. An asset nested inside another
settles with its own files, and takes the own files of every enclosing
asset the play session made with it, since it stands on source only
inside them. A path an earlier call settled, by name or carried this
way, answers as settled when it is named again, so a walk over a
vfs.playShadowPaths() snapshot one path at a time settles every path
in it.
Parameters
pathstring | { string }— A shadowed VFS path to promote, or an array of them (from vfs.playShadowPaths()).
local promoted = vfs.promotePlayShadow("/zero/source/cover.jpg")
local _, settled = vfs.promotePlayShadow("/zero/source/Hero.module/init.luau")
local _, kept = vfs.promotePlayShadow("/zero/source/game/Gold.material")
local named, _, unshadowed = vfs.promotePlayShadow("/zero/source/maybe_written.md")
local mine = {}
for _, p in ipairs(vfs.playShadowPaths()) do
if string.find(p, "/zero/source/mine/", 1, true) == 1 then table.insert(mine, p) end
end
local settled = vfs.promotePlayShadow(mine)
modules/vfs/read
read(path: string, opts: VfsOpts?): (string?, string?)
Read a file from the virtual filesystem. Binary-safe.
Returns file contents as a string. A read that finds no bytes
returns nil and the reason: one sentence naming the path and why,
the text the read_file tool and the VFS HTTP route give for the
same path (/zero/source/a.txt: not found, a directory's refusal,
a /runtime node's account of what it holds). Handed straight to
another call, the read passes that reason on as the next argument
too; wrap it in parentheses, Json.decode((vfs.read(path))), to
pass the bytes alone. Relative paths resolve under opts.root
(default /source/). When the bytes aren't locally cached and the
calling code can yield (coroutine.isyieldable(): a task,
awake, start, update, onEnable, onOwnerChanged,
onSyncReceived, a replicated event's
handler), the read waits while the lazy fetch runs and answers
the bytes. Code that cannot yield (onDisable, onDestroy,
onPropertyChanged, a received synced-function call, a vfs.watch callback, a
module's top level while require runs it, a metamethod, a
table.sort comparator) cannot wait: a read there of bytes still on their
way (a file vfs.exists knows, a render surface being captured, a
/runtime/sync node whose current reading the next frame assembles)
raises VFS_READ_CANNOT_WAIT, naming the path and where to read it.
Parameters
pathstring— VFS path.optsVfsOpts?(optional) —{ root = "/source/" }.
local src, why = vfs.read("/zero/source/notes.txt"); if src == nil then print(why) end
modules/vfs/readAsync
readAsync(path: string, opts: VfsOpts?): string
Asynchronous binary-safe read. Returns a promise ID that resolves to the file contents. Useful for reading render textures from the main thread without blocking.
Parameters
pathstring— VFS path.optsVfsOpts?(optional) —{ root = "/source/" }.
local data = task.await(vfs.readAsync("/zero/runtime/screenshots/last.png"))
modules/vfs/readBounded
readBounded(path: string, maxBytes: number): (string?, string?)
Read a file from the virtual filesystem, at most maxBytes
long. Binary-safe, and read the way vfs.read reads it. A file
longer than maxBytes answers nil, "too_large"; where the layer
holding it states its length (a file held in memory, a synced or
staged file) its bytes are never read. Relative paths resolve under
/source/. Where the calling code can yield, a file whose bytes
are not cached is fetched and held to the same bound; where it
cannot, a known file whose bytes have not arrived raises
VFS_READ_CANNOT_WAIT, as vfs.read does. A read that finds no
bytes answers nil and the reason vfs.read gives.
Parameters
pathstring— VFS path.maxBytesnumber— The most bytes the read answers, a whole number 0 or more.
local raw, why = vfs.readBounded("/zero/source/notes.json", 65536)
modules/vfs/reload
reload(modulePath: string?): boolean
Clear entries from the require() cache so the next
require(name) re-runs the module's source. Pass a single
module identity to drop only that entry; call with no
arguments to drop every cached module of the world's own. A
module of the built-in library runs once for the process — its
body registers into registries that outlive it — and stands
through a reload with no argument.
The next require runs the source the module's file holds
when the reload is called, whichever write brought those bytes
there, a quiet one included.
Parameters
modulePathstring?(optional) — Module identity to reload (omit to reload every module of the world's own).
vfs.reload("@mylib/utils.helpers")
modules/vfs/remove
remove(path: string, opts: VfsOpts?): (boolean, string?)
Remove a file. Refuses to remove directories unless
opts.recursive = true. Refuses protected system roots. While
play is running, authored /source content that predates play is
refused and the refusal RAISES with the reason; content this play
session created is removable, a folder included. Pass
opts.durable = true to say the removal IS a change to the source:
it takes the route edit mode takes with play still running and the
session still in play, the counterpart of
vfs.write(path, bytes, { durable = true }) for taking a path away
rather than replacing its bytes. Every other refusal stands in
either terms — a protected root, a read-only route, a plain
directory without recursive.
Parameters
pathstring— VFS path to remove.optsVfsOpts?(optional) —{ root = "/source/", recursive = false, durable = false }.
vfs.remove("/zero/source/scratch.luau")
modules/vfs/revertPlayShadow
revertPlayShadow(path: string | { string }): ((string | { string })?, { string }, { string })
DISCARD a source write made while play was running, keeping nothing — the opposite of promoting it. Reverts play-shadow edits: restores the pre-play copy captured at the first play-mode write (the last edit-mode state, unstaged edits included) into the live slot — or remove the file when it did not exist at that moment — then unmark the path. Hot-reload picks the original back up, so the running session actually reverts. It answers while play is RUNNING and takes ONE path or an ARRAY of them, on the same terms as vfs.promotePlayShadow. A revert that cannot happen raises with the reason. A file of a folder asset reverts with every other shadowed file of the same asset, as a promotion carries them, and a file of an asset the play session made reverts with every shadowed file beneath it, the assets nested in it included. Naming the folder asset's own path reverts every shadowed file of it. A path with nothing on the play shadow settles nothing and raises nothing, as for vfs.promotePlayShadow. A path an earlier revert settled answers as settled when it is named again; one an earlier promotion settled raises, naming that promotion.
Parameters
pathstring | { string }— A shadowed VFS path to revert, or an array of them (from vfs.playShadowPaths()).
local reverted = vfs.revertPlayShadow("/zero/source/Foo.component/init.luau")
local dropped = vfs.revertPlayShadow({ "/zero/source/a.md", "/zero/source/b.md" })
modules/vfs/sessionLost
sessionLost(): boolean
Whether the live world session this engine established is lost and
reconnecting. While it is, every write this engine makes to authored
source (/source outside /source/tmp/) is refused, because the backend
of a dropped session can never receive it; the refusal names the
reconnect. It answers false again from the frame the session
re-establishes, and is false on an engine whose session never established
(an offline boot, or a world still binding) unless vfs.simulateSessionLoss
put it in that state. Ask it before, or after a
failure of, work that writes source in steps: the importers do, and owe
such an import until the session is back.
if vfs.sessionLost() then log.warn("writes wait for the live session") end
modules/vfs/simulateFailedFetch
simulateFailedFetch(path: string, opts: VfsOpts?): (boolean, string?)
Test support. Put the file at path in the state a failed fetch of
its bytes leaves it in: the world holds the path (vfs.exists answers
true, and its identity and listing stand) and its bytes are not on this
engine, so vfs.read of it answers nil and the reason
<path>: this world holds the path, and its bytes are not on this engine.
It is the state a world session lands a file in when the fetch of its
bytes finds none upstream, reached for a file only this engine's memory
holds (any file on an offline engine, and /source/tmp/ scratch on a
world-bound one), so a test drives the readers that meet such a file. A
write of the path puts bytes there again. Relative paths are resolved
under opts.root (default '/source/').
Parameters
pathstring— The file whose bytes this engine stops holding.optsVfsOpts?(optional) — Options:{ root = '/source/' }.
local ok, why = vfs.simulateFailedFetch("/source/tmp/probe.scene/scene.json")
modules/vfs/simulateSessionLoss
simulateSessionLoss(lost: boolean)
Put the VFS in the state a lost live session puts it in (true), or
take it out of it (false), without touching the connection:
vfs.sessionLost() answers it, and every write to authored source is
refused exactly as it is while a real session is reconnecting. Once a
live session has established, the engine's connection observer states
the real session every frame, so the simulation holds on an engine whose
live session never established (an offline boot), which is where a test
drives the paths that answer a lost session.
Parameters
lostboolean— True to refuse writes to authored source as a lost session does, false to accept them again.
vfs.simulateSessionLoss(true)
vfs.simulateSessionLoss(false)
modules/vfs/sink
sink(path: string, opts: SinkOpts): PluginHandle
A sink for the file at path, to pass a plugin in a call. The
plugin writes it from empty, up to opts.maxBytes, and the file lands
when the plugin closes the sink or drops it. Only the world's own files
take a sink.
Parameters
pathstring— The file to write.optsSinkOpts—{ maxBytes = <bytes> }, required.
local out = vfs.sink("/source/imported/sphere.zvol", { maxBytes = 64 * 1024 * 1024 })
modules/vfs/stat
stat(path: string, opts: VfsOpts?): (VfsStat?, string?)
What is at path, how big it is and when it last changed, without
reading it. size is how many bytes vfs.read(path) returns: the
length the layer holding the file states (a file held in memory, a
synced or staged file), so a large file costs nothing to measure, and
where no layer states one (a runtime node, a built-in library file)
the length of the bytes this engine holds. It is absent for a directory
and for a file whose length nothing states and whose bytes are not on
this engine. modified is when this engine's copy last changed, in
seconds since the Unix epoch (the scale os.time() reads): the write
or arrival that put the current content there, which a move carries
along with the content. The memory layer
records it for every file whose bytes it holds: text up to the inline
size threshold, and everything on an engine with no world bound. It is
absent where no time is recorded: a directory nothing was written into
as such, a runtime node, and a file whose bytes the blob store holds
(binary content, and text past the inline size threshold, on a
world-bound engine). For a file, the shell's stat and ls -l print
the same size and time. A path nothing is at answers nil and the reason, the
sentence a vfs.read of it gives.
To tell whether a file changed without reading it: vfs.contentAddress(path)
names the bytes the blob store holds, and vfs.contentVersion(path)
moves on every change this session to a file the memory layer holds.
Parameters
pathstring— VFS path.optsVfsOpts?(optional) —{ root = "/source/" }.
local s = vfs.stat("/zero/source/scenes/main.scene/scene.json"); if s then print(s.size, s.modified) end
modules/vfs/unmarkPlayShadow
unmarkPlayShadow(path: string): boolean
Forget a single play-shadow path after it has been promoted (saved over source) or discarded. Tracking only — never touches the bytes.
Parameters
pathstring— VFS path to unmark.
vfs.unmarkPlayShadow("/zero/source/Foo.component/init.luau")
modules/vfs/unwatch
unwatch(watcherId: number): boolean
Remove a previously registered VFS watcher.
Parameters
watcherIdnumber— Watcher id returned byvfs.watch.
vfs.unwatch(id)
modules/vfs/watch
watch(path: string, callback: (string, string, string) -> ()): number
Register a callback that fires when a VFS path is written or
removed. Two match modes: exact, or folder/prefix (key ends with
/, and fires for any descendant). The callback runs in the VM
that registered it. Returns a watcher id for vfs.unwatch.
Parameters
pathstring— Exact path, or folder path ending in/.callback(string, string, string) -> ()—(mutated_path, kind, origin) -> (), kind"write"or"remove"; origin"local"for a change this engine made (throughvfs.*, the shell or any other surface) and"remote"for one that arrived from another participant in the world.
local id = vfs.watch("/zero/source/", function(path, kind, origin) print(kind, origin, path) end)
modules/vfs/write
write(path: string, content: string, opts: VfsOpts?): (boolean, (WriteReport | string)?)
Write content to a file. Binary-safe. Overwrites existing
files by default — pass opts.overwrite = false to refuse to
clobber. While play is running a /source write lands on the play
shadow: it succeeds and reads back, live in the session, and is
undone by a guarded play-exit unless accepted; the report's
survivesRestart says whether a restart keeps it. Scratch under /source/tmp/ writes through untouched,
in edit mode and in play, and is gone when the engine stops or restarts, so
its report says durable = false, survivesRestart = false and a warning
opening SCRATCH.
Pass opts.durable = true to say these bytes ARE the source: the
write reaches canonical /source with play still running and the
session still in play, hot-reloading the modules and components that
read it, so the edit is observed running in the same play session
with nothing left to promote. A durable write RAISES with the reason
when the bytes cannot become canonical source. One write carries at
most 256 MiB: longer content RAISES, naming its size and that limit,
and the path keeps what it held.
Parameters
pathstring— VFS path to write to.contentstring— File content (binary-safe).optsVfsOpts?(optional) —{ root = "/source/", overwrite = true, quiet = false, durable = false }.
vfs.write("/zero/source/notes.md", body)
local ok, report = vfs.write("/zero/source/game/Vent.component/init.luau", src)
if report.diagnostics then for _, d in report.diagnostics do print(d.severity, d.path, d.line, d.message) end end
if report.contentRequirements then for _, r in report.contentRequirements do print(r.path, r.detail) end end
if not report.durable then log.warn(report.warning) end
vfs.write("/zero/source/game/Vent.component/init.luau", src, { durable = true })
modules/video/README
require("@builtin::modules.api.engine.video") -- video (also available as global 'video')
Video playback — create / play / pause / seek / setRate / setLoop / destroy on render-target-backed video players. Public Luau surface over the __video Internal FFI namespace. The live picture of a webcam or phone camera is cameraInput.
Usage: local video = require("@builtin::modules.api.engine.video") Also available as global: video
modules/video/create
create(url: string, options: VideoOptions?): string
Create a video player. Returns a texture handle (e.g.
"video_0") usable directly in material.setTexture() — its
frames sample like any other texture.
Parameters
urlstring— URL or asset path to an MP4 video file.optionsVideoOptions?(optional) — Playback options:loop(default false),autoplay(default false),rate(default 1.0).
local tex = video.create("http://example.com/clip.mp4", { autoplay = true })
modules/video/destroy
destroy(handle: string): boolean
Destroy a video player and free the render target and all resources.
Parameters
handlestring— Video handle fromvideo.create.
video.destroy(rt)
modules/video/getInfo
getInfo(handle: string): VideoInfo?
Get video information and current playback state. codec is the
configuration the stream declares, such as "avc1.64002a", and
codecSupported is this host's answer about decoding it: true where it
has a decoder, false where it has none, and nil while the answer is
still being fetched. state reads "unsupported" for a stream this
host has no decoder for, with error naming the codec and what refused
it, and no frame is produced for it. The frame counts describe
playback since create: framesDecoded is how many frames the decoder
produced, framesPresented how many the player handed to its texture,
framesExpected how many frames the playback clock reached (one per
frame interval a tick landed in), and frameThreadDecodes how many
samples were decoded on the engine's frame thread rather than on the
decoder's own.
Parameters
handlestring— Video handle.
local i = video.getInfo(rt); print(i.currentTime, "/", i.duration)
modules/video/pause
pause(handle: string): boolean
Pause video playback. Can be resumed with video.play.
Parameters
handlestring— Video handle.
video.pause(rt)
modules/video/play
play(handle: string): boolean
Start or resume video playback.
Parameters
handlestring— Video handle fromvideo.create.
video.play(rt)
modules/video/seek
seek(handle: string, time: number): boolean
Seek to a specific time (seconds) in the video.
Parameters
handlestring— Video handle.timenumber— Target time in seconds.
video.seek(rt, 30.5)
modules/video/setLoop
setLoop(handle: string, loop: boolean): boolean
Enable or disable looping.
Parameters
handlestring— Video handle.loopboolean— Whether to loop playback.
video.setLoop(rt, true)
modules/video/setRate
setRate(handle: string, rate: number): boolean
Set the playback speed multiplier. 1.0 = normal, 2.0 = double speed, 0.5 = half speed.
Parameters
handlestring— Video handle.ratenumber— Playback rate.
video.setRate(rt, 2.0)
modules/video/stop
stop(handle: string): boolean
Stop video playback and reset to the beginning.
Parameters
handlestring— Video handle.
video.stop(rt)
modules/volume/README
require("@builtin::systems.volumetrics.volume") -- volume
3D textures as volumes: build one procedurally or from imported voxels, page it into bricks so it costs what it holds, and raymarch it through an entity's transform.
Usage: local volume = require("@builtin::systems.volumetrics.volume")
modules/volume/Volume:buildSparse
Volume:buildSparse(opts: SparseOpts?)
Store this volume as bricks, keeping only the ones holding anything
over threshold. What the volume costs on the GPU becomes what it
contains rather than the size of its bounding box, and the page table
built along the way is the grid the raymarcher skips empty space with.
Counting the bricks reads the allocation counter back from the GPU, so
this yields — twice unless capacity says how many slots to take;
refreshSparse re-pages without waiting on either.
Parameters
optsSparseOpts?(optional) — SeeSparseOpts— brick size, density threshold, which channel carries density, and how much slot headroom to leave for a volume that will grow.
local stats = v:buildSparse({ brickSize = 8, threshold = 0.01 })
print(stats.residentBytes, stats.denseBytes)
modules/volume/Volume:destroy
Volume:destroy()
Free the GPU resources backing this Volume — the named 3D texture, any companion occupancy R8 texture, and the brick pool and page table if the volume is paged. Subsequent operations on the wrapper return false silently.
v:destroy()
modules/volume/Volume:fillFromBuffer
Volume:fillFromBuffer(buffer: any, lanes: number): boolean
Fill this volume from a buffer on the device: one voxel per element,
x fastest, then y, then z, each element lanes floats (1 to 4) written to
the voxel's channels in order, the rest 0. What puts a grid a graph made
into a volume without reading it back. The volume is created with
storage = true.
Parameters
bufferany(optional) — The buffer's name, or a handle withbufferName().lanesnumber— Floats per voxel, 1 to 4.
cloud:fillFromBuffer(densityColumn, 1)
modules/volume/Volume:readSparseCounts
Volume:readSparseCounts(): { [string]: number }
Read how many bricks the last paging pass stored and how many found the pool full. Yields until the counter arrives.
local counts = v:readSparseCounts()
modules/volume/Volume:refreshSparse
Volume:refreshSparse(): boolean
Re-page this volume from its current contents. Two dispatches and no wait, so a volume a compute shader rewrites every frame keeps a page table that matches what it now holds. The brick counts the pass produces are collected on a later call rather than waited on, so a volume that grows past its pool reports the overflow — and warns — a frame or two after the refresh that caused it.
v:fillCompute(myShader); v:refreshSparse()
modules/volume/Volume:releaseDense
Volume:releaseDense(): boolean
Free the dense volume, leaving the brick pool as the only copy. The volume goes on rendering from the pool; re-paging it needs the dense copy, so this is for a volume that is finished changing.
v:buildSparse(); v:releaseDense()
modules/volume/Volume:releaseSparse
Volume:releaseSparse(): boolean
Free the brick pool and page table, returning the volume to rendering from its dense texture. The dense copy has to still be there, so a volume that released it stays paged.
v:buildSparse(); v:releaseSparse()
modules/volume/Volume:render
Volume:render(opts: RenderOpts): string
Dispatch the shared compute raymarcher to render this Volume through the entity's transform AABB. Output goes to a 2D storage texture (auto-created) — composite from there via a post-process effect, a material sampler, or another GPU copy.
Parameters
optsRenderOpts— SeeRenderOptsabove.
v:render({ entity = entity(id), targetWidth = 1280, targetHeight = 720, density = 8.0 })
modules/volume/Volume:sparseStats
Volume:sparseStats(): { [string]: any }
What this volume costs on the GPU, and what it would cost dense.
local s = v:sparseStats(); print(s.residentBytes / s.denseBytes)
modules/volume/bindComposite
bindComposite(target: string)
Point the composite holdComposite stands for at its render target.
Called every frame a raymarch writes it: the target is made on a later
engine queue than the post effect, and a size change makes it again.
Parameters
targetstring— The render target.
Volume.bindComposite("scene_volume_rt")
modules/volume/box
box(opts: { [string]: any })
Build a 3D volume filled with a solid-box SDF.
Parameters
opts{ [string]: any }—{name, size, color={1,1,1}, format="rgba16f"}.
local v = M.box({ name = "cube_volume", size = 64 })
modules/volume/compositeShaderSource
compositeShaderSource(): (string, string)
WGSL source for the post-process composite that blends the volume
render target over the scene with premultiplied-alpha. Zero-scaffolding:
author only fragment(); vol_rt is a declared texture property. Register
with postprocess.add(name, src, { properties = {{ name="vol_rt", type="texture", textureDefault="transparent" }} }) and bind the target via
postprocess.setTexture(name, "vol_rt", <render-target>).
local src, name = M.compositeShaderSource()
modules/volume/create
create(opts: CreateOpts)
Allocate a fresh, zero-filled 3D texture and return a Volume
wrapper bound to its name. The volume answers to that name in M.get
from here on; building over a name a live volume already holds releases
that volume first, so one volume owns the name and its brick pool.
Parameters
optsCreateOpts— Creation options; seeCreateOpts.
local v = M.create({ name = "cloud", width = 64, height = 64, depth = 64, storage = true })
modules/volume/get
get(name: string): any
The live volume built under name, with everything it knows about
itself: its voxel dimensions, its channel count, its occupancy grid, and
the brick pool it is paged into. Every volume this module builds answers
to its texture name here, so a script or a component that has only the
name renders the volume as it stands — including a paged one, whose
voxels live in the pool rather than under that name.
Parameters
namestring— The texture name the volume was built under.
local v = M.get("cloud")
if v then v:render({ entity = e }) end
modules/volume/holdComposite
holdComposite(target: string): string
Keep the composite that blends render target target over the scene
standing while something draws into it — a Volume component takes one
hold for the target it renders to. The first hold adds the post effect;
bindComposite points it at the target each frame, and the last
releaseComposite removes it.
Parameters
targetstring— The render target a raymarch writes (scene_volume_rtby default).
Volume.holdComposite("scene_volume_rt")
modules/volume/names
names(): { string }
The names every live volume is registered under, sorted.
for _, name in ipairs(M.names()) do print(name, M.get(name):sparseStats().residentBytes) end
modules/volume/noise
noise(opts: { [string]: any })
Build a 3D volume filled with FBM value-noise. Good base for procedural clouds, smoke, nebulae.
Parameters
opts{ [string]: any }—{name, size=64, scale=4, octaves=4, threshold=0.5, seed=42, color={1,1,1}, format="rgba16f"}.
local cloud = M.noise({ name = "cloud", size = 64, scale = 4, threshold = 0.55 })
modules/volume/raymarchShaderIdentity
raymarchShaderIdentity(): string
Return the built-in raymarch shader's asset identity. Callers
that want to diff or override the default raymarcher pull source
via asset.inspect(Volume.raymarchShaderIdentity()) and register
their variant under a different name.
local src = vfs.read(asset.inspect(M.raymarchShaderIdentity()).source .. "/shader.wgsl")
modules/volume/register
register(volume: any): any
Publish a wrapped volume under its own texture name, so holders of the name reach this object rather than building a wrapper of their own. Volumes this module builds are published as they are created; a wrapper over a texture another system owns is published by this call.
Parameters
volumeany(optional) — A Volume — the valueM.wrapor a builder returned.
M.register(M.wrap({ name = "imported", width = 64, height = 64, depth = 64 }))
modules/volume/releaseComposite
releaseComposite(target: string)
Let go of one hold holdComposite took; the last one removes the
composite, so a scene whose volumes are gone composites nothing.
Parameters
targetstring— The render target.
Volume.releaseComposite("scene_volume_rt")
modules/volume/releaseTarget
releaseTarget(name: string): boolean
Destroy the 2D storage texture a render names as its target and
forget the size this module built it at, so the next render builds it
again. A target is created on the first render that names it and shared
by every volume marching into it.
Parameters
namestring— The render-target name, as passed toVolume:render.
M.releaseTarget("scene_volume_rt")
modules/volume/sphere
sphere(opts: { [string]: any })
Build a 3D volume filled with a soft sphere SDF (centred at the volume's middle).
Parameters
opts{ [string]: any }—{name, size, falloffStart=0.3, falloffEnd=0.5, color={1,1,1}, format="rgba16f"}.
local v = M.sphere({ name = "blob", size = 64, falloffStart = 0.3 })
modules/volume/unregister
unregister(name: string): any
Drop the registration under name and hand back the volume that held
it, leaving its GPU resources alone. The returned volume is the way back
to the data — destroy it to free the texture and any brick pool.
Parameters
namestring— The texture name to stop answering for.
local v = M.unregister("imported")
if v then v:destroy() end
modules/volume/wrap
wrap(opts: { [string]: any })
Wrap an existing named 3D texture as a Volume without creating
a new one. Use when a producer outside this module owns the
texture lifetime (e.g. the .zvol viewer uploads voxels through
compute.writeFloatsTexture3D and then wraps the result for
rendering).
Parameters
opts{ [string]: any }—{name, width?, height?, depth?, format?, occupancyName?, occupancyBrick?}.
local v = M.wrap({ name = "imported", format = "rgba16f", occupancyName = "imported_occ", occupancyBrick = 8 })
modules/volume/zvolHeader
zvolHeader(bytes: string): (ZvolHeader?, string?)
Read a .zvol file's header. The payload it describes uploads
verbatim — payloadOffset and payloadBytes cut the voxel bytes out of
the same string, and writeBytes takes them as they are.
Parameters
bytesstring— The file's contents.
local h = M.zvolHeader(vfs.read(path))
v:writeBytes(string.sub(bytes, h.payloadOffset, h.payloadOffset + h.payloadBytes - 1))
modules/volumeSequence/README
require("@builtin::systems.volumetrics.volumeSequence") -- volumeSequence
An ordered run of .zvol frames played back through a fixed ring of resident volumes: frames are read from the VFS a little ahead of the playhead and uploaded into whichever ring slot is furthest from it, so what the sequence costs on the GPU is the ring, whatever the run's length.
Usage: local volumeSequence = require("@builtin::systems.volumetrics.volumeSequence")
modules/volumeSequence/Sequence:bounds
Sequence:bounds(): ({ number }, { number })
The world-space bounds frame 1's header declared, as the importer wrote them.
local mn, mx = seq:bounds()
modules/volumeSequence/Sequence:close
Sequence:close(): boolean
Cancel any read still in flight, free the ring and drop the sequence from the registry.
seq:close()
modules/volumeSequence/Sequence:current
Sequence:current()
The volume holding the frame currently on screen. Render it the way any other volume renders — the wrapper it answers with is one of the ring's slots, so the same handle comes back for as long as that frame is shown.
local v = seq:current(); if v then v:render({ entity = e, density = 6 }) end
modules/volumeSequence/Sequence:pause
Sequence:pause(): boolean
Hold the playhead where it is. Reads already in flight still land.
seq:pause()
modules/volumeSequence/Sequence:play
Sequence:play(): boolean
Resume advancing the playhead.
seq:play()
modules/volumeSequence/Sequence:residency
Sequence:residency(): { { frame: number?, loading: boolean } }
What each ring slot holds, in slot order — one entry per slot, whether or not it has ever been filled. A closed sequence holds no slots and answers with an empty array.
for i, slot in ipairs(seq:residency()) do print(i, slot.frame, slot.loading) end
modules/volumeSequence/Sequence:seek
Sequence:seek(frame: number): number
Put the playhead on a frame. The clock moves with it, so playback resumes from there rather than jumping back.
Parameters
framenumber— 1-based frame index; wrapped for a looping sequence, clamped otherwise.
seq:seek(12)
modules/volumeSequence/Sequence:setFps
Sequence:setFps(fps: number): number
Set the playback rate. The playhead keeps the frame it stands on and
the fraction of the way through it, so playback carries on from there at
the new rate. Zero holds the playhead while leaving playing alone.
Parameters
fpsnumber— Frames per second.
seq:setFps(12)
modules/volumeSequence/Sequence:stats
Sequence:stats(): { [string]: any }
What the sequence costs and how playback is keeping up. residentBytes
counts the ring, allBytes counts what holding every frame at once would
cost, stalls counts the frames playback reached before their read did,
and errors counts the frames of the run that could not be read — each
one counted and logged once, and stepped over from then on.
local s = seq:stats(); print(s.residentBytes, s.allBytes)
modules/volumeSequence/Sequence:tick
Sequence:tick(dt: number): number?
Advance the playhead by dt seconds, start the reads the new position
calls for, and promote the newest frame whose slot has filled. The
playhead moves once per engine frame however many callers tick the
sequence, so two entities can play one run without it running double
speed; every call promotes and reads ahead.
Parameters
dtnumber— Seconds since the last call.
seq:tick(dt)
modules/volumeSequence/all
all(): { [string]: any }
Every sequence currently open, by name.
for name, seq in pairs(M.all()) do print(name, seq:stats().residentBytes) end
modules/volumeSequence/close
close(name: string): boolean
Close the sequence open under this name.
Parameters
namestring— Name passed toopen.
M.close("plume")
modules/volumeSequence/get
get(name: string)
The sequence open under this name.
Parameters
namestring— Name passed toopen.
local seq = M.get("plume")
modules/volumeSequence/open
open(opts: OpenOpts)
Open a run of .zvol frames for playback. Frame 1's header sizes the
ring, so every frame of the run has to carry the same dimensions; the ring
itself is resident volumes and is the whole GPU cost of the sequence.
Reading frame 1 yields.
Parameters
optsOpenOpts— SeeOpenOpts— the frame paths, the ring size, and the playback rate.
local seq = M.open({ name = "plume", frames = paths, resident = 3, fps = 24 })
seq:tick(dt); local v = seq:current(); if v then v:render({ entity = e }) end
modules/volumetricLighting/README
require("@builtin::systems.volumetrics.volumetricLighting") -- volumetricLighting
Light scattered by the air between the camera and the scene — a spotlight cone visible in fog, a shaft where the sun cuts past an occluder, haze that brightens toward a source.
Usage: local volumetricLighting = require("@builtin::systems.volumetrics.volumetricLighting")
modules/volumetricLighting/active
active(): boolean
Whether the volumetric passes are running this frame.
if volumetricLighting.active() then ... end
modules/volumetricLighting/clear
clear()
Empty the air and release the passes. The other settings are kept, so a
later set({ density = ... }) brings back the same medium.
volumetricLighting.clear()
modules/volumetricLighting/get
get(): VolumetricState
The medium settings currently in force.
local d = volumetricLighting.get().density
modules/volumetricLighting/paramsBuffer
paramsBuffer(): any?
The buffer the marching passes read. lightScattering.renderFeature
binds what this hands it, so both passes carry the values this module
packed.
local p = volumetricLighting.paramsBuffer()
modules/volumetricLighting/set
set(opts: VolumetricOpts?): VolumetricState
Set the scene's participating medium. Any omitted field keeps its
current value. A density of 0 empties the air and releases the passes.
Parameters
optsVolumetricOpts?(optional) — Medium settings — seeVolumetricOpts.
volumetricLighting.set({ density = 0.06, anisotropy = 0.7 })
modules/watch
modules.watch(path, callback) -> number
Register a callback that fires when a module's source code changes via VFS write. Use for live-reload: re-require the module inside the callback. Returns a watcher ID. The subscription is recorded under the key the module reloads under, resolved from this call site the way require resolves the same string, so every spelling of one module reaches it: the folder foo.module, its init.luau, the dotted identity, the @local. world form, a ~package alias and a caller-relative .sibling. A spelling naming a module the engine holds no source for yet is recorded under that spelling's own canonical form and warns, so a watch taken out before the module is written is called by the write that creates it.
Parameters
pathstring— Any spellingrequireaccepts for the module to watch: an identity like '@builtin::modules.json', a VFS path such as '/source/hud.module', or a caller-relative form like '.sibling'.callbackfunction— Called with (path) when the module source changes
Returns number — Watcher ID (pass to modules.unwatch to remove)
modules/water_surfaces/README
require("@builtin::modules.water_surfaces") -- water_surfaces
The water surfaces a scene holds, gathered from the systems that make them. A system with water — a terrain's lakes and rivers, an ocean — registers a provider here, and whatever needs to stand things on water asks every provider at once: scene.water in a procedural graph reads them all through this list. A provider is { version = fn() -> string, stand = fn(request) }. version names what its water is now (a surface that changes every frame answers differently every frame). stand puts points on its water on the device: request carries run (the points' GPU positions, in the graph's space), count, out (P, normal, slope and wet GPU columns to write for the points over its water, leaving the rest as they are), place / unplace (graph to world and back, 16 numbers each, column major), offset (metres above the surface) and keepY (whether a point's own height rides on the surface's); it returns the names of the kernels it dispatched, which wrote those columns.
Usage: local water_surfaces = require("@builtin::modules.water_surfaces")
modules/water_surfaces/list
list(): { { name: string, provider: { [string]: any } } }
Every registered provider, by name in order.
for _, p in water_surfaces.list() do print(p.name) end
modules/water_surfaces/register
register(name: string, provider: { [string]: any })
Register a water provider under name, replacing one registered under
it before.
Parameters
namestring— The provider's name — the system it speaks for.provider{ [string]: any }—{ version = fn() -> string, stand = fn(request) -> { string } }.
water_surfaces.register("ocean", { version = oceanVersion, stand = standOnOcean })
modules/water_surfaces/unregister
unregister(name: string): boolean
Remove the provider registered under name.
Parameters
namestring— The provider's name.
water_surfaces.unregister("ocean")
modules/weather/README
require("@builtin::systems.weather.weather") -- weather
How surfaces respond to weather — wetness darkens and sharpens, snow settles on what faces up, and anything under cover stays clear.
Usage: local weather = require("@builtin::systems.weather.weather")
modules/weather/active
active(): boolean
Whether the weather pass is currently running.
if weather.active() then print("wet") end
modules/weather/bakeShelter
bakeShelter(): ShelterField
Re-derive the cover field the shelter test reads from the geometry the renderer currently draws. The field is baked when weather starts and re-derived when the count of renderables moves; call this after moving or reshaping cover that left that count where it was.
weather.bakeShelter()
modules/weather/clear
clear()
Clear the weather and release the pass. The other settings are kept, so
a later set brings back the same look.
weather.clear()
modules/weather/coverBuffer
coverBuffer(): any?
The cover field the shelter test reads, as a buffer a pass binds.
local b = weather.coverBuffer()
modules/weather/get
get(): WeatherState
The weather currently in force.
local w = weather.get().wetness
modules/weather/paramsBuffer
paramsBuffer(): any?
The parameter buffer this system's passes read. A pass binds what this hands it, so it has the values this module packed.
local b = weather.paramsBuffer()
modules/weather/refresh
refresh()
Re-pack the buffer against the light the scene is standing in now — its ambient and its sun — and bring the cover field along with the scene. The pass runs every frame and the scene's lighting moves between frames, so the sheen follows the light rather than the value it had when the weather was last set. Writes only when something in the buffer has moved.
weather.refresh()
modules/weather/set
set(opts: WeatherOpts?): WeatherState
Set the scene's weather. Any omitted field keeps its current value, so a
call can move one knob without restating the rest. With both wetness and
snow at 0 nothing is falling and the pass is released.
Parameters
optsWeatherOpts?(optional) — Weather settings — seeWeatherOpts.
weather.set({ wetness = 0.8, snow = 0 })
modules/weather/shelterField
shelterField(): ShelterField
Where the cover field the shelter test reads currently stands. A
resolution of 0 means no field is baked, and every surface is then open
to the sky.
print(weather.shelterField().filled, "columns hold a surface")
modules/world_defaults/README
require("@builtin::modules.world_defaults") -- world_defaults (also available as global 'world')
Grafts the per-world defaults + args + lifecycle-callback registry onto the world global. Companion to world_vcs.module. Backed by .world_settings for the persisted fields; callbacks live in in-process registries. Slot fields exposed on world.* (4 per-mode + 2 mode-agnostic): - avatar_default_edit AssetRefavatar_default_play AssetRefcamera_default_edit AssetRefcamera_default_play AssetRefstartup_scene AssetRefloading_screen AssetReforientation "any" | "landscape" | "portrait": the screen orientation the world plays in; installOrientationLock locks the display to it in play mode Per-mode slots are selected by wld.mode() at spawner-resolution time (player_spawner / camera_spawner). Worlds that don't care about the split set both halves to the same value. All setters are play-mode-gated: writes target .world_settings (a source-VFS file) which is locked in play mode. The gate raises a typed error at the API boundary instead of letting the call hit a downstream "VFS write refused" error. Set engine.mode = "edit" first. All bundle-typed setters enforce the slot's required tag (§ 7 of the player-camera-unification plan). Writing a wrongly-tagged ref is refused with a clear message naming the missing tag.
Usage: local world_defaults = require("@builtin::modules.world_defaults") Also available as global: world
modules/world_defaults/offLoaded
offLoaded(handle: number): boolean
Stop a callback registered with world.onLoaded from running.
Parameters
handlenumber— The handleworld.onLoadedreturned.
world.offLoaded(h)
modules/world_defaults/offSaved
offSaved(handle: number): boolean
Stop a callback registered with world.onSaved from running.
Parameters
handlenumber— The handleworld.onSavedreturned.
world.offSaved(h)
modules/world_defaults/offUnloaded
offUnloaded(handle: number): boolean
Stop a callback registered with world.onUnloaded from running.
Parameters
handlenumber— The handleworld.onUnloadedreturned.
world.offUnloaded(h)
modules/world_defaults/onLoaded
onLoaded(cb: (...any) -> ()): number
Register a callback to run after a world finishes loading.
Parameters
cb(...any) -> ()— Called when the event fires, with whatever the event supplies.
local h = world.onLoaded(function() log.info("loaded") end)
modules/world_defaults/onSaved
onSaved(cb: (...any) -> ()): number
Register a callback to run after a world is saved.
Parameters
cb(...any) -> ()— Called when the event fires, with whatever the event supplies.
local h = world.onSaved(function() log.info("saved") end)
modules/world_defaults/onUnloaded
onUnloaded(cb: (...any) -> ()): number
Register a callback to run after a world is unloaded.
Parameters
cb(...any) -> ()— Called when the event fires, with whatever the event supplies.
local h = world.onUnloaded(function() log.info("unloaded") end)
modules/world_defaults/reload
reload(): { started: boolean?, guid: string?, branch: string?, error: string? }
Run the bound world again from the top, the way a fresh boot into it
would: the world unloads, its content is taken again, its entrypoint and
startup scene run. The load is asynchronous; the answer says whether it
started. An engine with no world bound answers { error }.
world.reload()
modules/world_status/README
require("@builtin::modules.world_status") -- world_status
Composes world.status() + world.status_text() — a snapshot of world identity, mode, running flag, primary scene, all loaded scenes, and players across all scenes. Pure-Luau (no Rust); uses existing globals: world.guid / world.branch / world.title, engine.mode, layers.active, layers.list, scene proxy's players / camera registries, world.connectedUsers.localUser. Installed onto the world global by world_defaults.module/init.luau via the world-namespace metatable machinery (see § 4b of the player-camera-unification integration design).
Usage: local world_status = require("@builtin::modules.world_status")
modules/world_vcs.dependencies/README
require("@builtin::modules.world_vcs.dependencies") -- world_vcs.dependencies (also available as global 'world')
The dependency copies under /zero/source/deps/ and what uses them: which ones nothing in the world uses, removing those on an explicit call, uninstalling an install together with the dependencies only it used, and the notice that says the world holds unused ones. What uses a dependency is the engine's answer (install.dependencyUse): an install record that lists or pins it, a source whose reference table depends on it, and a used dependency that depends on it. Nothing here commits; a removed row of the world leaves as a deletion in the next commit, and a changed install record is the change the next commit carries.
Usage: local world_vcs.dependencies = require("@builtin::modules.world_vcs.dependencies") Also available as global: world
modules/world_vcs.dependencies/canonical
canonical(path: string): string
A path in the /zero/source/... spelling: /source/... and a path
relative to /zero/source are taken there, a trailing / dropped.
Parameters
pathstring— A path.
dependencies.canonical("/source/deps/w/a.module") --> "/zero/source/deps/w/a.module"
modules/world_vcs.dependencies/installInto
installInto(world: WorldNamespace, opsOf: () -> DependencyOps)
Graft uninstall and removeUnusedDeps onto the supplied world
namespace and, in the engine, start the unused-dependency notice.
world_vcs.installInto calls this once at boot.
Parameters
worldWorldNamespace— The target namespace.opsOf() -> DependencyOps— Answers the operations to run through.
require("modules.world_vcs.dependencies").installInto(world, opsOf)
modules/world_vcs.dependencies/noticeFor
noticeFor(unused: { UnusedDependency }, lastKey: string?): (string, boolean, { [string]: any })
The notice state for one look at the world: the unused paths, and whether they are a change from the last notice posted.
Parameters
unused{ UnusedDependency }— The unused dependencies.lastKeystring?(optional) — The key of the last notice posted, or nil.
dependencies.noticeFor({}, nil)
modules/world_vcs.dependencies/onlyPaths
onlyPaths(only: any, fn: string): { string }?
The only option as a list of canonical paths: nil, one path, or a list.
Parameters
onlyany(optional) — What the caller passed.fnstring— The calling function's name, for the error.
dependencies.onlyPaths("/source/deps/w", "world.removeUnusedDeps")
modules/world_vcs.dependencies/removeUnused
removeUnused(opts: { dryRun: boolean?, only: any? }?, ops: DependencyOps): RemoveUnusedReport
Remove the dependencies under /zero/source/deps/ that nothing in the
world uses, or with dryRun list them. A dependency an install placed is
deleted from that install's record (the record is taken out once it holds
nothing); one the world holds as rows of its own is removed as files.
Parameters
opts{ dryRun: boolean?, only: any? }?(optional) —{ dryRun?, only? }.opsDependencyOps— The operations to run through.
dependencies.removeUnused({ dryRun = true }, ops)
modules/world_vcs.dependencies/removeUnusedDeps
removeUnusedDeps(opts: { dryRun: boolean?, only: any? }?): RemoveUnusedReport
Remove the dependency copies under /zero/source/deps/ that
nothing in this world uses, or with dryRun only list them. A
dependency is used when an install record lists or pins it, when a
source of the world (its own content or an install's) depends on it
by its reference table, or when a used dependency depends on it. A
dependency an install placed is deleted from that install's record;
one the world holds as files of its own (written by hand, or left by
an earlier engine's install) is removed as files. Nothing is
committed: removed files leave as deletions in the next commit, and a
changed install record is a change the next commit carries. The
engine posts a notice whenever the world comes to hold unused
dependencies, naming them.
Parameters
opts{ dryRun: boolean?, only: any? }?(optional) —{ dryRun?: boolean, only?: string | { string } }:onlyholds the call to the dependencies at or under those paths.
world.removeUnusedDeps({ dryRun = true })
world.removeUnusedDeps()
world.removeUnusedDeps({ only = "/zero/source/deps/0d6c9a2e-4b1f-4c3e-9a7d-2f5e8b1c4d6a" })
modules/world_vcs.dependencies/uninstall
uninstall(path: string, opts: { dryRun: boolean? }?, ops: DependencyOps): UninstallReport
Remove the install at path with the dependencies only it used. A
dependency something else in the world uses stays and is named with what
uses it; a file of the install or of a dependency this world changed or
wrote itself stays where it stands as a file of the world.
Parameters
pathstring— The install's root.opts{ dryRun: boolean? }?(optional) —{ dryRun? }.opsDependencyOps— The operations to run through.
dependencies.uninstall("/zero/source/skate_physics.package", { dryRun = true }, ops)
modules/world_vcs.dependencies/unused
unused(ops: DependencyOps, only: { string }?): { UnusedDependency }
The dependencies nothing in the world uses, as the engine answers it,
held to only when given: a dependency is kept when its root is one of
those paths or lies under one.
Parameters
opsDependencyOps— The operations to read through.only{ string }?(optional) — The paths to hold the answer to, or nil.
dependencies.unused(ops, nil)
modules/world_vcs.dependencies/watch
watch(ops: DependencyOps, ready: () -> boolean)
Watch the world for unused dependencies and post a notice when the set of them changes. Reads only: it writes nothing to the world. Looks again only when the engine's dependency stamp moved, every install is materialized and the world's content has arrived. Started once.
Parameters
opsDependencyOps— The operations to read through.ready() -> boolean— Whether the world's content has arrived.
dependencies.watch(ops, function() return true end)
modules/world_vcs.derive.runner/README
require("@builtin::modules.world_vcs.derive.runner") -- world_vcs.derive.runner
Turns staged assets into reservations and computes them on workers: a staged asset a derive hook accepts is reserved on its stage in one call as staging returns, then each output is computed on a job-system worker, written beside the asset, and its reservation settled done, which stages the output (or failed with the reason), the settle carrying the fingerprint of the inputs the output was computed from and the generation of the reservation read before those inputs were.
Usage: local world_vcs.derive.runner = require("@builtin::modules.world_vcs.derive.runner")
modules/world_vcs.derive.runner/__groupRows
__groupRows(rows: { any }, roots: { string }): { [string]: { any } }
Group staged rows by the asset roots that contain them: one pass over the rows, each looked up against the set of roots on its way up through its folders. A row inside a nested asset belongs to every root above it.
Parameters
rows{ any }— The staged rows.roots{ string }— The asset roots.
modules/world_vcs.derive.runner/__includeScratchForTests
__includeScratchForTests(on: boolean)
Plan for assets under /zero/source/tmp/tests/ as well as for world
content, and resolve a staged path in that folder to an asset by its
extension when no asset resolves there: the seam suites use to exercise the
runner on scratch assets.
Parameters
onboolean— Whether scratch test assets are included.
modules/world_vcs.derive.runner/__sealedBefore
__sealedBefore(sealed: { any }, stageId: string): { any }
The sealed stages of sealed a commit of the stage stageId lands
after, oldest first: every one sealed before it, or every one when the
stage is not among them (a stage still taking entries lands last).
Parameters
sealed{ any }— The caller's sealed stages, each withstage_row_idandsealed_at.stageIdstring— The stage's row id.
modules/world_vcs.derive.runner/__setNoticeSink
__setNoticeSink(sink: ((string) -> ())?)
Replace where the runner's notices go with sink, which receives each
message; nil puts the notice store back.
Parameters
sink((string) -> ())?(optional) — A function taking the notice message, or nil.
modules/world_vcs.derive.runner/__setTransport
__setTransport(t: { [string]: any }): () -> ()
Replace the transport the runner reserves, settles, reads and writes through: the seam suites use to observe the reservation calls without a live world. A field the replacement leaves out keeps the default.
Parameters
t{ [string]: any }— The replacement fields:stageContext,reserve,unavailable,settle,drop,reservations,stageRead,sealed,stageEntries,baseEntries,write,generation,syncOutput,stageAsset,inputsAreLive,outputExists,liveInputs,putBlob.
Returns () — A function that puts the previous transport back.
modules/world_vcs.derive.runner/carry
carry(stageName: string, stageId: string, rows: { Row }): { carried: number }
Reserve on the stage with row id stageId the derived outputs rows
that a stage it replaces held, and compute them from what the stage holds:
a stage closed and opened again over the branch head keeps every output
it reserved, so its commit records each one with the fingerprint of the
inputs it lands. An output the user supplied (authored) is taken again
as the file stands; a dropped one stays out.
Parameters
stageNamestring— The stage's name.stageIdstring— The row id of the stage that replaces the onerowswere read from.rows{ Row }— The reservations of the replaced stage, asreservationsOfreads them.
runner.carry("default", newStageId, runner.reservationsOf("default", oldStageId))
modules/world_vcs.derive.runner/drop
drop(outputPath: string, stageName: string?): { dropped: number }
Leave the derived output at outputPath out of the commit: its
reservation is dropped. A required output is refused, except one whose
asset holds no input file in the tree its commit lands on nor in the
working tree: the commit removes that asset, and its reservation settles
empty.
Parameters
outputPathstring— The output's VFS path.stageNamestring?(optional) — The stage the output is reserved on; the shared stage when omitted.
runner.drop("/zero/source/gold.material/extra.json")
modules/world_vcs.derive.runner/onSettled
onSettled(name: string, fn: (() -> ())?)
Call fn on a task of its own after every settle the backend accepts,
done, empty or failed. A name registers once: registering it again replaces
what it held, and fn = nil removes it.
Parameters
namestring— What identifies the listener.fn(() -> ())?(optional) — The listener, or nil to remove it.
modules/world_vcs.derive.runner/provide
provide(outputPath: string, stageName: string?): { provided: number }
Take the file at outputPath as the derived output: the reservation is
reserved anew so no computation answers for it, and settled done with
the fingerprint "authored", which stages the file as it stands.
Parameters
outputPathstring— The output's VFS path; a file must exist there.stageNamestring?(optional) — The stage the output is reserved on; the shared stage when omitted.
runner.provide("/zero/source/gold.material/preview.png")
modules/world_vcs.derive.runner/reservationsOf
reservationsOf(stageName: string, stageId: string): { Row }
The reservations the stage with row id stageId holds now: what a
call that replaces the stage hands carry.
Parameters
stageNamestring— The stage's name.stageIdstring— The stage's row id.
modules/world_vcs.derive.runner/reserveAndStart
reserveAndStart(
Reserve, on the stage stageName, the derived outputs of the assets
holding stagedPaths in one call, with pending fingerprints, and start
computing them on workers. The reservations exist when this returns; each
output lands on the stage when it is computed, and its settle records the
fingerprint of the inputs it was computed from. The generation of each
reservation is read before its inputs are, and the settle answers that
generation.
runner.reserveAndStart("default", { "/zero/source/gold.material/mat.yaml" })
modules/world_vcs.derive.runner/resume
resume(stageName: string?): { resumed: number }
Re-dispatch every computing reservation of the caller's stage and of
its sealed stages that this engine is not computing, whichever engine or
session reserved it: the work a restart or another session left
unfinished. A reservation computes from the staged entries of its stage
laid over the tree that stage lands on, a sealed stage's included.
Parameters
stageNamestring?(optional) — The stage to resume; the shared stage when omitted.
runner.resume()
modules/world_vcs.derive.runner/retry
retry(outputPath: string, stageName: string?): { retried: number }
Compute the derived output at outputPath again: its reservation, on
the stage or on a sealed commit of the caller, is reserved anew and
computed from the inputs as they stand. A reservation that failed, was
dropped, or is done is returned to computing. An output no stage of the
caller reserves, one already committed, is reserved on the stage with its
asset staged beside it, so the next commit carries the new output.
Parameters
outputPathstring— The output's VFS path.stageNamestring?(optional) — The stage the output is reserved on; the shared stage when omitted.
runner.retry("/zero/source/gold.material/preview.png")
modules/world_vcs.derive.runner/status
status(): { computing: number, preparing: number, failed: number, statusReads: number }
How many reservations are being computed, how many staged batches are being prepared, how many failed settles the backend recorded since the engine started, and how many whole-status reads the runner made.
modules/world_vcs.derive.snapshot/README
require("@builtin::modules.world_vcs.derive.snapshot") -- world_vcs.derive.snapshot
A read-only view of an asset as a stage holds it, and the one fingerprint rule shared by that view and the live asset: the lines a fingerprint hashes are f <relative path> <content address> for every file of the asset that can change a derived output, each followed by d <guid> <version> for every asset the file references. A folder asset of the asset's own world is pinned at the version of its inputs (inputsVersion), so a derived output landing in it moves no pin.
Usage: local world_vcs.derive.snapshot = require("@builtin::modules.world_vcs.derive.snapshot")
modules/world_vcs.derive.snapshot/dependencyPaths
dependencyPaths(assetPath: string, staged: { StagedEntry }, opts: Options?): { string }
The paths of the assets of the world that the files of the asset at
assetPath reference outside it, as the stage holds them laid over
opts.base, sorted: the paths whose files opts.dependencies carries
into of, so every pin of the fingerprint states the version of that
asset's inputs in the tree the commit lands on.
Parameters
assetPathstring— The asset's path.staged{ StagedEntry }— Staged entries of the asset.optsOptions?(optional) —baseentries of the asset in the tree the commit lands on.
modules/world_vcs.derive.snapshot/depsOfRefs
depsOfRefs(refsJson: string?): { Dep }
The assets the reference table refsJson pins, as depsOfTable
states them; none for a missing or unreadable table. The one reader a
staged file's, a committed file's and a live file's dependencies go
through.
Parameters
refsJsonstring?(optional) — The table as a manifest row carries it.
modules/world_vcs.derive.snapshot/depsOfTable
depsOfTable(decoded: any): { Dep }
The assets a decoded reference table pins, each as the guid and the
version it is pinned at: sorted by guid then version, once each. One rule
reads both forms a table takes: the .refs file (deps entries with
their sites, and worlds entries whose sites name the assets of another
world) and the table asset.deps answers for a live file (one deps
entry per naming site). An asset of the file's own world is pinned at the
checksum of the entry that covers it; an asset of another world, at the
commit that world is pinned at, which an engine-surface site does not have.
A pin of an asset of the file's own world carries own = true.
Parameters
decodedany(optional) — The decoded table.
modules/world_vcs.derive.snapshot/fingerprintLines
fingerprintLines(s: derive.DeriveSnapshot): { string }
The lines a fingerprint hashes, in order: files by relative path, each followed by the dependencies it references. Empty when the snapshot holds no file.
Parameters
sderive.DeriveSnapshot— The snapshot.
modules/world_vcs.derive.snapshot/foldersOf
foldersOf(paths: { [string]: boolean }): { [string]: boolean }
The relative paths of paths that are folders of the asset: every
path another path of paths lies beneath. A folder asset nested in the
asset (a material's textures/basecolor.texture) is an entry of a stage
and of a commit beside the files it holds, and it is one of these.
Parameters
paths{ [string]: boolean }— Relative paths, as a set.
modules/world_vcs.derive.snapshot/inputsVersion
inputsVersion(files: { [string]: string }): string?
The version a pin of a folder asset of the world states: the digest of
the f <relative path> <content address> lines of the files beneath it
that can change a derived output, the lines a fingerprint of that asset
states for its files. A derived output, a README.md or a .metadata
landing in the folder leaves it as it is. Nil when the folder holds no
such file; a file asset is pinned at its checksum.
Parameters
files{ [string]: string }— Content address by path relative to the folder.
modules/world_vcs.derive.snapshot/laidOver
laidOver(base: { BaseEntry }, stages: { { StagedEntry } }): { BaseEntry }
The files a commit laid over base holds: the entries of base
with the entries of each of stages laid over them in order, oldest
first, each staged entry taking the place of the base entry at its path
and a staged delete removing it. The entries keep the base shape, sorted
by path.
Parameters
base{ BaseEntry }— The tree the commits are laid over, asBaseEntryrows.stages{ { StagedEntry } }— The staged entries of each commit, oldest first.
modules/world_vcs.derive.snapshot/live
live(path: string, opts: Options?): derive.DeriveSnapshot
The snapshot of the asset at path over its live files: each file's
address is the VFS content address and its dependencies are the assets
it references now, an asset of the world pinned at the inputsVersion of
its live files. The files opts.exclude names are left out.
Parameters
pathstring— The asset's path.optsOptions?(optional) —excluderelative paths.
modules/world_vcs.derive.snapshot/liveAddresses
liveAddresses(path: string, opts: Options?): { [string]: string }
The content address of each live file of the asset at path, by
path relative to the asset: the files a live snapshot of it holds, without
the dependencies they reference. The files opts.exclude names are left out.
Parameters
pathstring— The asset's path.optsOptions?(optional) —excluderelative paths.
modules/world_vcs.derive.snapshot/of
of(assetPath: string, staged: { StagedEntry }, opts: Options?): derive.DeriveSnapshot
The snapshot of the asset at assetPath as a stage holds it: the files
of the tree its commit lands on (opts.base) with the staged entries laid over them.
files maps each file's path relative to the asset to its content
address; read returns a file's bytes, fetched from its blob on first use
and kept on the snapshot, or nil when the file is absent or its blob cannot
be read. A staged delete removes the file; the files opts.exclude names
are left out, and so is every entry that holds other entries: a folder
asset nested in the asset is the files beneath it. A pin of an asset of
the world states the inputsVersion of that asset's files, read from the
same entries when the asset lies within this one and from
opts.dependencies when it lies outside; an asset with no files there is
pinned at the checksum its reference table states.
Parameters
assetPathstring— The asset's path.staged{ StagedEntry }— Staged entries: path, checksum, blob_sha256 and the dependencies the file references.optsOptions?(optional) —baseentries of the asset in the tree the commit lands on,excluderelative paths, anddependenciesby path.
modules/world_vcs.derive.snapshot/outputsExcluded
outputsExcluded(): { [string]: boolean }
The relative paths no fingerprint reads: the output of every asset-scope hook, the ones asset types export included. An output is computed from the asset's inputs, so another hook's output landing beside it never changes what it was computed from. The one exclusion set the runner and the push gate share.
modules/world_vcs.derive.worker/README
require("@builtin::modules.world_vcs.derive.worker") -- world_vcs.derive.worker
Worker entries for derive hooks: each runs one entry of a hook's module on a worker VM, over a snapshot handed across as data.
Usage: local world_vcs.derive.worker = require("@builtin::modules.world_vcs.derive.worker")
modules/world_vcs.derive.worker/compute
compute(args: any): any
The result args.hook.compute of args.hook.module computes for
args.snapshot: { bytes: string?, error: string? }.
Parameters
argsany(optional) —{ hook, snapshot }: the hook without its functions, and the snapshot as data.
modules/world_vcs.derive.worker/fingerprint
fingerprint(args: any): string
The fingerprint args.hook.fingerprint of args.hook.module states for
args.snapshot.
Parameters
argsany(optional) —{ hook, snapshot }: the hook without its functions, and the snapshot as data.
modules/world_vcs.derive/README
require("@builtin::modules.world_vcs.derive") -- world_vcs.derive
The derive-hook registry: computations that produce an output from the content a stage holds, so the output lands in the commit with it.
Usage: local world_vcs.derive = require("@builtin::modules.world_vcs.derive")
modules/world_vcs.derive/__setIncludeScratch
__setIncludeScratch(on: boolean)
Plan for assets under /zero/source/tmp/tests/ as well as for world
content: the seam suites use to exercise planning on scratch assets.
Parameters
onboolean— Whether scratch test assets are planned for.
modules/world_vcs.derive/allHooks
allHooks(): { DeriveHook }
Every hook: the registered ones and the one each asset type's
behavior.luau exports as derive, in name order. A registered hook
stands over a type's export of the same name. The set an output path is
looked up in: the outputs left out of an asset's inputs, and the hook a
retry of a committed output reserves it for.
modules/world_vcs.derive/cache.__setByteLimit
cache.__setByteLimit(limit: number): () -> ()
Replace the byte bound of the cache, dropping entries beyond it: the seam suites use to exercise the bound with small results.
Parameters
limitnumber— The new bound in bytes.
Returns () — A function that puts the previous bound back.
modules/world_vcs.derive/cache.bytes
cache.bytes(): number
How many bytes the cache holds.
modules/world_vcs.derive/cache.get
cache.get(hook: string, fingerprint: string): string?
The cached result of hook for fingerprint, refreshing its recency.
Parameters
hookstring— The hook's name.fingerprintstring— The fingerprint the result was computed for.
modules/world_vcs.derive/cache.put
cache.put(hook: string, fingerprint: string, bytes: string)
Keep the result of hook for fingerprint; the least recently used
entries leave when more than 64 are held or their bytes exceed 32 MiB. A
result larger than 32 MiB is not kept.
Parameters
hookstring— The hook's name.fingerprintstring— The fingerprint the result was computed for.bytesstring— The result.
modules/world_vcs.derive/hookNamed
hookNamed(name: string): DeriveHook?
The hook named name: a registered one, or the one an asset type's
behavior.luau exports as derive when name is <type>.<output>.
Parameters
namestring— The hook's name.
modules/world_vcs.derive/hooks
hooks(): { DeriveHook }
Every registered hook, in name order.
modules/world_vcs.derive/planFor
planFor(refs: { any }): { { hook: DeriveHook, ref: any } }
The reservations a set of staged assets calls for: one per asset and
asset-scope hook whose matches accepts it, in hook-name then path order.
Parameters
refs{ any }— The staged assets.
modules/world_vcs.derive/register
register(hook: DeriveHook)
Register a derive hook, replacing one of the same name.
Parameters
hookDeriveHook— The hook.
modules/world_vcs.derive/unregister
unregister(name: string)
Remove the hook registered under name.
Parameters
namestring— The hook's name.
modules/world_vcs.derivedGate/README
require("@builtin::modules.world_vcs.derivedGate") -- world_vcs.derivedGate
The push gate's freshness class for derived outputs: an output a commit records as computed by a hook must still match the inputs it was computed from. Each output's recorded fingerprint is compared with the fingerprint its hook states over the branch head's tree, so a source committed after its output was computed names the output as stale. A pin of an asset of the world states the version of that asset's inputs in the same tree. An output recorded as authored is the user's and always passes.
Usage: local world_vcs.derivedGate = require("@builtin::modules.world_vcs.derivedGate")
modules/world_vcs.derivedGate/check
check(): Verdict
Judge the derived outputs of the unpushed commits. Each output path takes the newest recorded row; one the head tree still holds is compared with the fingerprint its hook states over the files of its asset in the head tree. Only the derived-output rows of the unpushed commits, the files of the assets they name and the files of the assets of the world those reference are read. A required output that differs becomes an item of the returned section; a best-effort one is returned as a warning, once per output and recorded fingerprint. Nothing is judged when the backend does not serve derived outputs, the history cannot be read, or a hook is not registered here.
local verdict = derivedGate.check()
modules/world_vcs.finalize/README
require("@builtin::modules.world_vcs.finalize") -- world_vcs.finalize
Lands the commits world.commit sealed: a sealed stage whose required derived outputs are all done is committed under its sealed commit id, oldest first, and a commit that is not ready holds the ones sealed after it. A stage the branch head moved away from is rebased in place and committed again. A push asked for while commits are sealed is queued on the newest one and runs once it lands, and its outcome is recorded for the caller waiting on it and for zm status.
Usage: local world_vcs.finalize = require("@builtin::modules.world_vcs.finalize")
modules/world_vcs.finalize/__setTransport
__setTransport(t: { [string]: any }): () -> ()
Replace the calls the finalizer reads, commits, rebases and tells the caller through: the seam suites use to run it without a live world. A field the replacement leaves out keeps the default. A watch running over the transport being replaced ends, here and when the previous one is put back, so it never lands commits through a transport it did not start with.
Parameters
t{ [string]: any }— The replacement fields:status,commit,commitExists,rebase,unseal,setPushOnLand,push,notify.
Returns () — A function that puts the previous transport back.
modules/world_vcs.finalize/awaitPush
awaitPush(after: number, waitingOn: { string }, seconds: number): PushOutcome
Wait for the queued push that runs after push number after (read with
pushSeq before queueing it), for at most seconds. A sealed commit it
waits for that cannot land holds it: the refusal the commit met, or a
required output whose computation failed, ends the wait. The watch that
lands the commits keeps running whatever this answers.
Parameters
afternumber— ThepushSeqread before the push was queued.waitingOn{ string }— The sealed commit ids the push waits for, asqueuePushanswered them.secondsnumber— How long to wait.
modules/world_vcs.finalize/clearLastPush
clearLastPush()
Forget the outcome of the last queued push: a push that published since answers for the branch.
modules/world_vcs.finalize/kick
kick()
Run pass on a task of its own and return at once.
modules/world_vcs.finalize/landSealed
landSealed(commitId: string): (boolean, string?, string?)
Land the sealed commit commitId when every required output of it is
done, waiting for it; otherwise queue it behind its outputs.
Parameters
commitIdstring— The sealed commit's id.
modules/world_vcs.finalize/lastPush
lastPush(): PushRecord?
The outcome of the last queued push this engine ran, or nil when none
has run or a push published since. zm status states a refused one.
modules/world_vcs.finalize/onLanded
onLanded(fn: (commitId: string) -> ()): () -> ()
Call fn(commitId) whenever a sealed commit lands.
Parameters
fn(commitId: string) -> ()— The listener.
Returns () — A function that stops the calls.
modules/world_vcs.finalize/pass
pass(quietFor: string?): Result
Land the caller's sealed commits that are ready, oldest first, and wait
for each commit it lands. It stops at the first sealed commit that is not
ready (a required output not done) or that cannot land, so later commits
queue behind it. A commit call that the connection fails is made again
after a wait; a commit that exists once its call was refused was landed by
another engine of the account and counts as landed. Only a refusal of the
commit itself raises a notice.
Parameters
quietForstring?(optional) — A commit id whose refusal is recorded without a notice: the caller waiting on that commit raises it itself.
modules/world_vcs.finalize/pushSeq
pushSeq(): number
How many queued pushes this engine has run: a caller reads it before
queueing a push and hands it to awaitPush, which answers the first push
that ran after it.
modules/world_vcs.finalize/queuePush
queuePush(): ({ string }?, { commitId: string, reason: string }?)
Queue a push behind the caller's sealed commits: the ready ones land first, then the newest one left is marked to push once it lands, and a push that finds nothing sealed is left to the caller. A sealed commit that cannot land holds every push behind it, so when the oldest one left holds a refusal the push is not queued and the refusal is answered instead.
modules/world_vcs.finalize/refusals
refusals(): { [string]: string }
The refusal this engine holds for each sealed commit that could not
land, by commit id: what zm status states beside the commit.
modules/world_vcs.finalize/sealedIds
sealedIds(): { string }
The ids of the caller's sealed commits, oldest first.
modules/world_vcs.finalize/unseal
unseal(commitId: string?): string
Return the sealed commit commitId to the staging area it was sealed
from. Without an id, the oldest sealed commit that holds a failure, else
the newest.
Parameters
commitIdstring?(optional) — The sealed commit's id.
modules/world_vcs.finalize/watch
watch(resume: (() -> ())?)
Land the sealed commits as they become ready until none is sealed: a
pass every 2 seconds (every 4, 8 and up to 30 seconds while the oldest
sealed commit holds a refusal), which also picks up an output another
session settled. With resume, call it once the backend shows reservations or
sealed commits (and every 10 seconds while a commit stays sealed), or
give up after a minute with none. A status read that fails is logged
and read again, so a watch over sealed commits keeps watching. A call
made while the watch runs wakes it for a pass at once.
Parameters
resume(() -> ())?(optional) — Computes thecomputingreservations nothing in this engine is computing.
modules/world_vcs.history/README
require("@builtin::modules.world_vcs.history") -- world_vcs.history
The reads world.diff, world.show, world.log and the checkout and merge calls build on: a file's content at a commit, in the staging area or in the working tree, the paths two sources differ on and the per-file diff between them, a commit's ancestry and full tree, the history of one path, and the commit a git-style revision names.
Usage: local world_vcs.history = require("@builtin::modules.world_vcs.history")
modules/world_vcs.history/bind
bind(worldVcs: any, stageNameOfCaller: () -> string, workingSet: string)
Bind these reads to the world_vcs module worldVcs they run under.
Parameters
worldVcsany(optional) — The world_vcs module table.stageNameOfCaller() -> string— Answers the staging area a call from the calling caller acts on.workingSetstring— The area a status read names to read only the working set.
modules/world_vcs.history/diffCandidatePaths
diffCandidatePaths(status: any, set: Ignore.IgnoreSet, includeIgnored: boolean): { string }
The paths a status read names for a diff to compare: every row the
staging area holds, and every working-tree row but the ones a
.zmignore / .gitignore rule matches, which includeIgnored names
too. A row the area holds is named whatever rule matches it, since it
goes into the next commit. A scene's autosave overlay row stands for its
scene's scene.json, which the same rules decide, and an ignore file
itself is always named.
Parameters
statusany(optional) — The decoded status read: itsdirtyandstagedrows.setIgnore.IgnoreSet— The ignore set the world's ignore files state.includeIgnoredboolean— Whether the working-tree rows a rule matches are named.
modules/world_vcs.ignore/README
require("@builtin::modules.world_vcs.ignore") -- world_vcs.ignore
The .zmignore / .gitignore rules of a world: parses the ignore files in gitignore(5) syntax into one ignore set and decides whether a path matches it. The world's staging gates read it through world_vcs.
Usage: local world_vcs.ignore = require("@builtin::modules.world_vcs.ignore")
modules/world_vcs.ignore/isIgnored
isIgnored(set: IgnoreSet, path: string): boolean
Whether the ignore set ignores path (/source/... or
/zero/source/...): the last rule that matches it is not a ! negation.
Parameters
setIgnoreSet— The ignore setsetFromanswered.pathstring— The path to decide.
print(Ignore.isIgnored(set, "/source/scene_dirty/entities/a.json"))
modules/world_vcs.ignore/ruleFor
ruleFor(set: IgnoreSet, path: string): IgnoreRule?
The rule that ignores path: the last rule of the set that matches it,
when that rule is not a ! negation. Rules are walked in load order, so a
deeper ignore file overrides its parents and a later line an earlier one.
Parameters
setIgnoreSet— The ignore setsetFromanswered.pathstring— The path to decide, as/source/...or/zero/source/....
local why = Ignore.ruleFor(set, "/zero/source/generated/runs/a.serviceRun/run.json")
modules/world_vcs.ignore/setFrom
setFrom(ignorePaths: { string }, read: (string) -> any): IgnoreSet
The ignore set the .zmignore / .gitignore files at ignorePaths state,
each file read through read and parsed fresh, so an edit to an existing
ignore file is always reflected. O(ignore files): no /source tree walk.
Parameters
ignorePaths{ string }— The ignore-file paths, as the engine's index lists them.read(string) -> any— Reads a file's bytes by path.
modules/world_vcs.publishReminders/README
require("@builtin::modules.world_vcs.publishReminders") -- world_vcs.publishReminders
Tells the agents building in a world, without being asked, what keeps their work from being published: changes not committed or commits not pushed, a world still marked as a draft, and a world with no description or no cover image. Each is an engine notice addressed to every caller, naming the counts or the missing fields and the call that puts it right, and each is withdrawn once the state it reports is gone. When each one is posted: * Unpublished work, at intervals while an agent is at work: once the world has held uncommitted changes or unpushed commits for UNSAVED_INTERVAL_S, and again each UNSAVED_INTERVAL_S after that, only when the counts moved since the last one. An agent that stopped working is not told again about work that has not changed. * A draft world, and a missing description or cover image, while an agent is at work on a world whose work ZeroMind holds: after the push that leaves either state standing, so the agent that just published hears what is left of publishing within STATUS_S, unless the last turn end already told it the same. * At the end of an agent's turn, every notice whose state holds then: unpublished work, a draft world, a missing description or cover image. A turn end tells a notice again only when what it reports changed since the turn end that last read it: new counts of unpublished work, another intended visibility, another set of missing fields. An agent that leaves a world as it was (a person asked it to keep the world a draft) is not told again, however much other work it does. * A change to a notice a turn end already told, while the notice stood since (more commits held back on a person's word, a count the engine moved, one missing field of two set), is held for the agent's next work and posted then, read again, without waking anyone: DotBot hears it with the model request after its next tool call, inside the turn that makes it, and an MCP caller with its next tool call. Once no agent has been at work for UNSAVED_INTERVAL_S, the reminders read neither the world's status nor its ZeroMind record until one is again: an idle editor costs ZeroMind nothing. A turn ends, as the engine sees it, when DotBot reports a turn of its as completed (a stopped or failed turn is not one), and for an agent driving the engine over MCP when its tool calls go quiet for QUIET_S after one: an MCP caller states no turn boundary, so a pause in the calls made on the engine, over any transport, is the one the engine reads. DotBot's calls are not among them: the calls its host makes between turns to read the notices are no agent at work. While a DotBot turn is open its own events say where it ends, so the calls it makes and the pauses between them (a long reply being written) end no turn. A notice posted at a turn end is actionable, so an idle agent whose host wakes it for one is woken to act on it, and an MCP caller reads it on its next tool call. Every other notice is posted at a moment an agent at work reads what is posted with what it does next: an MCP caller's tool call, and a tool call of an open DotBot turn, after which DotBot makes another model request and reads the notices (driver). So it rides that work: a host that wakes an idle agent for any notice that lands is woken only by a turn end's first word on a state. The uncommitted count is what zm status reads as changes to commit: a file listed only because its references moved (its bytes are the branch head's) is not counted (uncommittedOf). The reminders of each world are kept while the engine runs, so a world swapped away from and back to is not told again what it was told.
Usage: local world_vcs.publishReminders = require("@builtin::modules.world_vcs.publishReminders")
modules/world_vcs.publishReminders/driver
driver(worlds: Worlds, turns: Turns): Driver
The live driver's two entries, over the reminders of each world
(worlds) and where agents' turns end (turns): poll(guid, newestCall, now, epochS) is one read, every TICK_S, of who is at work on the world
guid, and dotbot(guid, event, now) takes one of DotBot's turn events.
An agent at work hears what the reminders post with what it does next: an
MCP caller with its next tool call, and DotBot with the model request that
follows a tool call of its, which reads the notices. So while a DotBot
turn is open the reminders speak at its tool calls (tool_start), and a
poll then posts nothing: a post at another moment of the turn can land
after the turn's last model request, where DotBot's host starts a turn of
its own for it. The world's status is read at most every STATUS_S, by
either entry.
Parameters
worldsWorlds— The reminders of each world (worlds).turnsTurns— Where agents' turns end (turns).
modules/world_vcs.publishReminders/engineOps
engineOps(): Ops
The reminders' operations over this engine: the session branch's
unpublished counts from world.vcsStatus (uncommittedOf) and the
commits ZeroMind does not hold, the world record from ZeroMind, and
notices addressed to every caller, each read by a person as its catalog
key.
modules/world_vcs.publishReminders/new
new(ops: Ops): Reminders
Reminders over ops: activity() says an agent is at work now and
hands it what a turn end held for it, idle() says no agent is at work
now, tick() runs the rules that hold while an agent works, and
turnEnded() runs the turn-end rule for every notice.
Parameters
opsOps—{ now, counts, presentation, post, withdraw }.
modules/world_vcs.publishReminders/presentationOf
presentationOf(record: any): Presentation?
What a world record states about the world's release: whether it is a draft and who it is published to once it is not, whether it holds a description and a cover image, and whether the reader can edit it.
Parameters
recordany(optional) — A world record aszeromind.world'sgetWorldanswers it.
modules/world_vcs.publishReminders/start
start()
Start the reminders over the live engine, once per engine: a task
reads whether anybody is at work every TICK_S and the world's
unpublished counts every STATUS_S while an agent works, and DotBot's
turn events and the quiet of the engine's tool calls end turns (driver).
Called as a world becomes ready.
require("modules.world_vcs.publishReminders").start()
modules/world_vcs.publishReminders/turns
turns(): Turns
Where agents' turns end, from what the engine sees of them:
dotbot(event, now) takes one of DotBot's turn events and answers
whether it starts a tool call (tool_start), after which the turn makes
another model request and DotBot reads the notices before it, and
poll(newestCall, now, epochS) takes the newest tool call a caller that
states no turns of its own made (milliseconds since the Unix epoch,
__presence.newestTurnlessCall: every caller but DotBot, whose own events
say where its turns are and whose host calls the engine between them,
reading the notices it might wake on) and answers
whether an agent is at work now, whether a turn ended since the last
poll, and whether the work is a DotBot turn that is open. A DotBot turn
ends at its end event whose reason is completed;
any other turn ends once the tool calls go quiet for QUIET_S after one.
While a DotBot turn is open (an event of its within TURN_OPEN_S, no
end yet) the calls and the quiet are DotBot's, and end no turn.
Once DotBot has worked here, it sits between turns whenever no turn of
its is open, and its host starts a turn for any notice that lands then:
while it does, another caller's calls end that caller's turns but read as
no agent at work, so nothing but a turn end posts.
modules/world_vcs.publishReminders/uncommittedOf
uncommittedOf(status: any): number
How many changes a world's status holds for a commit to take: each
path its staging area or working tree holds changed, counted once, and
each installed asset whose rows differ from the branch head. A file
listed only because its references moved (reason = "references moved":
its bytes are the ones the branch head holds) is left out, as zm status
leaves it out when it reads a working tree with nothing to commit.
Parameters
statusany(optional) — A status asworld.vcsStatusanswers it.
require("@builtin::modules.world_vcs.publishReminders").uncommittedOf(world.vcsStatus())
modules/world_vcs.publishReminders/worlds
worlds(make: () -> Reminders): Worlds
The reminders of each world an engine authors, made by make the
first time a world is asked for and kept for as long as the engine runs:
a world swapped away from and back to keeps what its reminders told.
Parameters
make() -> Reminders— The reminders for a world, made once per world guid.
modules/world_vcs.sceneEdits/README
require("@builtin::modules.world_vcs.sceneEdits") -- world_vcs.sceneEdits
The live scene edits the world's publication calls are judged on: a scene's runtime dirty overlay and the paths that name it, the edits an overlay holds that the saved scene file does not carry, the notice that names the ones a call left out, and the refusal a call raises over them. Reads the scene saver, assetTypes.scene.shared.saver, where it loads.
Usage: local world_vcs.sceneEdits = require("@builtin::modules.world_vcs.sceneEdits")
modules/world_vcs.statusRead/README
require("@builtin::modules.world_vcs.statusRead") -- world_vcs.statusRead
Reads the derived-output part of a staging-area status payload: the reservations of the named stage and of the caller's sealed stages, the sealed commits with what each waits on, and the capabilities the backend lacks.
Usage: local world_vcs.statusRead = require("@builtin::modules.world_vcs.statusRead")
modules/world_vcs.statusRead/derivedView
derivedView(decoded: any): DerivedView
The derived-output view of a decoded status payload: derived holds
the named stage's reservations and then each sealed stage's (with
sealedIn the commit id), sealed each sealed commit in sealedAt
order with the required outputs neither done nor empty as waitingOn and the
failed ones with their error, and unavailable the refusal text of each
capability the backend lacks.
Parameters
decodedany(optional) — The decoded__spacetime_vcs.statuspayload.
modules/world_vcs.statusRead/statusLines
statusLines(status: any): { string }
The lines zm status prints for a status table's computed outputs
and sealed commits, in the order printed: a blank line and the group
title, then one line per computing or failed output (a computing
output whose hook is not registered in this engine says so and names
zm derived provide and zm unseal as the ways out), and the same for
each sealed commit with what it waits on or the output that failed.
A sealed commit the backend refused to land prints the refusal under
it with the zm unseal that returns it, and the commits sealed after it
read as queued behind it. A group with nothing to list prints nothing,
and a sealed commit that publishes once it lands says so on a line of
its own. A push queued behind sealed commits that ZeroMind refused once
it ran prints the refusal under a title of its own.
Parameters
statusany(optional) — A table withderived,sealedandqueued_pushasworld.vcsStatusreturns them; a sealed commit'srefusalis the backend's answer when it could not land.
for _, line in ipairs(statusRead.statusLines(world.vcsStatus())) do print(line) end
modules/world_vcs.statusRead/updateLine
updateLine(u: any): string
The one line zm status and zm diff print for a library update the
working tree holds: the library, the commit the head pins it at and the
one the working tree does, how many files it repins, and how many files
holding edits of their own it reaches (each listed on its own as well).
Parameters
uany(optional) — APinUpdateasworld.vcsStatus().updateslists it, or theupdateof aworld.diffentry (counts in place of lists).
statusRead.updateLine({ library = "@builtin", from = "2836c81aa", to = "6865af4bb", repins = { "/zero/source/a.luau" }, edited = {} })
modules/world_vcs.statusRead/updateLines
updateLines(status: any, staged: boolean): { string }
The lines zm status prints for the library updates the working tree
holds, one per update under the section it belongs in: staged picks the
updates the calling area holds, otherwise the ones it does not.
Parameters
statusany(optional) — A table withupdatesasworld.vcsStatusreturns it.stagedboolean— Whether to list the staged updates.
statusRead.updateLines(world.vcsStatus(), false)
modules/world_vcs.ulid/README
require("@builtin::modules.world_vcs.ulid") -- world_vcs.ulid
The commit ids world_vcs allocates: ULIDs in Crockford base32, 48 bits of millisecond timestamp and 80 bits of math.random() randomness, and the check that a ref has that shape.
Usage: local world_vcs.ulid = require("@builtin::modules.world_vcs.ulid")
modules/world_vcs.vcsWire/README
require("@builtin::modules.world_vcs.vcsWire") -- world_vcs.vcsWire
The wire helper every __spacetime_vcs.* caller shares: waits for one of its promises and unwraps the payload, restating the backend errors that read as something other than what happened, and reads the answers a read or a publish gives back.
Usage: local world_vcs.vcsWire = require("@builtin::modules.world_vcs.vcsWire")
modules/world_vcs.vcsWire/awaitVcs
awaitVcs(promiseId: any): (boolean, string)
Wait for one of the __spacetime_vcs.* promises and unwrap its payload.
Parameters
promiseIdany(optional) — The promise a__spacetime_vcs.*call answered.
modules/world_vcs.vcsWire/clarifyVcsError
clarifyVcsError(errMsg: string): string
Restate the real cause and the action of a backend error, keeping the original for debugging.
Parameters
errMsgstring— The error text after theERR:marker.
modules/world_vcs.worldReady/README
require("@builtin::modules.world_vcs.worldReady") -- world_vcs.worldReady
Counts the times a world's content finishes landing, so a call that swaps what the session is bound to (a checkout, the return trip after a failed one) waits for the swap to land rather than for a fixed time.
Usage: local world_vcs.worldReady = require("@builtin::modules.world_vcs.worldReady")
modules/zerojs.compiler/README
require("@builtin::packages.zerojs.compiler") -- zerojs.compiler
Compiles a JavaScript AST (zerojs.parser) to Luau source that executes against the SAME realm value model as the interpreter (zerojs.runtime). Objects, prototypes, the stdlib, typed arrays and the bridge are shared, so compiled code interoperates with interpreted code and host marshaling with no second value model. Speed comes from eliminating per-node dispatch and environment lookups, plus integer-indexed array fast paths (rt.iget/iset). compile returns Luau source; load returns a chunk taking the runtime companion rtc (built by makeRtc from a realm + its global object). A construct outside the covered subset raises "compile bail:
Usage: local zerojs.compiler = require("@builtin::packages.zerojs.compiler")
modules/zui/README
require("@builtin::modules.deprecated.zui") -- zui
DEPRECATED: Author screens as raw widget trees ({ type, style, props, children }) styled with the engine's CSS-parity ui.* surface; read @builtin::examples.ui.* for complete worked screens. This convenience layer predates CSS parity and writes unlike CSS.
Usage: local zui = require("@builtin::modules.deprecated.zui")
modules/zui/defineWidget
defineWidget(name: string, builderFn: (any, any) -> any)
Register a custom widget kind. builderFn(props, children) is
called at registerScreen / updateScreen time and its return value
is decoded in place — the renderer never sees the custom name.
Validates args locally so misuse fails immediately rather than
silently. Requires the engine ui global; off-host execution
raises a clear error.
Parameters
namestring— Non-empty widget name (the value of{ type = name, ... }).builderFn(any, any) -> any—(props, children) -> widgetbuilder.
Z.defineWidget("myCard", function(props, children) return ... end)
modules/zui/set
set(widgetId: string, key: string, value: any)
Per-widget state write. Persists value against
(widgetId, key) so a Luau-defined widget can own state across
frames without threading it through the app's reactive store.
No-op when the engine ui.widgetStateSet global is missing.
Parameters
widgetIdstring— The widget instance id.keystring— State key within the widget.valueany(optional) — New value.
Z.widgetState.set("toggle:1", "on", true)
modules/zui/unregisterWidget
unregisterWidget(name: string)
Unregister a previously-defined custom widget. No-op when the
engine ui global is absent.
Parameters
namestring— Non-empty widget name.
Z.unregisterWidget("myCard")