Builtin Library
README.md
playable
The playable milestone: whether the world is ready to play right now (could someone jump in and play it), what is still missing when it is not, and since when it has been ready. A screen offering Play, a test, a tool or a content run measuring the time to a first playable version reads it, waits on it or subscribes to it while the world is being built, in edit mode as well as in play.
Two things set it, and source says which:
- The scene (
"scene"): its play entry would spawn a player the person controls. The active scene's player intent is"spawns", a PlayerSpawn names a well-formed PlayerPrototype, the prototype's body carries a component that holds an input map (CharacterController, VehicleController, or a controller of your own with aninputMapfield) that activates (every.inputBindingcontrol of the map reads sound, as activation requires; a map that cannot activate readsplayer.controls_cannot_activate), its camera rig holds the Camera the player sees through, and on a touch device the input map binds a touch control. In play it reads the player play spawned: the local player's avatar carrying controls, and a main camera. - The agent (
"agent"):playable.declare({ by, note })states it, for a game the scene rule cannot see. It stands untilplayable.withdraw(), or until the engine moves to another world.
While both hold, source reads "both". When the scene does not set it,
missing lists why, each entry a stable code and the message to act on.
local s = playable.state()
if not s.playable then
for _, m in ipairs(s.missing) do print(m.code, m.message) end
end
local ok, state = playable.wait({ timeout = 120 }) -- hold until playable
local h = playable.onChange(function(now, previous)
playButton.visible = now.playable
end)
playable.offChange(h)
playable.declare({ by = "DotBot", note = "First version: tap the ball to bounce it" })
The engine judges it on every frame it runs, so a subscriber is told by the next
frame after the change, and onChange fires each time the world goes in or out
of the playable state. first keeps the first time the world reached it since
it was opened (at in Unix seconds, engineTime, frame, source), so a run
measures its time to first playable after the fact. While a world is being left
and the next one opened (a swap, a branch checkout, a reload, a leave) the
milestone reads not playable (world.loading). The agent's statement, first
and the change count belong to the world they were made in: once the next world
is ready they are cleared when it is another world (another guid, or another
branch of it) or when either world could not be read, and kept when the same
world comes back (a refused move, a reload of the world). A statement made while
the move runs is about the world arriving, and stands in it. A trusted screen reads the same verdict
through /zero/trusted/playable, and tools.use("scene", "playable") reads,
waits on and declares it from a tool.