# Protocol: blame

The `blame` 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](../protocol-commands.md).

## blame.on

`blame.on {on?: value} -> {step: integer, on: value, since: integer, whole: value, fields: integer, runs: integer}` · read, read-only

Starts or stops keeping who writes each field of the world and who makes each entity, for blame.value and blame.entity. It changes nothing in the game: the checksum and every frame are the same with it on. A game that has only played its recording so far is played again to this step with every write kept from the first, so the answer is whole. A game a client has stepped or changed cannot be, and one with snapshots kept is not (playing it again would forget them): what was written before now is then not known, and `whole` is false, until game.reset or game.seek plays it again. A snapshot holds what was kept when it was taken; game.restore leaves blame on or off as it is, and puts back a world from before blame was on as one whose writes are known from that step. Off, nothing is kept and nothing is paid. It needs only read trust: asking why changes nothing.

| Parameters | Type | Meaning |
| --- | --- | --- |
| `on?` | value | true or false: false stops and forgets. Left out: true. |

| Result | Type | Meaning |
| --- | --- | --- |
| `step` | integer | How many fixed steps have run. |
| `on` | value | Whether writes are kept now. |
| `since` | integer | The step from which they have been kept. null when off. |
| `whole` | value | true when every write since the game was loaded is kept, the scene files' among them. |
| `fields` | integer | How many fields have a history now. |
| `runs` | integer | How many runs of writes those histories hold between them: what it costs in memory, about 60 bytes each. |

## blame.value

`blame.value {entity: text, component: text, field: text, history?: integer, step?: integer} -> {step: integer, entity: text, component: text, field: text, value: value, since: integer, writer: record, history: [record], played_from: integer, recording: value}` · read, read-only

Says why a field holds the value it does: who wrote it last, in which steps, and what it was before. Needs blame.on, unless `step` is given: then it says so of the field as it stood at that step of the project's recording, played again aside from the moment the session kept at or before it (a keyframe of a seek, which carries its writers while blame is on and is proven on the way as a seek back proves it), or from the files with every write kept when there is none to use, and the game asked of is left as it was: its step, its checksum, its world, blame on or off. The entity is found at that step (a name followed to whatever thing has it then). Within the kept window it costs at most the steps to the keyframe before it (Ballast: under 50 ms).

| 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. |
| `field` | text | The field's name. |
| `history?` | integer | How many runs of writes to list, the latest first: at most 8 are kept for a field. Left out: none, only the last writer. |
| `step?` | integer | The step of the recording to answer at, from 0 to 36000. The step the game stands at, with blame on, is the game as it stands (strayed from its recording or not). Left out: the game as it stands. |

| Result | Type | Meaning |
| --- | --- | --- |
| `step` | integer | How many fixed steps have run. |
| `entity` | text | The entity's id. |
| `component` | text | The component's name. |
| `field` | text | The field's name. |
| `value` | value | The field's value now. |
| `since` | integer | The step from which writes have been kept. |
| `writer` | record | The last run of writes: {kind, ...}: kind is "scene" (with file and line), "script" (with file, line, the function the line is in, null at a script's top level and for a C# script, whose value a step's columns wrote is at the line its Step is declared on, and text, the line itself as the code read when it ran, trimmed, at most 200 bytes, null where the engine did not see that code load or the code is older than the newest 32 versions of its file; and callers: up to two {file, line, function, text} that called that function, the nearest first), "system" (with system: "ui", "physics" or "animation"; physics adds on when it wrote for a mover that stood on something: the id of what it stood on, or null when that entity is gone), "client" (a protocol command, with the trust it had and its hand, who and agent: the number, the name and whether an agent that its connection gave with session.hello, or 0, "a client" and false) or "engine", and beside it first and last (the steps of the run's first and last write: a write in step n is seen once the game is at step n), writes (how many), old (the value before the run), old_step (the step old was written in: the last of the run before, null when that run is not kept) and new (the value after it). A run is every write by one writer with no other writer between. For a field nobody wrote, {kind: "default"} when the whole game was watched and {kind: "unknown"} when it was not. |
| `history` | [record] | The runs asked for, the latest first, each in the shape of writer. |
| `played_from` | integer | With step: the step the play to it started from (a keyframe's, or 0 from the files); null when it is the step the game stands at. Left out without step. |
| `recording` | value | With step: true when the answer is of the project's recording played again, false when of the game as it stands. Left out without step. |

## blame.entity

`blame.entity {entity: text} -> {step: integer, entity: text, name: text, since: integer, made: record}` · read, read-only

Says who made an entity: the line of the scene file that wrote it, or the line of the script that spawned it, and in which step. Needs blame.on.

| Parameters | Type | Meaning |
| --- | --- | --- |
| `entity` | text | The entity's scene name, or its id as world.entities gives it, like "e3.0". |

| Result | Type | Meaning |
| --- | --- | --- |
| `step` | integer | How many fixed steps have run. |
| `entity` | text | The entity's id. |
| `name` | text | Its name, or null. |
| `since` | integer | The step from which writes have been kept. |
| `made` | record | {kind, ...}: kind is "scene" (with file and line), "script" (with file, line, the function the line is in, null at a script's top level, and text, the line itself as the code read when it ran, trimmed, at most 200 bytes, null where the engine did not see that code load or the code is older than the newest 32 versions of its file; and callers: up to two {file, line, function, text} that called that function, the nearest first), "system" (with system: "ui", "physics" or "animation"), "client" (a protocol command, with the trust it had and its hand, who and agent: the number, the name and whether an agent that its connection gave with session.hello, or 0, "a client" and false) or "engine" with the step it was made in. null when it was made before writes were kept. |

## blame.gone

`blame.gone {name: text} -> {step: integer, name: text, since: integer, alive: value, gone: record, said: text}` · read, read-only

Says who let a thing of a name go: the last thing of that name that was despawned, in which step, and by what (the script line, a scene loaded in its place, a client's command). What a script's find(name) that gave nil was asking about. Needs blame.on; only what went while writes were kept is known. A local of a script that is nil is not answered here.

| Parameters | Type | Meaning |
| --- | --- | --- |
| `name` | text | The thing's name, as a scene or a script gave it. |

| Result | Type | Meaning |
| --- | --- | --- |
| `step` | integer | How many fixed steps have run. |
| `name` | text | The name asked. |
| `since` | integer | The step from which writes have been kept. |
| `alive` | value | true when a thing of that name is there now. |
| `gone` | record | {entity, step, scenes, kind, ...}: the last thing of that name to go, its id, the step it went in, scenes {from, to} when it went because a scene changed (the scene it left with and the one started in its place; null for a despawn), and who despawned it, or asked for that scene change, as blame.entity's made says a maker (kind "script" with file, line, function, text and callers; "client" with its hand; "system"; "engine"). null when none of that name went since writes were kept. |
| `said` | text | The same in words: "hero went with room1 at step 250, when main.luau:14 loaded room2", or "hero was despawned at step 250 by main.luau:14"; null when gone is. |

## blame.pixel

`blame.pixel {x: integer, y: integer, view?: record} -> {step: integer, x: integer, y: integer, since: integer, hits: [record], passes: [record]}` · read, read-only

Says what is drawn at a pixel of the frame and why it is there: every entity that draws there, the one in front first, with who made it and who last wrote its place and its layer. What is drawn there is what frame.at answers, which needs no blame. Needs blame.on.

| Parameters | Type | Meaning |
| --- | --- | --- |
| `x` | integer | The pixel's column, 0 at the frame's left edge, as in a frame.capture at full size. |
| `y` | integer | The pixel's row, 0 at the frame's top edge. |
| `view?` | record | {left, bottom, right, top}, as frame.capture takes it: x and y are then pixels of that picture at its full size (before width and height shrink it), and boxes are counted in them too. Left out: pixels of the frame. |

| Result | Type | Meaning |
| --- | --- | --- |
| `step` | integer | How many fixed steps have run. |
| `x` | integer | The column asked. |
| `y` | integer | The row asked. |
| `since` | integer | The step from which writes have been kept. |
| `hits` | [record] | One record per entity that draws at the pixel, the one in front first, with everything frame.at says of it (entity, name, kind, tile, node, layer, alpha, coverage, added, fills, box, turned, pass, material) and two things more. made is as blame.entity gives it. placed is one {component, field, value, writer} for each of Transform.x, Transform.y and the layer of its kind, writer as blame.value gives it; for a thing under a parent with a Transform, whose own Transform is local to it, one more for the Transform.x and Transform.y of each such parent, the nearest first, with of: the parent's name. In a 3D game, the thing drawn at the pixel (frame.at's drawn: the nearest triangle drawn, whatever colliders there are) is one of them, among the layers as the passes draw it: {entity, name, kind: Mesh, pass, drawn (as frame.at gives it), made, placed}, placed for Transform.x, y and z, Mesh.file and Pose.clip where it has one. |
| `passes` | [record] | The frame graph's passes the pixel came through, the last first: {name, into, read, x, y} with draws = "layers" or effect = its name; x and y are the same place in the pixels of the target the pass writes (fewer in a smaller target). An effect's value at the pixel is made from what it read there; the hits were drawn by the pass each names. |
