Protocol: world, part 1 of 2#
The world commands a program sends to a running game, as the engine describes them: what each takes, what it answers and what it does. Back to all commands.
world.entities#
world.entities {with?: [text]} -> {entities: [record]} · read, read-only
Lists the living entities, or only those that have every given component.
| Parameters | Type | Meaning |
|---|---|---|
with? | [text] | Component names an entity must have. Left out: every entity. |
| Result | Type | Meaning |
|---|---|---|
entities | [record] | One {id, name, parent, file, line, placed} per entity, in the order of their slots, which scripts walk too. name is the scene name, or null when the scene gave none; parent is the name its Parent part gives (what it is under), or null when it is under nothing; file and line say where its table is written, or are null for a thing made at run time. placed is where a thing under a parent with a Transform is in the world and is drawn, {at: [x, y, z], turn: [x, y, z, w], scale: [x, y, z]} (a 2D turn is about z), its own Transform being local to that parent; null for any other thing, whose own Transform is where it is. An editor draws a thing's handles at placed when it has one. The Things tree orders siblings by file and line (included scenes first, then the scene's own text), things made at run time after, by slot. What is drawn over what is the layer's and depth's to say, never the tree's. |
world.get#
world.get {entity: text, component?: text} -> {entity: text, components: record} · read, read-only
Reads the fields of one entity: of every component it has, or of one.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
component? | text | Only this component. Left out: every component the entity has. |
| Result | Type | Meaning |
|---|---|---|
entity | text | The entity's id. |
components | record | Each component name with an object of its fields and their values. |
world.bone#
world.bone {entity: text, joint: text} -> {at: [number], turn: [number], scale: [number]} · read, read-only
Reads a named model joint's world pose from the live components, without drawing.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
joint | text | A unique model node name. |
| Result | Type | Meaning |
|---|---|---|
at | [number] | World x, y, z. |
turn | [number] | World quaternion x, y, z, w. |
scale | [number] | World scale x, y, z. |
world.series#
world.series {entity: text, component: text, field: text, from?: integer, to?: integer, against?: text, run?: text, buckets?: integer} -> {step: integer, from: integer, to: integer, played_from: integer, against: text, run: text, values: [record], buckets: [record]} · read, read-only
Reads one field's value at every step of a stretch of the recording, or the least, the most and the last of each of a number of stretches of it: what a timeline draws as a value over time. The stretch is played again aside, in a game of its own loaded as game.seek would load it, from a keyframe when a proven one stands at or before it: the game, its snapshots, its keyframes, its log, its sound and its step records are not touched. It costs playing that far: about 10,000 steps a second in a release build.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity, by its scene name or by its id as world.entities gives it. A name is looked for again at each step, so an entity made again under it is followed, and one that lives only in another scene is found there; an id is that one entity. Where none is, the value is null. |
component | text | A component name, as world.components lists them. |
field | text | The field's name. E0004 for one the component does not have. |
from? | integer | The first step. Left out: 0, the game as loaded. |
to? | integer | The last step, at most 36000. Left out: the step the game is at. |
against? | text | "accepted": the values of the game as it was last accepted (frost test --write keeps it in .frost/accepted beside the project file), played from those files and the recorded input, in place of the game's own: what a timeline draws as the accepted run beside the one now. Left out: the game's own. |
run? | text | Another of the game's recorded runs, read in place of the game's own: a project file with a replay in the game's folder, named from it with / as frost test lists them (tests/jump.toml), played aside from step 0 on its own recording. With against, that run as accepted. The game being served, and the run it plays, are not touched. Left out: the game's own. |
buckets? | integer | Cut the stretch into this many, 1 to 2,000, as equal as whole steps allow, and give the least, the most and the last value of each in place of every value. Left out: every value, for a stretch of at most 3,600 steps. |
| Result | Type | Meaning |
|---|---|---|
step | integer | How many fixed steps have run. |
from | integer | The first step. |
to | integer | The last step. |
played_from | integer | The step the stretch was played from: a keyframe's, or 0 when the game was loaded for it. |
against | text | "accepted" when the values are of the accepted game, else null. |
run | text | The run asked, as it was named; null for the game's own. |
values | [record] | One {step, value} for each step of the stretch, the value as world.get gives it after that step (step 0: the game as loaded), null where the entity is not or lacks the component. null with buckets. |
buckets | [record] | With buckets: one {from, to, min, min_step, max, max_step, last, last_step} per stretch, no more of them than the stretch has steps. min and max are of a number field's values in it, each with the first step it was at; last is the value after its last step, with that step; each null where there was none. null without buckets. |
world.query#
world.query {with?: [text], without?: [text], where?: [record], fields?: [text], tag?: text, limit?: integer} -> {step: integer, total: integer, entities: [record]} · read, read-only
Finds entities by their components and field values, and reads the fields asked for: one call for what world.entities and a world.get each would take.
| Parameters | Type | Meaning |
|---|---|---|
with? | [text] | Component names an entity must have. Left out: every entity. |
without? | [text] | Component names an entity must not have. |
where? | [record] | Conditions an entity must pass, each {field: "Component.field", op, value}. op is one of = != < <= > >= and may be left out for =. An entity without the component does not pass. |
fields? | [text] | What to read of each entity: "Component.field", or "Component" for all its fields. Left out: every field of the with components. |
tag? | text | One word an entity's Tags list must hold, as a whole word (its words are apart by commas or spaces): "pushable". Left out: any or none. |
limit? | integer | The most entities to return. Left out: 100. |
| Result | Type | Meaning |
|---|---|---|
step | integer | How many fixed steps have run. |
total | integer | How many entities matched, of which at most limit are returned. |
entities | [record] | One {id, name, components} per entity, in the order world.entities lists them. components is as world.get gives it, with only what was asked for and the entity has. |
world.set#
world.set {entity: text, component: text, field: text, value: value} -> {entity: text, component: text, field: text, value: value} · write
Writes one field of one component of one entity. A scale that a collider cannot take (a circle, a sphere or a capsule scaled unevenly, or any collider scaled by 0) is refused (E0471) and nothing changes; the writes of one world.apply are held to that together, so three of them scale a ball evenly.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
component | text | A component name, as world.components lists them. |
field | text | A field of that component. |
value | value | The new value, of the field's type. |
| Result | Type | Meaning |
|---|---|---|
entity | text | The entity's id. |
component | text | The component. |
field | text | The field. |
value | value | The value as stored. |
world.spawn#
world.spawn {name?: text, under?: text, components: record} -> {entity: text, name: text} · write
Makes an entity in the running game, as a script's spawn does: for an editor to show a change to a scene without loading the game again. No file is written, so the scene file stays the truth and game.reset puts the game back to it; a replay of input.history does not repeat it. No script is told: on_scene is not called.
| Parameters | Type | Meaning |
|---|---|---|
name? | text | The entity's name, as a scene file's key gives one. A name a living entity has is refused (E0006). Left out: no name. |
under? | text | The name of the entity it is under, which its Parent part then gives: a group (an entity with no Transform), or a thing whose Transform it is placed from. Left out: under nothing. |
components | record | Each component the entity has, by name, with an object of the fields to set; a field left out has its default, and {} is the component at its defaults. What a scene file writes under an entity, as JSON. A mistake in any of it, a picture, clip or text style the game has not loaded, or a Tween that names no number field (E1004, E1003) or no easing (E1002), makes no entity. |
| Result | Type | Meaning |
|---|---|---|
entity | text | The new entity's id. |
name | text | Its name, or null when none was given. |
world.move#
world.move {entity: text, under: text, before?: text, keep?: text} -> {entity: text, under: text} · write
Puts an entity under another, or under nothing, in the running game: a drag in the Things tree, as one change. Under a thing with a Transform its Transform is local to that thing's; under a group (no Transform) or nothing it is in the world. No file is written, so the scene file stays the truth and game.reset puts the game back to it. blame.value names this client as the writer of Parent.of.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
under | text | The name of the entity to put it under, or "" for under nothing. One that would make a loop is refused (E0455), and so is a Body or Mover under a thing with a Transform. |
before? | text | Not yet: a thing's place among its siblings is the order of the scene's text, and moving its table there is the scene door's edit, which cannot move a table yet. Given, the move is refused and nothing changes. |
keep? | text | "world": it stays where it is in the world, its own Transform worked out again under the new parent (a 2D one's Rotation and Scale too). "local", the default: its own Transform stays as written and it moves with the new parent. |
| Result | Type | Meaning |
|---|---|---|
entity | text | The entity's id. |
under | text | What it is under now: a name, or null for nothing. |
world.despawn#
world.despawn {entity: text} -> {entity: text} · write
Removes an entity from the running game, as a script's despawn does. No file is written, and game.reset brings back what the scene file has.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
| Result | Type | Meaning |
|---|---|---|
entity | text | The id of the entity that was removed. |
world.insert#
world.insert {entity: text, component: text, fields?: record} -> {entity: text, component: text, fields: record} · write
Puts a component on an entity of the running game, which keeps its id: for an editor's "Add a part". It is held to what world.spawn is held to, and one that is refused leaves the world as it was, checksum and all. An entity that has the component already is refused (E0413): world.set changes its fields. No file is written, so the scene file stays the truth and game.reset puts the game back to it; a replay of input.history does not repeat it. blame.value names this client as the writer of every field of the part, the defaults too.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
component | text | The component's name, as world.components lists it. |
fields? | record | The fields to set, as world.spawn's components give them: a field left out has its default. Left out, or {}: the component at its defaults. A mistake in any of it, a picture, clip or text style the game has not loaded, a shape the physics cannot make or a Tween that names no number field puts nothing on. |
| Result | Type | Meaning |
|---|---|---|
entity | text | The entity's id, the one it had. |
component | text | The component's name. |
fields | record | Each field of the component with its value now, as world.get gives them. |
world.remove#
world.remove {entity: text, component: text} -> {entity: text, component: text, gone: [text]} · write
Takes a component off an entity of the running game, which keeps its id: for an editor's "Remove". A tween of one of the component's fields goes with it. What needs the component refuses the remove, with the code that says why and the world as it was: a joint that holds the entity by its Collider (E1111), a TileCollider beside its Tilemap (E1107), a node that is in this one (E1301). A script then sees the entity as any that lacks the component: has() is false, each() leaves it out, and get or set of it stops the step with E0003. No file is written, and game.reset puts back what the scene file has; a replay of input.history does not repeat it.
| Parameters | Type | Meaning |
|---|---|---|
entity | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |
component | text | The component's name. An entity that does not have it is refused (E0003). |
| Result | Type | Meaning |
|---|---|---|
entity | text | The entity's id, the one it had. |
component | text | The component's name. |
gone | [text] | The ids of the tweens that went with it: each changed one of the component's fields. Usually empty. |
world.apply#
world.apply {writes: [record]} -> {writes: [record]} · write
Makes several writes to the running game as one: each in order, as its own command makes it (world.spawn, world.insert, world.set, world.remove, world.despawn), and all of them or none. When one is refused the world is as it was before the first, checksum and all, and the error is that write's, its code kept, naming its place: writes[N]. A write names the entity of an earlier one as "$N" (N from 0): spawn a thing, then put a part on "$0". One answer and one entry in session.hands; blame.value names this client as the writer of every field written. For an editor's one undoable step ("Paint tiles") or an agent's change that must not stop half way. No file is written, and game.reset puts back what the scene file has.
| Parameters | Type | Meaning |
|---|---|---|
writes | [record] | The writes, in order. Each is {"op": "spawn" | "insert" | "set" | "remove" | "despawn"} with the parameters of that command: {"op": "set", "entity": "$0", "component": "Transform", "field": "x", "value": 10}. |
| Result | Type | Meaning |
|---|---|---|
writes | [record] | Each write's answer, in order, as its own command answers. |
world.components#
world.components {} -> {components: [record]} · read, read-only
Lists every component the game has, with its fields, their types and defaults, and what each is in a sentence.
| Result | Type | Meaning |
|---|---|---|
components | [record] | One {name, about, fields, declared} per component; each field is {name, type, default, role, range, about}. type is f32, f64, i32, u32, bool or str; floating defaults and values that are not finite are null in JSON. about is what it is, in a sentence, or null: for the engine's components and their fields what the reference says (each has one), and for the game's own components and their fields the comment lines right above their declaration in the project file (a field has a line of its own only under [components.Name]). A comment is documentation: nothing checks it. role says what the value means beyond its type: "color" for a whole number that is a colour as 0xRRGGBB, "entity" for a text that is the name of an entity (empty for none), null for nothing more. range is {min, max, step} for a number meant to stay inside it (step may be null), null otherwise; nothing enforces it. declared is {file, line}, where the project file declares the component, null for the engine's own. |
Generated from Coldwave 0.0.1 r289, 2026-11-30 by the binary itself: do not edit by hand.