Builtin Library
README.md
zeromind.swap
Move the engine onto a different world without restarting the process. The engine loads the world the way it loads one at boot: it checks the world exists and that you may open it, then leaves the world that is running (its world entrypoint's onWorldUnload and every engine.onWorldUnloading subscriber run, its scene and the entities in it are unloaded, and the entities it made with no scene loaded are despawned) and moves onto the new world, whose content syncs and whose startup scene loads. The call returns once the engine has moved; from then on filesystem and versioning operations run against the new world's workspace, and world.syncStatus().binding reports its content arriving. A world that does not exist, that you may not open, or that is asked for while another world load is running is refused with the reason, and the engine stays on the world it was on with that world still running. It can target a world's live editable workspace or a frozen commit for read-only inspection, and optionally enter play mode as part of the swap.
In an agent's own client the user's client makes the same switch of world once this one has (its play/edit mode stays its own, so mode is not carried); { follow = false } leaves it where it is. In the user's client follow is false, and in a sub-client made with client create it follows only with { follow = true }. The user's client switches on its own time, so the call returns once this client has switched; the engine state's split lists a sub-client that is on another world or branch than the user's client until the user's client has caught up, and a switch the user's client could not make is told to you as a notice. world.swap(guid, version, mode, branch, { follow = false }) takes the same option.