Builtin Library
README.md
modules.api.engine.world_entrypoint
The user-space world-entrypoint loader. Subscribes once per VM to
engine.onWorldReady / engine.onWorldUnloading (fired by the trusted
VM via world.markReady() / world.markUnloading() once content sync
has written the world's bytes into the VFS) and drives the world's
onWorldLoad / onWorldUnload / onModeChange callbacks — the SAME way
scene_loader.runEntrypoint loads a scene entrypoint:
loadstring(vfs.read("/source/.world_entrypoint.luau")) into a fresh
sandboxed env, run the body, auto-discover the top-level lifecycle
functions, and route them to the canonical event hooks. Pure user-space,
callback-driven, and fully decoupled from the connection / boot / seed
race — nothing here is Rust- or trusted-VM-driven. Installed once from
prelude.luau.
An entrypoint that fails — compile error, a body that raised, an
onWorldLoad that raised — is reported at error level, and the world's
configured world.startup_scene is loaded so the world still comes up on the
scene its settings name. A world that already carries a root layer when the
failure lands, and one whose startup_scene slot is clear, are left exactly
as the entrypoint left them.
Each of those paths also fires the world-loaded latch once it has taken the
world as far as that entrypoint takes it, so engine.worldLoaded reads true
and every engine.onWorldLoaded subscriber resolves on a failed entrypoint
the same way it does on one that ran to the end. A world with no entrypoint
fires it as soon as it is ready.
onWorldLoad runs on its own task, and the world is loaded when it returns:
the latch fires then, and the boot's loading screen stays up until the
window shows the frame after it. Work that runs for the whole session goes in
a component, a service, or a task.spawn that onWorldLoad starts and
leaves running.