Log inGet started

The engine

Updated December 1, 2026

A live, shared world

Every world is a multi-user session. Everything you do is live — your edits sync to everyone else in the world as you make them, and you see theirs. There is no "save" step: with a world bound, writes are durable the moment you make them (more on persistence next). The world's filesystem is the source of truth; "what you see is what exists."

Publishing a playable version for players is a separate, deliberate act (commit/push) — covered in the worlds guide. Saving and publishing are different things.

Your work reaches the user's client while it runs. A write to canonical source reaches a running play session in place, and a play-shadow edit you make in play reaches the clients in your play room, and a client in edit mode sees it once you promote it (core/vfs has the terms). state.rooms.<room> says which clients share a room and whether they run the same content (sameContent), so a two-player test is your own sub-client and the user's client in play on one scene, and one read of that field. A call on the user's client (client: "user") changes what the person sees: a scripted camera move or a mode flip changes the view they are reading and moves under their controls, which is why work they have no need to watch goes in your own sub-client. Running a call in the user's client is your decision whenever the task needs it, your own sub-client being unavailable included, and it needs no confirmation from the person. When a change is the point, write it from your call; a change made through a component stays on the client that ran the component.

What persists

Durability comes from the world holding /zero/source, so the first question is which world that is. world.guid() answers it: a guid when one is bound, nil on a bare local boot. With no world, /zero/source is a session buffer — a write is taken, reads back exactly as written for the rest of the run, and ends with the process. The engine says so on every such write, in the notice your tool call carries back; world.create / world.swap bind a world and end it.

With a world bound, the filesystem boundary is the whole story:

  • /zero/source/... — durable. Anything you write here persists (it's stored in the backend and synced to everyone). This is where all authored content lives. No save step.
  • /zero/runtime/... — live runtime state. Never persists; it's rebuilt as the world runs.
  • /zero/source/tmp/ — local scratch that does not sync to other clients and is gone when the engine stops. Use it for throwaway working state.
  • /zero/source/local/ — this machine's own content for the world and user: it never syncs, and it survives restarts.
  • /zero/source/.authoring/ — the authoring folder: what the world's writers keep for each other (notes, plans). It persists and syncs like the rest of /zero/source, and it is read and written by the writers' own code alone (the editor, the agent's tools, execute): a world script, component, installed library, loadstring chunk or shell command a world ships is refused it, an account that reads the world without writing it is refused it, and no play session, pack, export or carried closure holds it. The home world's is at /zero/home/<you>/.authoring/. Its memory/ folder holds the world's memories, which every agent working in the world is given (guides core/agent-memory, the memory toolbox).

So "will this survive a reload / be seen by others?" has a simple answer: it survives if a world is bound and it's under /zero/source, and others see it if it is outside tmp/ and local/.

Edit vs play

engine.mode is "edit" or "play", and you flip it directly:

engine.mode                 -- "edit" or "play"
engine.mode = "play"        -- enter play
engine.mode = "edit"        -- back to edit
engine.setMode("play", { strict = false })            -- enter play, waiving the script gate for this call
engine.onModeChange(function(newMode, oldMode) end)   -- react to flips
  • Edit is where you author. Entering it stops the gameplay clock, so component update(dt) / fixedUpdate(dt) go idle and editorUpdate(dt) takes over — set engine.paused = false here and all three tick together (see the pause section below). Writes to /zero/source are durable.
  • Play is where gameplay runs. update ticks once a frame and fixedUpdate once per physics step, straight after it.

Entering play doesn't just "start ticking": the engine snapshots the edit state, re-initialises a fresh play world (so components re-run awake/start in play), and a write to /zero/source lands on the play shadow: live in the session, and shared with every client in the same play room (core/vfs has the play-session terms). Leaving play discards that play world and restores the edit snapshot, whichever exit ends the session (an agent's guarded exit, the editor's Stop or Back, a component writing engine.mode = "edit"): a shadowed write is put back to its pre-play copy unless it was kept, and a file play created goes away, so edit mode and the next play session start from source as it stood before this one. A scene saved during play is a shadowed write like any other. A restart ends it, and survivesRestart on the write's report says so. (The exact component lifecycle across the flip is in the components guide.)

Play belongs to the callers in the play session

Several agents drive one engine, and play belongs to the ones taking part in it. The play session is the caller that entered play and every caller that writes engine.mode = "play" (or calls the play tool) while it runs. engine.playSession names them and says whether you are one:

engine.playSession   -- { agents = { { key, agent } }, takesPart } in play, nil in edit
  • Taking part. Your /source writes land on the play shadow, and engine.mode = "edit" (or the edit tool) takes YOU out of the session. While other callers are still in it, the engine keeps playing for them: the exit answers for your own work alone (the source files you edited in play and the entities you tuned), engine.discardPlayChanges() throws away exactly that, engine.setMode("edit") answers leftPlaySession = true with mode still "play", and your writes land on canonical source from then on. The last caller to leave takes the engine to edit, and its exit answers for everything the session left behind.
  • Not taking part. You author beside the session: your /source writes land on canonical source as they do in edit, and no exit from play judges them. Leaving play is the session's to take, so your engine.mode = "edit" is refused, naming the session's callers; engine.waitForEdit(reason) tells them you are waiting, and engine.mode = "play" joins. Ending their session for them is a deliberate act: engine.setMode("edit", { endSession = true }) takes the engine to edit for every caller and answers for everything the session holds, and engine.discardPlayChanges() arms its discard. The simulation is one for the whole engine, so the entities, the cameras, the clock and every capture are the session's play world: an entity you change through the ECS goes back to what the scene holds when the session ends, and the engine says so in a notice the first time you tune one. The run-state block a capture carries answers for you: playSession.takesPart reads false and its note names the session, so a camera the session's game spawned is not mistaken for your edit view.
  • Alone. A session of one caller is the whole engine's play: its exit takes the engine to edit, as does a flip no caller is named for (the editor's Stop button, a component). No guard asks about a flip no caller is named for, and it restores the edit snapshot all the same: what the session left on the shadow goes back to its pre-play copy. A caller whose connection ended no longer holds the session open, and the next exit judges what it left.

Every write no caller is named for (a component, the engine's own work) lands on the shadow. A tool call whose transport named no caller comes from outside the simulation, whichever tool it is: its writes (a write_file or edit_file, an execute and the tasks it spawns, a bash command and the background jobs it starts, a use_tool call) land on the shadow when play was entered, or asked for while it ran, with no caller named (a call naming none, the editor's Play button, a component), and on canonical source otherwise. A tool call a component's Luau makes through mcp.call is the component's own, so its writes land on the shadow with the component's. Any other agent on the engine is authoring beside the session, so its writes, and the writes of the tasks its calls spawned (a generation finishing, an import it runs, a shell command it runs through bash and the background jobs that command starts), land on canonical source as they would in edit mode, and the play-exit somebody else takes leaves them where they are. What the engine does on its own after such a write is the simulation's: the automatic import of a loose file waits for play to end or pause. A caller is one connection to the engine, and the agents one agent session runs (its sub-agents) share that connection: each of them that passes its own name in the as argument every tool takes, on every call, is a caller of its own, with its own play session, play-shadow writes, roster name, shell session and notices, while the work all of them write is staged and committed as the connection's. Agents sharing a connection that do not name themselves count as one caller. vfs.durability(path, { pending = true }) answers for the caller asking.

engine.discardPlayChanges() arms that discard for a flip the safeguard refused: it returns paths, the source files the flip would throw away as it stands, and keep, the routes that keep any of them first, and posts a notice naming them. The exit then throws away what it answers for as it stands when it runs, your own edits while other callers stay in play and every edit the shadow holds when it ends the session, and names each path it took in a notice and the engine log. The arm is the caller's own, and a call no caller is named for cannot be told apart from any caller, so the exit that ends the session also takes a discard armed for the whole session from the other side of that line: an exit no caller is named for takes the one a named caller armed, and a named caller's exit takes the one a call no caller was named for armed. An agent whose transport names it on some calls (execute) and not on others (edit) thus arms and leaves as one caller. A write made with { durable = true } lands on canonical source, and the discard keeps it.

Keeping one does not cost you play. vfs.promotePlayShadow(path) — or a list of paths — takes them onto canonical source with the session still running, and vfs.write(path, bytes, { durable = true }) states the destination up front so the write skips the shadow entirely. vfs.durability(path) answers where any write's bytes went and names both routes; the core/vfs guide has the model, the whole set a folder write shadows, and what each route costs the rest of the session.

Entering play is also gated on the scripts you answer for being healthy: while a script in the world's own content carries an error-severity diagnostic, engine.mode = "play" raises instead of flipping — refusing to enter play — N script error(s) in your own content: followed by the offending path:line — message entries. The world's own content is every script under /zero/source except library content under /source/libs and /source/deps, session scratch under /source/tmp and this machine's own content under /source/local (the shell's /tmp and ~): the same files zm.push checks, so a half-written scratch script there, or in your home folder under /zero/home, holds up neither play nor a push. Content an install carries that the world never changed is its package's: an error there refuses play only in a file play runs (a component, a scene entrypoint, or a script they reach through require or tools.use), and the refusal names it as the package's by name and version (N script error(s) in the installed package <name> <version> (<where it is installed>), in code play runs:); an error in an installed file play does not run, such as the package's own test suite, is logged under the package's name and lets play start. Neither holds back zm.push, and editing an installed file makes that file the world's own. Run lsp.checkAll({ scope = "user" }) to list them yourself, fix them, and flip again; lsp.check(path) checks any one file, scratch included. The gate is calibrated by the lsp.strict world setting: "strict" (the default) blocks on any error, "soft" blocks only structural errors (syntax, unresolved require, broken lifecycle-callback signatures), and "off" logs a warning and proceeds. Returning to edit is never gated — you can always get back to fix the error. Neither override carries to publishing: zm.push refuses unconditionally while user-script errors exist, whoever wrote them (see the development guide).

You answer for what you wrote and for the world you opened — the content already there when you bound it, including your own from an earlier session. A file a neighbour wrote while you were already running is reported rather than gated: the flip proceeds and the diagnostics go to the engine log. Theirs to finish, since you hold a copy and correcting it would write over an edit still in flight. Read the log after a flip to see what rode along: /zero/runtime/logs/engine reads it as a file, and the logs toolbox's search tool narrows it to the lines another session's content raised.

To take one flip past a diagnostic without changing the gate for anyone else, pass the strict waiver on the call:

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

engine.setMode is engine.mode = ... with the gate under your control for that one call: the world's lsp.strict_mode is untouched, so every other session and every later session of the world keeps the gate it had, and report.bypassed (mirrored into the engine log) names exactly what the call went past. lsp.setStrictMode is the other lever and a different one — it writes lsp.strict_mode into the world settings, which every session reads.

Paused vs running

Pause is a separate axis from edit/play. engine.paused gates the gameplay tick:

engine.paused = true        -- freeze gameplay
engine.timeScale = 0.5      -- or slow it down (1.0 real, 0.0 frozen, 2.0 double)

When paused, update(dt) / fixedUpdate(dt) stop — but editorUpdate(dt) keeps firing, so the authoring loop stays live. engine.timeScale scales time without fully stopping it. Both are orthogonal to engine.mode: edit/play and paused/running are independent, which is why the pair has four states and not two. A mode flip resets the flag to that mode's default (edit paused, play running), so the two axes look like one until something writes engine.paused — and in edit with the clock running, update and editorUpdate fire together. core/components has the table.

Who holds the run state

One process runs one simulation, and several agent sessions drive it at once. The mode is decided by the callers in the play session (above), and so is everything else the session's simulation runs on: the pause, the clock rate and simulated input. Both cells name the caller that flipped them:

engine.pauseOwner   -- who asked for the standing pause: { id, agent, name, heldSeconds } or nil
engine.modeOwner    -- who flipped the engine out of its boot mode: { id, agent, name, heldSeconds } or nil

id is the caller key vfs.currentAuthor().id reads, so the run state and the play-shadow set name the same caller. agent is the name the world's roster holds for that caller now, the name to ask it by: name is its account's username, which every agent of one account shares. pauseOwner is nil while the engine is running and nil when the standing pause is the mode's own rather than something somebody asked for. modeOwner names a caller only while it holds the mode: it is nil in the mode the engine booted into (the flip back to it ends the hold), once the caller that entered play has left the session (which may keep running for others; engine.playSession names them), and once that caller is no longer on the world's roster.

Every result an agent gets from a play-mode engine that is not stepping carries a runState block saying so, naming the holder. It is decided per call rather than from whether the state snapshot moved, because under a steady pause the snapshot never moves: state reports unchanged and the pause would go unmentioned. Every capture result carries the same block whatever the engine is doing, and the frame block a capture tool returns carries paused, gameplayReady and pausedBy beside frame and sceneTime: a frozen simulation and a still scene hand back the same rising frame, the same rising scene time and the same bytes, so a pair of captures taken to prove motion reports a difference of exactly zero either way.

The play and edit tools answer for both cells, because the state each one names covers both: play leaves the engine in play mode AND running, so it resumes a standing pause, and edit leaves it in edit mode AND at rest, so it takes one. Either tool reports the state it produced, { mode, paused, resumed, settled } for play and { mode, paused, froze, settled } for edit, where resumed and froze answer for the move the call made: a play call that met a stopped simulation and left it running answers resumed true whichever of the two cells it wrote to do it, and edit answers froze the same way. engine.mode moves the moment it is written, and the scene follows over the frames after it, as the flip unloads the root layer and loads it again for the new mode; both tools answer once that rebuild has ended, so settled is true and the entities the caller reads next are the new mode's. A call made from code that cannot yield answers settled false while the rebuild runs, and layers.rebuildInFlight() reads true until it ends. Through MCP, a rebuild that outlasts the call's inline budget answers with a handle to wait on: the flip has happened, and calling the tool again only waits on the same rebuild, so wait on the handle instead. The pause play will not lift is one another caller holds: it refuses and names them, since the frozen moment is what their session is working on, and engine.paused = false (paused: false through the pause tool) is the deliberate way past that.

A play session holds the simulation in play for every caller outside it, so a caller whose edit-mode work needs the engine in edit (an entity edit the session's end would undo) says so and the session hears it:

local done = engine.waitForEdit("promote my scene edits")
-- the run state on every response now names this caller as waiting
done()                      -- or reaching edit mode takes every wait off
engine.editWaiters()        -- what the session holding play reads

What a play session owns, and what every caller shares

While a play session runs for other callers, a caller outside it moves none of the controls its simulation runs on, because each one lands in the test the session's callers are running: engine.paused (the pause tool too), engine.timeScale and engine.holdTimeScale, Physics.advance (the phys toolbox's advance too), and simulated input (Zin.test, Zin.scheme.drive and undrive, and the inputSim toolbox: its presses and drives, the device class it forces and the pointer lock). engine.releaseTimeScale hands back the holds the caller took itself, so a hold taken before the session began is always the taker's to release, and a key naming a hold another caller took is refused. Each is refused with a sentence naming the session's callers and the way in: engine.mode = "play" joins the session, after which the caller shares them. engine.playControlRefusal(control) answers that sentence, or nil when the caller may move the control, for a tool or a script of your own that drives the session's simulation. The simulation's own gameplay code (a component's hooks and the tasks they spawn, task.class() == "gameplay") moves them as part of the session whoever attached the component, and a person at the window is never refused. A capture whose cells span a stretch of game time (duration) taken from outside the session samples the clock as it runs, since pinning it would pause the session. A test run is refused in play for everybody, because a suite empties the world it runs in; the refusal a caller outside the session meets names the session, and engine.waitForEdit(reason) tells its callers.

The callers in one session share one simulation: one mode, one pause, one clock, one set of held keys and touches, one viewport and one frame clock, and one copy of every module's state, so two of them testing at once reset each other's game. Joining a session is agreeing to that. Work that needs a simulation of its own runs in a client of its own: on the desktop editor a sub-client on a world no other sub-client is on (man subclient; an editor runs one sub-client per world), or a separate engine.

How fast time passes

The engine steps on its own. Its frame loop runs whether or not a tool call is in flight, so the real seconds between two of your calls are seconds the world spent running: in play with the clock running, a twelve second gap that nothing called into left a component holding twelve more seconds of update(dt), and two calls sent back to back with no wait between them were nearly three seconds apart. The durationMs on a tool result measures that one call and not the gap before it, so it is not the number to read elapsed gameplay from.

Two consequences, pointing opposite ways:

  • Wait for real seconds, then read. This works. Idle wall clock buys the same simulated seconds, in every state below where the gameplay clock is running.
  • Start it, then poll. This samples seconds apart rather than milliseconds. Enter play and read a position on the next call and a launched body has already crossed the course. To watch something mid-flight, sample it inside ONE call: with the clock running, read the value, task.waitFrames(n), read it again, and return the whole series from that call. Across calls, engine.timeScale = 0.1 slows the world so the next one arrives while the motion is still going, and engine.paused = true freezes it where it stands, so a read or a capture is of that exact moment. To check a result, read the settled end state with data (positions, rotations, raycasts) rather than sampling a series.

Which clock each callback is on:

stateupdate(dt) / fixedUpdate(dt)editorUpdate(dt)
edit, paused (edit's default)idleruns
edit, runningrunsruns
play, running (play's default)runsidle
play, pausedidleruns

engine.timeScale multiplies the seconds update(dt) and fixedUpdate(dt) receive and the seconds task.wait counts, so at 0.25 a second of wall clock hands a component a quarter of a second of dt and a task.wait(0.5) takes two seconds to come due.

Which clock a wait counts on follows what it waits for. A wait that is part of the game (a timed sequence, a cooldown, a delay the player sees) counts the game's seconds with task.wait or task.delay, so it slows, stops and starts again with the rate. A wait for anything else counts the wall clock with task.waitRealtime: a measurement window, a poll for work outside the simulation (a GPU readback, a network or ZeroMind call, a file), a timeout, a retry backoff and a test's bound. profiler.frameCost({ seconds = n }) and the profiler toolbox's flamegraph(seconds) measure n wall-clock seconds, and compute_abi.read waits on the wall clock for its readback, so each answers at every rate, 0 included. A tool call (execute, use_tool, wait) whose task waits on the game's seconds while that clock stands still (engine.timeScale at 0, or a gameplay pause for a gameplay task such as one a component spawned; execute runs its code as a system task, whose clock runs on through a gameplay pause) is answered about a second later, still running, with heldClock naming the clock, what holds it and who, and the ways on: hand the rate back (engine.releaseTimeScale(key) for a hold), wait on the wall clock instead, or end the task with task.cancel. An answer of a call whose task still runs carries latestOutput once that task or a task it spawned has written a line: the last lines they wrote (lines, oldest first) and how many they have written (total), so a long install, update or build says how far it has got, and a ZeroMind read it is making again says how often it has failed and the call's bound. A bash command's Luau (zero, zm, luau, run), and every task that Luau starts, writes its lines to the output of the task awaiting the command as it prints them.

A material animated from time (the time a shader's vertex() and fragment() read) runs on the world's seconds at that same rate: it slows with engine.timeScale and stops while a play is paused. Edit mode runs it whatever the pause, so the viewport shows water, grass and effects moving while you author. An editor nobody has attended for three seconds draws such motion at its preview rate (below).

Physics runs on that same clock at that same rate: a dynamic body covers the distance a real second of falling covers. So a body's travel between two of your calls is the travel those real seconds bought, and engine.paused and engine.timeScale are what hold it still enough to watch. To get a physics outcome over many simulated seconds in less wall time than they cover, Physics.advance runs a stated number of steps (or simulated seconds) as fast as the machine computes them, each the step this clock runs, from a paused clock or a running one; the physics guide's "Running a measurement faster than real time" covers it.

To run the whole game faster than real time (a scripted playtest, a balance match played several times, a timed sweep over cars or levels), wrap the run in engine.fastForward(body, { frameRate }). Every frame while body runs steps the game by exactly 1 / frameRate seconds (60 unless stated) whatever the frame cost, and the frame loop runs the next frame as soon as the last one ends; nothing is drawn for a frame nothing reads, a window on screen presents a glimpse four times a second, and a capture or recording gets every frame it reads. Physics, components, scripts, task.wait, task.delay, getTime() and time.time() all see the frames a steady display at that rate brings, so the outcome is the one a real-time run at that frame rate gives, and the call answers what body returned with a report: frames, gameSeconds, wallSeconds and speedup. Drive the player with real input inside it (inputSim goTo, aimAt, jump, playthrough), and measure game time with the seconds task.wait returns or time.time(), never os.clock() or time.realtime(), which read the wall clock the run outpaces. A run is faster than the game it plays wherever a frame computes in less than 1 / frameRate seconds; a lower frameRate covers more game a frame. One run holds at a time, and it ends when the engine mode changes.

getTime(), time.time() (the same reading, under the namespace's name) and time.realtime() are a different quantity. All three read the wall clock (inside engine.fastForward getTime() and time.time() count the run's steps instead), and none of them is scaled by engine.timeScale or stopped by engine.paused: across a paused span a component receives no dt at all while getTime() advances by the whole span. Drive gameplay and animation from the dt a callback receives or from task.wait, and keep getTime() for when something happened and time.realtime() for a wall-clock duration. time.frameCount() counts the frames the engine ran, and task.waitFrames(n) waits on exactly that counter.

Seconds the engine LOST are refused. A frame costing far more than the frames around it reads as a hitch rather than as the rate, and the world takes only a ceiling of it: four times the interval the engine has been holding, and never under 0.1 seconds. A script that blocked a single frame for two seconds gave getTime() and time.realtime() the whole two and gave update(dt) a tenth of a second, so an engine that stalls resumes where the world was instead of teleporting every animation and filling the physics accumulator in one step.

Every target behaves this way: a headless engine, a windowed one, one bound to a live world and one running in a browser all advance the world by the wall-clock seconds of a gap nothing called into.

An engine that is still runs fewer frames. Still means the renderer has nothing to draw, the gameplay clock is stopped (edit mode with the clock paused, or play paused), no work is under way (a task.defered task or a settled task.await to resume, commands waiting to be applied, a tool call in flight, a background shell job at work: one a shell started with &, for as long as it is neither only sleeping nor stopped) and no key, button or touch is held. Sound plays on through a still engine: the audio output feeds itself on its own clock, streamed music and ambience included, so a playing sound keeps no frame running. Its loop then runs a frame at once when something arrives (input, a tool call, a promise settled on another thread, a loaded file, a file written, a message from another participant, a frame or an answer on a websocket a script holds, a request to a route), and otherwise when the earliest wait a task holds comes due, with frames at least a quarter of a second and at most a second apart. So in a still editor time.frameCount() advances at most 4 times a second, a task.wait() or task.waitFrames(1) loop polls that often (and keeps the editor at that rate: a watch with nothing to read while nothing moves waits with task.waitFrames(n, { wake = false }), which counts the same frames and asks a still engine for none; a calm animation that steps at a rate of its own below the display's names that rate, task.waitFrames(1, { wake = 30 }), and a still engine runs its frames that far apart, at 30 a second, while a timer stated the same comes due on its deadline), and a timer comes due on the first of those frames at or after its deadline: a task.wait(2) returns after two seconds and at most a quarter of a second more. editorUpdate(dt) (a component's, and a scene entrypoint's) and update(dt) run on every frame the engine runs, with the seconds since the last call, and ask a still engine for none: a still editor ticks them on the frames it runs for something else (at least one a second), and input, a call, a write or a message runs the frame that ticks them at once. The moment something moves, frames run at the full rate again. renderer.framePacing() reports engineStill, movingBecause, per reason the frames that kept the engine moving (movingFrames), and what ran each frame of a still engine (wokenBy): the first arrival since the frame before when it ran early (input / pointer, call / tool call or shell job, write / file written, message / datagram, ...), else the schedule its tasks set (task waits on frames, task timer, task waits at its rate, longest gap). renderer.activity() names what keeps an engine busy in one reading: its frame rate and CPU over the last ten seconds, what moves it, and the owners whose changes keep its picture redrawing (redrawReasons, the component and entity a script writes, the screen a UI pass lays out).

A headless engine that nobody observes (an agent's sub-client, or a primary engine started without a window) runs its gameplay at a lower rate. Nobody observes it while no tool call is in flight in it, no key, button, touch or pad is held, nothing reads its frames (a capture, a readback, a recording) and no take or replay steps it. Its loop then runs at most 10 frames a second (20 while another participant shares a room with it, the rate what it owns is sent at), and the world's clock takes every waited second whole: update(dt) receives the same seconds in fewer, longer frames, physics catches each frame up by its fixed steps, and a task.wait(2) still returns after two seconds. The first call into it, a capture, input or a request to one of its routes runs its next frame at once, and every frame while a call is in flight runs at the full rate; a message from another participant, a file written or a settled promise is taken on its next frame. renderer.framePacing() reports the gap in force as unobservedGapMs, and unobservedWaits and unobservedSeconds count the frames held back and the seconds waited.

An editor whose picture alone moves draws that motion at a preview rate once nobody attends it. The picture alone moves when a material reads the frame clock, clouds drift, or content moves things in editorUpdate(dt) while the gameplay clock is stopped and no other work keeps the engine moving. Nobody attends the editor once three seconds have passed with no key, button, touch, pad or wheel input, nothing reading its frames (a capture, a readback, a recording) and no change of its UI, window or surface. Its loop then runs one frame per 1 / edit_preview_rate seconds (15 frames a second unless the world's .world_settings states another edit_preview_rate under [render]; 0 draws such motion at the full rate), and every one of those frames draws. The world's clock takes every waited second whole, so the water, clouds and editorUpdate(dt) move as far per second as they do at the full rate, in fewer, longer steps, and a task.wait comes due on the first of those frames at or after its deadline. The first input, call or capture runs its next frame at once. After input or a capture the frames run at the full rate again for three seconds. An agent's call is not a person attending: a tool call runs the frames it is in flight for at the full rate and leaves the preview rate in force once it is answered, so an agent calling every second leaves the editor at its preview rate between its calls. Play mode is never held to it, and neither is a world that asked for every frame (renderer.setDrawEveryFrame(true)). renderer.framePacing() reports the rate as previewFps, the gap in force as previewGapMs, and previewWaits and previewSeconds count the frames held back and the seconds waited. While its window holds no input focus (another window has it, the browser page is blurred or hidden, the Android activity lost its window focus) the preview runs at no more than 2 frames a second, and the window taking the focus back or any input runs the next frame at once.

Who is holding the clock

engine.timeScale is one number for the whole process. Several agents drive one engine at once, and the rate one of them sets for a hitstop is the rate every other one's entities, physics and task.wait deadlines run at. A run that computes a delta of its own from getTime() or time.realtime() is on the wall clock while everything around it is on the scaled one, so at 0.25 it moves four times as far per second as the world it is measuring. Multiply a self-computed delta by engine.timeScale, or read time.deltaTime() or the dt a callback receives, which already have it applied.

engine.timeScale                -- the rate in force
engine.timeScaleOwner           -- who it answers to: { id, name, scale, exclusive, held } or nil
engine.onTimeScaleChange(function(new, old, who) end)   -- every move of it, whoever made it

To run at a rate for a stretch, hold it rather than assigning it. A hold records who took it and refuses a plain engine.timeScale write while it stands, so the rate cannot move under a measurement without the measurement hearing about it:

local release = engine.holdTimeScale(0.08)              -- hitstop, attributed to this caller
release()                                               -- the previous rate is back

local pinned = engine.holdTimeScale(1, { owner = "duel-measurement", exclusive = true })
-- while that stands, another agent's engine.holdTimeScale and engine.timeScale = n
-- are refused with an error naming "duel-measurement"
engine.releaseTimeScale("duel-measurement")             -- hands it back by key, from any call

Holds nest and are counted: the innermost names the rate, and the rate that stood before the outermost is back once the last is released. The release is a closure, so a hold taken in one tool call and left to a later one is handed back by key instead. Every hold answers to a key even when the call states none, and engine.timeScaleOwner.id reads it, so a rate left pinned by a task that ended is always recoverable:

local who = engine.timeScaleOwner
if who ~= nil and who.held then
    engine.releaseTimeScale(who.id)                      -- takes that key's holds off the stack
end

World lifecycle

engine.profile        -- "editor" or "runtime" (read-only; the boot profile)
engine.worldLoaded    -- true once the world's entrypoint has finished loading
engine.onWorldReady(function() end)    -- content synced into the VFS, installed packages in place
engine.onWorldLoaded(function() end)   -- the world entrypoint has run (latched: fires immediately if already loaded)

A world boots: its content syncs and the packages it installs materialize (onWorldReady), then /source/.world_entrypoint.luau runs (onWorldLoaded), which loads the startup scene and seeds defaults, so the startup scene finds an installed package by ~name.

Finding the rest

engine is an authored module — read it at modules/api/engine/engine.module. Publishing and ZeroMind are in the worlds guide; how components behave across edit/play is in the components guide; how a loaded world surfaces players and the camera is in the scenes guide.

  • documentation
  • guide