engine
The engine namespace — the engine's Luau API reference for engine.
The engine namespace — 14 functions.
globals/engine/discardPlayChanges
globals/engine/discardPlayChanges() -> any
globals/engine/gameplayReady
globals/engine/gameplayReady() -> any
globals/engine/gpuCompute
globals/engine/gpuCompute() -> any
globals/engine/mode
globals/engine/mode() -> any
globals/engine/offWorldLoaded
globals/engine/offWorldLoaded(id: number) -> boolean
Remove an onWorldLoaded subscriber by its watcher id.
globals/engine/onModeChange
globals/engine/onModeChange(callback: (string, string) -> ()) -> number
Register a callback that fires synchronously whenever
engine.mode changes. Callback receives (newMode, oldMode) as
strings. Returns a watcher id for future removal. Consumers
(player_spawner, camera_spawner, editor-UI bootstrap, world
entrypoint top-level onModeChange, etc.) all subscribe through
this single API — there is no other fire path. Mode is engine
state, so the watcher hangs off the engine module.
globals/engine/onPauseChange
globals/engine/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.
globals/engine/onWorldLoaded
globals/engine/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.
globals/engine/onWorldReady
globals/engine/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.
globals/engine/onWorldUnloading
globals/engine/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.
globals/engine/paused
globals/engine/paused() -> any
globals/engine/profile
globals/engine/profile() -> any
globals/engine/timeScale
globals/engine/timeScale() -> any
globals/engine/worldLoaded
globals/engine/worldLoaded() -> any