# Coldwave: every page > A game engine for 2D and 3D where every run replays. --- Page: index.md # Coldwave: make the game, replay every run Coldwave is an engine for 2D and 3D games, in private development. Write gameplay in Luau or C#, change it while it runs, and ship one game to the web, the desktop, iPhone and Android. Open source at launch, MIT or Apache-2.0; no fees, no revenue share, no account, no telemetry. [Read the docs](docs/index.md), starting with [your first game](start/first-game.md). ![Caravan, an open-world game made with Coldwave and written in C#: the oasis at dusk](files/media/caravan/oasis_dusk.webp) ## A tested 3D game in three commands ```terminal $ frost new mygame --template embers $ frost check mygame/game.toml $ frost test mygame mygame/game.toml: ok: 2653 steps to run checksum c3c50481c8ab98c7 $ frost dev mygame/game.toml ``` Measured from `frost` 0.0.1 r289. ## What makes Coldwave different - **The engine is the server.** `frost serve` and `frost mcp` hand your game to any program: step it, press its keys, read and change its world, take a picture. No editor has to be open, and there is no account or licence key. - **Every run replays exactly.** Sixty fixed steps a second and a checksum for each. When a run stops matching, `frost test` names the step, the value and the script line that wrote it, and `frost blame` tells you who wrote a value and when. - **Changes go on trial before you keep them.** An AI agent works on its own copy of your game. Its change is tested against your recorded run and against what it said it would change, shown over the picture, and kept only when you say so. - **Your game is text.** A project file, scenes in TOML whose things you refer to by name, scripts in Luau or C#. Git merges it, you review it like code, and an agent reads it. - **Agents see exactly what you see.** A frame on request, what is drawn at any pixel and how it is lit, shots with every collider drawn, kept pictures compared on every test, stable error codes as JSON from `frost check --json`, and the whole reference printed by `frost reference`. - **Fair, for good.** Open source at launch, MIT or Apache-2.0 at your choice. No fees, no revenue share, no account and no telemetry. ## You and your agent drive the same engine The editor has no private way in: everything it shows comes through [the protocol](concepts/protocol.md), so whatever you can do by hand, an agent can do. ![The Coldwave editor with the Ballast template open](files/media/editor.png) ## Working with an agent, start to finish 1. **Open.** `frost new` sets the game up for Claude Code and Codex: skills, an `AGENTS.md` and an MCP server. 2. **Watch.** The agent joins the game you are playing; its edits appear in your window and mark the timeline. 3. **Prove.** Each change is replayed against your recorded run before it can land. 4. **Keep or undo.** Keep it, or not this one; later, [undo one change](guides/undo-landing.md) and keep everything made after it. 5. **Measure.** `frost bench --json` gives the agent where each step's time went. [Start here, for agents](agents/index.md). ## Made with Coldwave - **Caravan.** An open-world road in 3D, written in C#: guard a caravan from the steppe to a mountain pass. - **Scrap Riot.** A twin-stick factory brawler, ported from Unity. Every recorded shift replays exactly, and it runs in the iPhone simulator with touch controls. - **Held Note.** Deep-sea horror in 3D, explored by the light of a welder's torch. - **The templates.** Embers, Cinder, Ballast, Vigil and more: finished small games to start from. [See the showcase](showcase.md). ## Fast by design, measured in the open - No garbage collector in the engine: Rust underneath, and no allocation in the engine's frame loop. - A C# script is lent each component as the world's own memory, a span per field. - Shaders are built ahead of time, so nothing compiles while you play. - `frost bench --check` fails when a game goes over its time budget. An empty game exports to 4.6 MB for the desktop; on the web it is 1.1 MB gzipped with WebGPU and {{facts:empty_game.web.webgl2.gzip|mb2}} with WebGL2. A median step of the Embers template takes 0.044 ms (`frost bench`, `frost` 0.0.1 r289, measured 2026-11-30). ## Bring your game Each page maps what you know to what Coldwave calls it. There are no automatic importers yet. [From Unity](from/unity.md), [from Godot](from/godot.md), [from Defold](from/defold.md), [from Unreal](from/unreal.md). ## Where your game runs today | Where | Today | | --- | --- | | Web | `frost export web` writes a folder for any static host. Tested in Chrome, WebGPU and WebGL2 | | Desktop | Tested on macOS on Apple silicon. Linux builds. Windows is not verified yet | | iPhone | Tested in the simulator only. Real devices and signing are not ready yet | | Android | An arm64 apk signed with a debug key, tested in the emulator only | Coldwave is in private development, with no public download yet; it will be open source at launch, under MIT or Apache-2.0. [What works today](status.md) lists plainly what does not work, and [the changelog](changelog.md) what changed lately. Coming next: [a physical sky](soon/physical-sky.md), [GPU skinning](soon/gpu-skinning.md) and [engine effects](soon/effects.md). --- Page: docs/index.md # Coldwave documentation Everything you need to make a game with Coldwave, from installing `frost` to shipping on a phone. Pick the door that fits you; every page is also plain Markdown at the same address with `.md`. ### Start making games New to Coldwave? Build `frost`, make a game from a template and change it while it runs. - [Install `frost`](../start/install.md) - [Your first game](../start/first-game.md), about ten minutes - [The editor](../start/editor.md) ### Learn how it works The few ideas everything else is built on. - [Things and components](../concepts/things.md) - [Steps and determinism](../concepts/steps.md) - [Recorded runs](../concepts/runs.md) - [The protocol](../concepts/protocol.md) ### Guides by area 2D, 3D, physics, input, sound, interface, multiplayer, export. - [2D games](../guides/2d.md) and [3D rendering](../guides/3d-rendering.md) - [Physics](../guides/physics.md) and [input](../guides/input.md) - [Debugging](../guides/debugging.md) and [profiling](../guides/profiling.md) ### Coming from another engine What you know, in Coldwave's words, with code before and after. - [From Unity](../from/unity.md) and [from Godot](../from/godot.md) - [From Defold](../from/defold.md) and [from Unreal](../from/unreal.md) ### For AI agents Short recipes with exact commands and the checks that prove a change. - [Start here, for agents](../agents/index.md) - [Set up Claude Code or Codex](../agents/harnesses.md) - [llms.txt](../llms.txt), every page listed ### Reference Every call, component and protocol command, written by the engine itself. - [Scripting reference](../reference/index.md) - [Protocol commands](../reference/protocol-commands.md) - [Error and warning codes](../reference/errors.md) ## Before you start Coldwave is pre-release. [What works today](../status.md) says plainly what is not built yet, and the [changelog](../changelog.md) what changed lately. --- Page: start/install.md # Install `frost` > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. `frost` is the one program you need. It makes, plays, checks, tests, measures, debugs and exports your games, and it is what the editor and AI agents talk to. It will be a download: you unpack it and put it on your `PATH`, and there is nothing else to install to make and export a game for the web and the desktop. ## Download and unpack The first downloads will be for macOS on Apple silicon, in two kinds: one with Luau, and one with C# scripts as well. Unpack the download where you keep tools, and take macOS's download mark off the folder once, from inside it. The build is not signed, and macOS refuses to start an unsigned program a browser downloaded ("cannot be opened because the developer cannot be verified"): ```sh cd coldwave # the folder you unpacked xattr -dr com.apple.quarantine . ``` Keep the folder together: `frost` reads `players/` and `templates/` from beside itself. ## Put it on your PATH Add the folder to your `PATH`, so you can type `frost` anywhere; these docs write `frost`. For zsh, the shell macOS starts: ```sh echo 'export PATH="$HOME/tools/coldwave:$PATH"' >> ~/.zshrc ``` Write the folder where you unpacked it in place of `$HOME/tools/...`, and open a new terminal. `frost --version` prints the version you have. ## Check that it works Make a game from a template, check it, test it and play it: ```sh frost new --list # the templates, one a line frost new hello --template pong frost check hello/game.toml # checked 7 files: no problems frost test hello # ok: 2124 steps to run checksum ... frost dev hello/game.toml # a window: W and S, Up and Down ``` `frost test` replays the template's recorded match and compares the result with the one written in its project file. If it passes, your `frost` plays games exactly as the engine's own machines do. Next: [make your first game](first-game.md). ## Optional parts Install these only when you want what they give you. If one is missing, `frost` names it when you ask for the thing that needs it. | To | You need | Then you can use | | --- | --- | --- | | Write scripts in C# | The `-csharp` download, and the .NET SDK, version 10 or later | Scripts ending in `.cs` | | Debug C# scripts | netcoredbg on your `PATH` | `frost dap` for a game in C# | | Export for iPhone or Android | A build with the phone players, which the first downloads do not have yet, and Xcode or the Android NDK | `frost export ios`, `frost export android` | Exporting for the web and the desktop needs nothing more: `frost` copies the players that came in the download and compiles nothing. ## On other systems The first downloads are for macOS on Apple silicon. [What works today](../status.md) says how far each other system is tested. ## Working with an AI agent `frost new` sets every new game up for Claude Code and Codex: it writes the reference into the game as skills (`.claude/skills/`), an `AGENTS.md`, and an `.mcp.json` that registers `frost mcp game.toml`. For a game made another way, or after you upgrade `frost`, run `frost skills --here` beside its `game.toml`. See [for AI agents](../agents/index.md). --- Page: start/first-game.md # Your first game > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. In about ten minutes you will have a game you changed yourself, checked, and exported for the web and the desktop. You start from a finished small game, so there is something to play from the first minute. ## 1. Get `frost` [Install `frost`](install.md): download it, unpack it, take macOS's download mark off the folder (`xattr -dr com.apple.quarantine .`) and put it on your `PATH`. The rest of this page writes `frost` for it. ## 2. Start from a template A template is a finished small game. `frost new` copies one into a new folder, and you change a game that already works. ```sh frost new mygame ``` That copies `pong`, the smallest: two paddles and a ball, one script. To start from another, add `--template NAME`: | Template | Is | | --- | --- | | `platformer` | A side-scroller with a tilemap level, a camera and music | | `arena` | One screen, waves of enemies, a score | | `breaker` | A brick breaker: three levels as three scenes, capsules, a combo | | `shooter` | A top-down shooter aimed with the mouse, with a boss | | `ballast` | A physics puzzle in three rooms: a crate to push, a lift, a seesaw, a cart, a drawbridge on a chain, and darts to hide from | | `embers` | A third-person game in 3D: a hero to steer with the camera behind it, ramps, pillars, eight embers to gather and two wardens that chase | | `blank` | One square that moves, with every key of the project file written out, for starting from nothing | This page uses `pong`. Your new folder holds: | File | Is | | --- | --- | | `game.toml` | The project file: which scene and scripts make the game, the window, the game's own components, the keys | | `court.toml` | The scene: every entity the game starts with, by name, with its components | | `pong.luau` | The script: a `step(dt)` function the engine calls sixty times a second | | `sounds/` | Four WAV files, and the Python script that made them | All of it is text you can read, apart from the sounds. ## 3. Play it ```sh frost dev mygame/game.toml ``` A window opens. W and S move the left paddle, Up and Down the right one; first to five wins. To play in a browser instead, add `--web` and open the address it prints. Leave it running for the next step. ## 4. Change it while it runs Open `mygame/pong.luau`. Near the top is a table of numbers: ```lua local TUNING = { ball_speed = 420, -- units a second at the serve ``` Change `420` to `700` and save. The game does not restart: the score and the ball stay where they were, and the ball is faster from the next serve. `frost dev` prints one line for each reload, with how long it took. If you save a mistake, the line says what is wrong and where, the game waits, and it goes on when you save a fix. This works because what the game must remember is not in the script's local variables: it is in components (the score is in the entity named `match`) and in the script's `state` table, and both outlive a reload. ## 5. Add something of your own Pong counts the hits of a rally but shows nothing. Show the longest rally so far. First a place to write it. Add this entity at the end of `mygame/court.toml`: ```toml [best] Transform = { x = 480, y = 28 } Text = { text = "", size = 2, color = 0x8f939d, layer = 2 } ``` `Transform` puts it at the middle of the bottom edge (the frame is 960 by 540, the origin is the bottom-left corner and y grows up). `Text` draws in the built-in font. Then a script to fill it. Make a new file, `mygame/rally.luau`: ```lua -- Shows the longest rally so far. `state` outlives a reload and is saved with the game. state.best = state.best or 0 function step(dt) local rally = get(find("ball"), "Ball", "rally") if rally > state.best then state.best = rally set(find("best"), "Text", "text", "LONGEST RALLY " .. state.best) end end ``` `find` looks an entity up by the name the scene gave it; `get` and `set` read and write one field of one component. `Ball` is a component this game declares itself, in `game.toml` under `[components]`. Last, tell the project about the script. In `mygame/game.toml`, change the `scripts` line to: ```toml scripts = ["pong.luau", "rally.luau"] ``` A new entity or a new script is read when the game starts, so stop `frost dev` (close the window) and start it again. From then on, saving `rally.luau` reloads it like any other. ## 6. Check it without playing ```sh frost check mygame/game.toml ``` lists what is wrong with your game without running it: a key the project file does not know, a component a scene names that nobody declared, a script that does not parse, a picture that is missing. One problem a line, with the file and the line. A game can also be run with no window, for a test or a picture: ```sh frost run --headless --steps 2124 --shot end.png --state mygame/game.toml ``` The template's project file holds a recorded match (`recording`), and `frost run` replays it: 2,124 steps, the same every time and on every machine. It prints the step count, a checksum of the world at the end and one of the whole run, and with `--state` what each script keeps in `state`, so you can see your script worked: `"rally.luau":{"best":4}`. `end.png` is the last frame. The project file also says what that match comes to (`replay = { steps = 2124, checksum = "..." }`), and `frost test mygame` holds the game to it and to its `shots`. The faster ball from step 4 changes how the match goes, so `frost test` now fails: it names the first step and value that differ. When the change is what you meant, accept it, then keep the new pictures once you have looked at them: ```sh frost test --write mygame # writes the new checksum frost check --shots --write-shots mygame/game.toml # keeps the new shots frost test mygame # passes again ``` ## 7. Export it For the web: ```sh frost export web mygame/game.toml --out mygame-web ``` writes the folder a static web host serves: a page, the game's files and two builds of the player, one for browsers with WebGPU and one for the rest. It prints what each kind of browser downloads. Nothing is compiled: `frost` copies the players that came in its download. To try the folder, serve it with any static server, for example `python3 -m http.server --directory mygame-web`. For the system you are on: ```sh frost export desktop mygame/game.toml --out mygame-desktop ``` writes the player, named after the game, with the game's files beside it. Send the folder to someone on the same kind of system; they start the player and it plays. There is no installer, and nothing is signed. To put your game on a phone, see [export](../guides/export.md). ## Where next - [Things and components](../concepts/things.md) explains how a game is put together, and the guides go area by area: [2D](../guides/2d.md), [3D](../guides/3d-rendering.md), [physics](../guides/physics.md), [input](../guides/input.md), [sound](../guides/audio.md). - [The scripting reference](../reference/index.md) has every call and component. Offline, `frost reference` prints its short core, `frost reference CALL` one entry, and `frost reference --search words` finds one. - Give each kind of thing its own component (`Moth = {}`, `Coin = {}`), and a name to a thing there is one of: the editor groups a scene's entities by it, and `each("Moth")` finds them. - The other templates are worth reading even if your game is like none of them: their `kit.luau` is a library of helpers to copy and change (tile collisions, a camera that follows, animation frames, a key pressed this step). - Want an AI agent to work on your game? `frost serve mygame/game.toml` and `frost mcp mygame/game.toml` let a program play it: step the game, hold keys, read and change entities, and take pictures. [For AI agents](../agents/index.md) starts there. - `frost --help` lists everything `frost` does. --- Page: start/editor.md # The editor Coldwave, the editor, is a desktop app for making your game: the running game in the middle, with its things, its code, its assets and its timeline around it, and AI agents working in the same game beside you. Everything the editor shows comes through [the protocol](../concepts/protocol.md), so `frost` and an agent can ask for all of it too. > **Note.** Coldwave is in private development, and there is no download of the editor > yet. Everything on this page can also be done with `frost`. See > [what works today](../status.md). ## Opening a game The editor opens on the game you left, at the moment you left it: press **Continue**. Under it are your games as cards; their recorded runs play under the pointer. At the right are the templates to start from (what `frost new --list` names): pick one, give it a name, and the editor makes it as `frost new` does. ## Two views: Game and Code The title bar switches between **Game** and **Code**, with the game's search in the middle (files and actions) and **Undo** and **Redo** on the right. | Part | Shows | | --- | --- | | The game | The running game, played and picked in place. A press on a thing picks it | | Scene | The scene's things as a tree, by name and by parent | | Inspector | The picked thing's components and fields, as the engine declares them. With nothing picked, the game itself: its `[tuning]` numbers as they run, its window, input, physics, clips and interface | | Files and Assets | The game's files, each drawn as what it is: a sheet as its frames, a sound as its wave, a font in its own letters. Drag a picture into the game to make a thing of it | | The timeline | The recorded run under the game: drag to scrub back and forth, with lanes for events and for what each step cost | | Profiler | Where the time of the step on the timeline went | ## Who wrote this value Ask **Why?** of a field in the Inspector. A card tells you who wrote it (the scene or script line, which opens in Code), what it was before, and its value over the whole run on the timeline. Ask it of the picture, and it tells you what is drawn at that point and how it is lit. On the command line the same answers come from `frost blame` ([debugging](../guides/debugging.md)). ## The profiler A bar of the timeline's cost lane is one step; a press opens the **Profiler** at that step. On the left, the step as an icicle on a time axis: the whole step, its stages in the order they run (input, interface, physics, scripts, animation, layout, events), and under the scripts each script, down to each function and the engine calls it made at their lines; a press on one opens that line. One sentence says what took the most. On the right, the run's worst steps (a press moves the timeline there) and each script's share of the run. When a game cannot keep up with sixty steps a second, **Why?** in the dock says how many it makes and where a median step goes. Every number is the engine's own, and `frost bench` prints the same: see [profiling](../guides/profiling.md). ## Debugging The **Debug** layout shows a stop: the game above, and under the timeline where it stopped and in what, the moves (**Next line**, **Into**, **Out**, **Go on**), the script's lines around the stop and the call path. A script stops at a breakpoint, when paused, or where it raises an error. Because your game replays, you can reach a stop again by scrubbing back. [Debugging](../guides/debugging.md) has the rest. ## AI agents in your game An agent never edits your game directly: it works in its own copy. The **Copies** group lists each copy: whose it is, what it is about, what it changed, what it said it would change, its last test, and the buttons **Test**, **Land**, **Rebase** and **Drop**. - **Land** merges a copy into your game, thing by thing and field by field. The **Landing** tab is the log, and you can [undo one landing](../guides/undo-landing.md) on its own. - A change on trial shows over the picture, with the game as it was on the other side of a divider you drag, and **Keep** or **Not this one** under it. - The timeline has a lane for everyone working in the game, with a mark at each change. - You choose what each agent may do: an agent in plan mode can read and changes nothing. ## Exporting **Where the game goes**, on the right of the title bar, exports your game. For the web, the exported page plays in the editor itself. --- Page: from/unity.md # Coming from Unity You can keep writing C#. What changes is where the game lives: in text files you can read and diff, run at a fixed step so every run replays exactly. There is no importer for Unity projects yet: you rebuild scenes and scripts by hand or with an AI agent, and your art comes across as files. Scrap Riot, a game first made in Unity, was ported this way, and its recorded play-throughs replay exactly. ## What maps to what | Unity | Coldwave | | --- | --- | | GameObject | A thing: a number with an optional name, made of components ([things](../concepts/things.md)) | | `Transform`, `SpriteRenderer`, `Rigidbody2D` | Components: `Transform`, `Sprite`, `Body`, `Collider` | | Your MonoBehaviour's fields | Your own component, declared under `[components]` in `game.toml` | | `Update` and `FixedUpdate` | One `Step(dt)`, called 60 times a second at a fixed step | | `Start` and `Awake` | `OnScene`, called when a scene has started | | Scene (`.unity`) | A scene: a TOML file of named things and their components ([scenes](../concepts/scenes.md)) | | Prefab | No prefab asset yet. Spawn the thing from a script, or keep the group in a scene | | ScriptableObject | A data file a script reads (`data("levels/one.toml")`), or `[tuning]` numbers | | Inspector values in Play mode | `[tuning]` numbers, changed while the game runs | | Input System actions | `[input] actions` and `[input.keys]` in `game.toml`, read with `Input.Get` | | Play mode tests | A recorded run that `frost test` replays to a checksum ([recorded runs](../concepts/runs.md)) | ## Movement A hero that walks left and right. In Unity: ```csharp public class Hero : MonoBehaviour { public float speed = 90f; void Update() { transform.position += Vector3.right * Input.GetAxis("Horizontal") * speed * Time.deltaTime; } } ``` In Coldwave, with a `move_x` action in `game.toml` and a thing named `hero` in the scene: ```csharp using Ven; [State] public struct Game { public Thing Hero; } public static class Main { public static void OnScene(string scene, ref Game game) { game.Hero = World.Find("hero"); } public static void Step(float dt, TransformColumns transform, ref Game game) { int row = transform.Row(game.Hero); if (row >= 0) transform.X[row] += Input.Get(0, "move_x") * 90 * dt; } } ``` The `[State]` struct is what the script remembers between steps. It is saved with the game and restored when a run replays, so the hero is found once in `OnScene` and kept. ## Instantiate becomes spawn In Unity: ```csharp Instantiate(coinPrefab, new Vector3(40, 90, 0), Quaternion.identity); ``` In Coldwave, the components are named and their fields set: ```csharp Thing coin = World.Spawn("Transform", "Sprite", "Coin"); World.Set(coin, "Transform", "x", 40); World.Set(coin, "Transform", "y", 90); World.Set(coin, "Sprite", "image", "art/coin.png"); ``` ## What carries over - **C#.** Scripts ending in `.cs` get the same engine calls as Luau and reload while the game runs ([gameplay in C#](../guides/csharp.md)). - **Your art.** PNG pictures, glTF models with their clips, WAV sounds and OGG music. JPEG is not read yet, so convert those to PNG. - **Thinking in components.** A thing is what its components make it. ## What changes - **Unity's API.** `MonoBehaviour`, `transform.position` and `Time.deltaTime` do not exist. Components reach `Step` as columns; the rest are calls such as `World.Find` and `Input.Get`. - **The frame rate does not change the game.** Every step is 1/60 s of game time. Do not read the clock to decide anything. - **C# runs on the desktop today.** Phones are in progress, the web runs a subset through [FusionCompile](../guides/fusion.md), and a multiplayer game must be written in Luau ([what works today](../status.md)). ## Next [Your first game](../start/first-game.md) takes about ten minutes. [C# or Luau](../agents/recipes/csharp-or-luau.md) helps you choose. --- Page: from/godot.md # Coming from Godot Most of what you know from Godot has a direct counterpart here. Scenes are text files, scripts are Luau or C#, and the engine runs at a fixed step, so every run replays exactly. There is no importer for Godot projects yet: you rebuild scenes and scripts by hand or with an AI agent, and your art comes across as files. ## What maps to what | Godot | Coldwave | | --- | --- | | Node | A thing: a number with an optional name, made of components ([things](../concepts/things.md)) | | Scene (`.tscn`) | A scene: a TOML file of named things and their components ([scenes](../concepts/scenes.md)) | | Instanced scene | No instancing yet. Spawn the thing from a script, or keep the group in a scene | | GDScript | Luau, or C# | | `_ready()` | `on_scene(name)`, called when a scene has started | | `_process` and `_physics_process` | One `step(dt)`, called 60 times a second at a fixed step | | Signals | Events: `send("hit", thing, 1)` in one script, `events("hit")` in another | | `@export` variables | `[tuning]` numbers in `game.toml`, which you can change while the game runs | | Input Map actions | `[input] actions` and `[input.keys]` in `game.toml`, read with `input.get` | | Groups | A component per kind of thing (`Moth = {}`), found with `each("Moth")` | | `change_scene_to_file()` | `scene.load("level2.toml")` | ## Movement A hero that walks left and right. In Godot: ```gdscript extends Node2D @export var speed := 90.0 func _physics_process(delta): position.x += Input.get_axis("left", "right") * speed * delta ``` In Coldwave, with `speed = 90` under `[tuning]` and a `move_x` action in `game.toml`: ```lua function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") set(hero, "Transform", "x", x + input.get(0, "move_x") * tuning.speed * dt) end ``` ## Signals become events In Godot, a coin tells the score it was picked up: ```gdscript signal picked(value) func _on_body_entered(body): picked.emit(5) ``` In Coldwave, one script sends an event and any other reads it in the same step: ```lua send("picked", coin, 5) for _, picked in ipairs(events("picked")) do state.score += picked.value end ``` ## What carries over - **Text you can diff.** You already review scene changes in git. Here that covers the whole project. - **A small, dynamic language.** Luau adds optional types; `frost reference --types game.toml` writes them for your game. - **Your art.** PNG pictures, glTF models with their animation clips, WAV sounds and OGG music. JPEG is not read yet, so convert those to PNG. ## What changes - **Behaviour comes from components.** A thing can sit under a parent, but there is no node type to inherit from. - **There is one fixed step.** Every step is 1/60 s of game time, so the same input always plays the same game. - **State lives in components or `state`.** A plain `local` is a cache that a reload or a replay does not keep. ## Next [Your first game](../start/first-game.md) takes about ten minutes. [Gameplay in Luau](../guides/luau.md) covers what a script keeps and how reload works. --- Page: from/defold.md # Coming from Defold Defold is the closest starting point: small games, Lua scripts and messages between objects. Coldwave's scripts are Luau, a descendant of Lua, so most of your code reads the same. The calls into the engine change, state moves out of `self`, and every run replays exactly. There is no importer for Defold projects yet: you rebuild collections by hand or with an AI agent, and much of your Lua carries over line by line. ## What maps to what | Defold | Coldwave | | --- | --- | | Collection | A scene: a TOML file of named things and their components ([scenes](../concepts/scenes.md)) | | Game object | A thing: a number with an optional name, made of components ([things](../concepts/things.md)) | | Sprite, collision object | Components: `Sprite`, `Body`, `Collider` | | `go.property` | Your own component under `[components]` in `game.toml`, or `[tuning]` numbers | | `update(self, dt)` and `fixed_update` | One `step(dt)`, called 60 times a second at a fixed step | | `init(self)` | `on_scene(name)`, called when a scene has started | | `msg.post` and `on_message` | `send("hit", thing, 1)` in one script, `events("hit")` in another | | `self` | Components on the thing, or the script's `state` table | | `go.get_position()`, `go.set_position()` | `get(thing, "Transform", "x")`, `set(thing, "Transform", "x", value)` | | Factory | `spawn(...)` with the components the new thing starts with | | Collection proxy | `scene.load("level2.toml")` | ## Movement A thing that slides right at its own speed. In Defold: ```lua go.property("speed", 90) function update(self, dt) local p = go.get_position() p.x = p.x + self.speed * dt go.set_position(p) end ``` In Coldwave, with `Slider = { speed = 90.0 }` under `[components]`: ```lua function step(dt) for _, thing in ipairs(each("Slider", "Transform")) do local x = get(thing, "Transform", "x") set(thing, "Transform", "x", x + get(thing, "Slider", "speed") * dt) end end ``` ## Messages become events In Defold: ```lua msg.post("/score", "picked", { value = 5 }) ``` In Coldwave, the event is read in the same step by any script: ```lua send("picked", coin, 5) for _, picked in ipairs(events("picked")) do state.score += picked.value end ``` ## What carries over - **Your Lua.** Tables, functions, loops and most helpers work as they are. Luau adds optional types and a few conveniences such as `+=`. - **Messages.** Events play the same role, and they are part of the replay. - **Your art.** PNG pictures, glTF models with their clips, WAV sounds and OGG music. JPEG is not read yet, so convert those to PNG. ## What changes - **`self` is not memory.** Keep what the game must remember in components or in `state`. - **One script walks many things.** Scripts run once a step and find their things with `each`. - **Positions are fields.** `Transform` has `x`, `y` and, in 3D, `z`, read and written one at a time. ## Next [Your first game](../start/first-game.md) takes about ten minutes. [Steps and determinism](../concepts/steps.md) explains why every run replays. --- Page: from/unreal.md # Coming from Unreal Coldwave is a much smaller engine, made for games one person or a small team can hold in their head. Moving a game over is a rebuild: the design and the models carry across, the code and Blueprints do not. There is no importer for Unreal projects yet. Check [what works today](../status.md) before you start: there is no level of detail, no reflection probes, and at most eight point and spot lights. ## What maps to what | Unreal | Coldwave | | --- | --- | | Actor | A thing: a number with an optional name, made of components ([things](../concepts/things.md)) | | Actor and Scene Components | Components: `Transform`, `Mesh`, `Light`, `Body` | | Level | A scene: a TOML file of named things and their components ([scenes](../concepts/scenes.md)) | | Blueprint graph | A script in Luau or C# | | C++ gameplay classes | Scripts in C# or Luau; the engine's own code is Rust | | `Tick(DeltaTime)` | One `step(dt)`, called 60 times a second at a fixed step | | `BeginPlay` | `on_scene(name)`, called when a scene has started | | Event dispatchers | `send("hit", thing, 1)` in one script, `events("hit")` in another | | Data Assets and Data Tables | A data file a script reads (`data("levels/one.toml")`) | | Enhanced Input actions | `[input] actions` and `[input.keys]` in `game.toml` | | Automation tests | A recorded run that `frost test` replays to a checksum ([recorded runs](../concepts/runs.md)) | ## Movement An actor that slides along x. In Unreal C++: ```cpp void AHero::Tick(float DeltaTime) { Super::Tick(DeltaTime); AddActorWorldOffset(FVector(Speed * DeltaTime, 0.f, 0.f)); } ``` In Coldwave, with `speed = 90` under `[tuning]` and a thing named `hero`: ```lua function step(dt) local hero = find("hero") set(hero, "Transform", "x", get(hero, "Transform", "x") + tuning.speed * dt) end ``` ## What carries over - **Models and animation**, as glTF: meshes, materials, rigs and clips. Second UV sets, lights and cameras inside a glTF are not read yet. - **Your design.** Levels, rules and tuning move across as ideas. An AI agent can rewrite scenes and scripts with you, a scene at a time. ## What changes - **Code is rewritten.** Blueprints and C++ become scripts. - **The renderer is smaller.** No bounce light, no screen-space reflections, no level of detail ([3D rendering](../guides/3d-rendering.md)). - **The tick is fixed.** Every step is 1/60 s of game time, so the same input always plays the same game. ## Next [Your first game](../start/first-game.md), starting from the `embers` template, a small third-person game in 3D. [Third-person 3D game](../agents/recipes/third-person.md) has the exact steps. --- Page: concepts/things.md # Things and components Everything in your game is a thing, and what a thing is comes from the components you give it. A thing (the engine's code calls it an entity) is a number and, if you give it one, a name. A component is a small record of named fields: `Transform = { x = 40, y = 90 }` says where it is, `Rect = { w = 12, h = 12, color = 0xf2364b }` that it is drawn as a red square. There are no classes and no inheritance: a thing that should fall gets a `Body`, one that glows gets an `Emission`, and a script finds things by what they have. ## The engine's components and your own The engine declares the components its systems read: drawing (`Transform`, `Rect`, `Sprite`, `Text`, `Tilemap`, `Camera`, `Mesh`, `Light`, `Sky`), physics (`Body`, `Collider`, `Mover`, `Joint`), the interface (`Node`, `Button`, `Bar`, ...), animation (`Clip`, `Tween`) and more. Each one's fields, types and defaults are in the [reference](../reference/index.md). A game declares its own in its project file, under `[components]`: a name and its fields with their defaults. The default's form is the field's type: `0.0` is a number, `0` a whole number, `""` text, `false` true or false. ```toml [components] Spinner = { speed = 90.0 } Coin = { value = 1 } ``` Give each kind of thing its own component, even an empty one (`Coin = {}`): `each("Coin")` then finds every coin, the editor groups them, and the [protocol](protocol.md) can ask for them. A name the engine owns cannot be one of yours (`E0528` says which revision took it, so you can rename yours). ## In a scene, in a script A scene file names the things a game starts with and gives each its components. This is the basics example the concepts pages share (from the engine's examples, shipped at launch): ```toml # example: basics/scene.toml # Every thing the game starts with, by name, and its components. [hero] Transform = { x = 40, y = 90 } Rect = { w = 12, h = 12, color = 0xf2364b } Spinner = { speed = 0.0 } [coin] Transform = { x = 200, y = 90 } Rect = { w = 8, h = 8, color = 0xf5c542 } Rotation = { angle = 0 } Spinner = { speed = 180.0 } Coin = { value = 5 } [score] Transform = { x = 8, y = 168 } Text = { text = "SCORE 0", size = 1, color = 0xeceae6 } ``` A script reads and writes fields by name, finds things by name or by components, makes and removes them, and sends events: ```lua -- example: basics/main.luau -- Moves the hero with the move_x action, spins every Spinner, and turns a touched coin -- into points: an event sent in one place and read in another. state.score = state.score or 0 local SPEED = 90 function step(dt) local hero = find("hero") set(hero, "Transform", "x", get(hero, "Transform", "x") + input.get(0, "move_x") * SPEED * dt) for _, thing in ipairs(each("Spinner", "Rotation")) do local angle = get(thing, "Rotation", "angle") + get(thing, "Spinner", "speed") * dt set(thing, "Rotation", "angle", angle % 360) end local coin = find("coin") if coin and math.abs(get(coin, "Transform", "x") - get(hero, "Transform", "x")) < 10 then send("picked", coin, get(coin, "Coin", "value")) despawn(coin) end for _, picked in ipairs(events("picked")) do state.score += picked.value set(find("score"), "Text", "text", "SCORE " .. state.score) end end ``` | Call | Does | | --- | --- | | `find("hero")` | The named thing, or nil | | `each("Spinner", "Rotation")` | Every thing with both components | | `get(e, "Transform", "x")`, `set(e, "Transform", "x", 40)` | Read or write one field | | `has(e, "Coin")` | Whether it has the component | | `spawn({ name = "spark", Transform = { x = 1, y = 2 } })`, `despawn(e)` | Make or remove a thing (and what is under it) | | `send("picked", e, 5)`, `events("picked")` | Send an event, read the step's events of that name | ## Names and parents A name is part of the world: the scene's keys give them, `spawn({ name = ... })` gives one, and no two living things share one (`E0006`; `E0106` when a scene brings it). A thing can be under another with `Parent = { of = "name" }`: under a thing with a `Transform` its own `Transform` is local to it, so it moves with it; under a group (a named thing with no `Transform`) nothing moves, it is only filed there. Despawning a thing despawns what is under it. The third-person sample puts the hero's drawn capsule under the capsule the physics walks. ## What is not a component What a script keeps in `state` (plain numbers, text, true or false, and tables of those) is game state too, and the checksum covers it. A script's own `local` outside its functions is not: it is a cache that a reload, a seek or a rollback does not bring back. [Steps and determinism](steps.md) says why that matters. --- Page: concepts/scenes.md # Scenes A scene is one level, menu or room of your game, written as a TOML file of things: each table is one thing, its key the thing's name, its entries its components. The project file says which scene a game starts in (`scene`), which others scripts may switch to (`scenes`) and which scripts run (`scripts`). The two-scenes sample starts in one level and has a second for its script to switch to: ```toml # example: two-scenes/game.toml # Two levels that share one file of things, and a script that switches between them. # # frost dev game.toml # frost test game.toml scene = "level1.toml" scenes = ["level2.toml"] scripts = ["main.luau"] seed = 1 replay = { steps = 260, checksum = "4c1890c067bda6c0", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [ [205, "f0012d92de8e4b5a"], [256, "6c0e19595318f5ea"], ] [window] size = [320, 180] background = 0x15171c [input] actions = ["move_x"] recording = [{ steps = 260, move_x = 1 }] [input.keys] move_x = { negative = "A", positive = "D" } ``` ## Switching scenes `scene.load("level2.toml")` changes the scene at the end of the step. Every thing of the old scene goes, so every entity a script kept is dead: the engine calls the script's `on_scene(name)` once the new things are in place and before anything is drawn, and also for the scene the game starts in. Set a scene up there, finding things again with `find`; do not carry a flag to the next step, which would draw one frame of the scene bare. ```lua -- example: two-scenes/main.luau -- Walk right to the door to go to the second level. `state` outlives a scene; things -- and the entity numbers a script kept do not, so on_scene finds them again. state.level = state.level or 1 function on_scene(name) set(find("title"), "Text", "text", "LEVEL " .. state.level .. ": " .. name) end function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") + input.get(0, "move_x") * 80 * dt set(hero, "Transform", "x", x) local door = find("door") if door and x > get(door, "Transform", "x") - 8 then state.level = 2 scene.load("level2.toml") end end ``` `state` outlives the switch; things do not. ## Sharing what several scenes have What several scenes share (the camera, the interface, the lights) goes in one file the others include, never in a copy per level: ```toml # example: two-scenes/common.toml # What both levels have: the hero and the line at the top. Each level includes this. [hero] Transform = { x = 20, y = 60 } Rect = { w = 10, h = 10, color = 0xf2364b } [title] Transform = { x = 8, y = 168 } Text = { text = "", size = 1, color = 0xeceae6 } ``` ```toml # example: two-scenes/level2.toml include = ["common.toml"] [floor] Transform = { x = 160, y = 40 } Rect = { w = 320, h = 8, color = 0x3a4250 } ``` A name written in two of them is an error (`E0106`), and an included scene includes nothing itself (`E0426`). [`frost reference project`](../reference/project.md) is the whole project file. ## Big worlds: streamed cells A world too big to keep whole is cut into cells: a `[stream]` table names a folder of scenes on a grid, and the cells near the things it follows (a camera, the hero) enter before physics each step and leave behind them, by the same rule on every machine, so a recorded run streams the same way when it is played again. See [streaming cells](../reference/project.md#streaming-cells) in the reference. ## Editing scenes from a program A scene is text, so any program can write one. Over the [protocol](protocol.md), `world.spawn`, `world.set` and `world.despawn` change the running game (`world.apply` makes several as one, all or none) and `game.reset` puts back what the files say. To change the files themselves, an agent works on a copy of the game (`copy.make`), tests it, and lands it (`copy.land`), which merges a scene by thing, component and field with every comment kept. `project.add` makes a new scene or script from the engine's stub, as `frost add scene NAME` does on the command line. --- Page: concepts/steps.md # Steps and determinism Your game plays the same way every time, on every machine. That is what makes replays, tests, time travel and multiplayer possible, and it comes from one rule: a game moves in fixed steps, sixty a second, each exactly 1/60 s of game time, however fast the machine draws. A step takes the step's input, runs the engine's stages in one declared order and ends with a checksum of the whole world. The same files, the same seed and the same input give the same world at every step, bit for bit, on every machine that plays it. Today that is measured on the desktop, on Linux and in a browser; phone exports are tested in the simulator and the emulator ([what works today](../status.md)). Everything else the engine does (replays, tests, time travel, multiplayer, "who wrote this value") is built on that. ## One step | Stage | Does | | --- | --- | | input | The step's actions: held keys, sticks, the pointer, fingers, or a recording's | | interface | Menus and controls (`Node`, `Button`, ...) use the input; a use sends its event | | physics | Box2D in 2D, Jolt in 3D: bodies and movers move, contacts and sensors send events | | scripts | Each script's `step(dt)`, in the project's order, reading where physics left things | | animation | Clips and tweens write their frames and fields | | layout | The interface again, reading no input, so a menu a script showed is laid out this step | | events | The step's events are kept for the next step's scripts | Drawing is not a stage: a picture is drawn from the world after a step, as often as the display asks, and drawing changes nothing. A window that is hidden gets no frames and the game still steps. ## What keeps it the same everywhere - **Fixed time.** `dt` is always 1/60. A slow frame is dropped, never queued, so lag never builds up. - **Seeded random.** `math.random` starts from the project's `seed`. The same seed plays the same game. - **The same arithmetic.** Machines' C libraries differ in the last digit of `sin` and its kin, so scripts' math functions are the engine's own and Luau is built so a multiply and an add are never fused. Use `math.pow` for a power that is not a written 2, 3 or 0.5. - **A declared order.** Systems run in the order above; events come sorted by kind and by the things' slots; physics steps the same on one thread or eight. ## The checksum `frost run --headless --steps 600 game.toml` prints two numbers: - **world checksum**: the world after the last step, 16 hex digits. Equal checksums mean equal worlds, on any machine. - **run checksum**: every world from the start to there, summed. A project's `replay` holds this one; [recorded runs](runs.md) explain how `frost test` uses it. The world is every thing's components, every script's `state`, the physics' own state and the random generator. It is not the picture, the sound, the time a step took or a script's `local` variables. ## What to keep where What the game is lives in the world or in `state`. A `local` at the top of a script is a cache: the checksum does not cover it, a reload empties it, and a world put back by a seek, a test or a rollback does not bring it back. Keep there only what can be built again from the world and `state` (in `on_scene`, or when first needed), and empty it in `on_restore()`, which the engine calls after a world is put back. `frost test --restore` finds a script that breaks this rule. `state` holds plain data only: numbers, text, true or false, and tables of those. Sound is output, never game state: a game never reads what it played. Input is read by action (`input.get(0, "move")`), never by device, so a key, a pad, a finger and a recording drive the same game. ## Where it pays off - [Recorded runs and checkpoints](runs.md): a test is a recording and one checksum. - [Debugging](../guides/debugging.md): seek to any step, and ask who wrote a value. - [Networking](../guides/networking.md): peers send inputs only, and roll back. - [The protocol](protocol.md): an agent tries a change and compares runs, step for step. --- Page: concepts/runs.md # Recorded runs and checkpoints Play your game once, keep the recording, and you have a test: `frost test` plays it again and tells you whether the game still goes the same way. It works because a game is [the same at every step](steps.md) for the same input. Your project file holds the recording: what was pressed, step by step, and what the whole run came to. ## A recording `[input] recording` is a list of stretches, each held for its `steps`; an action left out is at rest. The basics sample waits half a second, moves right for two seconds and left for half a second: ```toml # example: basics/game.toml # The concepts pages' game: things with components, a scene, a script that steps them, # an event, and a recorded run that `frost test` holds to one checksum. # # frost dev game.toml # frost test game.toml scene = "scene.toml" scripts = ["main.luau"] seed = 1 replay = { steps = 180, checksum = "4dc3795c2a4e1351", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [320, 180] background = 0x15171c # The game's own components: a name and its fields with their defaults. [components] Spinner = { speed = 90.0 } Coin = { value = 1 } [input] actions = ["move_x"] # The run `frost test` plays: rest, then right for two seconds, then left. recording = [ { steps = 30 }, { steps = 120, move_x = 1 }, { steps = 30, move_x = -1 }, ] [input.keys] move_x = { negative = "A", positive = "D" } ``` A long recording goes in a file of its own (`recording = "run.toml"`), which players never read and exports leave out. Record one by playing: the protocol's `input.history` returns a played session in exactly this form, which is how a bot or an agent writes one. ## The replay and its checkpoints `replay = { steps, checksum }` says what the recorded run comes to: the run checksum, every world from the start to `steps` summed. Write zeros the first time and let the engine fill it in: ```sh frost test --write game.toml # plays the run, writes replay and checkpoints frost test game.toml # plays it again and requires them ``` `--write` also writes `checkpoints`: the run's checksum at every 256th step and at each step a scene started. A test that fails then says between which two checkpoints the game first went another way, and plays the stretch beside the accepted copy of the game to name the first step, the first value that differs and the script line that last wrote it. Changing the coin's `value` in the sample from 5 to 6 and testing again says: ```text game.toml: FAILED: at step 0 coin.Coin.value is 6 and was 5; last written by scene scene.toml:12. That is the first step that differs from the game as accepted (by `frost test --write`); changed since then: scene.toml. If the change is meant, `frost test --write` writes the new checksums. ``` `frost test --write` keeps the game as accepted in `.frost/accepted/` beside the project file, so that comparison needs no git; with uncommitted changes it compares against git HEAD too. `frost test --unaccept` takes one acceptance back. ## Shots `shots = [{ name = "walk", step = 140 }]` names frames the game is judged by: the picture after that step of the recorded run, kept as `shots/NAME.png`. `frost test` takes each again and compares; `frost check --shots` says which changed, the most changed first. A machine with no graphics adapter skips shots and says so. ## Asking more of the same recording | Command | Asks | | --- | --- | | `frost test` | Does the run still come to its checksum, and do its shots still match? | | `frost test --restore` | Put back at each checkpoint, does the game go on the same? (It finds a `local` that should be `state`) | | `frost test --says PART@STEP` | Did my change alter only the parts I said (as `world.checksum` names them), from the step I said? Needs git | | `frost bench` | How long does each step of the run take? See [profiling](../guides/profiling.md) | | `frost blame GAME.toml hero.Transform.x --step 300` | Who wrote this value at that step? See [debugging](../guides/debugging.md) | A saved test is a copy of a project file with its own recording under `tests/`; `frost test FOLDER` runs every game and every saved test in a folder. A game with no `replay` has no recorded run: `frost test` says `no recorded run` and counts it apart, never as a pass. ## When a change is meant A change that alters how a run goes fails its test, as it should. Play the game, look at its shots, and when the new behaviour is right accept it with `frost test --write`, which writes the new checksum and checkpoints. A shot that already has a picture is compared, never replaced: `frost check --shots --write-shots` keeps new pictures, once you have looked at them. --- Page: concepts/protocol.md # The protocol Anything you can do to your game by hand, a program can do too. A running game answers commands: the editor, the command line and an AI agent all send the same ones, and none of them has a private way in. About a hundred commands step the game, hold its input, read and write its world, swap a script, capture a frame, explain a pixel, debug, profile and test a change. [Every command](../reference/protocol-commands.md) is listed in the reference. ## Three ways to connect | Command | Serves | | --- | --- | | `frost serve game.toml` | JSON-RPC 2.0, one object a line, on standard input and output; `--port N` on a TCP port of 127.0.0.1 instead | | `frost mcp game.toml` | The same commands as MCP tools for an AI agent (dots become underscores: `frame_capture`) | | `frost dev game.toml` | A window to play in, with the protocol on a local port beside it, so an agent can read, drive and capture the game while a person plays | `frost protocol` lists every command; `frost protocol world.get` describes one in full. ## A conversation Against the basics example (from the engine's examples, shipped at launch), one request a line in and one answer a line out: ```sh frost serve basics/game.toml ``` ```json {"jsonrpc":"2.0","id":1,"method":"game.step","params":{"steps":60}} {"id":1,"jsonrpc":"2.0","result":{"checksum":"a3728cc2465e2d08","reached":false,"step":60,"stopped":null}} {"jsonrpc":"2.0","id":2,"method":"world.get","params":{"entity":"hero","component":"Transform"}} {"id":2,"jsonrpc":"2.0","result":{"components":{"Transform":{"x":40.0,"y":90.0}},"entity":"e1.0"}} {"jsonrpc":"2.0","id":3,"method":"game.seek","params":{"step":150}} {"id":3,"jsonrpc":"2.0","result":{"checksum":"504a4a5a1e5ef03f","from":0,"replayed":150,"started":"load","step":150,...}} {"jsonrpc":"2.0","id":4,"method":"script.state","params":{}} {"id":4,"jsonrpc":"2.0","result":{"kinds":{},"states":{"main.luau":{"score":5}},"step":150}} ``` `game.step` advanced 60 steps on the input `input.set` holds (none here, so the hero stood still); `game.seek` played the project's recording to step 150 instead, where the coin has been picked up. ## The commands by what they are for | For | Commands | | --- | --- | | Where the game stands | `game.info`, `world.entities`, `world.components`, `world.get`, `script.state` | | Driving it | `input.set`, `game.step`, `game.seek`, `game.time`, `game.reset` | | Changing it | `world.set`, `world.spawn`, `world.despawn`, `world.apply`, `script.reload`, `tuning.set` | | Seeing it | `frame.capture`, `frame.at` (what is drawn at a pixel, and how it is lit), `render.passes` | | Trying things | `game.snapshot`, `game.restore`, `game.try` (play a branch of input from a snapshot in one call) | | Explaining it | `blame.on`, `blame.value`, `blame.pixel`, `events.since`, `log.since`, `profile.steps` | | Debugging scripts | `debug.attach`, `debug.breakpoints`, `debug.step`, `debug.stack`, `debug.evaluate` | | Changing files safely | `copy.make`, `change.test`, `copy.land`, `project.undo` | | Who is connected | `session.hello`, `session.hands`, `session.mode` | ## You and an agent on one game `frost mcp --join-file PATH` serves the tools for a session that is already running (the editor's, or a `frost dev` window), so you and an agent act on one game. Each client can say who it is (`session.hello`), and every write then names it: `blame.value` answers that a client wrote a field, and which one. You can hold an agent to reads only in the editor (mode `plan`): every command that would change the game is then refused with `E0447`, naming what was tried. An agent that changes files works on a copy of the game, tests the copy against what it said it would change (`change.test`), and lands it; a landing can be undone on its own ([undoing a landing](../guides/undo-landing.md)). Requests are carried out one at a time in the order they arrive, so two clients never see half a step. --- Page: guides/2d.md # 2D Draw a 2D game with rectangles, sprites, text, tilemaps and shapes, ordered by layer and seen through a camera. This page is the tour, with one small game you can copy; every field is in the [drawing reference](../reference/drawing.md). ![The sprites-2d sample at step 150](../files/examples/sprites-2d/shots/walk.png) That frame is the sprites-2d sample: a tilemap level wider than the frame, a sprite that walks along it, a camera that follows, a turned bar, a pulsing ring and a label that stays put. Its pictures are drawn by its `make.py`. ```toml # example: sprites-2d/game.toml # The 2D guide's game: a tilemap level wider than the frame, a sprite that walks along # it, a camera that follows on whole units, a turned and a scaled thing, a ring, and a # line of text that stays on the frame. make.py draws tiles.png and hero.png. # # frost dev game.toml # frost run --headless --steps 150 --shot shot.png game.toml scene = "level.toml" scripts = ["walk.luau"] seed = 1 shots = [{ name = "walk", step = 150 }] replay = { steps = 150, checksum = "28b5e912cdbd2af1", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [320, 180] background = 0x1b2030 filter = "nearest" [input] actions = ["move_x"] recording = [{ steps = 20 }, { steps = 130, move_x = 1 }] [input.keys] move_x = [{ negative = "A", positive = "D" }, { negative = "Left", positive = "Right" }] ``` ## The frame and the world A game sees its whole frame (`[window] size`, 960 by 540 when left out), with the origin at the bottom-left corner, x to the right and y up, and one world unit to one pixel. A `Transform` is the centre of what is drawn: a rectangle 12 wide at `x = 40` covers 34 to 46. A frame keeps its shape in any window, as large as fits, with the background beside it; `[window] fit = "fill"` takes the screen's shape instead, and `frame.size()` says the frame the game runs in. ## What is drawn A thing is drawn when it has a `Transform` and one or more of these: | Component | Draws | | --- | --- | | `Rect` | A rectangle in one colour, `0xRRGGBB` | | `Sprite` | A PNG picture, or a part of one (`src_x`, `src_y`, `src_w`, `src_h`), at a size (`w`, `h`: 0 is one unit an image pixel), tinted and flipped | | `Text` | The built-in pixel font, or a font of the game's own (see [interface](ui.md)) | | `Tilemap` | A level from text: each character one tile of a tileset picture | | `Shape` | A ring, a disc or a line: an arc, a wedge, dashes | The level and the things on it: ```toml # example: sprites-2d/level.toml # The camera's Transform is the world point at the middle of the frame. [camera] Transform = { x = 160, y = 90 } Camera = { zoom = 1 } # A tilemap's Transform is its bottom-left corner; the last line of rows is the bottom. [ground] Transform = { x = 0, y = 0 } [ground.Tilemap] image = "tiles.png" tile = 16 legend = "#=^" rows = """ ............................... ............................... ............................... ............................... ............................... ........===.........===........ ............................... ............^^..........^...... ############################### ############################### """ # One frame of hero.png, drawn twice its size: one image pixel is two units. [hero] Transform = { x = 40, y = 48 } Sprite = { image = "hero.png", src_w = 16, src_h = 16, w = 32, h = 32, layer = 2 } # Turned about its centre (Rotation), and drawn larger without touching w and h (Scale). [windmill] Transform = { x = 260, y = 120 } Rect = { w = 40, h = 6, color = 0xeceae6, layer = 1 } Rotation = { angle = 0 } [coin] Transform = { x = 290, y = 60 } Shape = { kind = "ring", w = 14, h = 14, width = 3, color = 0xf5c542, layer = 1 } Scale = { x = 1, y = 1 } # Screen: in frame units, wherever the camera is. [label] Transform = { x = 8, y = 168 } Screen = {} Text = { text = "WALK RIGHT", size = 1, color = 0xeceae6, align = 0, layer = 9 } ``` A tilemap's `Transform` is its bottom-left corner, not its centre, and the last line of `rows` is the bottom row. A character not in `legend` draws nothing, and `rows` is a field like any other: a script can read it to find where a `C` stands, or `set` it to break a block. Only the tiles the camera sees are sent to the device, and a whole map is one draw call. Many pictures on one page, each a frame by name, are an [atlas](atlases.md). ## Order, turn and size - **Layers.** Lower layers are drawn first; within a layer the order is the engine's, so give things that overlap different layers. `YSort` sorts a layer by height, for a game seen from above. - **Rotation.** `Rotation = { angle = 30 }` turns a rectangle or a sprite about its centre, anticlockwise; `Pivot` moves the point it turns about (an arm at its shoulder). - **Scale.** `Scale = { x = 1.3, y = 1.3 }` draws a thing larger without touching its `w` and `h`: how a coin pops or a jump squashes. Below 0 mirrors. - **Opacity, Tint, Blend.** `Opacity` fades a thing and what is under it; `Tint` multiplies its colour; `Blend` adds it to what is behind, for glows and sparks. - **Slice** cuts a sprite in nine, so one small picture of a frame makes a panel of any size; **Repeat** tiles a picture across a sprite larger than it. `Rotation`, `Opacity` and `Scale` are components, not fields of `Sprite`: a script cannot add one later, so give a thing that will turn or fade `Rotation = {}` or `Opacity = {}` in its scene. ## The camera With no `Camera` the world and the frame are the same. A thing with a `Camera` and a `Transform` is the camera: its `Transform` is the world point at the middle of the frame, and `zoom` scales the world about it. It is world state like any other, so a script moves it with `set`, and a thing with `Screen` stays where the frame puts it whatever the camera does: a score, a title. The sample's script: ```lua -- example: sprites-2d/walk.luau -- Walks the hero with move_x, flips it to face the way it goes, keeps the camera on it -- (on whole units, so pixel art stays sharp), turns the windmill and makes the coin pulse. local SPEED = 60 state.t = state.t or 0 function step(dt) state.t += dt local hero = find("hero") local move = input.get(0, "move_x") set(hero, "Transform", "x", get(hero, "Transform", "x") + move * SPEED * dt) if move ~= 0 then set(hero, "Sprite", "flip_x", move < 0) end local camera = find("camera") set(camera, "Transform", "x", math.max(160, math.floor(get(hero, "Transform", "x") + 0.5))) local windmill = find("windmill") set(windmill, "Rotation", "angle", (get(windmill, "Rotation", "angle") + 90 * dt) % 360) local pulse = 1 + 0.25 * math.sin(state.t * 4) local coin = find("coin") set(coin, "Scale", "x", pulse) set(coin, "Scale", "y", pulse) end ``` ## Sharp pixels, the same everywhere - `[window] filter = "nearest"` (the default) keeps pixel art sharp; `"linear"` blends. - The renderer does not round. Keep the camera, and what moves, on whole units, as the sample does with `math.floor`. - For the same picture on every graphics backend, keep every drawn edge on a whole frame pixel: give sprites even sizes, or place an odd-sized one half a unit off. - A turned edge falls between pixels, so it is the same picture on Metal and in both web builds as measured, not promised for every adapter. ## What it costs The whole world goes to the device as one batch: quads that follow each other in drawing order and share a picture, or have none, are one draw call. Rectangles, text and shapes cost nothing extra; another picture on the same layer costs a call. `frost bench --draw` counts the draw calls ([profiling](profiling.md)). --- Page: guides/3d-rendering.md # 3D rendering Make a 3D game look the way you want: models and shapes, materials, lights and shadows, the sky, fog, ambient occlusion, bloom, smooth edges and effects. This page is the tour, with one scene you can copy; every field is in the reference ([3d](../reference/3d.md) and [render](../reference/render.md)). ![The lit-room sample at step 120](../files/examples/lit-room/shots/dusk.png) That frame is the lit-room sample, and `frost test` holds every run of it to the same checksum and this picture. Its project file: ```toml # example: lit-room/game.toml # The 3D rendering guide's scene: a courtyard at dusk under the engine's Sky, lit by its # sun with shadows, two lamps that come on as the sun sets, a glowing orb that blooms, # ambient occlusion in the corners and smoothed edges. The script moves the time of day. # # frost dev game.toml # frost run --headless --steps 120 --shot shot.png game.toml space = "3d" scene = "court.toml" scripts = ["dusk.luau"] seed = 1 shots = [{ name = "dusk", step = 120 }] replay = { steps = 120, checksum = "6614dbbec930932f", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [640, 360] background = 0x101318 # Four samples a pixel on edges, a soft glow above the threshold, and darker corners. [render] msaa = 4 bloom = { threshold = 0.9, strength = 0.8 } ao = { radius = 1.0, strength = 0.9 } ``` ## A 3D game `space = "3d"` in the project file makes the game 3D: its `Transform` has a place (`x`, `y`, `z` in metres, y up), a turn (a quaternion, or `turn = { x, y, z }` in degrees in a scene) and a scale. A `Camera` looks along its own -z; the lowest thing with one sees. With no `[render]` table the frame is the sky, then the meshes, then the 2D layers over them (the interface, text). ## Meshes and shapes `Mesh = { file = "art/hero.glb" }` draws a glTF model (`.glb` or `.gltf`), cooked once into the engine's own format and kept in a cache. `Mesh = { file = "box" }` draws one of the engine's shapes with no file: `box`, `sphere`, `plane`, `capsule`, `cylinder`, each a metre across, so the thing's scale sizes it. A model only a script names goes in the project's `models`. ## Materials A model's own glTF material is used as written: base colour, metal and roughness, normal, occlusion and glow pictures, alpha masks and blending. A thing can change its look like any value: `Mesh.roughness`, `Mesh.metallic` (0 to 1; below 0, the model's) and `Mesh.blend`. `Tint` multiplies the colour of a thing and what is under it, and `Opacity` fades it. `Emission = { color, strength }` is a thing's own light, regardless of lighting; above 1 it saturates and, with bloom, glows. For a look no glTF material gives, `[render.materials]` declares up to eight of your own, each one WGSL function for the vertex, the fragment, or both, and a `Material` component gives a thing its numbers. A material has no clock: what moves, moves because a script wrote its numbers this step, so a frame put back is the same picture. ## Lights `Light = { kind = ..., color, energy }`: | `kind` | Lights | | --- | --- | | `"ambient"` | Everything, evenly | | `"sun"` | Along its own -z, from infinitely far | | `"point"` | From its place, fading to nothing at `range` | | `"spot"` | A cone along its own -z: whole within `inner` degrees, nothing past `outer` | The first eight points and spots, by thing, are lit; more are ignored. A point or spot with `night = true` shines only once the Sky's sun is down, smoothly over dusk. ## Shadows A sun with `shadows = true` (or a `Sky` with `shadows = true`) draws a 2048-pixel shadow map of the ball `range` (the Sky's `reach`) metres round a point that far ahead of the camera, soft over one map pixel. One spot can cast shadows too, from a 1024-pixel map of its cone, and can project a picture (`cookie = "art/mask.png"`). Points cast none. Shadows are off by default and cost nothing until asked for. ## The sky `Sky = { time = 15.5 }` is a day: the hour sets the sun's direction, colour and strength, the sky's colours and the ambient light, with no picture. The sun rises along +x at 6, stands 50 degrees up towards -z at noon and sets along -x at 18, and `turn` turns that path about y. At night a dim moon shines from the other side. `time` is a field like any other, so the sample's script moves it, and a recording, a seek and a checksum all see it: ```lua -- example: lit-room/dusk.luau -- The sun goes down: an hour of the game's day every two seconds. The Sky is a -- component like any other, so a recording, a checksum and a seek all see the time. local HOURS_A_SECOND = 0.5 function step(dt) local sky = find("sky") set(sky, "Sky", "time", get(sky, "Sky", "time") + HOURS_A_SECOND * dt) end ``` `haze` and `haze_far` fade meshes and ground into the horizon's colour between two distances, melting the world's edge into the sky. Metal mirrors the sky above it, blurred by its roughness (it reflects no other things). Without a Sky, `Fog = { color, density }` fades lit meshes towards a colour instead. A physically based sky (sun and sky colours from the atmosphere itself) is [coming next](../soon/physical-sky.md). ## Ground `Ground = { file = "art/hill.ground.toml" }` is a height field from a grey PNG: drawn in tiles of 64 by 64 cells, each with only as much detail as its distance needs, in one colour or up to four pictures blended by slope and height. `ground.at(x, z)` gives the height, the slope and each picture's weight under a point, and `Collider = { shape = "ground" }` makes the physics walk on it. ## Ambient occlusion `[render] ao = { radius = 1, strength = 1 }` darkens the ambient light and the sky's reflection where surfaces close a point in: corners, a crate on a floor. Sun, lamps, shadows and emission are untouched. Its sample pattern is fixed, so it never shimmers and every run draws one picture. It is screen-space: what is hidden or off screen shades nothing. ## Bloom, float light and tone mapping `[render] bloom = { threshold = 0.85, strength = 1.5 }` spreads what is brighter than the threshold into a soft glow. For light above 1 kept through the frame, draw the sky and meshes into a float (`rgba16f`) target and read it with the `aces` effect, which tone maps it: the [render reference](../reference/render.md) shows the passes. ## Smooth edges `[render] msaa = 4` takes four samples a pixel on the sky and meshes, with alpha to coverage on masked materials. `cull = true` and `samplers = true` follow a glTF's double-sided flags and its texture filters; both are off by default so older games draw as they did. ## Your own frame graph and effects `[render]` can name targets and passes: what draws where (`layers`, `meshes`, `sky`) and effects that read targets (`copy`, `bright`, `blur`, `add`, `aces`, `panini`). Up to eight effects of your own are WGSL files with one function, `effect(at, size, threshold, strength)`, that returns a pixel's colour. A `Pass` component sets a pass's numbers from a script each frame. `render.passes` over the protocol lists the graph that is running. ## Explain a pixel `frame.at` over the protocol says what is drawn at a pixel and how it is lit: the triangle of which mesh and material, then one line a light with its share and why. Asked of the lit-room sample at step 120, at a pixel of its floor: ```json {"name": "floor", "mesh": "box", "material": "shape", "distance": 11.324, "light": [ {"kind": "sky", "name": "sky", "share": 0.586, "why": "the sky's light, everywhere"}, {"kind": "sun", "name": "sky", "share": 0.0, "why": "the sky's sun: in shadow"}, {"kind": "point", "name": "lamp_left", "share": 0.414, "why": "3.123 away, 0.141 of its light left there"}, {"kind": "point", "name": "lamp_right", "share": 0.0, "why": "out of its reach: 7.811 away, it reaches 4.5"}, {"kind": "haze", "name": "sky", "share": 0.0, "why": "11.324 away, nearer than the haze begins (15)"}], "unread": ["ambient occlusion (`[render] ao`) is not read; ..."]} ``` It needs no graphics device and changes nothing. `frost blame GAME.toml --pixel X,Y` asks the same of a 2D frame from the command line; [debugging](debugging.md) has more. ## Every backend, one picture Native, WebGPU and WebGL2 draw the same picture, with two known exceptions: a smoothed edge's pixel may be one level off in WebGL2, and two surfaces at exactly one depth (a pillar standing exactly on a floor) may tie differently, so sink a thing a hundredth of a unit into what it stands on. Model pictures over 2048 on a side are halved for the web (`W0455` says which). See [status and limits](../status.md) for what 3D does not do yet. --- Page: guides/animation.md # Animation and posing Make things move without writing a line of script for each step: clips that play frames of a sheet, tweens that take a number somewhere over a time, specks from an emitter, and in 3D the poses of a model's own clips. All of it is world state, so a recording, a seek and a checksum see it. Every field is in the [animation reference](../reference/animation.md). Animation runs after the scripts in each step. What a script decides is on the frame drawn after that step, and an event the animation sends (a clip's footstep, a tween's `done`) is read by scripts in the next step. ## The sample The clips sample walks a sprite across and back with a tween, plays its walk clip, puffs dust at each footstep the clip sends, and fades a banner in halfway: ```toml # example: clips/game.toml # The animation guide's game: a clip that plays a walk from a sheet and sends an event on # each footfall, tweens that carry a thing and fade a banner in, and specks from an # Emitter on each footfall. The script decides when; the animation stage moves things. # # frost dev game.toml # frost run --headless --steps 180 --state game.toml scene = "scene.toml" scripts = ["walk.luau"] seed = 1 replay = { steps = 180, checksum = "fdc8b0822819e33f", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] # Four frames of 16 by 16 pixels from the left of hero.png, ten a second. Frames 1 and # 3 send `footstep` about the thing as they come up. [clips] walk = { image = "hero.png", frame = [16, 16], count = 4, fps = 10, events = [{ frame = 1, name = "footstep" }, { frame = 3, name = "footstep" }] } [window] size = [320, 180] background = 0x1b2030 ``` ```toml # example: clips/scene.toml [hero] Transform = { x = 40, y = 40 } Sprite = { image = "hero.png", w = 32, h = 32, layer = 2 } Clip = { name = "walk" } # Dust where the feet fall: a small puff that rises and fades. [dust] Transform = { x = 40, y = 26 } Emitter = { life = 0.5, speed = 25, spread = 60, gravity = -20, size = 3, size_end = 0, color = 0xc8b89a, color_end = 0x1b2030, add = 0, layer = 1, seed = 4 } # Opacity must be in the scene for a tween to fade it later. [banner] Transform = { x = 160, y = 140 } Text = { text = "ACROSS", size = 2, color = 0xf5c542 } Opacity = { alpha = 0 } ``` ```lua -- example: clips/walk.luau -- A tween carries the hero across and back for ever; its clip walks by itself. Each -- footstep the clip sends (read a step later: animation runs after the scripts) puffs -- dust under the hero and is counted. Halfway there, the banner fades in. state.steps = state.steps or 0 function on_scene(name) tween(find("hero"), "Transform", "x", 280, 2.5, { ease = "in_out_quad", loop = "pingpong" }) end function step(dt) local hero = find("hero") for _, footstep in ipairs(events("footstep")) do state.steps += 1 local dust = find("dust") set(dust, "Transform", "x", get(hero, "Transform", "x")) emit(dust, 4) end local banner = find("banner") if get(hero, "Transform", "x") > 160 and get(banner, "Opacity", "alpha") == 0 then tween(banner, "Opacity", "alpha", 1, 0.5, { ease = "out_cubic" }) end end ``` ## Clips A clip is a run of equal frames on one picture, left to right, declared once under `[clips]`: `frame` is a frame's size in pixels, `at` where the first one is, `count` how many and `fps` how fast. A thing with a `Sprite` and `Clip = { name = "walk" }` plays it: the engine writes the sprite's `src_*` (and its `image`, when the clip names one) every step. - A clip loops unless it says `loop = false`; then it holds its last frame, and `end = "landed"` sends that event once when it is over. - `events = [{ frame = 1, name = "footstep" }]` sends an event about the thing each time that frame comes up. - To change clip, set `name` and set `time` to 0. Setting only `name` carries on from the same moment, which keeps a run and a run-with-sword in step. - `speed` 0 holds the frame, 2 plays twice as fast. `frame` is the engine's to write: read it, do not write it. ## Tweens `tween(entity, "Transform", "x", 280, 2.5, { ease = "in_out_quad" })` takes one number field from what it is to 280 over two and a half seconds. Options: `ease` (one of `linear`, `in_quad`, `out_quad`, `in_out_quad`, `in_cubic`, `out_cubic`, `in_out_cubic`, `out_back`, `out_bounce`), `from`, `loop` (`"restart"` or `"pingpong"`, for ever) and `done`, an event sent when it ends. A tween is a thing of its own: `tween` returns it and `despawn` stops it. When it ends it writes `to` exactly and is gone. Of two tweens on one field, the later one wins. A tween cannot move the `Transform` of an interface node the engine places (`E1306`): tween its `Anchor.dx`, `Scale` or `Opacity` instead. ## Specks An `Emitter` describes specks: how long they live, how fast and how widely they leave, their gravity, size and colour from start to end, whether they add light or cover. `emit(entity, n)` lets `n` of them go and returns a `Burst`, the one thing that holds them all, so a thousand specks are not a thousand things. The `seed` picks directions and speeds, so equal seeds emit equal patterns and a run replays the same dust. At most 4,096 are alive at once (`E0560`). They are untextured squares. ## Spinning `Spin = { rate = 90 }` turns a thing at a steady rate with no script: in 2D its `Rotation.angle`, in 3D about its own axis (`axis_x`, `axis_y`, `axis_z`). ## 3D models: poses A glTF model's own clips play with `Pose = { clip = "walk" }` beside its `Mesh`: set `clip` to play another, `time` to 0 to start again, `speed` 0 to hold, and `fade` to mix the pose it was in into the new one over that many seconds. `[poses]` in the project file declares events a model's clip sends at moments of it, read by scripts in the next step. `Gait` picks the clip for a walking thing by how fast it goes over the ground: `idle` below `walk_at` metres a second, `walk` from there, `run` from `run_at`, each played at the speed it was made for, with a fade between. A script can turn one joint of a posed model itself: a `Bone = { of = "hero", joint = "head", qx, qy, qz, qw }` thing overrides that node after the clip, and `bone(thing, "hand")` reads where a joint is in the world. `Parent = { of = "hero", joint = "hand" }` holds a sword in the hand. The engine's own `pose` example has an arm, a held box and a light at its tip. Not yet: sharing one clip between models that have one rig, and hiding a model's node. Bending posed models on the graphics device is [coming next](../soon/gpu-skinning.md). ## Checks ```sh frost check game.toml frost run --headless --steps 180 --state game.toml # state: {"walk.luau":{"steps":15}} frost test game.toml ``` `--state` prints what the script counted: fifteen footsteps in three seconds of a clip that sends two every four frames at ten frames a second, back and forth. --- Page: guides/physics.md # Physics: recipes and measured numbers How to get the physics behaviour you want: a stack that stands, a belt that carries, a hero that climbs stairs, a jump that forgives. Every number on this page is measured by one of the engine's own tests, so it stays true. The calls and fields themselves are in the [physics reference](../reference/physics.md). ## How stiff things are Contacts and joints give a little under load, and `substeps` in `[physics]` stiffens them. Nothing else does: there is no setting for it. | `substeps` | A stack of 10 crates stands low by | A bridge of 8 planks under 20 heavy crates: its hinges come apart by, at worst | |---|---|---| | 4 (when left out) | 3.2 units | 8.5 units | | 8 | 0.8 | 2.8 | | 16 | 0.2 | 1.3 | Under 4 a stack does not stand. ## How long things swing One body on a hinge with no `damping` swings for ever: it has 99% of its energy after a minute. A chain of 4 links let go from 30 degrees has 98% after a minute. Let go level, the same chain folds and whips, and 20% is left, whatever `substeps` is: the links hit each other, and that is where it goes. ## Belts `Collider.surface` is the speed a collider's surface runs at, in units a second, clockwise round it: its top goes to the right, its underside to the left. A negative speed runs the other way. ```toml [belt] Transform = { x = 200, y = 20 } Collider = { w = 200, h = 8, surface = 60 } ``` A body on it is brought up to that speed by friction, so a `friction` of 0 on either carries nothing. A `Mover` on it is taken along exactly, a unit a step at 60, on top of its own walk: walking against it at 60 it stays where it is. It works on a collider that moves too, so a belt on a lift carries both ways at once, and on a `one_way` collider, which carries a mover from the step it lands on it and not while it passes up through it. ## Ledges and stairs A `Mover` stops at anything it walks into that is steeper than its `slope`, however low. `Mover.step` is the highest ledge it walks up onto instead: ```toml [hero] Collider = { shape = "capsule", w = 16, h = 32 } Mover = { step = 8 } ``` It steps only from the ground, only where it fits on top, and only onto what it could stand on; a dynamic body that low is pushed, not climbed. Going up costs it no speed. A ledge higher than the capsule's radius (half its `w`) is stepped too, all at once. Coming down is the same: off a kerb no deeper than `step` it stays on the ground, where without one it is in the air for a few steps and `grounded` is false. A mover stays on ground that falls away no faster than its `slope` either way. ## A jump that forgives Gravity and the jump are the script's: the engine does not know what a jump is, so it cannot time one. What it does keep is `Mover.air`, the seconds since the mover last stood (0 on the ground), and with that the two usual kindnesses are one call of the kit library, `kit.jump`: ```luau local kit = library("kit.luau") function step(dt) local hero = find("hero") local pressed = kit.pressed(state.keys, "jump", input.held(0, "jump")) local air = get(hero, "Mover", "air") -- 0.1 s after a ledge (coyote time), 0.1 s before a landing (a buffered press) if kit.jump(state.keys, pressed, air, dt, 0.1, 0.1) then set(hero, "Mover", "vy", 330) end end ``` It is true on the one step the jump should start, and once for each time off the ground. What it remembers is in the table it is handed, which belongs in `state` so that a rollback or a reload keeps it. `kit.luau` is a file of your game, yours to change: the function is twelve lines. ## One-way platforms `Collider.one_way` and `TileCollider.one_way` hold a `Mover` that comes down onto them and let it through from below and from the side; `Mover.drop` lets it fall through. That is for movers: a dynamic body meets a one-way collider as solid from every side. --- Page: guides/input.md # Input Bind keys, gamepads, the mouse and touch to your game once, and your scripts never need to know which one the player is using. A script reads actions, never a device. The project file names the actions and says which keys, pad buttons, sticks, pointer and fingers drive them; a recording, a test and a protocol client drive the same actions, so the game cannot tell them from a hand. That is what lets a run [replay](../concepts/runs.md). Every key name and option is in the [input reference](../reference/input.md). ## The sample The controls sample is one square to walk and jump, a ring that follows the pointer, and a hint that names the jump key: ```toml # example: controls/game.toml # The input guide's game: one set of actions driven by keys, a gamepad, the pointer and # fingers on a touch screen, and a hint that names the keys of the device last used. # The script reads actions only, so the recording below drives it the same way. # # frost dev game.toml # frost test game.toml scene = "scene.toml" scripts = ["controls.luau"] seed = 1 replay = { steps = 150, checksum = "d734d0ac6e707474", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [320, 180] background = 0x1b2030 [input] actions = ["move_x", "move_y", "touching", "jump", "aim_x", "aim_y"] # Where the mouse, or the first finger, is: each -1 to 1 across the frame. pointer = { x = "aim_x", y = "aim_y" } # On a touch screen: a stick on the left half (a stick slot has both axes and a press; # this game reads only move_x) and a jump button on the right half. fingers = [ { region = { x = -1, y = -1, w = 1, h = 2 }, x = "move_x", y = "move_y", press = "touching", stick = 0.15, shown = true }, { region = { x = 0, y = -1, w = 1, h = 2 }, press = "jump", shown = true, label = "JUMP" }, ] # What `frost test` plays: rest, aim at the top right, walk right, jump, walk left. recording = [ { steps = 20, aim_x = 0.8, aim_y = 0.6 }, { steps = 60, move_x = 1, aim_x = 0.8, aim_y = 0.6 }, { steps = 1, move_x = 1, jump = 1 }, { steps = 69, move_x = -0.5 }, ] [input.keys] move_x = [{ negative = "A", positive = "D" }, { negative = "Left", positive = "Right" }, "PadLeftX"] jump = ["Space", "PadA"] ``` ```lua -- example: controls/controls.luau -- Reads actions, never a device: a key, a stick, a finger and a recording are the same. local SPEED, JUMP, GRAVITY, FLOOR = 90, 220, 600, 32 state.vy = state.vy or 0 function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") + input.get(0, "move_x") * SPEED * dt local y = get(hero, "Transform", "y") if y <= FLOOR and input.held(0, "jump") then state.vy = JUMP end state.vy -= GRAVITY * dt y = math.max(FLOOR, y + state.vy * dt) if y == FLOOR then state.vy = 0 end set(hero, "Transform", "x", math.clamp(x, 8, 312)) set(hero, "Transform", "y", y) -- The pointer's place in frame units: (value + 1) / 2 times the frame's side. local width, height = frame.size() local aim = find("aim") set(aim, "Transform", "x", (input.get(0, "aim_x") + 1) / 2 * width) set(aim, "Transform", "y", (input.get(0, "aim_y") + 1) / 2 * height) -- The names of the keys that jump on the device used last: SPACE, or the pad's A. local keys = input.keys("jump") set(find("hint"), "Text", "text", "JUMP: " .. string.upper(keys[1] or "?")) end ``` ## Actions and keys `[input] actions` names what a script reads. `[input.keys]` binds each one: - A key name alone is a button for player 0: 1 while it is down. `input.held(0, "jump")` says whether it is held; `input.get(0, "jump")` reads its value. - A table with `negative` and `positive` is an axis: -1 to 1. `input.get(0, "move_x")`. - A list binds several keys, pads or players to one action; an axis is the sum of its bindings, held to -1 to 1. - `player = 1` in a binding gives it to the second player, so two people can share one keyboard (`[input] players` says how many play). Keys are named by what a US keyboard prints on them: `"A"` to `"Z"`, `"0"` to `"9"`, `"Space"`, `"Enter"`, `"Tab"`, `"Escape"`, `"Left"`, `"Right"`, `"Up"`, `"Down"`, and the pointer's buttons `"MouseLeft"`, `"MouseRight"`, `"MouseMiddle"`. There are no names for Shift, Ctrl or Alt yet. ## Gamepads A pad is bound in the same table: its buttons are keys (`"PadA"` at the bottom, `"PadB"`, `"PadX"`, `"PadY"`, the shoulders, the d-pad `"PadUp"` to `"PadRight"`, `"PadStart"`, `"PadSelect"`, the sticks pressed), and a stick is an axis by its name alone (`"PadLeftX"`, `"PadLeftY"`, `"PadRightX"`, `"PadRightY"`, right and up as 1), with a dead centre. A player's pad is the one with the player's number, and keeps it while it is plugged in. An exported player reads pads only when its game binds one, so a game with none ships no pad code. ## The pointer The mouse, or a finger on a touch screen, is two actions the project names with `pointer = { x = "aim_x", y = "aim_y" }`, each -1 at the frame's left or bottom edge and 1 at its right or top. In frame units that is `(x + 1) / 2 * width`, as the sample does with `frame.size()`. Its buttons are keys; a finger is `"MouseLeft"`. There is no mouse capture and no mouse look yet. ## Fingers `[input] fingers` gives a touch screen up to four slots, each a region of the frame (in the pointer's units, the whole frame 2 by 2) and its actions. A finger that comes down in a free slot's region drives that slot until it lifts, wherever it goes: - a slot with `x`, `y`, `press` and `stick` is a thumb stick: `x` and `y` are how far the thumb is from where it came down; - a slot with `press` alone is a button. `shown = true` draws the control (a disc with its `label`, or a stick's ring and knob) over the game inside the screen's safe area. It is the player's picture only: no thing, no checksum, no shot. `while_hidden` and `while_shown` tie a slot to whether an interface node is shown, as Embers does with its title panel. ## Showing the right key `input.keys("jump")` lists the names of the keys bound to an action on the device the player used last: the keyboard's (`Space`) until a pad is used, then the pad's (`PadA`). The sample writes it into its hint. Which device was last used is recorded, so a replay shows the same hint. ## Recordings `[input] recording` is a list of stretches, each holding some actions at values for some steps; an action left out is at rest. `input.history` over the protocol returns a played session in exactly this form, and a long one goes in a file of its own (`recording = "run.toml"`). A recording also says the frame it was made in when that is not `[window] size`, so a game that fills a phone's screen replays at that shape. ## Checks ```sh frost check game.toml frost test game.toml ``` Over the protocol, `input.set {player, action, value}` holds an action and `game.step` steps on it: how an agent plays a game by hand, with the same result as a person at the keys. --- Page: guides/ui.md # Interface Build menus, buttons, sliders and a HUD without writing layout code. They are things in the scene, like everything else. A thing with a `Node` is a box; boxes sit in boxes; the engine lays them out and drives them from input actions each step, before the scripts, which read what was used in that same step. The focus is world state, so a recording replays a menu. Every field is in the [interface reference](../reference/ui.md). ![The menu-ui sample at step 120](../files/examples/menu-ui/shots/menu.png) That frame is the menu-ui sample: a stack of a button, a slider, a choice and a toggle, a health bar that drains, and a line cut short with `...`. Its project file says which actions drive the interface and its design height: ```toml # example: menu-ui/game.toml # The interface guide's game: a menu laid out by the engine (a stack of a button, a # slider, a choice and a toggle), a health bar, and a line cut short with an ellipsis, # all at a design height of 180 that is drawn at the frame's height. # # frost dev game.toml # frost run --headless --steps 120 --shot shot.png game.toml scene = "menu.toml" scripts = ["menu.luau"] seed = 1 shots = [{ name = "menu", step = 120 }] replay = { steps = 120, checksum = "2a6eedea15152a6d", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [640, 360] background = 0x15171c [input] actions = ["move_x", "move_y", "accept", "back"] # Down to the slider, right twice, down to the choice, accept, up to the top, accept. recording = [ { steps = 20 }, { steps = 2, move_y = -1 }, { steps = 10 }, { steps = 2, move_x = 1 }, { steps = 10 }, { steps = 2, move_x = 1 }, { steps = 10 }, { steps = 2, move_y = -1 }, { steps = 10 }, { steps = 2, accept = 1 }, { steps = 10 }, { steps = 2, move_y = 1 }, { steps = 4 }, { steps = 2, move_y = 1 }, { steps = 10 }, { steps = 2, accept = 1 }, { steps = 20 }, ] [input.keys] move_x = [{ negative = "Left", positive = "Right" }, "PadLeftX"] move_y = [{ negative = "Down", positive = "Up" }, "PadLeftY"] accept = ["Enter", "Space", "PadA"] back = ["Escape", "PadB"] # The actions that drive the interface, the node a menu opens on, and the design height: # every node and text with Screen is laid out in units of a 180-high frame. [ui] fit = 180 x = "move_x" y = "move_y" accept = "accept" back = "back" start = "play" [ui.theme] normal = 0x8a8f98 focus = 0xf2a53b pressed = 0xffffff ``` ## Boxes and where they go The menu, with no `Transform` saying where anything is: ```toml # example: menu-ui/menu.toml # Every thing here is a node: the engine lays them out, so no Transform says where. [menu] Transform = {} Screen = {} Node = {} Anchor = { dy = 6 } Stack = { gap = 4, pad = 4 } Rect = { color = 0x1c1f27, layer = 9 } [play] Transform = {} Screen = {} Node = { parent = "menu", order = 1, w = 110, h = 20 } Rect = { layer = 10 } Text = { text = "PLAY", color = 0x15171c, layer = 11 } Button = { event = "play" } [volume] Transform = {} Screen = {} Node = { parent = "menu", order = 2, w = 110, h = 20 } Rect = { layer = 10 } Text = { text = "VOLUME", color = 0x15171c, layer = 11 } Slider = { value = 0.5, step = 0.1, event = "volume", fill = "volume_fill" } [volume_fill] Transform = {} Screen = {} Node = { parent = "volume", h = 3 } Anchor = { x = 0, y = 0, dx = 2, dy = 2 } Rect = { color = 0x15171c, layer = 11 } [quality] Transform = {} Screen = {} Node = { parent = "menu", order = 3, w = 110, h = 20 } Rect = { layer = 10 } Text = { text = "", color = 0x15171c, layer = 11 } Choice = { options = "LOW|MEDIUM|HIGH", index = 1, event = "quality" } [sound] Transform = {} Screen = {} Node = { parent = "menu", order = 4, w = 110, h = 20 } Rect = { layer = 10 } Text = { text = "SOUND", color = 0x15171c, layer = 11 } Toggle = { on = true, event = "sound" } # A bar nobody moves: the script sets its value and the fill follows. [health] Transform = {} Screen = {} Node = { w = 100, h = 8 } Anchor = { x = 0, y = 1, dx = 6, dy = -6 } Rect = { color = 0x2b3140, layer = 9 } Bar = { value = 1, fill = "health_fill" } [health_fill] Transform = {} Screen = {} Node = { parent = "health", h = 4 } Anchor = { x = 0, dx = 2 } Rect = { color = 0x6fd16f, layer = 10 } # One line cut to the width with "..." rather than wrapped. [news] Transform = {} Screen = {} Node = {} Anchor = { y = 0, dy = 6 } Text = { text = "THE CARAVAN LEAVES AT DAWN FROM THE EASTERN GATE", color = 0xeceae6 } Wrap = { w = 150, ellipsis = true } [said] Transform = {} Screen = {} Node = {} Anchor = { x = 1, y = 1, dx = -6, dy = -6 } Text = { text = "", color = 0x8a8f98 } ``` - A node's box has its middle on its `Transform` and is `w` by `h`; its `Rect` or `Sprite` is drawn that size. Write the size once, in `Node`. - A node with a `Text` and no size is as big as its words; a `Stack` or `Grid` with none is as big as what is shown in it. - A node goes where the `Stack` or `Grid` it is in puts it (by `order`, lower first: give each one), else where its `Anchor` says, else where its `Transform` is. A node in nothing is anchored to the frame: `Anchor = { x = 1, y = 1, dx = -6, dy = -6 }` is six units in from the top-right corner. - `stretch_x` and `stretch_y` make a node as wide or as tall as what it is in. - Give interface things `Screen`, so the camera does not move them. - `set(find("pause"), "Node", "shown", true)` shows a menu and everything in it. ## Controls | On a node | Is used by | Sends | | --- | --- | --- | | `Button = { event = "play" }` | accept, or a click | its event | | `Slider = { value, min, max, step, fill }` | left and right, or a drag | its event with the new value | | `Choice = { options = "LOW\|MEDIUM\|HIGH" }` | accept, left and right | its event with the new index; writes the option into its text | | `Toggle = { on, mark }` | accept, or a click | its event with whether it is on | | `Bar = { value, fill }` | nobody: a script sets `value` | nothing | A script that sets a `value`, an `index` or an `on` itself sends nothing. `locked = true` takes the focus and refuses to be used (`ui_locked` is sent instead); an `off` button is not there at all. `modal = true` makes a shown node the only one that can be used, and `back = "closed"` on a menu sends that event when the back action is used anywhere in it. The sample's script reads what was used: ```lua -- example: menu-ui/menu.luau -- The interface sends events as it is used; the script reads them in the same step. state.said = state.said or "PICK ONE" state.volume = state.volume or 0.5 local function say(text) state.said = text set(find("said"), "Text", "text", text) end function on_scene(name) say(state.said) -- ui.measure: how wide a text is drawn, in design units at size 1. local width = ui.measure("PLAY") print("PLAY is " .. width .. " units wide") end function step(dt) for _, e in ipairs(events("play")) do say("PLAY") end for _, e in ipairs(events("volume")) do state.volume = e.value say("VOLUME " .. math.floor(e.value * 10 + 0.5)) end for _, e in ipairs(events("quality")) do say("QUALITY " .. e.value) end for _, e in ipairs(events("sound")) do say(if e.value ~= 0 then "SOUND ON" else "SOUND OFF") end -- The bar drains with time, to show it follows its value. local health = find("health") set(health, "Bar", "value", math.max(0, get(health, "Bar", "value") - 0.2 * dt)) end ``` ## Focus `[ui]` names the actions: `x` and `y` move the focus (and a slider), `accept` uses the node with the focus, `back` goes back, and `press` is the pointer's button. One node has the focus; a direction moves it to the nearest one that way, round a stack's ends and along a grid's rows. Where the rules guess wrong, a node names its neighbour with `up`, `down`, `left` or `right`. When a menu opens, the focus goes to the node that last had it, else the `[ui]` `start` node. `ui.focus(entity)` gives it to a node. `[ui.theme]` colours a usable node by its state: `normal`, `focus`, `pressed`, `off`, `locked`. A pointer press that began on a shown node is the interface's: scripts read the `press` action as 0 until it is let go, so a click on a button never fires the game's gun too. ## A design height `[ui] fit = 180` lays the interface out in units of a frame 180 high and draws it at the frame's real height: the sample's frame is 360 high, so every node and text is drawn at twice its size, and a frame of another height draws the same layout larger or smaller. Everything with `Screen` follows it, in 2D and in 3D, and the pointer finds nodes in the same units. Left out, the interface is laid out in pixels. `frame.size()` still says the frame's pixels. ## Text The built-in font is 5 by 8 pixels a glyph, printable ASCII, `size` a whole number, so every font pixel is a sharp square. `align` says where `Transform.x` is along a line, `Shadow` draws a copy under it, and `Wrap = { w = 150 }` starts new lines before a word that would pass the width. `Wrap = { w = 150, ellipsis = true }` cuts each line to the width with `...` instead, as the sample's news line does. `ui.measure("PLAY")` is how wide and tall a text is drawn, in design units at size 1 (the sample prints 23: four letters of six font pixels, less the last gap). Give it a style name to measure a text in that style. A game's own fonts are text styles under `[fonts]`: a size in pixels and one or more TrueType or OpenType files, each character drawn from the first file that has it, so a second file adds an alphabet the first lacks. A text is written in a style with `Font = { style = "body" }` beside it. Letters keep their own widths and kerning, and each glyph stands on whole pixels. Not yet: joining scripts (Arabic, Devanagari), right-to-left lines, colour emoji, combining marks, and text outlines. Fonts are the game's own files: never load one from a player or a server. ## Checks ```sh frost check game.toml frost test game.toml ``` Over the protocol, `ui.tree` reads the laid-out tree (each node's box, in design units) and `ui.focus` moves the focus: what an agent uses to see a menu without a picture. --- Page: guides/audio.md # Audio Play sound effects and music from your scripts, and check what a game plays without speakers. Sound is output: a script cannot read what was heard, and a request to play is not in the world, the checksum or a snapshot. What a recorded run asks to hear is still the same every time, and the command line can list it or write it to a file. Every call is in the [sound reference](../reference/sound.md). ## The sample The sounds sample loops a music track and blips each time a ball bounces, to the side the ball is on. Its two WAV files are written by its `sounds/make.py`. ```toml # example: sounds/game.toml # The sound guide's game: a looping music track, and a blip each time the ball bounces, # panned to where the ball is and a little different in pitch each time. Sound is output: # nothing here changes the world, and `frost run --sounds` lists what was asked for. # # frost dev game.toml # frost run --headless --steps 240 --sounds game.toml # frost run --headless --steps 240 --wav out.wav game.toml scene = "scene.toml" scripts = ["bounce.luau"] seed = 1 sounds = ["sounds/blip.wav", "sounds/hum.wav"] replay = { steps = 240, checksum = "00d88d25c7211edd", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [320, 180] background = 0x15171c ``` ```lua -- example: sounds/bounce.luau -- A ball crosses the frame and back. Each bounce plays the blip at the ball's place -- (left or right of the camera) with its pitch varied by up to a tenth; the varied pitch -- comes from the game's seeded random, so a recording sounds the same every time. state.vx = state.vx or 120 function on_scene(name) music.play("sounds/hum.wav", { volume = 0.4 }) end function step(dt) local ball = find("ball") local x = get(ball, "Transform", "x") + state.vx * dt if x < 8 or x > 312 then state.vx = -state.vx x = math.clamp(x, 8, 312) sound.play("sounds/blip.wav", { volume = 0.8, vary = 0.1, at = ball }) end set(ball, "Transform", "x", x) end ``` ## Files A game lists the sounds its scripts play under `sounds` in the project file: WAV files, or Ogg Vorbis. An Ogg file of ten seconds or less is decoded whole when the game loads; a longer one is decoded as it plays and can only be the music (`sound.play` of one is `E0430`). On the web every Ogg file is decoded when the game starts, so every browser plays the same samples a desktop does; `frost check` warns of a sound over three minutes in a game meant for a browser (`W0437`). ## Effects `sound.play("sounds/blip.wav", { volume = 0.8, pitch = 1, vary = 0.1, at = ball })` plays a sound once. - `volume` is 0 to 1 and `pitch` a speed, 0.25 to 4; outside the range is an error. - `vary = 0.1` draws each play's pitch within a tenth of `pitch` from the game's seeded random, so a recording sounds the same every time (and the `math.random` numbers after it move). - `at = entity`, or `x = 40`, pans a 2D play left or right by where it is against the camera. In 3D, `at` pans by the thing's side of the camera and fades it with distance: full within `near` metres, silent past `far` (`[sound] near` and `far`, 2 and 30 when left out). - At most 4 plays of one sound and 32 in all are heard; one more eases out the quietest. A playing sound has no handle: it cannot be stopped, looped or moved once asked for, and there is no positioning beyond the pan and the distance fade. ## Music `music.play("sounds/hum.wav", { volume = 0.4 })` loops one track, in place of the one before: there is one music track at a time. `music.stop(1)` fades it out over a second, `music.pause()` and `music.resume()` hold it and let it go on, and `music.volume(0.2, 2)` moves its own volume over two seconds. To cross from one track to the next, stop the first with a fade and play the second when it is done. ## Volumes `sound.volume(level)` is the gain of everything heard and `sound.effects(level)` of all that `sound.play` plays; volumes multiply. A settings screen's sliders write `music.volume` and `sound.effects`. ## Hearing a run without speakers ```sh frost run --headless --steps 240 --sounds game.toml ``` lists every request with its step, for the sample: ```text sound: step 0 music sounds/hum.wav 0.4 1 sound: step 76 play sounds/blip.wav 0.8 1.0133123 0.9375 sound: step 228 play sounds/blip.wav 0.8 1.0491563 -0.9375 ``` (the volume, the pitch as varied, and the pan: right at the right wall, left at the left). `--wav out.wav` writes what the run would sound like: 16-bit stereo at 48,000 a second, the same bytes every run, and prints its peak (`peak: 0.488` here). A peak over 1 would be cut off by a real device, and `frost run` warns of it (`W0438`). `frost bench --sound` mixes each step's sound as it measures. Over the protocol, `audio.requests` answers the same list. ## Checks ```sh frost check game.toml frost test game.toml frost run --headless --steps 240 --sounds game.toml ``` --- Page: guides/atlases.md # Atlases: frames by name Draw many different sprites for the cost of one. An atlas is many pictures on one, each a frame with a name: a sprite gives the atlas as its `image` and the frame as its `frame`. Every sprite of an atlas is one picture to the device, so sprites of one atlas on a layer are one draw call, wherever they are. An atlas is a file of its own, `NAME.atlas.toml`, in one of two forms: ```toml # art/hero.atlas.toml: the PNG files the patterns match, packed onto one page; each # frame is named by its file's name without .png (hero/run_0.png is "run_0"). pictures = ["hero/*.png"] ``` ```toml # art/coins.atlas.toml: one sheet cut into cells, row by row from the top left; each # name is the next cell's. sheet = "coins.png" grid = [8, 8] names = ["turn_0", "turn_1", "turn_2", "turn_3"] ``` ## Patterns Paths are from the atlas file's folder. In a pattern, `*` is any run of a file's name in one folder, and nothing else is special: no `**`, no `?`, no braces, no `*` in a folder's name. Matches are taken in sorted order; a pattern that matches nothing is `E0532`, and `frost check` prints what each pattern matched. ## The page The pictures go whole onto one page of at most 4096 by 4096, tallest first, shelf by shelf; frames that do not fit are `E0530`, which says how many do. Nothing is trimmed: a frame's rectangle is its picture's. Each picture's edge pixels are copied once outward, so a frame draws the pixels its picture draws alone: exactly with `filter = "nearest"`; with `"linear"` a scaled frame may differ from its picture alone by one step in a few pixels. A sheet is kept as it is. ## A sprite on a frame With a `frame`, `src_x`, `src_y`, `src_w` and `src_h` cut a part of the frame, from its top left, a width or height of 0 being the rest of it; a part that would reach past the frame's edge stops at it, so a sprite never shows its neighbour on the page (and never stretches the frame's edge the way a part past a picture's own edge does). A name the atlas does not have is `E0531`, which says the three nearest. A sprite with a `frame` and a `Repeat` is refused (`E0533`): a repeat reads the whole page, so a repeating sprite needs a picture of its own. It is refused whichever came first and whenever they meet: at load; when the editor puts a `Repeat` on a sprite with a frame (`world.insert` is refused and the world stays as it was); and at the end of the step in which a script spawns such a sprite or a frame is written on a repeating one, by a script or by `world.set` (the step stops with `E0533`, shown where the game shows errors, as a picture that was not loaded is with `E0420`). Until then such a sprite is not drawn at all: never drawn wrong. A `Clip` writes `src_*` of the whole picture, so a sprite that plays one leaves `frame` empty; a script that changes `frame` animates an atlas's sprite. ## Cooked and exported `frost cook FILE.atlas.toml` prints each frame's size and place. The editor reads the same through `assets.cooked {path}`: the page's size and every frame's `{name, x, y, w, h}`. An exported game carries each atlas cooked, `NAME.atlas.toml.vatl`, and not the pictures packed in it. --- Page: guides/streaming.md # Streaming worlds Build a world bigger than you could keep loaded at once. You cut it into cells: scenes on a grid that enter near the things your game follows and leave behind them. Which cells are in at a step is decided by one rule, before physics, from what the world holds, so a recorded run streams the same way on every machine and every time it is played again. The whole of it is [streaming cells](../reference/project.md#streaming-cells) in the reference. ## A road of four cells The stream-cells sample is a hero walking right along a road of four cells and back: ```toml # example: stream-cells/game.toml # A road of four cells that enter ahead of the hero and leave behind it, by one rule on # every machine. The hero walks right across them, then back. # # frost dev game.toml # frost test game.toml scene = "base.toml" scripts = ["main.luau"] seed = 1 replay = { steps = 600, checksum = "c6b840469fb21a48", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [ [256, "d58d9b4530b1d282"], [512, "023608768c5b3d94"], ] [window] size = [320, 180] background = 0x15171c # Cells are scenes in `folder`, named by their grid place (X_Y in 2D), each `size` # units on a side. Those within `load` cells of a follower enter; those beyond `drop` # leave. At most `budget` things enter in a step. [stream] folder = "cells" cells = ["0_0.toml", "1_0.toml", "2_0.toml", "3_0.toml"] size = 160 load = 1 drop = 1 followers = ["hero"] budget = 64 [input] actions = ["move_x"] recording = [{ steps = 290, move_x = 1 }, { steps = 310, move_x = -1 }] [input.keys] move_x = { negative = "A", positive = "D" } ``` A cell is an ordinary scene, written in world coordinates, named by its grid place (`X_Y.toml` in 2D, `X_Z.toml` in 3D); `floor(position / size)` is the cell a point is in, negative places too. Only the cells listed exist; a gap is empty world. ```toml # example: stream-cells/cells/1_0.toml # Cell 1 of the road: world coordinates, names unique across every cell. [road1] Transform = { x = 240, y = 40 } Rect = { w = 160, h = 8, color = 0x466450 } [post1] Transform = { x = 280, y = 64 } Rect = { w = 6, h = 40, color = 0xc9bfae } ``` What is always there (the hero, the camera, the interface) is the base scene. A follower must be in it: a follower that is missing or outside the grid is `E0577`. ```toml # example: stream-cells/base.toml # The base scene: what is always there. A follower stays in it, never in a cell. [hero] Transform = { x = 40, y = 60 } Rect = { w = 10, h = 10, color = 0xf2364b } [camera] Transform = { x = 160, y = 90 } Camera = {} [cells] Transform = { x = 160, y = 168 } Text = { text = "", size = 1, color = 0xeceae6 } Screen = {} ``` ## The table | Key | Is | | --- | --- | | `folder` | Where the cells are, from the project file | | `cells` | The cells, listed: a file missing is an error | | `size` | A cell's side, in world units | | `load` | How many cells round a follower are brought in (1 when left out) | | `drop` | How far a cell may be before it leaves, at least `load` (2 when left out): the gap stops a cell entering and leaving on a boundary | | `followers` | The things cells gather round; left out, the lowest placed `Camera` | | `budget` | How many things may enter in one step (256 when left out): a cell enters whole, or waits for the next step | ## In a script `cell.enter` and `cell.leave` are events like any other, with the cell's `"X,Y"` as their value, seen by scripts in the same step. Entering means every thing of the cell is there; leaving means its things were saved and removed. ```lua -- example: stream-cells/main.luau -- Walk the hero along the road; the camera follows. A cell's entry and leaving are -- events like any other, with the cell's "X,Y" as their value. state.entered = state.entered or 0 state.left = state.left or 0 function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") + input.get(0, "move_x") * 120 * dt set(hero, "Transform", "x", x) set(find("camera"), "Transform", "x", math.max(160, x)) for _, cell in ipairs(events("cell.enter")) do state.entered += 1 state.last = "LAST IN " .. cell.value end for _, cell in ipairs(events("cell.leave")) do state.left += 1 state.last = "LAST OUT " .. cell.value end set(find("cells"), "Text", "text", "IN " .. state.entered .. " OUT " .. state.left .. " " .. (state.last or "")) end ``` | Call | Does | | --- | --- | | `stream.loaded(x, y)` | Whether the cell at this world position is wholly in. A position, not a cell's number: the cell two along with `size = 160` is `stream.loaded(2 * 160, 0)` | | `stream.hold(x, y, on?)` | Keeps the cell at this world position in (or, with `false`, lets it go) whatever the followers do | An entity number kept from a cell is dead once the cell leaves: `find` it again after it comes back. Physics waits while a cell it needs is still on its way in; scripts still run, and can hold back travel on `stream.loaded`. ## What a cell remembers A thing a cell owns keeps its changes when the cell leaves: a moved crate is where it was left when the cell comes back, a body keeps its velocity, a despawned thing stays gone. A thing that crosses out of its cell becomes the world's for good and never doubles on the way back. Things scripts spawn are always the world's. All of it is world state, so a replay, a snapshot and a seek keep it; `scene.load` starts it afresh. ## Checks and costs - `frost check` reads every cell; a wrong grid or cell is `E0576`, a name two cells share at entry `E0578`, holding a cell that is not listed `E0579`. - `frost test` holds the run's checksum, streaming included, and `frost test --restore` shows that a game put back at a checkpoint streams on the same. - The protocol's `stream.read` says which cells are in, what is saved of those that are out, and whether physics may step. The `stream` span in `frost bench` times the boundary; `stream.cells` and `stream.entered` count its work. ## Limits Cell text and assets are read when the game loads, on the web too: this version bounds the things and bodies alive, not the memory of assets. Connected things (a `Parent`, a `Joint`, an interface `Node`) belong in the base scene, and a cell cannot include scenes. Ground must cover its cell, and bodies must stay within the cells kept in. --- Page: guides/networking.md # Multiplayer Let 2 to 8 players on different machines play one game. You write the game as you would for players sharing a keyboard: read each player's input by number, and the engine keeps every machine's game the same. It works by rollback. Because a Coldwave game [plays the same on every machine](../concepts/steps.md) for the same input, players send each other their inputs and nothing else, and every machine plays the whole game. A player's input reaches the others a few steps late; until it arrives, each machine predicts it, and when the real input was not what was predicted, that machine puts its world back a few steps and plays them again. You write no network code for any of it. > **Note.** Multiplayer today is for games among friends on one network: players > connect directly to the host's address over UDP. There is no relay, no lobby that > finds games and no multiplayer in the web player yet, and a game in C# is refused. > See [not yet](networking.md#not-yet). ## Make a game for two or more ```toml [input] actions = ["move"] players = 2 # 2 to 8 over a network [net] # optional; these are the defaults delay = 2 # steps a player's input waits before its step, 0 to 8 window = 8 # steps that may be played on predicted input, 1 to 16 sync_every = 30 # steps between checksum comparisons, 1 to 600 wait_ms = 10000 # how long the game waits for a silent player before dropping it, 1000 to 60000 ``` A script reads each player's input by number, as it does for a recording or a test: `input.get(1, "move")`. Your script is never told which player is the local one, because that would make the players' worlds differ. **The one rule:** everything your game is must live in components or in `state`, never in a script's `local`. A rollback puts the world back, and a `local` does not come back with it. The engine checks this before a network game starts (`E0540`), and `frost test --restore` tells you where the problem is. The engine's own example, Duel, has two paddles, a ball and a crate it knocks about, all of it 2D physics, with a version of the same court for four players. ## Play it One player hosts, the others join the address the host prints: ```text frost dev game.toml --host hosting at 127.0.0.1:52371: ... frost dev game.toml --join 127.0.0.1:52371 ``` Each window plays at 60 steps a second with its own player's keys. The title bar says which player the window is and, when the game waits, why: `waiting for 1 more player to join at ...`, `waiting for player 2: silent 1.4 s`, `player 2 is not answering`, `player 2 left`, `the worlds differ from step 120`. - **A player who closes the window** says goodbye: that player's input is at rest from then on, on every machine, and the others play on. - **A player who goes silent** for `wait_ms` (10 seconds when left out) is dropped, and the others play on. With no window, `frost run --headless --host` or `--join ADDRESS`, with `--seconds S`, does the same with each player's recording as its input. ## Host and join from your own menu Your game can host and join from its own menu: a button's script calls `net.host()` or `net.join(address)`. Until every player is in, the game is local and each machine runs its menu alone. Once they are in, every machine loads the game again from its files, at the scene `[net] start` names, at step 0, so every player starts from the same world whatever each menu did. ```toml [net] start = "court.toml" # the scene every player starts in address = "127.0.0.1:7170" # where net.host() and net.join() go when given no address ``` | Call | Does | | --- | --- | | `net.host(address?)` | Asks to host, on `address`, `[net] address` or a free port of this machine | | `net.join(address?)` | Asks to join the host at `address` or `[net] address`; it asks again every 100 ms for up to 60 s | | `net.cancel()` | Stops hosting or joining | | `net.state()` | `{phase, player, players, joined, address, words, refused}`: `phase` is `off` (no `[net]` table, or a program with no network), `alone`, `hosting`, `joining` or `playing`; `words` is the sentence the window's title shows (`waiting for the host`); `refused` is the last request that could not be done, `{code, words}` | | `net.player()` | The player this machine plays, from 0, once it is known | A request that cannot be done is not an error in the step: `net.state().refused` tells you, with its code. Once the game is playing with the others, these five calls stop the step with `E0544`, because each machine would get a different answer. So ask `net.player()` in the menu ("you will be player 2"), not in the game. A test or a replay keeps the requests and does nothing with them, so a menu that hosts still replays. The Duel example has such a menu, with HOST, JOIN and PLAY ALONE (`lobby.toml`, `menu.toml` and `menu.luau`). ## Join a game already under way A game can begin before every seat is taken, and a player can join later: - Set `[net] begin_with = 1` and a game your menu hosts begins with the host alone, the other seats open. An open seat's input is at rest until someone takes it. - A player who joins late is sent the game as it stands, catches up, and then plays like the others. The others play on all the while. One player joins at a time (`E0546` for a second). - **Coming back.** A player who was dropped or left can take the same seat back. An exported game remembers its seat in `net-seat.toml`, beside the game's saves, so a player who starts the game again after a crash takes the seat back by pressing JOIN. Nobody else can take that seat (`E0569`). The seat of a host who left cannot be taken back yet. - A game whose state is over 1,000,000 bytes cannot be joined late (`E0568` says its size). For scale, Duel for four is 16,042 bytes at step 300, and the Embers template in 3D 46,562. > **Warning.** A seat's token is sent unencrypted, like everything else, so anyone who > can read your network traffic could take a seat. That is fine for friends on a home > network; it is not protection for the open internet. ## Ship it `frost export desktop` builds network play into your game's player when the game has a `[net]` table, and only then: a game without one ships no network code. The exported player takes the same flags: ```text duel --host hosting at 127.0.0.1:52371 duel --join 127.0.0.1:52371 joined as player 2 ``` Network play adds 100,752 bytes to an exported player (measured on Duel's, on macOS on Apple silicon). Android exports of a game with `[net]` ask for the Internet permission. ## When something is refused | Code | When | | --- | --- | | `E0540` | The game, put back at the middle of its recording, does not go on the same: a rollback would change the game. Keep what the game is in the world or in `state`, not in a script's `local`; `frost test --restore` finds where | | `E0541` | A player's game files are not the host's, file for file | | `E0542` | Two players' worlds differ. The report names the step, the value on each side and the script line that last wrote it | | `E0543` | The game is in C#: not supported yet | | `E0544` | A setting out of its range, a second session, or none | | `E0545` | One player, or no actions | | `E0546` | A join with no seat: the game has every player, or has begun with every seat taken, or another player is joining right now | | `E0547` | An input that cannot be taken: a player the game does not have, values of another length, a value that is not a finite number, a step too far ahead, or one older than the window | | `E0548` | An address that is none, or a socket that cannot be opened | | `E0549` | A host or player that says nothing for the time allowed | | `E0565` | A game's menu asked to host or join, and the game has no `[net]` table | | `E0566` | A late join where the game sent does not fit this game: its components, players, scenes, tuning or physics are different | | `E0567` | A late join where the game sent cannot be read: from another version of the engine, or cut or changed on the way | | `E0568` | A late join to a game whose state is over 1,000,000 bytes: the refusal says its size | | `E0569` | A join to a seat whose player left, without that seat's token: only its player can take it back | When two worlds differ (`E0542`), you do not have to guess why: each machine reports the step, the field, its value on both sides and who last wrote it, for example `Match.travel` of `match`, last written by `duel.luau` line 54. ## How well it holds up Measured with two players on one machine for 60 seconds, with 30 ms of latency (give or take 10) and 10% of packets lost each way, on a busy machine: all 3,600 steps were confirmed with the same checksum on both sides, the same as the recording played alone. The host rolled back 8 times and the joiner 6. Putting the world back and playing 8 steps again, the most the default settings ever ask for in one frame, took a median of 0.15 ms for a small 2D game and 4.0 ms for a 3D game with 160 physics bodies, out of a 16.7 ms frame (Apple M4 Max, on a busy machine). Sound is never rolled back. A sound a corrected step asks for that the prediction did not is played then, a little late; one only a wrong prediction asked for is left to finish, because a sound cut short clicks. ## Driving it from a program Everything above is also a [protocol](../concepts/protocol.md) command, for a test or an AI agent: `net.host`, `net.join`, `net.run`, `net.status`, `net.leave`, and for tests `net.condition` (make the link late and lossy) and `net.desync` (make the worlds differ). [The protocol's net commands](../reference/protocol/net.md) have the details. ## Not yet - A relay, or a lobby that finds games: players connect directly to the host's address. - Multiplayer in the web player: a browser has no UDP. - Games in C# (`E0543`). - Taking back the seat of a host who left. - A network view in the editor. --- Page: guides/undo-landing.md # Undo one agent's change When an AI agent's change has been merged into your game (a "landing") and you later decide against it, you can take that one landing back and keep everything that was made after it. The editor's **Landing** tab lists every landing, and each can be undone on its own; over [the protocol](../concepts/protocol.md) it is one command: ```json {"jsonrpc":"2.0","id":1,"method":"project.undo","params":{"landing":1}} ``` ## What it does, and when it is refused - **It reverses that landing only.** Later edits that do not depend on it stay. The undo is merged field by field and line by line, the same way a landing is. - **It is tested before anything is written.** The undo is played against what the landing said it would change (its `says`). If a later edit touched the same field, or the undo would move something the landing never said it changes, it is refused with `E0470` and a reason. Resolve the conflict, or undo the change that depends on it first. - **Your tests stay in step.** The game's replay checksums and any changed shots are accepted together with the undo. A game with shots needs a graphics adapter: the undo is refused when the picture check cannot run. - **A shot the landing added goes with it.** Its entry leaves the project file and its picture is removed from `shots/`; both come back if you undo the undo. The landing must belong to the current session, and its original change must still be among the latest 64 changes of the session's journal. `copy.landed` lists the landing numbers (they are not the journal's change numbers), and `copy.landed` and `copy.diff` answer `undone: true` for a landing you took back, for the rest of the session. ## Try it You need no window for this. Make a game with these two files: ```toml # game.toml scene = "s.toml" replay = { steps = 20, checksum = "0000000000000000" } ``` ```toml # s.toml [ball] Transform = { x = 0, y = 0 } ``` Run `frost test --write game.toml`, then `frost serve game.toml`. Send each JSON-RPC request as one line on standard input and read its reply before sending the next: ```json {"jsonrpc":"2.0","id":1,"method":"copy.make","params":{"name":"x"}} ``` In the returned folder's `s.toml`, change `x` to 10, then send: ```json {"jsonrpc":"2.0","id":2,"method":"copy.land","params":{"copy":"x","says":["ball.Transform.x"]}} {"jsonrpc":"2.0","id":3,"method":"copy.make","params":{"name":"y"}} ``` In that second folder's `s.toml`, keep `x = 10` and change `y` to 20. Send: ```json {"jsonrpc":"2.0","id":4,"method":"copy.land","params":{"copy":"y","says":["ball.Transform.y"]}} {"jsonrpc":"2.0","id":5,"method":"project.undo","params":{"landing":1}} ``` The game's `s.toml` now has `x = 0, y = 20`, and `frost test game.toml` passes. The undo reply's `change` is a new inverse change. Ordinary `project.undo` takes that inverse back, restoring `x = 10, y = 20`; `project.redo` applies it again. `copy.diff {"landing": 1}` and `copy.landed` report whether landing 1 is undone. ## When two changes pass alone and fail together Two agents' changes can each pass their own test and still break the game once both are in. To find out why, test one copy with the other changes underneath it: ```json {"jsonrpc":"2.0","id":6,"method":"change.test","params":{"copy":"thud","with":[{"copy":"lip"}],"says":[]}} ``` When the combined run fails, the answer shows you the same value in each run side by side. For a first differing component field, `differs` names `step`, `entity`, `component`, `field`, `value`, `was` and `writer`. `was` is the reference run's value. The added `differs.comparison` gives the columns directly: | Field | Meaning | | --- | --- | | `window` | Always 5: the differing step plus up to four preceding steps. | | `from`, `to` | `max(0, differs.step - 4)` and `differs.step`, inclusive. | | `alone` | One run per `hands` entry, in the same order (`with`, then the tested change). Each has `copy` and `who`, or `folder`. | | `together` | The combined run that failed the test. | | `extra_steps` | The number of attempted simulation steps replayed for all comparison columns. | Each run has `present`, `value`, `writer`, `samples`, and `error`. Its top-level value and writer are at `to`. `samples` contains at most five `{step, present, value, writer}` records in step order. Values use the same JSON scalar types as `world.get`; writers are the structured objects from `blame.value`, including script callers, or null when unknown. These are observations after each completed step; step 0 is after loading and scene initialization. `present: false` means the named thing, component or field does not exist at that step; its value and writer are null. This is distinct from a present field with a null JSON value. If an alone cannot load or reach the differing step, has no replay, or its own replay ends before that step, its `error` explains why, `samples` is empty, and `present`, `value` and `writer` are null. The original together failure remains the answer. Each `with` alone applies only that change over `before` when supplied, otherwise over the served game. The final hand uses the served game plus `folder`. Each uses its own recording, including its own tuning and script state. It is not a prefix of the `with` stack. These values do not assert that an alone passes: use that copy's own `change.test` verdict. Files saved since that verdict are read afresh, as in every change test. `who` names the copy's hand; `writer` names the scene, script or system that last wrote the value in that run. A passing test keeps no field snapshots and enables no writer tracking. Only after finding a component-field difference does the comparison load each returned run, one at a time, and replay to `to` with writer tracking. It samples only the reported field, at steps `max(0, to - 4)` through `to`; no pictures are taken. Each alone and together is played once. For two changes this costs `3 * to` extra steps; for H hands it costs at most `(H + 1) * to`, counted in `extra_steps` (failed attempts count too). With one `with` and no `before` the test's reference is the same game as that change alone; it is played again like every other column. The comparison keeps at most five samples and the final value for each run, however long the recording is, and nothing is cached between requests. The added work is included in `ms`; comparison data contains no clock times. There is no comparison for a passing test, a failure without a component-field path (such as a script-state or entity-list difference), or a request without `with`. No picture is added to the answer. An example: two copies, `lip` and `thud`, each pass alone. At step 76, `player.Player.vy` is 590 in lip alone, 590 in thud alone and 586 together. The window is steps 72–76; steps 72–75 hold 0 in all three runs. Lip's writer is `demo.luau:51` in `move`, called from line 70; thud and together use line 52, called from line 71. The comparison reports `extra_steps: 228`. --- Page: guides/luau.md # Gameplay in Luau You write your game's rules as Luau scripts: a small, fast language, sandboxed by the engine, with no JIT. The project file lists them under `scripts`, and they run in that order every step. [The scripts reference](../reference/scripts.md) is the whole API; this page is how to write a game with it. ## The shape of a script A script's top level runs once, when it is loaded. The engine then calls the functions it defines: | Function | Called | | --- | --- | | `step(dt)` | Once a fixed step, sixty a second; `dt` is the step's length in seconds | | `on_scene(name)` | When a scene has started, its things in place and nothing yet drawn; also for the scene the game starts in | | `on_restore()` | Before the script next runs, after the game was put back to another moment (a seek, a test, a rollback) | Every engine call but `print` needs the world, so `find`, `each` and `math.random` work in those functions, not at the top level. The two-scenes sample: ```lua -- example: two-scenes/main.luau -- Walk right to the door to go to the second level. `state` outlives a scene; things -- and the entity numbers a script kept do not, so on_scene finds them again. state.level = state.level or 1 function on_scene(name) set(find("title"), "Text", "text", "LEVEL " .. state.level .. ": " .. name) end function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") + input.get(0, "move_x") * 80 * dt set(hero, "Transform", "x", x) local door = find("door") if door and x > get(door, "Transform", "x") - 8 then state.level = 2 scene.load("level2.toml") end end ``` ## `state`, and what a `local` is for `state` is the script's own table that outlives a step: counters, timers, the level number. The engine copies it into the world at the end of every step, so it is in every snapshot and checksum, a client can read it (`script.state`), and a world put back hands the script its old `state` again. It holds plain data: numbers, text, true or false, and tables of those (a function or a metatable in it is `E0307`). Fill it at the top of the script with `state.score = state.score or 0`, which keeps the value through a reload. A `local` at the top of a script is a cache. It is not saved, not in the checksum, and empty after a reload, and a world put back does not bring it back. Keep there only what can be built again from the world and `state` (a lookup table, a list of things found with `each`), build it in `on_scene` or when first needed, and empty it in `on_restore`. `frost test --restore` finds a script that breaks this. ## Libraries, data and tuning | In the project file | In a script | Is | | --- | --- | --- | | `libraries = ["lib/kit.luau"]` | `local kit = library("lib/kit.luau")` | Shared code: the library's text runs and its return value (a table of functions) is the result. Each call is a copy of its own | | `data = ["levels/one.toml"]` | `data("levels/one.toml")` | A TOML file as a plain table: a level, a list of waves. Read when the game loads, never while it runs | | `[tuning] jump = 280` | `tuning.jump` | Numbers to try: `frost run --set tuning.jump=300` and the protocol's `tuning.set` change one without editing a file | `library` and `data` take paths from the script's own folder too (`./`, `../`). A changed data file starts the game again, and a replay recorded with other data gives another checksum. ## Numbers and the same bits everywhere - Luau's numbers are 64-bit. A component field declared `0.0` stores 32 bits, so `0.1` reads back as `0.10000000149011612`; `0` is a whole number; `{ f64 = 0.0 }` keeps every bit. - All of `math` is the engine's own, the same on every machine and in a browser: turn and aim with `math.sin` freely. The one exception is `^` with a power other than a written `2`, `3` or `0.5`: use `math.pow`. - `math.random` is the game's seeded source. There is no clock, no file, no network and no `require`. - A run of a script is stopped after a million loop turns and calls (`E0305`), and all scripts may hold 64 MiB (`E0306`): counted, not timed, so they stop at the same point everywhere. ## Changing a script while it runs Under `frost dev` a saved script is swapped in at once, keeping the world and the script's `state`; the time from save to screen is printed. A script that does not compile is refused and the old code keeps running; one that fails while running pauses the game until a save fixes it. In a browser, `frost dev --web` sends each saved script to the open tabs. ## Types in your editor ```sh frost reference --types game.toml > frost.d.luau ``` writes the script API as a Luau definitions file, with `get`, `set`, `each` and `spawn` typed from the game's own components and each library typed as the table it returns. Give it to luau-lsp as a definitions file, and make it again when the components or the libraries change. Hovering a call shows its reference comment. ## Fast loops over many things `each("Transform", {"Transform.x"})` returns the things and a buffer of the field's values, eight bytes a thing; `set(ids, "Transform", "x", buffer)` writes them back in one call. It is for a script that moves thousands of things a step; see the [scripts reference](../reference/scripts.md). --- Page: guides/csharp.md # Gameplay in C# You can write your game's scripts in C# instead of Luau, or beside it. A script whose name ends in `.cs` gets the same engine calls a Luau script has, live reload while you work, and a desktop export your players can run without installing .NET. This page is how to write a game with it; the [C# reference](../reference/csharp.md) has every call, side by side with Luau's. > **Note.** C# runs on the desktop today. On the web it runs through > [FusionCompile](fusion.md), a subset; on phones it is in progress; and multiplayer refuses a > game in C#. See [what C# cannot do yet](csharp.md#what-c-cannot-do-yet). ## What you need - The .NET SDK, version 10 or later. - `frost` with C#: the download whose name ends in `-csharp`. Without it, a game with a `.cs` script is refused (`E0482`). ## A script ```csharp using Ven; [State] // the one struct the script keeps between steps public struct Game { public int Score; public Thing Hero; // a thing of the game, or Thing.None } public static class Main { public static void OnScene(string scene, ref Game game) { game.Hero = World.Spawn("Transform", "Sprite", name: "hero"); World.Set(game.Hero, "Sprite", "image", "art/hero.png"); } public static void Step(float dt, TransformColumns transform, ref Game game) { int row = transform.Row(game.Hero); if (row >= 0) transform.X[row] += Input.Get(0, "move_x") * 90 * dt; if (Input.Held(0, "fire")) Sound.Play("sounds/pew.wav", vary: 0.1); } } ``` `Step` runs once a step, sixty times a second, as Luau's `step(dt)` does, and `OnScene` when a scene has started. - **Components come as columns.** `Step` names the components it walks, and each is lent to it as the world's own memory for the length of the step: one span for each number or true-or-false field (`transform.X[row]`), with `Rows`, `Thing(row)` (the thing at a row) and `Row(thing)` (a thing's row, or -1). This is the fast path, and what Luau's `each`, `get` and `set` are in C#. - **Everything else is a call**: `World.Find`, `World.Spawn`, `Input.Get`, `Sound.Play`, `Scene.Load` and the rest. The [reference](../reference/csharp.md) lists the C# call for every Luau one. ## What your script keeps The struct you mark `[State]` is your script's memory between steps, as Luau's `state` is. It is saved with the game, covered by the checksum and put back by a seek, a test or a rollback. It holds `bool`, `int`, `uint`, `float`, `double` and `Thing` fields; keep anything else in components. A `static` field is not saved, exactly as a Luau `local` is not. Use one only for a cache you can build again, and empty it in `OnRestore()`. `frost test --restore` finds a static that changes how the game plays. ## Changes happen when the step returns While your `Step` runs, it holds the world's memory, so the world's shape does not change under it. A call reads the world as it is; what a call changes (`Set`, `Spawn`, `Despawn`, `Send`, `Tween`, `Place`, `Ui.Focus`, `Scene.Load`) is done when your `Step` or `OnScene` returns, in the order you asked, before the next script runs. In practice: - A thing you `World.Spawn` exists from the next step. You can `Set`, `Despawn`, `Tween` and `Send` it at once, and keep it in your `[State]` struct, but columns do not have it yet (`Row` gives -1) and `Get` and `Has` refuse it. - `World.Get` reads the world as the step found it, plus what you wrote through spans. A `World.Set` you made earlier in the same step is not seen yet. - So make things after walking the ones that are there. (A Luau loop over `each` after a `spawn` finds the new thing; a C# loop over a column does not.) ## Differences from Luau worth knowing - **Time and chance come from the game.** `DateTime.Now`, a `Stopwatch`, `new Random()` with no seed, `Random.Shared` and `Guid.NewGuid()` are refused when the script compiles (`VEN105`, in `E0309`), because a replay must play the same on every machine. Time is `dt`; chance is `World.Random`. A `Random` with a seed is yours to use. - **Maths that is the same everywhere.** Use `Maths` for sine and its kin, `pow` and `log`: it gives the same bits on every machine. `System.Math.Sin` and its kin are refused (`VEN104`). - **`%` keeps the sign in C#.** `-30 % 360` is 330 in Luau and -30 in C#. For an angle kept from 0 to 360, write `a - Math.Floor(a / 360) * 360`. - **Luau scripts run first**, then C# scripts, each in the project's order. A game can mix the two. - **Tables.** `Data.Get("levels/one.toml")` and `Save.Get` give a `Table`: flat, each value under its path, so Luau's `level.waves[1].count` is `.Number("waves.1.count")`. ## While you work - Save a `.cs` file under `frost dev` and the new code is swapped in, keeping the world and your `[State]` struct. Code that does not compile is refused (`E0309`, with its line) and the old code runs on. - A call that cannot be done stops the step with `E0302`, on your script's own line and column. - `World.Print` lines carry the file and line of the call, as Luau's `print` does. - `frost check` writes a project you can start a C# language server on. - `frost dap` debugs a C# game from your editor with your own netcoredbg (on your `PATH`, or named by `FROST_NETCOREDBG`): breakpoints go in your `.cs` files, and a stop shows .NET's threads, stack, locals and expressions. A game in both Luau and C# cannot be debugged this way yet. ## Shipping a C# game ```sh frost export desktop game.toml --out mygame-desktop ``` compiles your C# scripts ahead of time, with .NET's Native AOT, into one native library beside the game. The person who plays your game needs no .NET. After you change a script, export again: a player refuses a library that was not compiled from its game's scripts. Native AOT needs .NET's ILCompiler package for your machine. If your .NET SDK has it beside itself (Homebrew's does), nothing is downloaded. If not, the export stops with `E0311`, names the package, and tells you that `--fetch` lets it be fetched once from nuget.org and kept in frost's cache. For the web, see [FusionCompile](fusion.md). A web export of a C# script that is not marked `[FusionCompile]` is refused. ## Whole games to read Two of the templates have been written in C# as well: Vigil (the arena game; played on its recording it matches the Luau one at every step, apart from what each script keeps) and Embers (the 3D game, with a character on 3D physics, sensors, chasers, the interface and the following camera). [Caravan](../showcase.md), an open-world game, is written in C# too. ## What C# cannot do yet - **Phones.** C# runs on the desktop only; phones are in progress. Keep a phone game in Luau. - **The web**, except through [FusionCompile](fusion.md), which cannot spawn things, read input, play sounds or load scenes. - **Multiplayer.** A game in C# is refused (`E0543`). - **Libraries** are compiled into each script, so in practice one script is the root that composes the rest, and a library's compile errors are reported at the script. - **A script cannot read an event it sent**, and a spawned thing is seen the next step. - `World.Spawn` takes at most 8 component names. - `HashCode` and `GetHashCode` differ from run to run: never let them decide anything in your game. --- Page: guides/fusion.md # Fusion: C# on the web Fusion compiles your C# gameplay to WebAssembly, so it runs in the browser with no .NET runtime. Mark a class `[FusionCompile]` and Fusion compiles its `Step` into one WebAssembly module that the web player loads beside the game: it walks the world's columns of numbers and booleans with plain arithmetic. On the desktop the same class runs under .NET as usual. See [C#](csharp.md) for C# in general. For agents: `[FusionCompile]` works like Unity's `[BurstCompile]`. ## What Fusion is A C# script whose `Step` classes are all marked `[FusionCompile]` can be exported to the web. Such a class walks columns of the world, numbers and booleans, with plain arithmetic: - It reads and writes the columns its `Step` takes (`TransformColumns`, your own components' columns), the entity indices it is lent, and fields it keeps between steps. - A checked index or an arithmetic failure stops the game with the script's name and C# line. What it cannot do: spawn things, read input, play sound, set text, load scenes or call the engine's random source (`World.Random`). Heap arrays, the `[Engine]` maths routines and `uint` kept state are outside it too. A game that needs those gives that part to a Luau script beside the C# one, which prepares columns for it to read. Luau scripts run first; C# scripts run after them, in the project's order, on every host. ## The example The engine's Bunnymark demo has a version with its motion in Fusion: `motion.cs` moves every bunny with the original double arithmetic, and `setup.luau` reads input, spawns bunnies and prepares their seeded floor kicks. Its positions, velocities and random state match the Luau Bunnymark at every recorded step. The engine also tests Fusion on a 60-step recorded run: every step's world is the same under .NET and under the exported module played by Node. ## Exporting Fusion needs `frost` with C# (the `-csharp` download) and the .NET SDK, version 10 or later, on the machine you export from. The browser downloads no .NET. ```sh frost export web game.toml --out web frost play web --port 8081 ``` The export runs the same C# generator and checks the desktop does, then the engine's own emitter, and writes one `game/compiled.wasm`; each exported `.cs` file is replaced by a description of the script, and your sources stay the source of truth. The browser downloads no .NET runtime. A C# `Step` that is not marked `[FusionCompile]` is refused for the web, with Fusion named as the way. ## While you work `frost dev` and headless runs on the desktop go on running the marked class under .NET, so debugging and live reload work as for any C# script. The web build is an export: after changing a C# source, export again and reload the page. ## Measured The engine's own measurements: at 100,000 bunnies the Fusion module alone took a median 0.257 ms a step under Node, against 90.6 ms for the Luau scalar step and 39.8 ms for C# on .NET, one run each on a busy machine. They time different things (the Node column has no world, scheduler or Luau boundary), so do not divide them into an end-to-end speed-up; browser timing is not measured yet. --- Page: guides/export.md # Put your game on a phone > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. `frost export ios` and `frost export android` turn your game into an app for an iPhone or an Android phone. You do not change the game for a phone: it is the same game, played by the same player program as on a desktop and on the web, and the same input comes to the same checksum on all of them. A finger is the pointer (`MouseLeft`), and it fills the finger slots you name in `[input] fingers`. Exporting for the web and the desktop is covered in [your first game](../start/first-game.md#7-export-it). This page is about phones. > **Note.** Phone exports run in the iPhone simulator and the Android emulator today. > They have not been tried on a real device, and signing an app for a device or a store > is yours to do: [see below](export.md#what-only-you-can-do-a-real-phone-and-a-store). The first downloads will not have the phone players yet: iPhone and Android exports need a build that has them. ## Make your game ready for a phone What to write in your game's files so it plays well on a phone, each checked by `frost check`: ```toml title = "Embers" # the app's name under its icon [window] size = [960, 540] orientation = "landscape" # or "portrait"; left out, from the frame's shape fit = "fill" # the frame takes the screen's shape (below) [export] icon = "art/icon.png" # a square PNG, 1,024 pixels a side for a store [input] actions = ["turn", "walk", "jump", "thumb", "start"] # A stick on the left half and a JUMP button on the right while the node `panel` is # hidden (in play), and START pressed where the title draws it while `panel` is shown. fingers = [ { region = { x = -1, y = -1, w = 1, h = 2 }, x = "turn", y = "walk", press = "thumb", stick = 0.15, shown = true, while_hidden = "panel" }, { region = { x = 0.4, y = -1, w = 0.6, h = 1.2 }, press = "jump", label = "JUMP", shown = true, while_hidden = "panel" }, { region = { x = -0.21, y = -0.2, w = 0.42, h = 0.15 }, press = "start", while_shown = "panel" }, ] controls = { alpha = 0.35 } # how the drawn controls look: color, alpha, size ``` The `embers` template's own `game.toml` shows the fill and finger settings, and `frost reference` describes every key above. Then run `frost export ios` or `frost export android`, below. ## On a phone - **The screen.** The frame is fitted inside the phone's safe area (clear of the notch or the Dynamic Island, the cutout and the home bar), and the background's colour runs under the rest. The safe area is no input of the game's: no script reads it and no checksum moves with it. The pointer and fingers are found in the frame where it is drawn. - **The frame's shape.** Left as it is (`fit = "letterbox"`), the frame keeps its size and shape, and a phone longer than it has bars beside it. With `[window] fit = "fill"` the player gives the frame the shape of the safe area when it starts: the project's height is kept and the width grown to the screen's (for a frame taller than it is wide, its width kept and the height grown), and it prints `the frame fills the screen: W by H`. The game sees that frame: `frame.size()` returns it, interface nodes anchored to an edge follow that edge, a 3D camera sees further to the sides, and a 2D game draws more of its world. A game that fills is made to be right at any width, which is worth trying with `frost run --size WxH` (a phone on its side is about 2.1 times as wide as it is tall). - **The shape is input.** A run at another frame than `[window] size` comes to another checksum, so the frame is part of what a recording says: a run at another shape writes `frame = [W, H]` at the head of its recording (`input.history`), as `[input] frame` in a project file, and `frost run`, `frost test` and the player's `--hold` replay it in that frame. A recording with no `frame` replays at `[window] size`, as every recording made before did. Embers has both: a run at an iPhone's shape with its own checksum and its ordinary run at 960 by 540. - **Away and back.** Sent to the background, the game stops where it is: nothing is drawn or stepped and its sound is held. Back, its window's surface is made again (Android takes it away), the sound goes on, and its clock starts from then: the time away is not played. The player prints `away at step N` and `back at step N`. - **Which way up.** `[window] orientation = "landscape"` or `"portrait"`; left out, landscape for a frame wider than it is tall. - **Name and icon.** The app is named by the project's `title` (else its folder) and shows `[export] icon`, a square PNG file, 1,024 pixels a side for a store (`E0534` when it is not a square PNG). On iOS it is compiled into the app by Xcode's `actool`, on Android it is the apk's one resource. - **Touch controls with no script.** A finger slot with `stick = R` is a stick (its `x` and `y` are the thumb's way from where it came down, over R of the frame's heights), one with only a `press` is a button, and `shown = true` has the player draw it over the game: a stick a ring with a knob that follows the thumb, a button a disc with its `label`, at a thumb's size in points inside the safe area, see-through at rest and brighter while pressed, never over a shown interface node. `while_hidden = "panel"` / `while_shown` keeps a slot to the moments its node says (Embers: START on the title, the stick and JUMP in play), and `[input] controls = { color, alpha, size }` restyles them all. The player's picture, not the game's world. ## iOS ``` frost export ios GAME.toml --out DIR [--device] [--recording] [--any-engine] ``` writes `DIR/NAME.app`: the player named after the game, `Info.plist` and the game's files in `game/`. It is for the iPhone simulator on a Mac with Apple silicon (`aarch64-apple-ios-sim`) unless `--device` asks for an iPhone (`aarch64-apple-ios`). The app is full screen with no status bar, held the way `[window] orientation` says. Its id is the project's `id` (or `dev.coldwave.` and the game's name), printed by the export. It is not signed: the simulator runs it as it is, and an iPhone runs nothing that is not. Needs: Xcode with its iOS platform (`E0500` without it) and `rustup target add aarch64-apple-ios-sim` (`aarch64-apple-ios` for `--device`). To play it in a simulator with no window (the Simulator app is not needed): ```sh xcrun simctl boot "iPhone 17" xcrun simctl install "iPhone 17" DIR/NAME.app xcrun simctl launch --console-pty "iPhone 17" APP_ID # what the player prints xcrun simctl launch --console-pty "iPhone 17" APP_ID --hold 600 # held at step 600 of a recording exported with --recording xcrun simctl io "iPhone 17" screenshot shot.png ``` ## Android ``` frost export android GAME.toml --out DIR [--recording] [--any-engine] ``` writes `DIR/NAME.apk` for arm64 phones and emulators (`arm64-v8a`, Android 8.0 and later, API 26: the first with AAudio, which sound goes through). The app has no Java: the system's own `NativeActivity` loads the player, `lib/arm64-v8a/libfrost_player.so`, and the game's files are the apk's assets (`assets/game/`, named in `assets/ven-files.txt`). It is signed with a debug key the export makes once, in the build folder (`target/players/android-debug.keystore`): it installs on an emulator or a phone with USB debugging, and no store takes it. Needs: the Android SDK with `build-tools`, a platform and the NDK (found from `ANDROID_HOME`, `ANDROID_NDK_HOME`, or `~/Library/Android/sdk`; `E0535` names what is missing), Java's `keytool`, and `rustup target add aarch64-linux-android`. Nothing is downloaded: no Gradle. `E0529` is a program of the SDK that failed, with what it said. ```sh adb install -r DIR/NAME.apk adb shell am start -n APP_ID/android.app.NativeActivity adb logcat -s frost_player # what the player prints adb shell setprop debug.ven.args.APP_ID "'--hold 600'" # the arguments after game.toml, for the next start adb exec-out screencap -p > shot.png ``` An app is started with no command line, so the player takes its arguments from the system property `debug.ven.args.APP_ID` (a test's `--hold N`); set it to `' '` to play live again. Each app reads its own property and no other's. Whoever has `adb` can set it, for a shipped game too, so what it can ask for is kept small: `--out` takes a file's name there, not a path, and the picture is written to `files/pictures/NAME` in the app's own folder (a path could have named the game's save). What an Android app does that a desktop's program does not: - **A game that ends, ends its process.** Android keeps an app's process after its screen is gone and starts the app in it again; the player cannot start twice in one process, so when the game ends (it failed, or a test's `--picture-at` is written) its activity is finished, the process ends with it and the next start is a new one. - **One of the game at a time.** The activity is `singleTask`: a second start, from the launcher or from another app, brings the running game forward and makes no second one. - **A setting changed while the game runs** (the font's size, the language, dark mode, a keyboard plugged in) does not restart the game: the apk's manifest says the app takes every such change itself, and the game draws nothing from the system's resources. - **Not handled: an activity the system destroys while its process lives.** That is the developer option "Don't keep activities", and any change of the phone's the manifest has no name for (the one name that covers them all, `resourcesUnused`, is read by Android 16 and later). The game then stops answering and the system offers to close it; started again, it starts from the beginning. A fix is being built. ## Sizes How big an exported app is, measured on 27 Nov 2026 on macOS on Apple silicon: | Game | iOS simulator app | Android apk (its player before the apk compresses it) | | --- | --- | --- | | An empty game | 2,442,412 bytes | 1,626,661 bytes (3,141,104) | | A 2D game with scripts | 3,717,853 bytes | 2,327,211 bytes (4,816,200) | | A 3D game with scripts and physics | 4,513,243 bytes | not measured alone | ## How it is tested Phone exports are tested in the iPhone simulator and an arm64 Android emulator, not yet on a real device. In both, an exported game replays a recorded run and must stand at the same checksum `frost run` prints on the desktop, with the game on the screen. On Android the tests go further, since that is where an app meets a system least like a desktop's: - Embers' whole recorded run of 2,653 steps comes to the desktop's checksum. - The player's own picture of a step is compared with the desktop's: pixel for pixel for a 2D game, and for Embers within a small bound, because the emulator draws in software (measured: 0.6% and 1.6% of pixels differ, nearly all by one level). - Taps on the screen reach the finger slots where the finger was. - A game that ends leaves no process behind and starts again cleanly, and a saved game written by one start is read by the next. - The font size changed under a running game does not restart it. - Embers was sent to the background and brought back thirteen times: a finger still turned it afterwards, it held no more memory, threads or open files after the last five times than before them, and the system logged no crash and no "not responding". On iOS there is no touch test yet: nothing can touch a simulator's screen without opening its window. ## What only you can do: a real phone, and a store Each needs an account and a key that are yours, which the engine never holds. **An iPhone.** An Apple Developer account (free for one's own phone, paid for TestFlight and the App Store), a signing identity and a provisioning profile for the app's id, made in Xcode or at developer.apple.com. ```sh frost export ios game.toml --out out --device cp ~/Downloads/NAME.mobileprovision out/NAME.app/embedded.mobileprovision security cms -D -i out/NAME.app/embedded.mobileprovision > profile.plist /usr/libexec/PlistBuddy -x -c 'Print :Entitlements' profile.plist > entitlements.plist codesign --force --sign "Apple Development: YOUR NAME (TEAMID)" --entitlements entitlements.plist out/NAME.app xcrun devicectl device install app --device DEVICE_ID out/NAME.app ``` For the App Store: an "Apple Distribution" identity and an App Store profile in place of the two above, then `mkdir Payload && cp -R out/NAME.app Payload/ && zip -r NAME.ipa Payload` and `xcrun altool --upload-app -f NAME.ipa -t ios --apiKey KEY --apiIssuer ISSUER` (or Transporter). The store needs the app's icon, which the export makes from `[export] icon`; with none the app has no icon and the store refuses it. **An Android phone.** Developer options and USB debugging on, then `adb install -r out/NAME.apk` installs the debug-signed apk as it is. For Google Play: a key of one's own, kept for the life of the app, and the apk signed with it in place of the debug key: ```sh keytool -genkeypair -keystore release.keystore -alias release -keyalg RSA -keysize 4096 -validity 10000 apksigner sign --ks release.keystore --ks-key-alias release --out NAME-release.apk out/NAME.apk ``` Google Play takes new apps only as an Android App Bundle (`.aab`), which needs `bundletool` (the export does not make a bundle yet); other stores and direct downloads take the signed apk. You need a Play developer account of your own. ## Not done yet - Signing for an iPhone or a store, an `.ipa` or an `.aab`, and uploading: all yours to do, above. The export never holds a key, an account or a profile. - A launch picture, a version number other than 1.0. - A frame that fills is given its shape once, when the player starts; the phone is held one way (`orientation`), so the screen does not change shape under it. - Recording on a phone: the player plays and replays, it writes no recording. A run at a phone's shape is recorded on a desktop, by a tool over the protocol: `game.reset` with a `width` and `height`, the game played, then `input.history`. - Android on x86_64 (an emulator image for Intel Macs), and a phone that is not arm64. - An automated touch test on iOS. - Saves: on Android they are kept in the app's own folder, under `.local/share` there; on iOS in the app's container under `.local/share`, not the system's `Library`. - An Android activity destroyed while its process lives (above). - Sound is built for both, but nobody has listened to it on either yet. --- Page: guides/debugging.md # Debugging A bug you saw once, you can see again: every run of a game [replays to the bit](../concepts/steps.md), so you can stand at the same step, with the same values, as often as you need. This page goes from the cheapest question to the deepest: what is wrong with the files, who wrote this value, why is this pixel this colour, and what is this script doing line by line. The examples use the basics sample, a square that walks right and picks up a coin worth 5 at step 131. ## What is wrong with the files ```sh frost check game.toml ``` lists every problem one a line, as `FILE:LINE: CODE: what is wrong and what to do`, and runs what loading runs (each script's top level and `on_scene`) without stepping. Every code is stable; the [error index](../reference/errors.md) links each to where it is explained. Under `frost dev`, a script that does not compile is refused and the old code keeps running, and a script that fails while running pauses time until a save fixes it. `print` writes to standard error with its file and line; over the protocol `log.since` reads the same lines, with the warnings `game.info` lists. ## Who wrote this value `frost blame` plays the game on its recording with the world keeping who writes, then says who wrote a field last and what it was before: ```text $ frost blame game.toml score.Text.text score.Text.text is "SCORE 5" at step 180 script main.luau:24 in step: step 131, 1 write, from "SCORE 0" $ frost blame game.toml hero.Transform.x --step 100 --history 2 hero.Transform.x is 145.0 at step 100 script main.luau:9 in step: steps 1 to 100, 100 writes, from 40.0 scene scene.toml:3: step 0, 1 write, from 0.0 ``` A writer is a line of a scene, a line of a script (and the two functions that called it, so a write through a helper names who used the helper), one of the engine's systems (physics, the interface, animation), a protocol client, or the default. Keeping writers changes nothing in the game and costs about a tenth of a step. Over the protocol it is `blame.on`, then `blame.value`, `blame.entity` and `blame.gone` (who despawned a thing). ## Why is this pixel this colour ```text $ frost blame game.toml --pixel 200,90 --step 10 pixel 200,90 at step 10: 1 drawn there coin (e0.0): Rect, layer 0, covers 255 of 255 made by scene scene.toml:7 in step 0 Transform.x is 200.0: scene scene.toml:8: step 0, 1 write, from 0.0 ``` Every thing drawn at the pixel, the one in front first, who made it and who placed it. In 3D, the protocol's `frame.at` also says which triangle of which mesh is there and how it is lit, one line a light with its share and the reason for it ("in shadow", "out of its reach: 7.811 away, it reaches 4.5"): [3D rendering](3d-rendering.md#explain-a-pixel) shows one. Neither needs a graphics device or takes a picture. ## Time travel The protocol puts a game at any step of its recording and back: | Command | Does | | --- | --- | | `game.seek {step}` | Plays the recording to that step, from a kept moment when it can (one every 300 steps) | | `game.time {rate}` | Under `frost dev`: 1 is normal, 0.5 half speed, 0 paused; `game.step` then steps it | | `game.snapshot`, `game.restore` | Keep a moment and go back to it | | `game.try {from, inputs}` | Play a branch of input from a snapshot and read what came of it, in one call | | `events.since {step}` | Every event of the steps after one, in order | | `world.series` | A field's values over a stretch of steps | Seeking twice to one step gives one world, checksum for checksum. To compare a change before and after on the same input, seek to the step, change the script (`script.reload`), and seek again. ## Breakpoints `frost dap` is a Debug Adapter Protocol server for any editor with a DAP client: it starts the game (with or without a window) or joins one `frost dev` is playing, and stops the scripts at breakpoints in the game's `.luau` files. A stop shows the stack, each function's locals and upvalues, and tables to open; the debug console runs Luau where the script stands; one filter, `errors` (on by default), stops where a script raises an error. `frost dap --help` prints the launch and attach settings and an nvim-dap configuration. A game in C# is debugged the same way through your own netcoredbg. The same is the protocol's `debug.` commands. Stopped at line 23 of the sample as the coin is picked up: ```json {"method":"debug.attach","params":{}} {"method":"debug.breakpoints","params":{"file":"main.luau","lines":[23]}} {"method":"input.set","params":{"player":0,"action":"move_x","value":1}} {"method":"game.step","params":{"steps":300}} -> {"step":101,"stopped":{"file":"main.luau","line":23,"reason":"breakpoint"}} {"method":"debug.evaluate","params":{"text":"picked.value"}} -> {"type":"number","value":"5"} {"method":"debug.step","params":{"kind":"over"}} -> {"line":24,"state":"paused"} {"method":"debug.evaluate","params":{"text":"state.score"}} -> {"type":"number","value":"5"} ``` A game runs the same, checksum for checksum, with a debugger attached that stops nothing. An exported game has no debugger in it. ## When a test fails `frost test` names the first step, the first value and the line that wrote it, against the game as last accepted (and git HEAD when there are uncommitted changes): see [recorded runs](../concepts/runs.md). A bug that appears only after a seek, a reload or a rollback is almost always a `local` that should be in `state`: `frost test --restore` puts the game back at each checkpoint and names the first step that goes another way. --- Page: guides/profiling.md # Profiling Find where a step's time goes, and show that your change made the game faster. A game's recorded run is also its benchmark: the same input plays the same steps every time, so two measurements of it differ only by the engine and the machine. ## `frost bench` ```sh frost bench game.toml # the steps, by stage and span frost bench --draw game.toml # and the off-screen draw: quads, draw calls frost bench --json game.toml # one JSON object, for a program ``` It plays the game's recording (its `replay` steps, `--steps N`, or 600), leaves the first 30 out as warm-up, and prints the median, the 99th percentile and the worst milliseconds a step of the whole step, of each stage, and of every span inside them. For the third-person sample: ```text third-person/game.toml: 240 steps (30 to warm up, not measured), 9684 steps a second ... load average 16.94, loaded in 9.2 ms, memory 26.5 MB at most (the process, seen 17 times), scripts 0.44 MB at the end: entities 8, bodies 5, joints 0, script_bytes 438128 slowest: 0.388 ms at step 127: scripts 0.173 ms, of which script main.luau 0.159 ms span median p99 worst (ms a step) step 0.065 0.330 0.379 input 0.001 0.010 0.017 physics 0.025 0.139 0.168 scripts 0.017 0.096 0.173 animation 0.015 0.081 0.123 physics.movers 0.006 0.042 0.077 script main.luau 0.013 0.086 0.159 ``` Read the median to compare: one slow step does not move it. The worst names its step, so you can stand at it (`game.seek`) and look. The load average is printed because a busy machine's numbers lie: that run's machine was at 17, so compare it only with a run made under the same load. Several games are each measured in a process of their own. With `--draw` it draws every step off-screen too and adds the renderer's spans (`draw`, `gpu.submit`, `render.build`, ...), the quads and the draw calls. It does not count allocations, and it does not time the graphics card after a frame is handed over. ## Spans Every stage is a span (`input`, `ui`, `physics`, `scripts`, `animation`, `layout`, `events`), and the engine's work inside them has spans of its own (`physics.solve`, `physics.movers`, `stream`, each script by file, `step()` inside it). They are timed in every step by every program, so a measurement needs no special build. ## Over the protocol | Command | Answers | | --- | --- | | `profile.steps` | What each step of the last hour took, and the slowest with where their time went: each stage, each script, down to each engine call a script made, by the line that made it. `totals` adds a stretch up | | `profile.frame {step?}` | The spans and counters of the last frame that drew a picture, or of one step as it was played | | `profile.frames {from, to}` | The median and the longest, per span, over a range of frames: the number to compare before and after a change | Time is never part of the game: it is in no checksum and no snapshot, and it differs from run to run. A step played again by a seek is told as it last ran. ## The editor's profiler The editor shows these same numbers: `profile.steps` is what its timeline draws as a cost row under the game's steps, and a click on a spike opens that step's tree. An agent that asks sees the same numbers you do. ## Budgets You can hold a game to a time budget. `frost bench --check` compares each game's median with the `perf.NAME_step_ms` and `perf.NAME_draw_ms` written in a `budgets.toml` file, allows it to be over by at most `perf.tolerance_percent` (10 when left out), and fails when one is over. A game that no key names is only reported. The engine holds its own stress games (sprites, bodies, scripted, interface, tilemap, voices) to budgets the same way. ## Proving a change 1. `frost bench --json game.toml > before.json` on an idle machine. 2. Make the change. `frost test game.toml` must still pass: a faster game that plays differently is a different game. 3. `frost bench --json game.toml > after.json`, under the same load, and compare medians. When you tell someone a change made the game faster, give them the two commands and the two medians, so they can run it again. --- Page: showcase.md # Showcase What has been made with Coldwave so far: an open-world game, two games ported from other engines, and the finished small games you can copy and change with one command. ## Caravan ![Caravan: arriving at the market town of Sarai-Kum, with thieves in the market](files/media/caravan/town_arrival.webp) An open-world game in 3D, written in C#. You are a hired guard walking a salt-and-silk caravan across one day: off the steppe at dawn, through the market town of Sarai-Kum at noon, over the dunes at golden hour and into a mountain pass at dusk, where a golem keeps the way. You fight for the camels: if the caravan dies, you lose. **What it proves:** a full 3D game, kept in a repository of its own, runs on the engine as it is: its 3D physics and character movement, its sky, its models and its interface. Like every Coldwave game, Caravan has a recorded run that `frost test` replays to check nothing broke. ![Choose who walks with the camels: the camp at the start of the road](files/media/caravan/title_camp.webp) ![A fight in the town](files/media/caravan/town_fight.webp) ![An ambush in the foothills at night](files/media/caravan/foothills_ambush_night.webp) ![The Pass-Keeper golem, second phase](files/media/caravan/boss_phase2.webp) The interface on screen is the engine's own (`Node`, `Bar`, `Text` with the game's fonts), laid out once for a design height and drawn here at 1080p: ![The interface in a fight on the dunes](files/media/caravan/hud_warden.webp) ![Travelling with the caravan](files/media/caravan/calm_travel.webp) Caravan uses third-party models, music and fonts, each under its licence: see the [credits](credits.md). ## Scrap Riot ![Scrap Riot: a wave on the first factory floor](files/media/scrap-riot/floor1.webp) A twin-stick factory brawler: shoot a robot and it lights, and lit robots set each other off, across four floors to the Head Press. It was first made in Unity and ported to Coldwave, with its gameplay rewritten in Luau, and every recorded shift replays exactly. ![The title screen](files/media/scrap-riot/title.webp) ![The Head Press, second phase](files/media/scrap-riot/boss-phase2.webp) The same game runs in the iPhone simulator, with touch controls: ![Scrap Riot in the iPhone simulator, mid-fight with the touch sticks](files/media/scrap-riot/ios-fight-touch.webp) ![Scrap Riot's lobby in the iPhone simulator](files/media/scrap-riot/ios-lobby.webp) ## Held Note ![Held Note: a corridor of the flooded station](files/media/held-note/first-cut.webp) A third-person deep-sea horror game: a welder goes six kilometres down to a flooded station that stopped answering, and explores its dark decks by the light of her cutter's torch. It was first made for the browser and ported to Coldwave, with its gameplay in Luau. ![Splicing a relay by torchlight](files/media/held-note/relay.webp) ## Games to start from Each template is a finished small game. `frost new NAME --template T` copies one for you to change, and `frost new --list` names them all. ![**Cinder**, the `platformer` template: a side-scroller with a tilemap level, a camera, enemies, pickups, lives and music](files/templates/platformer/shots/mid-level.png) ![**Embers**, the `embers` template: a third-person arena in 3D where you gather eight embers and keep clear of two wardens](files/templates/embers/shots/rise.png) ![**Ballast**, the `ballast` template: a physics puzzle in three rooms](files/templates/ballast/shots/bridge.png) ![**Vigil**, the `arena` template: one screen, waves of enemies, shooting, a score and lives](files/templates/arena/shots/wave-4.png) | Template | What it is | What it shows you | Recorded run | Web download, gzip | | --- | --- | --- | --- | --- | | `pong` | Two paddles and a ball for two players on one keyboard | The smallest whole game: one scene, one script | 2,124 steps | 1.1 MB (WebGPU) | | `platformer` | Cinder: a side-scroller with a tilemap level, a camera, enemies, pickups, lives and music | A 2D level, a camera that follows, music | 3,509 steps | 1.2 MB (WebGPU) | | `arena` | Vigil: one screen, waves of enemies, shooting, a score and lives | Spawning waves and keeping score | 3,732 steps | 1.2 MB (WebGPU) | | `breaker` | A brick breaker with three levels, capsules and a combo | Levels as separate scenes | 7,236 steps | 1.2 MB (WebGPU) | | `shooter` | The Last Lamplighter: a top-down shooter aimed with the pointer, four waves and a boss | Aiming with the mouse | 4,098 steps | 1.2 MB (WebGPU) | | `ballast` | A physics puzzle in three rooms: a crate on a switch, a lift, a seesaw, a drawbridge on a chain | 2D physics: a switch, a lift, a chain | 2,009 steps | 1.2 MB (WebGPU) | | `embers` | A third-person arena in 3D: gather eight embers and keep clear of two wardens | 3D, a following camera, touch controls | 2,653 steps | 1.5 MB (WebGPU) | | `blank` | One square that moves | A project file with every key written out | 60 steps | 1.1 MB (WebGPU) | Every template comes with a recorded run, so `frost test` can tell you at once whether a change you made altered how it plays. The runs and sizes above are measured from `frost` 0.0.1 r289, the release this site describes. --- Page: status.md # What works today This page describes `frost` 0.0.1 r289, its 8 templates and its 107 protocol commands. Coldwave is pre-release. This page tells you plainly what works and what is not built yet, so you can decide whether it fits your game and plan around the gaps. When something on this page ships, it leaves the page and gets a line in the [changelog](changelog.md). ## Where your game runs | Where | How well it works today | | --- | --- | | macOS on Apple silicon | Fully tested: this is where the engine is built and checked | | The web (Chrome) | Tested: WebGPU and WebGL2 builds, playing a recorded run to the same checksums as the desktop | | iPhone | `frost export ios` works in the simulator only. It has not been tried on a real device, and it does not sign the app yet | | Android | `frost export android` makes an apk for arm64, tested in the emulator only and signed with a debug key | | Linux | A `frost` with no window passed the core, script and physics tests and replayed the engine's test games to the Mac's checksums on arm64. Its window and sound have not been tried there | | Windows, x64 | Meant to work, but nobody has verified it yet | | Consoles | Not started: it needs agreements with the platforms. The engine's rules (no JIT, portable C and C++ only) keep a port possible | Coldwave is in private development: there is no public download yet. The first release will be a download for macOS on Apple silicon, not signed at first, so macOS will need its download mark taken off once ([install](start/install.md)). Coldwave will be open source at launch, under MIT or Apache-2.0. ## Coming next Being built now, and not in `frost` yet: a [physical sky](soon/physical-sky.md), [GPU skinning](soon/gpu-skinning.md), [engine effects](soon/effects.md) (cards, flipbooks, blend modes, `Mesh.shadows`), JPEG import, C# on phones, and a fix for an Android app whose screen the system closed while the app was still running. ## Rendering - At most eight point and spot lights, and a light that is off still counts. - Point lights cast no shadows. The sun has one shadow map, with no cascades. - No bounce light, no reflection probes, no screen-space reflections: metal mirrors the sky only. - No level of detail and no distance culling for models (a `Ground` does choose its detail by distance). - No water, no vegetation or scatter system, no trails, no decals. An `Emitter`'s specks are untextured squares. Text has no outline. - No JPEG import and no compressed textures (KTX2). Of glTF, second UV sets, other extensions, lights and cameras are not read (`W0460` tells you what was left out). - No GPU timers per render pass: `frost bench --draw` times the CPU side and the submit. ## Animation - A clip cannot be shared between models that have one rig. - A model's node cannot be hidden. ## Physics - No mesh or convex colliders: boxes, spheres, capsules, cylinders and height-field ground. - A collider cannot be offset from its thing's `Transform` (put it on a child thing). - Of 3D joints, a `"wheel"` joint (a `Vehicle` is the car), a weld's `spring` and a distance joint's `power` are refused, and a `"ball"` joint has no limits. ## Input and sound - No key names for Shift, Ctrl or Alt; no mouse capture and no mouse look. - A played sound has no handle: you cannot stop or loop it. Placing one in 3D is a left-to-right pan and a fade with distance, nothing more. One music track at a time. ## C# - C# runs on the desktop only. Phones (through Native AOT) are in progress. The web runs [FusionCompile](guides/fusion.md), a subset of C# that cannot spawn things, read input, play sounds or load scenes. - Multiplayer refuses a game in C# (`E0543`). - Libraries are compiled into each script, so in practice one script is the root that composes the rest. A library's compile errors are reported at the script. - `[State]` holds only `bool`, `int`, `uint`, `float`, `double` and `Thing`. - A spawned thing is seen the next step, and a script cannot read an event it sent. - `World.Spawn` takes at most 8 component names. `HashCode` and `GetHashCode` differ from run to run: never let them decide anything in your game. ## Tools - Cooked assets and runs are written to your user cache folder unless you set `FROST_CACHE`. - There are no unit tests for scripts yet: you test a game by its recorded runs. - `frost bench` counts no allocations. ## Multiplayer Rollback multiplayer between players over UDP is built. Not yet: taking back the seat of a host who left, a relay, a lobby that finds games, multiplayer in the web player, C# games, and a network view in the editor. --- Page: changelog.md # Changelog What is new in Coldwave, and what to change in a game you made with an older version, newest first. `frost changes` prints the same list offline. A change here usually moves a recorded run's checksum: play your game, see that it is still right, then accept the new run with `frost test --write`. Part 1 of 7: [older](changelog/2.md). - **Ambient occlusion**: `[render] ao = { radius = 1.0, strength = 1.0 }` darkens the ambient light (and the sky a metal mirrors) in corners and where things touch; sun, lamps, shadows, emission and layers are untouched. Off unless written, so existing games, checksums and pictures are unchanged. It works with the engine's passes, a `bloom`, or a game's own (float light and `aces` included), natively and in both web builds. A game's own effect named `ao` or `ao_blur` must be renamed (they are now the engine's), and one that writes `ao` must not name a target or pass `ao`, `ao_distance`, `ao_depth`, `ao_rough`, `ao_seen`, `ao_occlude` or `ao_soften`. `frame.at` names it unread. - **Bloom between passes and interface design units**: `add` keeps radiance above one in float targets, so a later `aces` can tone-map it. An 8-bit target still clamps as before; use one to retain that clamp. Float `bright` keeps unnormalized radiance, including at threshold 1; 8-bit `bright` requires a threshold below 1. Graphs reject nonfinite effect parameters. Graphs with unequal colour/depth target sizes or `read` on a drawing pass are refused when loading. `[ui] fit = H` gives screen interfaces a design height, including text in 3D; omit it for the old pixel units. Luau `ui.measure` / C# `Ui.Measure` measure text and styles, and `Wrap.ellipsis` truncates to `Wrap.w` (false keeps wrapping and old checksums). `input.keys` / `Input.Keys` return the current device's binding labels. Recordings keep device hints in `player = { id = 0, device = "pad" }`; old recordings use keyboard labels. - **Smoother 3D edges**: `[render] msaa = 4` uses four samples for sky and meshes, with alpha-to-coverage on MASK materials. It resolves into the colour target's own format before effects or UI; float targets stay float. Default `1` keeps the old path. - **Model back faces**: `[render] cull = true` honours glTF `doubleSided`, including mirrored instances. Default `false` preserves existing pictures pending GPU review. - **Model samplers**: `[render] samplers = true` honours each texture slot's wrap and min/mag/mip filters, with up to 8x anisotropy for fully linear mipmapped sampling. Default `false` keeps the previous shared repeat/trilinear sampler. Cooked models now keep samplers (VMSH 5); older cooked models still read. - **Unread model data is reported**: embedded JPEG and damaged PNG pictures fail by name instead of drawing white. Convert them to PNG and update/re-embed them; changing the container to `.glb` does not convert pictures. `frost check` and `frost cook` report unsupported material extensions, texture transforms/UV sets, lights and cameras as W0460. No JPEG decoder is added; there is no switch for the old silent loss. - **Streamed scene cells**: `[stream]` declares deterministic residency before physics, entry budgets, dormant changes, world-owned migrants, `cell.enter`/`cell.leave`, Luau `stream.loaded`/`stream.hold`, C# `Scene.Loaded`/`Scene.Hold`, and protocol `stream.read`. Games without `[stream]` retain their checksums. Cell text/assets load eagerly; live entity and body residency is bounded. See `frost reference project`. - **A frame that fills the screen**: `[window] fit = "fill"` gives the frame the shape of the screen's safe part, its height kept and its width grown (a tall frame: its width kept); left out, or `"letterbox"`, the frame keeps its size as before. `frame.size()` says the frame the game runs in. The frame is part of a run's input: a run at another shape than `[window] size` writes `frame = [W, H]` at the head of its recording (`[input] frame`), and `frost run`, `frost test` and the players' test flags replay it in that frame; a recording with no frame replays at `[window] size`. the engine's `fill` example holds one game at two shapes; Embers fills, and the engine's `embers/phone.toml` example holds a run at an iPhone's shape (1060 by 540) to its own checksum. - **Phones**: `frost export ios` writes an app for the iPhone simulator (`--device`: an iPhone, unsigned) and `frost export android` an apk for arm64 Android 8.0 and later, signed with a debug key; `docs/export.md` says what a real phone and a store need. A game plays on them as it is: the same checksum as `frost run`, a finger as the pointer and in the finger slots. The graphics device asks for no more than the adapter offers (a phone's may offer less than wgpu's defaults), which changes nothing where the adapter has them. Android exports of games with `[net]` request Internet permission so their multiplayer menus can host and join. No game behaves differently. A player held at a step (`--hold N`) prints the run's checksum on a line after the world's. - **Luau queries can carry numeric columns**: `each("Bunny", {"Transform.x", "Bunny.vx"})` returns IDs and copied f64 buffers; `set(ids, component, field, buffer)` writes one back. Writes follow list order with scalar conversions and lifetime checks. A bad entry stops there, keeping earlier writes. Existing scripts and checksums are unchanged. - **Scripts reach model joints**: `Bone` overrides local rotation and optional translation; `bone` / `World.Bone` reads the world pose, and `Parent.joint` attaches a tool. `screen.project` / `screen.ray` (`Screen.Project` / `Screen.Ray`) convert world and pointer coordinates. Overrides and attachments opt their model clips into stepping before scripts, with exact posing for pictures and shadows; other games keep their checksums and timing. A game's own component named `Bone` must be renamed (E0528). Spatial C# reads now include queued writes; read before writing to retain the previous pose. - **Fusion C# ships to the web**: `frost export web` compiles marked Step classes to one module beside the player, with no .NET in the browser. Both web backends use the same column/state door; desktop runs keep .NET. Unmarked C# still refuses web export and names `[FusionCompile]` as the route. See `docs/csharp.md` and the engine's `bunnymark-fusion` example; existing Luau and desktop games keep their behaviour. - **Agent harness files ship with games**: `frost new` installs reference skills in `.claude/skills`, a stdio MCP registration and short `AGENTS.md`. Existing games use `frost skills --here`; edited files are preserved using the previous installation's bytes. `frost skills --out DIR` installs skills alone. MCP tool descriptions are now short selection hints; full contracts remain in `frost reference protocol.COMMAND`. Gameplay and recorded checksums are unchanged. See `docs/agent-harnesses.md`. - **The reference opens small**: `frost reference` now prints the game-making core and page index. Fetch a page or call by name, or use `--search words`; `--all` keeps the previous whole output. `reference.read` and `reference.search` serve the same text inside the editor. New games and releases include short game-making instructions. The core plus index is limited to 3,000 tokens and each page to 7,000; `frost budgets` fails naming any page over its limit. The whole output has no total limit. Gameplay and recorded checksums are unchanged. - **Fusion trees can be compiled without .NET**: the engine now holds its WebAssembly emitter and its replay checks. This first compiler piece takes trees and returns bytes; web export is not wired to it yet, and existing games keep their behaviour. - **A together test costs what a plain one does, and six smaller fixes**: `change.test` with `with` no longer reads every field of both games at every step (Breaker's 7,236 steps: 194 s, now 1.2 s, what a test without `with` takes). `differs.comparison` is made only after a field differs, by playing each run again to that step, so `extra_steps` now counts every column: at most (hands + 1) times the step. With `before`, a change of `with` alone is played over `before`, not over the served game, where it showed the together value. `project.undo {landing}` removes a shot the landing added, leaves no `.frost/undo-landing` behind, and `undone` stays true after the journal's 64 changes. `frost export` of a game in C# names packages restored as download dependencies too, and of two versions with the same numbers takes the release over a pre-release (`rc.10` over `rc.2`). `frost run --record` writes an input that goes from 0 to -0. A peer's input that is NaN or an infinity is refused (`E0547`): send finite numbers. No recorded checksum moves. - **Playable engine demos**: the engine adds Bunnymark, grid-based boids in Luau and C#, and a Jolt box pyramid, with small recorded runs and reproducible benchmark tools. The engine's own checks play them too. Existing games and their checksums are unchanged. - **Opt-in HDR presentation**: an `aces` frame-graph effect makes float mesh/sky passes retain linear light above 1, including emission, fog and blending. The effect applies exposure (`strength`, default 1), the ACES fitted curve, then sRGB encoding. Draw layers after it to leave UI/text unchanged; the engine's `torch/tonemap.toml` example shows how. Without `aces`, existing pixels, targets and pass counts stay unchanged. WebGL2 now accepts half-float targets when renderable, filterable and blendable; unsupported devices refuse the graph (E0208). `frame.at` names the presentation unread. A game's own effect named `aces` must be renamed. This adds no visible beam. - **Custom fields can hold doubles and unsigned words**: declare `{ f64 = 0.0 }` or `{ u32 = 0 }` in `[components]`. Luau, C# columns and `[State]` (`uint`), scenes, snapshots and inspection preserve their precision. Float equality and checksums treat all NaNs alike, as before. Existing declarations and recorded checksums are unchanged; no migration is needed. - **Fog without a Sky**: in 3D, `Fog = { color = 0x183040, density = 0.058 }` on the lowest entity fades lit meshes and ground by `1 - exp(-(density * distance)^2)`. Defaults are black and density 0 (off); a Sky keeps its existing haze and ignores Fog. No Fog keeps the old pixels and checksums. A game's own `Fog` component must be renamed. `frame.at` explains fog colour and share; this adds no visible torch beam. - **A torch can project a picture**: the shadow-winning spot's `Light.cookie` names a PNG as other pictures do, multiplying its light by linear RGB and alpha across the cone. The default `""` keeps previous checksums and pixels, with no cookie sampling or pass. Other lights ignore it. `frame.at` explicitly names its unsampled cookie. - **One spot can cast shadows**: `Light = { kind = "spot", shadows = true }` uses a 1024² perspective map with soft edges, including posed meshes and ground, beside the sun's map. Among the first eight point/spot lights, the lowest entity spot requesting shadows with `0 < outer < 90` wins. Set `shadows = false` for the old appearance and no extra pass. `frame.at` names its unread shadow map; its colour is then partial. - **Embers takes place in a ruined foundry**: both language versions add staggered outer piers, broken walls, distant towers, bronze ground inlays and three warm lamps. Five ember spill lights leave room for the lamps within the eight-light limit; all eight stones and the warden eyes keep their emission. Pickup sparks are larger, live longer and number 32. Only dressing and effects change the recorded worlds; keep the older arena scene and script together to keep the older appearance. - **Together tests show each change alone**: `change.test` with `with` adds `differs.comparison` for a differing component field: each change's own value, last writer and up to five observed steps beside the combined run. `was` remains the test reference. Missing values and unplayable standalone runs are explicit; `extra_steps` reports standalone work needed. Gameplay and checksums are unchanged. - **3D light shares follow materials**: `frame.at` now includes roughness and metal overrides, sky reflection, emission and tint inherited from parents. For transparency, `color` is the premultiplied surface contribution and `cover` its coverage; `unread` names the unseen destination and other unsampled inputs. Ordinary opaque materials keep their answers. Rendering and recorded checksums are unchanged. - **Rollback corrects an input whose zero has the other sign.** A late `-0` used to leave a prediction of `+0` in place (and conversely), so a script that distinguishes them could disagree with a peer that had the input on time. Corrections now compare the input's bits. Input history and its recording text preserve `-0.0` too, so a recorded network game replays with the same signs. Finite nonzero inputs are unchanged. - **A C# desktop export reports only the package versions its restore used**, even when its cache holds other versions from earlier exports. An unused version fetched from nuget.org no longer makes an export from the SDK's own packages say it fetched. The SDK's newest package version is compared as numbers: `11.0.10` follows `11.0.9`. Nothing changes in a game's run. - **Undo one landing**: `project.undo {landing}` reverses a landing still in this session's journal, merging around later independent edits and testing the inverse before writing it. A clash or an unsaid change is refused (`E0470`); replay sums and changed shots are written for the resulting game. The inverse is a new change, undone/redone by ordinary `project.undo`/`project.redo`. A game with shots needs a graphics adapter. Without `landing`, undo behaves as before. `copy.list` reads saved base texts only for changed files. - **Embers shows the new rendering and sound tools**: the Luau and C# games give embers and warden eyes `Emission`, fade waking wardens with `Opacity`, add short foot specks, metal wall caps and dusk haze, and place pickup sounds in the arena with an explicit distance range. Collection sparks are smaller and bloom is gentler. Their replay checksums change for the visual components and bursts; the recording, rules and gameplay state stay the same. Existing games are unaffected; to keep an older Embers look, keep its scene, models, script and render/sound settings together. - **Joining a game under way, and coming back**: `net.run {begin_with}` and `[net] begin_with` begin a game before every seat is taken; a `net.join` to it takes an open seat by a moment of the game sent as bytes, and `net.join {token}` (a menu's `net.join()`, which a shipped player gives the token it kept) takes back the seat its player left (`E0568`, `E0569`). `net.status` has `token`, `open` and `join`. No game plays or sums differently. - **A game's own menu hosts and joins**: scripts have `net.host(address?)`, `net.join(address?)`, `net.cancel()`, `net.state()` and `net.player()` (C#: `Net`), and `[net]` takes `start` (the scene every peer starts in at step 0 once everyone is in) and `address`. A script that defined a global `net` of its own now hides the engine's. Duel's recording moved into the engine's `duel/run.toml` example; no checksum moved. - **Particles**: an `Emitter` part and `emit(thing, n)` (C#'s `World.Emit`) let a thing's specks go as one `Burst`, drawn from a seed and its age and in no world: squares in 2D, unlit squares that face the camera in 3D. Both `Emitter` and `Burst` are declared in every game: a game's own component of either name must be renamed (`E0528`). A game with neither is as it was. - **A bloom in one line**: `[render] bloom = { threshold, strength }` (0.85 and 1.5 when left out) adds a bloom to the graph the engine makes, in 2D and 3D; a game with its own `passes` is refused the line in words. No game that has no such line behaves differently. - **Sound in 3D**: in a 3D game `sound.play(name, { at = thing })` (C#'s `Sound.Play(at:)`) is heard from where the thing is against the camera that sees: panned by the camera's own right and quieter with distance, whole within 2 metres and nothing past 30, which `[sound] near, far` and a play's own `near` and `far` change. It was panned by the thing's world x against the camera's x and never faded. A 2D game, and a play with `x` or no place, is heard as it was. - **A 3D thing's light of its own**: `Emission = { color, strength }` beside a `Mesh` adds its colour times its strength to what lights it, with its parents', and a graph that blooms spreads a strong one into a halo. `Emission` is declared in every 3D game: a 3D game's own component of that name must be renamed (`E0528`). No game that has none draws differently. - **A game's component named as one of the engine's is told so**: a project's `[components]` that declares a name the engine owns is refused with `E0528` (was `E0001`), which names it, the revision that took it and says to rename the game's own. - **A 3D thing takes its `Tint`**, as a 2D one does: `Tint = { color }` beside a `Mesh` (and on every thing it is under, by `Parent`) multiplies its colour, with `Mesh.tint`, which stays. A 3D game that gave a Mesh thing a `Tint` other than white sees it tinted where it was not; no other game draws differently. - **A 3D thing fades by its `Opacity`**, as a 2D one does: `Opacity = { alpha = 0.5 }` beside a `Mesh` (and on every thing it is under, by `Parent`) covers what is behind it by that much, drawn after every whole thing as a see-through model is; at 0 it is not drawn. Its shadow stays whole. A 3D game that gave a Mesh thing an `Opacity` below 1 sees it fade where it was drawn whole; no other game draws differently. - **A metal under a sky mirrors it**: in a game with a `Sky`, a metal surface adds the sky's colours the way it reflects (blurred as it is rougher), times its own colour. A game with no Sky, or whose models have no metal, draws as it did. - **Tags**: every game has a `Tags = { list = "pushable, heavy" }` part, the words a thing is known by, and `world.query {tag}` finds the things whose list holds a word; a script reads them as any part (`get(e, "Tags", "list")`, `each`). A game that declared a component of its own named `Tags` must rename it. No other game behaves differently, every checksum the same. - **The game's own picture at another shape**: `frame.capture {fill: true, width, height}` draws the frame from the game's camera into exactly that size with no bars, the world going on beside the frame, and says where the frame is (`game_rect`); `frame.view {fill}` says the same. No game behaves differently. - **A thing's say over its model's look, told to the editor**: `Mesh` gains `roughness` and `metallic` (below 0, the default: the model's own) and `blend` (`""`, the default: as the model says; `"blend"`; `"opaque"`), each out of the checksum while at its default, so every recorded game holds. `assets.cooked` keeps each part's `material` (its name) and adds `paint`, what that material is. No game behaves differently. - **A model's material drawn as glTF says**: a material whose `alphaMode` is `BLEND` is see-through by its alpha and drawn after everything that is not, the farthest first (it was drawn opaque); a `doubleSided` one lights its back faces as its front ones (they were lit as facing away); an occlusion picture of its own darkens what it covers (only one packed with metal and roughness did); and the base colour picture's `KHR_texture_transform` moves, turns and scales every picture of its material (it was left out). The model importer (6) keeps the transform (VMSH 4), so every model is cooked again once. A game with such a model draws differently; its checksum does not move. No way to have the old pictures: remove the field from the model. --- Page: changelog/2.md # Changelog, part 2 Part 2 of 7: [newer](../changelog.md) · [older](3.md). - **A shipped game plays over a network**: `frost export desktop` gives a game with a `[net]` table a player with the `net` feature, which takes `--host [IP:PORT]` and `--join IP:PORT` (`--for SECONDS` with no window); a game without one is exported as before, with no network code. A peer the others dropped for silence ends with E0549 ("the others played on without you from step N"). `net.condition` takes `cut_after_ms` and `cut_for_ms`. - **Multiplayer, live**: `frost dev GAME.toml --host` and `--join IP:PORT` play a game with other windows at 60 steps a second; `frost run --headless --host|--join --seconds S` plays with no window. `net.desync` takes `entity`, `component` and `field`; `net.status`'s `desync` names who last wrote the value on each side (`written_here`, `written_there`) and `net.status` has `words`. the engine's `duel` example's `Match` has `travel`, so its checksums moved. No other game plays or sums differently. - **Together copies**: `copy.make {of: [copies]}` makes a copy that shows those copies' changes merged on the game, never landed; it goes when one of them changes. The landing log keeps the texts of its most recent 256 landings. - **`copy.diff`**: what a copy changed, or a landing wrote, line by line, bounded. The landing log keeps each landing's texts and stages, and each file's lines added and removed; an older log's entries are answered without them (`copy.diff` of such a landing is `E0551`). - **Shared moments**: copies made from one moment of the game park with one moment between them until each moves; `copy.list` answers `shared`. Nothing a copy does changes. - **Pages**: `copy.list` answers at most 100 copies unless `limit` says (`next` names where to go on), and `copy.events` at most 500 events (`limit`, `next`). A tool that read every copy in one answer asks again after `next`. - **`copy.claim`**: a copy may claim scene things and files, advisory: everyone sees it, nothing is refused for it, a landing on a claimed thing says whose it was (`claimed`). - **Cheap copies**: a copy's files are clones where the disk can (APFS), and its record keeps its base's texts once, shared by every copy, in `.frost/copies/.texts`: 20.8 KB a copy of Ballast against 766 KB. A record an older engine wrote (texts in it) is still read; one written now is not read by an older engine. - **How a 3D pixel is lit**: `frame.at`'s `drawn` says each light's share of the pixel's light and why (`in shadow`, `faces away`, `out of its reach`, how far, and how far into a Sky's haze), worked out by the lit pass's twin on the CPU. No game behaves differently. - **W0459**: `frost check` and `frost export web` say of a ground over 512 samples a side how much memory its mesh takes (about 80 MB at 1024). A warning only. - **A ground is drawn in tiles**: 64 by 64 cells each, only those in view, each with every corner, every second or every fourth (the fewest that move it under half a pixel), 8 bytes a corner: a ground of 1024 samples a side holds about 12 MB on the device where it held 80 MB. `render.passes` counts a draw a tile. No world value, checksum or picture of a test game moves. - **A ground is drawn in tiles**: 64 by 64 cells each, only those in view, each with every corner, every second or every fourth (the fewest that move it under half a pixel), 8 bytes a corner: a ground of 1024 samples a side holds about 12 MB on the device where it held 80 MB. `render.passes` counts a draw a tile. No world value or checksum moves; a ground's picture may differ by one level in up to about one pixel in a thousand from its one mesh's (each corner's normal is kept in two 16-bit numbers, and its x, z and uv are worked out on the device), so the ground test games' kept shots were taken again: ground climb 114 and end 114, evening late_morning 106 and afternoon 189, fields 168, lamps day 141 and night 57 pixels of 230,400, each by one level. Every other test game's shot is as it was. - **W0459**: `frost check` and `frost export web` say of a ground over 512 samples a side how much memory its tiles take (about 12 MB at 1024). A warning only. - **Night lamps**: `Light = { ..., night = true }` shines only as the Sky's sun goes down, of the picture alone (its `energy` stays as written). Off by default: no game behaves differently. - **What a 3D pixel draws**: `frame.at` answers `drawn`, the thing whose triangle is drawn at the pixel (posed shapes too) with its part, triangle and material, whatever colliders are in front; `blame.pixel` names it in a 3D game, where it named nothing. No game behaves differently. - **Pictures for an editor of posed things**: `frame.capture` draws a thing at a clip and time for one picture (`pose`), the bones of every posed thing (`overlay = "skeleton"`), the picture a seek to a step would show (`step`) and the one a `game.try` from a snapshot would show (`from`, `inputs`, `steps`), none moving the game; `assets.cooked` says a model's clips and bones and `game.info` the project's `poses`. Posing reads a column at a time (1,600 figures: 1.4 to 0.95 ms a picture). No game behaves differently and no checksum or shot moves. - **Haze**: `Sky = { ..., haze = 20, haze_far = 80 }` fades the meshes into the sky's horizon colour from 20 to 80 units from the eye. Off by default: no game that says nothing draws differently. - **`copy.list` for hundreds**: `{summary: true}` answers counts and groups with no rows; `{group, after, limit}` pages the rows and answers `next`. A list asked with none of them is as it was. - **`copy.events`**: what a party did, in order: each copy made, working (with the things and fields it changed), asked to land, tested, landed, held, refused, queued, rebased, parked, given, dropped. Nothing changes for a game. - **The landing queue**: `copy.queue` and `copy.flush` land many copies' changes in batches, each tested once, in the order asked; a batch that fails is halved down to the landing that fails. `copy.list` answers `queued`. `copy.land` is as it was. - **`keeps_things`**: a Luau script may say at its top level which numbers it keeps in `state` are things, `keeps_things({ "bits.*.e" })`; a landing then holds them to the same things when an add moves them, as a C# `Thing` field already is. `frost check` plays the game's run and warns of a kept number that looks like a thing's and is not declared (`W0312`, with the line to add) and of a declared path that holds no thing (`W0313`). The templates declare theirs. The line keeps nothing: no checksum moves. A game with a global of its own named `keeps_things` must rename it. - **A test of a change pairs things by name**: `frost test --says`, `change.test` and a landing compare the two games with each named thing matched by its name and the others by their order (or by slot when the change says `entities`); a change that only moved things to other slots (a thing added to a scene) no longer differs where it did not say, unless a script keeps a moved thing's number in `state`, which is compared as a number. A part may be a whole thing, `added_7`. `world.checksum` takes `paired`. No game plays differently and no recorded checksum moves. - **A landing merges a scene by thing, part and field**: `copy.land` and `copy.rebase` merge a `.toml` file's things, parts and fields, so two copies that changed other fields of one thing (on one line, or lines that touch) both land where they were refused (`E0477`) before; the same field changed two ways is still refused, now naming the thing, part, field and both values (`data.clashes`). A part said may be one thing's, `ball.Transform.x` (`world.checksum`, `change.test`, `frost test --says`): nothing a game does changes, and no checksum moves. - **The Sky's sun casts shadows**: `Sky = { ..., shadows = true, reach = 30 }` casts the sun's shadows as a sun `Light` with `shadows` does, moving with the time of day; a sun Light's shadows beside a Sky are not cast (its light was not used already). A ground casts and receives them as any mesh. No game that says nothing behaves differently. - **Ground layers and questions**: a ground's `.ground.toml` may give up to four picture `layers`, by slope and height, and `ground.at` says their weights; scripts ask `ground.at(x, z)` (Luau) and `Ground.At(x, z)` (C#), the protocol's answer; an export ships a ground only as its cooked `.vgrd`, not its heights picture. - **A person, a gait and a clip's events**: the engine's `figure/art/figure.gltf` example is a person of eleven joints with seven clips (idle, walk, run, sit, type, carry, wave) for a game to copy. `Gait = {}` beside a `Pose` plays idle, walk or run as fast as the thing goes over the ground, with no script. A project's `[poses]` names what a model's clip sends as it plays (`walk = { seconds = 1.0, events = [{ at = 0.25, name = "step" }] }`), read with `events("step")`. Posed things are cheap by the hundred: one pose a clip and step (every 4 steps for a thing drawn under 64 pixels tall), worked out only for what the picture or the sun's shadow map sees. `Gait` is declared in every 3D game: one of a game's own of that name must be renamed. No recorded game moves. - **A model plays its clips in a game**: a 3D thing with a `Mesh` and `Pose = { clip = "walk" }` plays the model's glTF clip (its nodes moved, its skin bent), with `speed` and a `fade` between clips, posed on the CPU the same bits in a browser and shadowed like any mesh. `Pose` is declared in every 3D game: a 3D game that declared a component of its own named `Pose` must rename it. The model importer (5) keeps a model's nodes, skins and clips in it (VMSH 3, a model with neither is written as before), so such a model is cooked again once. A clip's turns between keys are mixed and made one long (nlerp) where `assets.picture` turned them along the arc, which a picture between keys may show. - **Multiplayer by rollback** (`docs/multiplayer.md`): a project file may have a `[net]` table (`delay`, `window`, `sync_every`), and the protocol has `net.host`, `net.join`, `net.run`, `net.condition`, `net.status`, `net.desync` and `net.leave`. A project file with a `[net]` table is refused by an older `frost`. No game plays or sums differently. - **C# refuses the machine's clock and unseeded chance** as a script compiles (`VEN105`): `DateTime.Now` and its kin, `Environment.TickCount`, `Stopwatch`, `new Random()` with no seed, `Random.Shared`, `Guid.NewGuid()`. A script that read them did not replay; count steps or add up `dt`, and draw from `World.Random`. - **A game in C# ships to the desktop**: `frost export desktop` of a game in C# compiles each script ahead of time (Native AOT) into `game/csharp/`, and the player runs it with no .NET; `--fetch` lets the one package that needs be fetched when the SDK has it not (`E0311`). Coldwave's second download, `-csharp`, has a `frost` with C# and desktop players that run it. A web export of a game in C# is refused, desktop only (`E0482`). No Luau game behaves - **Shapes with no file**: `Mesh = { file = "box" }` (`sphere`, `plane`, `capsule`, `cylinder`) draws one of the engine's own one-metre shapes, sized by the thing's scale. Such a name was refused when the game loaded, so no game that loaded behaves differently. - **A new game's first Accept takes its shots**: `frost test --write` takes each shot that has no picture kept yet and says so (`took shots/title.png (step 30), its first picture`), where it failed on them; a kept picture is never written over by it, and one that changed still fails for `frost check --shots --write-shots`. No game behaves differently. - **What making a 3D game found**: a model's material with a glow colour and no glow picture (glTF's `emissiveFactor` alone) glows by that colour, as glTF says, where it was drawn with no glow at all. No checksum moves; such a model's picture does. A 3D game has `Follow`: `Follow = { of = "hero" }` on a camera keeps it behind the thing and looking at it, in front of walls, with no script (`back`, `up`, `aim`, `speed`, `walls`). No game that has none behaves differently. - **Ground**: a 3D game has a `Ground = { file, color }` part, a height field read from a `.ground.toml` and a 16-bit grey PNG, cooked, drawn and asked with `ground.at`. A game with none is as it was. A 3D game that declared a component of its own named `Ground` must rename it. - **Spot lights, a sun's shadows and a model's picture**: `Light = { kind = "spot", inner, outer }` lights a cone along its turn's -z (whole within `inner` degrees, out by `outer`; one of the eight lights a pass has, with the point lights). A sun with `shadows = true` casts shadows within `range` of the point `range` ahead of the Camera. `assets.picture` draws one model file alone, at a moment of one of its glTF clips, for an asset viewer; the model importer (4) keeps a skinned mesh's `JOINTS_0` and `WEIGHTS_0`, so such a model is cooked again once. `inner`, `outer` and `shadows` are left out of the checksum at their defaults: no recorded game moves and every game that asks for neither draws as before. - **C# has the rest of Luau's API**: `Physics` (every question and push of Luau's `physics`, 2D and 3D), `Save`, `Data` (both as `Ven.Table`), C# libraries (a `.cs` file under `libraries`) and `OnRestore()`; `docs/csharp.md`'s table has no row left without C#. the engine's `csharp/` example holds Vigil, the car and the 3D questions in C#, each the Luau test game's world at every step. A push takes a `Vec2` or `Vec3` (`Physics.Impulse(crate, new Vec2(40, 120))`). `frost dap` debugs a game in C# through the person's own netcoredbg. No Luau game behaves differently. - **C# scripts have Luau's API** (in a `frost` built with `--features dotnet`, which no release is): `World`, `Input`, `Events`, `Sound`, `Music`, `Scene`, `Frame`, `Tuning`, `Quat`, `Ui` and `OnScene` (`docs/csharp.md`). What a C# call changes is done when the script's step returns, in the order asked. A C# script's errors say their column, blame names its lines. A game in C# is refused in a sentence where there is no C# and by `frost export` (`E0482`); `frost test` passes over it in a `frost` without C#. No Luau game behaves differently. - **A sky and the time of day**: a 3D game has a `Sky = { time, turn }` part, from whose time in hours the engine works out the sun's way, colour and strength, the sky's light and the sky's colours, drawn by a new kind of pass, `draw = "sky"`; a 3D game with no `[render]` whose scene gives a thing a `Sky` draws `sky`, `meshes`, `layers`. A game with no Sky draws and plays as it did, every checksum the same. A 3D game that declared a component of its own named `Sky` must rename it. - **Copies' loose ends**: `copy.make {for}` for a tag whose hand works in another copy is refused (`E0480`, naming that copy) and makes nothing, as `copy.give` refuses it; it moved the hand into the new copy and left the other without one. `copy.land` holds each saved test of the game to what the copy said, on its own recording, and writes the run it now comes to in the same change, as it does the game's own: a saved test that held before a landing holds after it, where it failed until `frost test --write` was run on it; one that moves where the copy did not say holds the landing. `frost test --unaccept` after the game's first Accept takes the copy away with the folders that Accept made (it refused: nothing was kept from before), so Accept and its undo leave the game's folder as it was to the byte. `debug.stack` says each frame's `column` (the stop's for the innermost, the line's first code for the others), and `frost dap` sends it in its stack frames, where it sent 1. No game behaves differently. - **Truths the editor asked for**: `blame.value {step}` answers who wrote a value as it stood at any step of the recording, blame on or off, and leaves the game where it was; every run of writes says `old_step`. A script's error says its `column` in `data`, and for a nil it indexed or called `nil` (`{name, how, key, also, since}`, `since` for a field of `state`); `debug.state` says `column` and `nil` of a stop. `render.passes` says each pass's `cpu_ms`, a measurement. `project.rename`, `project.refs` and the other `project.*` commands work for a game served by a bare file name (`frost serve game.toml`), which `E0464` refused. A picture renamed through `project.rename` keeps its recorded runs as a script does (`runs`), where it moved them. No game behaves differently. - **A renamed script keeps its recorded runs**: `project.rename` of a script writes what each recorded run that held comes to under the new name (the game's and its saved tests', only the digits of each sum) and carries the game as accepted, in the same change `project.undo` takes back; the answer lists them as `runs`. A script renamed by hand still fails `frost test`, which now says it was renamed, naming both files, where it said the old name's `state` was not there. No game behaves differently. - **Copies are kept**: a copy idle ten minutes, made room for when a seventeenth would be live, or asked with `copy.park` is parked (its game let go, one moment kept) and woken by the next command that reaches it; at most 256 are kept (`E0479`). `copy.give` gives a copy to another hand, and the one it had is refused (`E0480`). Copies' bases and the landing log are kept on disk (`.frost/copies/NAME.json`, `.frost/landings.json`), so a game served again finds its copies, parked, and numbers its landings on; a folder there with no record is listed and never reused (`E0481`). `copy.list` adds `held` and `moment` and lists parked copies; `copy.drop` no longer waits for a busy copy and answers `busy`; `copy.make` answers `parked`. A file that is a join file (an `address` and a `token`) is never copied into a copy. `change.test {folder | copy}` and `copy.land` add the stage `put_back`, which fails a change whose game, put back at a step, plays on another way (a `local` that keeps part of the game). No game behaves differently. - **A copy lands**: `copy.land` merges a copy's changes onto the game line by line, tests them on the recording and writes them as one change `project.undo` takes back, with the run and the shots it changed accepted in the project file and `shots/`; `copy.rebase` puts a copy on what has landed; `copy.landed` is the log. New codes `E0477` (lines changed on both sides) and `E0478`. `change.test`'s `on.landing` and `copy.make`'s `base.landing` are now numbers (0 before any landing), not null; `copy.list` adds `landing`, `behind`, `busy` and `tests`, and no longer waits for a busy copy. A copy no longer gets the session's join files. No game behaves differently. --- Page: changelog/3.md # Changelog, part 3 Part 3 of 7: [newer](2.md) · [older](4.md). - **Copies of the game, one per agent**: `copy.make`, `copy.list` and `copy.drop` make, list and drop a copy of the game in `.frost/copies/NAME/` beside the project file, played in the same engine on a thread of its own; a hand made for it (`copy.make {for}`) acts in it with every command, and the session's owner names one with `copy: NAME` on any command. `change.test {copy}` and `with: [{copy}]` test a copy's changes. New codes `E0473` to `E0476`. With `before` alone, `change.test` now lists the game's own changed lines in `hands`. No game behaves differently. - **`change.test` tests a folder of changed files with no repository**: `change.test {says, folder}` plays the folder's files over the served game's beside the game's own, on its recording, and holds the run to what it said as `frost test --says` does; `with: [{folder}]` plays other changes under it on both sides (two that pass alone, together), and `before: {folder}` holds the files on disk to a whole game kept in another folder. Its answer adds `stages`, `steps`, `on`, `hands` and `ms`; with a folder `says` may be empty, and a folder it cannot test is refused (`E0472`). Without `folder` and `before` it is as it was. No game behaves differently. - **`project.remove {file}` has two ways through, and is undone**: `maybe: true` removes a file although places that only may name it remain (a script's call whose name is made as it runs; the answer lists them as `maybe`), and `unlist: true` takes its name out of the project file's other keys and lists in the same change (`recording = "run.toml"`), refused in words for the start scene and where the game would not load. A file's remove is now a change `project.undo` takes back and `project.redo` makes again: the file is moved into `.frost/removed/N/` beside the game (answered as `kept`) and no longer deleted outright; delete that folder to let it go. `project.refs` gives each place `why`: `"made"` for one not followed, else null. No game changes. - **A `Collider` is as large as its thing's scale makes it**: its shape is its written size times the thing's scale in the world (`Scale` in 2D; `sx`, `sy`, `sz` in 3D; its own times its parents'), at the load and whenever the scale changes, for bodies, sensors, movers, tilemaps and a car's body, and in `physics.read`, the overlay and a pick. It was the written size whatever the scale, so a crate drawn double collided at its old size. A circle, sphere or capsule scaled unevenly (a cylinder: unevenly along x and z), and any collider scaled by 0, is refused (`E0471`) at the load, at the next step and at a `world.set`; below 0 mirrors. A changed scale makes the body again (`contact_end`, then `contact`), its mass following its size. To keep the old size, divide `w`, `h`, `d` (or a polygon's `points`) by the scale, or put the `Collider` on a thing that is not scaled and what is drawn on a thing under it; do the second for a picture whose scale a script or a tween changes. A recorded game with a scaled collider moves its checksum; none of the engine's did. - **An eye's picture is the size asked, and an eye can have no perspective**: with `eye`, `frame.capture`'s `width` and `height` are the picture's size, exactly (1 to 4096 each, the frame's where left out), where before they shrank the frame's own shape to fit; its `view_projection` has that shape, with fov held from bottom to top; and `frame.at`, `frame.in` and `frame.view` take the same `width` and `height` with an eye (refused without one). `eye.ortho`, in place of `fov`, is a picture with no perspective, that many world units from bottom to top. An eye's capture now says `view: null`, and an eye with `target` is refused in words. Without an eye every answer is as it was. - **A 3D pick says the part of the model, and a pass says its draws**: a `frame.at` hit of kind `Mesh` has `part`, `{index, mesh, primitive, material, point, distance}` for the first triangle the ray meets, or null where it is in the model's box and meets none (and null for a `Collider`); `render.passes` gives each pass `draw_calls`, the draws it made in the last picture drawn, null before one. Both are new keys; no game changes. - **A 3D game is looked at from an `eye`**: `frame.capture`, `frame.at`, `frame.in` and `frame.view` take `eye: {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?}` and draw, pick and measure the game from there in place of its `Camera`, for that answer only; the answer's `view_projection` is the eye's. What the layers draw (a HUD) is left out of such a picture and its hits. Nothing of the game changes and no checksum moves. `E0449` now says both refusals: a `view` in a 3D game, and an `eye` in a 2D one. `blame.pixel` takes no eye. - **`graph.uses {kind: "clip", name}` says who plays a clip**: the `[clips]` key that declares it, each scene thing whose `Clip` starts with it, and each script line that sets a `Clip`'s `name` to it or spawns a thing with it, the name written out. A name that comes through a variable is not found. No game changes. - **A `Collider` with no `Body` under a parent is held where its parents put it**: in 2D and in 3D the physics held such a collider at its own `Transform` read as a place in the world, away from where it is drawn. It now stands where `Parent` puts it, turned with its parents, and goes with them each step; its size is still not scaled. A game that relied on the old place puts the thing under a group (an entity with no `Transform`) or under nothing. A `Body` or `Mover` under a placed parent is refused as before (`E0455`). A recorded game with such a collider may move its checksum; none of the engine's did. - **`frame.at` and `frame.in` answer for a 3D game's things**: `frame.at {x, y}` now also lists each thing the ray through the pixel meets, the nearest first, by its `Collider` (box, sphere, capsule, cylinder) or else the box around its `Mesh`'s model, with `projected: true`, the `point` met and its `distance`; `frame.in` each thing whose box, as the camera projects it, touches the box asked. A 3D game's answers were only what its layers draw, and those hits are as they were, in front. A 2D game's answers are the same bytes, and no checksum moves. `blame.pixel` is as it was. - **`project.rename` renames a file of the game with every name of it, and `project.refs` lists more**: `project.rename {from, to}` moves one file and writes the new name over the old in the project file, the saved tests, the scenes, the files of values and the scripts, each where it stands and in the spelling it had, as one change `project.undo` takes back byte for byte and `project.redo` makes again (`E0463` to `E0470` say why not, with what to do). No game changes until it is asked. `project.refs` now also lists a plain string in a script or in a `data` file that is the file's path, and a name spelled another way (`./art/hero.png`), so `project.remove {file}` refuses a file such a string names; a `data(...)` whose argument is made as the script runs now counts only against a `.toml` file. A planning hand's refusal (`E0447`) says `from` and `to` among what was tried. No checksum moves. - **A 3D game has a car: `Vehicle`**: on an entity with a `Collider` and a dynamic `Body` it makes the body a car on four wheels, with springs, an engine and gears. A script drives it by writing `Vehicle.forward`, `right`, `brake` and `handbrake`, and reads `speed`, `revs`, `gear` and `touching`; `physics.wheels(car)` and `physics.read`'s `vehicles` say where its wheels are. A `Vehicle` in a 2D game, on a body that is not dynamic, without a `Collider` or made of what no car is stops the load, with what to do (`E0459` to `E0462`). A 3D game with physics that declares a component of its own named `Vehicle` no longer loads: give it another name. A 3D game without one, and every 2D game, is as it was, and no checksum moves. - **`frost test` says a game with no recorded run apart: it has not passed**: a project with no `replay` was `ok: nothing to replay` and counted in `all passed`. Its line now starts `no recorded run:`, and the last line counts it apart (`tested 2 games: 1 passes, 1 has no recorded run`); `all passed` is said only when every game has a run and held to it. The exit status is as it was, 0 unless one failed. `--json` adds `state` to each run (`"passed"`, `"failed"`, `"no_replay"`) and the counts `passed` and `no_replay` beside `failed`; a run's `passed` is still false only for a failure, so read `state`. A script that looked for `all passed` or `: ok:` sees such a game no longer match. No game changes. - **A hand has a token of its own, and the engine holds it to the editor's mode**: the editor's `session.token {tag, mode?}` answers `{tag, hand, mode, file}` and writes a join file for that hand alone beside the session's (`PATH.handN`), which `frost mcp --join-file` takes. Whoever joins by it is that hand under any name, and `session.mode {hand, mode: "plan"}` refuses its writes (`E0447`) on every connection that came by its token, open or made later, until another mode lets it. A hand's token of another session is `E0458`. Nothing changes for a client of the session's own token or the read-only one, except that a name a connection says never joins a hand that has a token. No game changes. - **`audio.requests` says the music playing now, and a restore puts the requests back**: `music: {name, since, paused}` or null, however long ago the music started. A game put back with `game.restore` has the requests (and `made`) it had at the snapshot, without those of the future it came back from, and the music then playing starts again, at the volumes (`sound.volume`, `sound.effects`, `music.volume`) set by then. No game changes. - **A 3D game's `frame.capture` and `frame.view` answer `view_projection`**: the 16 numbers (column-major, world to clip) the picture's meshes were drawn with, so an editor puts a point of the world on the picture: after the divide, x and y from -1 to 1 span the whole picture, y up, depth reversed. `frost run --shot` and a held web player print it too. A 2D game answers no such key. No checksum or picture changes. - **`project.remove {file}` removes any file of the game**: it leaves the project file's lists and is deleted, refused while anything else names it. `{kind, name}` still takes back a `project.add`. No game changes. - **A step drawn again tells one picture**: `profile.steps` and `profile.frame` with `step` give a step's `draw_calls`, `quads`, `instance_bytes` and the renderer's other counters, and the time of its picture's spans (`render.build`, `gpu.submit` and the rest), as the last picture drawn of it took them, where they added every picture (a paused game captured three times said 10, 20, then 30 draw calls, and three pictures' time; now 10 and one picture's time each time). `totals` adds one picture a step. The slowest steps and each script's share were never touched by it (the step's own time, the scripts' time). No game changes. - **A load that cooked again says why**: `game.info` has `cooked`, `{fresh, cached, ms, why}`, with `why` one of `importers`, `files`, `first`, `off`; `frost` prints one line on stderr when a load, or the first frame, cooked something now and took over half a second. The cook's cache keeps an `importers` file beside its blobs; a tool that lists the cache folder finds it. - **`project.refs {file}` lists every place that names a file of the game**: what an editor asks before it renames or removes one; a script's call whose file is made as it runs is listed as one that cannot be followed. No game changes. - **A game writes its own full-frame effects in WGSL**: `[render] effects = { lines = { file = "lines.wgsl" } }`, run by a pass as `bright` or `panini` are, with the pass's `threshold` and `strength` (set each frame through `Pass`; an effect has no clock), at most 8, reading 1 or 2 targets. One that does not compile is refused at its own file and line when the game loads (`E0456`), with no device, so a check and an export for the browser refuse it too. The engine's five effects are now plain WGSL files written the same way, so a game can start from any of them, and each draws the same pixels as before. No checksum or picture changes; the engine's scan example is new. - **The engine's sentences say "repository", not "git"**: `frost test`'s line and `reason` name "the game as committed (the repository's last commit …)" and "the folder is not a repository"; flags and docs that name the tool keep it. No game changes. - **A thing under a parent takes its Opacity, and a new `Tint` part, from the things above it**: a whole rig fades or flashes with one write on its root. **What it does to a game:** one with `Opacity` on a thing that others are under now draws those others faded too (a parent at 0.5 over a child at 0.5 is drawn at 0.25); no checksum changes. The interface's `Inherit` is as it was. `Tint = { color }` is new. Known visible change: Scrap Riot's nine recordings keep their checksums, and of 3,750 frames compared 15 differ, in two cases (an entering robot's glow and hit-flash now fade in with it; Bolt's white flash now blinks with him), both what the original's own code does. - **A saved test says which game it tests**: a top-level `test_of = "game.toml"`, which `frost test --write` writes, `frost test --json` and `frost projects` report and `frost check` holds to a project file beside it (`E0445`). Left out: game.toml. No game changes. - **A run that draws nothing decodes no model picture**: a model's pictures are read and decoded when something is first drawn, not at load, so `frost test`, `frost bench` and a headless game load faster and smaller. A picture's header is still checked at load (a missing file, another format or impossible sizes are errors there and in `frost check`, as before); a picture whose body is damaged is now an error at the first frame, naming it. - **A person's edits are told one by one**: in blame, each write a client makes is a run of its own (an edit and its undo are two), and a write made right after `blame.on` mid-game has the step the game stands at, not 0. No game changes. - **An Accept can be undone**: `frost test --write` keeps the copy it replaces (`.frost/accepted/NAME.before`, one level), and `frost test --unaccept RUN.toml` puts it back once the run's project file is as it was. No game changes. - **`frost check` warns of a `Pass` that gives its numbers to a pass that reads neither** (`W0457`): one on `copy`, `blur`, or a pass that draws changes nothing. - **A model's pictures go to the device with every level, and their pixels are let go**: a picture a model is drawn with is uploaded with its smaller levels (so it does not shimmer drawn small), one at a time, and its decoded pixels are dropped once it is on the device; on a new device the model is read again from its file. A new picture no longer puts every other one on the device again. No checksum or picture changes. - **`frost run --size` says when it replays a recording in another frame**: a recording holds the pointer as a share of the frame and is made in the project's frame, so a game whose scripts read `frame.size()` (to fit its camera) plays it as another game at another size. W0456 says so, with both sizes; leave `--size` out to replay it as it was made. A window of another size changes nothing: it shows the project's frame with bars. - **`frost projects [DIR] [--json]` lists a folder's project files**: each with its space and how many scenes it lists, in the order `frost test` walks them. No game changes. - **E0447 writes a text it names in quotes**: `world.set with entity "platform", path "a, b.luau" is refused`, each value as JSON writes it, so the sentence can be taken apart whatever a name holds. No game changes. - **An exported game takes its own picture**: `frost_player --picture-at N --out FILE.png` plays the game's recording N steps, draws that step off-screen (no window ever opens), writes it as a PNG and prints how long the program took to its first frame ("started in 0.21 s"). It is pixel-equal to what `frost run --shot` draws at that step on the same machine (the same pixels, not the same file). A player is 49,840 bytes larger for it. - **A wide 3D view can be bent by the Panini projection, and a pass's numbers set each frame**: the effect `panini` bends what a pass reads by the Panini projection of distance `strength` (0 none, 1 cylindrical), the middle kept and the edges of a wide view pulled in, filling the frame. `Pass = { of, threshold, strength }` on one thing gives a pass its numbers this frame, so a script can turn a bloom up or the bend with speed; `E0449` (new): it names a pass the graph has not, or two give one. **What it does to a game:** `Pass` is declared in every game; no checksum or picture changes. - **`game.info`, `game.check` and `frost check --json` answer `csharp`**: one field more for every client, null for a game with no C# script (and for every game of an engine built without C#, which is every released one). For a game with one it is `{solution, dotnet, compiler}`: the file a C# language server is started on, which the engine now writes itself whenever the game is loaded or checked, and the .NET and the compiler the engine uses. No game changes. - **Who let a thing go is kept**: `blame.gone {name}` says which step the last thing of a name was despawned in and by what (a script's line, a client), or the scene change it went with and the line that loaded the next scene. No game changes. - **`frost test --json`, `frost check --json` and `frost check --costs --json` say how long they took**: each answer carries `took_ms`, the engine's own time for the run in whole milliseconds. It is the one field that differs from run to run: a program that compares two answers leaves it out. - **3D models are lit as their materials say**: in linear light, each part by its metal and roughness (a shine from the sun and the lamps), its normal picture, its occlusion, its glow, and a masked material's cutoff. A material's `fragment` function is handed and returns its colour in linear light. **What it does to a game:** every lit 3D picture changes (brighter falloff, shine on smooth and metal surfaces); no checksum changes. A glTF material that does not say its metal is metal, as glTF says. - **A model's pictures download small on the web**: for the web and phone profiles (and `frost export web`) a picture inside a model is cooked packed, its level 0 as a PNG file (VTEX format 2), and its levels are made again when it is read, by the same function, byte for byte. The Spin Top hull cooks to 15.4 MB for the web where it was 69.8 MB; loading it takes about 0.2 s more natively for the picture it draws. The desktop profile is as before. Nothing a game draws changed. - **A failed step says so**: `game.info` gives `failed_step` (the step a script's error stopped part way, null when the last step finished) and `whole`. No game changes. - **`frame.capture {times: true}` says what the picture took**: `took: {draw, read, encode, text}` in milliseconds, the engine's share of a picture's way to a client. Without it the answer is as before. No game changes. --- Page: changelog/4.md # Changelog, part 4 Part 4 of 7: [newer](3.md) · [older](5.md). - **`frost` builds headless**: `cargo build -p frost_cli --no-default-features` leaves out the machine's sound device and gamepads, and with them the only system libraries `frost` needed on Linux (ALSA's and udev's headers). It still tests, runs, exports and serves, and `frost run --wav` and `frost test`'s loudness check still hear the game: they use the software mixer, which frost_remote's new `tape` feature gives without a device. A default build is as it was. - **Every not-a-number is one value to the world**: the checksum, the test of whether a column is all one value, and every compare of kept data and of field values read any not-a-number as the quiet one with no sign (`frost_core::bits`). Machines disagree on which one `0/0` makes (positive on Arm, negative on x86, either in WebAssembly), `-(0/0)` flips it anywhere, and a save writes every one as `nan`: a world that held one could come to another checksum on another machine, or after a save and a load. A recorded game whose world held a not-a-number with a sign comes to a new checksum: `frost test --write`. - **A planning hand's refusal says what was tried**: `E0447` names the command's own parameters (`game.seek with step 240 is refused: ...`), and its `data` carries them as `{command, tried}`. No game changes. - **A model's pictures are held once**: a cooked model read from its blob keeps each picture inside it in place, not copied out, and decodes one only when it is drawn (`Model::picture`). Loading the Spin Top hull (three 4096² pictures) from a warm cache holds 483 MB where it held 751 MB. Nothing a game draws changed. - **A picture the web draws smaller is said**: `frost check` and `frost export web` warn (`W0455`) of each picture inside a model longer than 2048 on a side, with its size and the size the web cooks it to. The game's checksums are the same in a browser; its frames are not, and `frost test` compares shots natively only. Nothing a game draws changed. - **`profile.frame` tells the last frame that drew a picture, and a step as it was played**: a request that only reads (`game.info`) no longer becomes the frame told; the answer names the `step` drawn. `profile.frame {step}` gives that step's spans and counters as `profile.steps` does, `recorded: true` when they are as it was played; the 16 slowest steps of a run keep theirs past the minute, so `profile.steps`' `worst` has them too. No game changes. - **What `--write` wrote is named, with the hash of its bytes**: each `frost test --json` run gives `wrote: [{path, sha256}]`, and `frost check --json --shots [--write-shots]` gives `shots` and `wrote`; `--json` now goes with `--shots`. No game changes. - **A model's pictures have their levels, and 2048 a side on the web**: `frost cook` makes each picture inside a `.glb` a texture with every level (VTEX 2), and for `--profile web` (and `frost export --web`) halves one longer than 2048 on a side first. A 2D picture is cooked as before, one level, the same pixels for every profile. A model's triangle that has one vertex twice once its corners are welded has no area and is left out, and counted: `frost cook` says how many for each part (VMSH 2 keeps the count). A model with a part that loses every triangle so is refused (`E0527`). Cached pictures and models cook again once. Nothing a game draws changed. - **`frame.capture {fast: true}` writes the picture quickly rather than small**: the same pixels in a PNG a tenth to a fifth larger (twice as large at first: it now uses the Paeth filter), for a client that shows frames live, with or without `view` or `target`. Without it, every capture is the same bytes as before; saved pictures and `frost check --shots` never use it. No game changes. - **The editor can see more of the world than the camera**: `frame.capture {view: {left, bottom, right, top}}` draws that rectangle of a 2D world, the interface on the camera's rectangle at its scale; `frame.at`, `frame.in` and `blame.pixel` take the same `view`. A 3D game's view is `E0449` for now. Without `view`, nothing changes. No game changes. - **`frost test --json` gains `dotnet`** in each run: `{accepted, here}`, the major version of .NET a game with C# was accepted on and the one it runs on here when they are two; null otherwise, and always for a game with no C#. No game changes. - **Scripts run faster: the step budget's counter is the engine's own**: Luau counts every loop turn and call for the step budget through a callback of the engine's instead of the binding's general one. Measured on an Apple M-series Mac, built like release, ns a turn: a trivial loop turn 12.3 to 10.0, an empty loop 6.5 to 4.3, a call to a small function 28.1 to 21.3, arithmetic 11.6 to 9.5 (327 to 274 machine instructions a loop turn). The count, where a script is stopped and that `pcall` cannot hide it are as they were: no checksum and no `script_work` moves. And a correction: a loop turn never cost 83 ns; that figure divided each step's walk of `state` by the loop's turns (see `state` in the reference: keep a big table that never changes in a `local`). - **Another run of the game is read beside the one played**: `world.series` and `events.since` take `run` (a project file of the game with a `replay`, as `frost test` lists them), with or without `against: "accepted"`, and echo it. No game changes. - **A failing test that names no step says where, why, and whether to accept**: `frost test --json` gives each run `stretch` (the checkpoints its run first differs between), `reason` (one plain sentence) and `accept_sound`. No game changes. - **A model's surfaces show its pictures**: each part of a 3D model is drawn with its material's base colour picture, inside the model or beside it, as the file paints it (sampled smoothly and repeated past its edges). Nothing that names no picture changes: its parts draw white under their colours, as before. - **`script.state` says which kept numbers are a thing**: its answer gains `kinds`, a script's name with `{key: "thing"}` for each key of its state whose number is a thing of the game (a C# script's `Thing` field; -1 is no thing). `states` is as it was, and a game of Luau scripts answers `kinds: {}`: a client that held the whole answer to its exact bytes meets one more field. No game changes. - **`frost dev` says which process it is**: into a pipe it prints a second line, `process PID`, after the line that says where it listens, and `debug.state` answers the same number as `process`: what a debugger of the machine attaches to. The first line is unchanged, token last; a program that reads every line `frost dev` prints meets one more. No game changes. - **Atlases: frames by name**: a `.atlas.toml` file puts many pictures on one, packed from the PNG files its `pictures` patterns match (`*` in one folder's file names) or cut from one `sheet` by a `grid`, and `Sprite.frame` (new) names the frame a sprite shows: `Sprite = { image = "art/hero.atlas.toml", frame = "run_0" }`. Sprites of one atlas share one picture, so a layer of them is one draw call. A frame draws exactly its picture's pixels (`filter = "nearest"`; one step in a few pixels with `"linear"`). An unknown frame stops the game with `E0531` and the nearest names; frames that do not fit 4096 by 4096 are `E0530`; a pattern that matches nothing is `E0532`; `frost check` prints what each pattern matched. `frost export` ships each atlas cooked (`NAME.atlas.toml.vatl`) and not the pictures packed in it. With a `frame`, `src_*` cut a part of the frame, stopped at its edge; a sprite with a `frame` and a `Repeat` is refused (`E0533`). `Sprite.frame` is marked `Schema::added`, so **no recorded game's checksum moved**. `assets.cooked {path}` (new, the protocol and MCP) says what the cook makes of a file: a picture's size, an atlas's frames, a model's parts. - **Two fingers on a touch screen: `[input] fingers`**: up to 4 finger slots, each a `region` of the frame (in the pointer's -1 to 1 units) and three actions, its place (`x`, `y`) and its `press`. A finger takes the first free slot whose region it comes down in and keeps it until it lifts; a finger over the bars is at the frame's edge. Slots are actions, so recordings, tests and `input.set` play them. A new key: no checksum moves, and the first finger is still the pointer with `"MouseLeft"`. An exported page's loader lets touches and clicks through to the game as it fades (it took them for 300 ms). - **Each thing a material draws has four numbers of its own**: `Mesh = { ..., p0, p1, p2, p3 }`, which its material's functions read as `thing` (a heat, a flash, a hole's size), set by a script per thing. **What it does to a game:** a 3D game with a Mesh changes its run checksum (four more numbers a Mesh); no picture changes. - **A save is on the disk when the player is quit**: Cmd-Q on macOS ends the process without unwinding, so a save still being written could be lost; the player and `frost dev` now finish it first. No game changes. - **What `frost test --write` accepts keeps the recording it was played on**: a game whose recording is a file of its own (`recording = "run.toml"`, a saved test's `tests/NAME.run`), and a model's buffers and pictures, are kept in `.frost/accepted/NAME` beside the rest, so a later failure names the first step that differs with no git. A copy an older `frost` kept without its recording says so and how to keep it again (`frost test --write` once), instead of `E0401` from inside it. - **A project lists the models only its scripts name**: `models = ["kit/drum.glb"]`, beside `images`, loads each as the scenes' meshes are. A Mesh naming a model that was not loaded is `E0438` (new) and `frost check` says `E0439` (new) of a script whose text names one, in a tool and in an exported player alike. A changed picture in a game with models is redrawn again rather than restarting the game. - **A 3D game's materials bend and paint what they draw**: `[render.materials]` names each material's WGSL functions (`vertex`, which moves a point already in the world; `fragment`, a surface's colour before it is lit), and `Mesh.material` draws a mesh with one. Its eight numbers are `Material = { of, p0..p7 }` on one thing, written by a script: a shader has no clock. `E0437` (new): a thing names a material not declared, or two give one its numbers. **What it does to a game:** a 3D game's run checksum changes, as `Mesh` holds `material` and `Material` is declared; no picture changes. - **A hand carries its mode, and a planning hand changes nothing**: `session.hello {mode}` (`frost mcp --join --mode plan|ask|trial|free`) and the editor's `session.mode {hand, mode}`; in `plan` every command that is not read-only is refused (`E0447`), and only the editor lifts it (`E0448`). No game changes. - **A port has a read-only token**: `frost serve --join-file PATH --read-join-file PLANS` writes PLANS with it (`read_only: true`). An agent that joins by it changes nothing (`E0447`) under any name or mode until the editor's `session.mode` lets its hand, so an agent that opens its own connection is held too. The first token and its answer are as they were. No game changes. lifts it (`E0448`). It holds an agent that acts through `frost mcp --join`; one that opens its own connection to the port under a new name is not yet held. No game changes. - **An exported web page opened with `?mute` plays no sound at all**: it opens no audio, keeps no samples, and nothing a script asks for turns it on; the game plays the same to the same checksum. Open the page again without it to hear it. Nothing else changed. - **A restore can bring the changes made since into the moment it puts back**: `game.restore` answers `changes` (each command that made `edits_after`: step, what, hand, who, name), and `game.restore {id, again: true}` makes them again there, all or none (a refusal keeps its own code and leaves the game as it was). No game changes. - **An exported game draws its models**: `frost export` (desktop and web) ships each model a scene's `Mesh` names as the model cooked from it, `NAME.vmsh` beside where the model was (`art/crate.gltf.vmsh`), and not the `.glb` or `.gltf`, which a player cannot read; the player, and any program given a game with no model file, draws that. A game with no Mesh exports as before. - **`change.test {says, against?}`** is `frost test --says` over the protocol and as an MCP tool: the same answer (`passes`, `said`, `differs`, `shots`) with the line and the warnings, for an editor's landing line and an agent's report without a shell. A program that cannot run it (a browser's) says so (`E0452`). Nothing else changed. - **The accepted run beside the one now: where a difference ends, and its events**: `frost test --json`'s `differs` gains `until`, the last step of the recording at which the run still differs from the game it is told against (null when it differs to the end), and `events.since {against: "accepted", to?}` reads the accepted game's events, played aside from its kept files. Nothing else changed. - **`events.since` lists each event once**: an event sent early in a step was in the log again for every stage after the one that sent it (four times for a script's `send`). A client that counted events counts fewer. Nothing in a world changed. - **A 3D game's `Mesh` draws the model it names**: `Mesh = { file }` names a `.glb` or `.gltf`, cooked when the game loads and kept in the cache (`E0436`, new: one the cook cannot read). An exported game draws no model yet. No game that has no Mesh changes. - **`frost cook` cooks glTF models, and `frost cook FILE` cooks one asset alone**: a `.glb`, or a `.gltf` with its buffers inside it or beside it (each one's hash is in the key), becomes a model (`VMSH` 1, `crates/frost_assets/src/mesh.rs`, agreed with the 3D renderer): every mesh the default scene draws, placed by its nodes' transforms (a mirror keeps faces counter-clockwise), welded, with flat normals and Lengyel tangents made where the file has none, `COLOR_0` and an application's own `_` attributes kept as streams, the bounding box and sphere, the materials, and the pictures they name (one beside the model by its path; a PNG inside it cooked as a texture). One level, the whole mesh. `frost cook FILE.png|FILE.glb|FILE.gltf` says what it became; a file its importer cannot read is `E0526` (new). `frost_remote::cooked_model` gives a loader the model for a path. No game draws a model yet; nothing else changed. - **`graph.uses` and `script.complete` answer from the game's text**: every place a part, field, thing, event, input action or tuning key is named (scripts, libraries, scenes, the project file), and the names that fit where a script is being written. Both read the text, say so (`read: "text"`), and count columns in UTF-16 code units (`columns: "utf16"`). Nothing else changed. - **A 3D game draws its meshes, lit, as its Camera sees them**: in a project with `space = "3d"`, `Camera` has `fov`, `near` and `far` beside `zoom`, and `Mesh` and `Light` exist; the frame graph's implicit passes are the meshes, tested against a 32-bit reversed depth target, then every layer over them. A `[render]` pass may draw meshes (`draw = "meshes"`, `depth = "..."`, a target of format "depth"). Meshes are handed to the renderer by name (see the entry above for models). **What it does to a game:** a 3D game's run checksum changes, as its Camera holds three more numbers (its pictures do not: `zoom` stays, and the layers are seen through it as before); `frost test --write` writes the new one. No 2D game changes. - **An agent joins with arguments that never change**: `frost serve GAME.toml --join-file PATH` writes where it listens and its token to PATH (mode 0600) and removes it on exit, and `frost mcp --join-file PATH` reads it, so the agent's command line is the same at every start of the game. A file left by a session that is gone is refused (`E0521`). - **`frost test --json`** prints one line for the whole test: each run's `passed`, `steps`, `against`, the first difference (`step`, `thing`, `part`, `field`, `now`, `was`, `more`, `written`) and the line it prints. Nothing else changed. - **`Repeat` makes a sprite's picture repeat past its edge**: with it, a part (`src_x`, `src_w`, and down) that runs past the picture shows the picture again instead of stretching its last pixels: scroll a belt by moving `src_x`. A new component: no checksum moves. The whole picture repeats, not a frame of it. - **`Shape` draws rings, discs and lines**: `Shape = { kind = "ring" | "disc" | "line", w, h, width, from, to, dash, color, layer }`, in the rectangle `w` by `h` (an ellipse when they differ), cut from `from` to `to` degrees into an arc or a wedge, dashed, its edges smooth; `Rotation`, `Scale`, `Opacity` and `Blend` apply as to a `Rect`, and it sorts with everything else by layer. A new component: no checksum moves. `frame.at` names it `"Shape"` where it draws, and not in a ring's hole. - **A scaled `Tilemap` draws all of itself**: a map with `Scale` was cut to the part of the view its unscaled grid covered (an 8 by 8 map at 0.5 showed one row), and `frame.at` named the tile of the unscaled grid. Both now go by the scaled grid. No checksum moves; a picture of a scaled map shows the tiles that were missing. - **The frame says how it was drawn**: `render.passes` lists the frame graph as it runs (passes kept and dropped, targets and the textures they share, pipelines); `frame.capture { target }` returns a target between passes; `frame.at`, `frame.in` and `blame.pixel` name each hit's `pass` and `material`, `blame.pixel` adds the `passes` the pixel came through, and `frame.view` the passes' names. Nothing else changed. - **A project may declare its frame graph in `[render]`**: targets between passes, passes that draw a range of layers, and the built-in effects `copy`, `bright`, `blur` and `add` (a glow, say: the engine's `ballast/glow.toml` example). A project without the table is drawn as before, by one pass of every layer into the frame: no checksum and no picture moved. A graph that cannot run is refused when the project is read, with the line of its pass. - **A game's pictures are read through the cook's cache**: `frost run`, `frost dev`, `frost test`, `frost serve` and the rest keep each picture's texture the first time it loads and read it from the cache after, in `FROST_CACHE` or the system's folder for caches. The pixels, frames and checksums are the same; `FROST_CACHE=off` decodes at every load as before. An exported game is not changed. Under `cargo` (tests, `cargo run`, `scripts/verify`) the cache is `target/ven-cache` (`.cargo/config.toml`), never the system's folder. --- Page: changelog/5.md # Changelog, part 5 Part 5 of 7: [newer](4.md) · [older](6.md). - **`frost cook GAME.toml` cooks a game's pictures into a cache**: each PNG the game loads becomes a texture kept under the SHA-256 of the file, the importer and its version and the profile (`--profile desktop|web`), in `--cache DIR`, `FROST_CACHE` or the system's folder for caches (`E0525`, new, when there is none). A second cook of unchanged files cooks nothing; `--check` cooks again in an empty cache and requires the same bytes. The game itself still reads its files as written. Nothing else changed. - **`session.writes {hand?, since?}` lists every change of the hands**: oldest first, each `{n, hand, what, name, line, step, at_ms}` as `session.hands` says a last change, with `next` to ask from next time; the latest 4,096 are kept, and `missed` says about how many an ask from before them lost. Nothing else changed. - **Blame says the text of the line that wrote**: a script writer in `blame.value`, `blame.entity` and `blame.pixel`, and each of its callers, has `text`: the line as the code read when it ran (a reload since does not change it), trimmed, at most 200 bytes; null for code older than the newest 32 versions of its file. The function's name is read from that code too. Nothing else changed. - **`game.seek` says where it played from and what that cost, and where the keyframes are**: it answers `from`, `started` ("here", "keyframe" or "load"), `replayed` and `ms`, and `keyframes.steps` lists the keyframes' steps. `world.series` buckets give `min_step`, `max_step` and `last_step` beside their values. Nothing else changed. - **Every command answers `--help`**: `frost COMMAND --help`, `frost COMMAND -h` and `frost help COMMAND` print what the command takes and exit 0 (they were refused with E0501 by most commands), and exit 2 for one that is not built, so a tool can ask an engine whether it has a command. Nothing else changed. - **The checksum covers a scene asked for and not started yet** (a `scene.load` in `on_scene` waits for the end of the next step): two games of equal checksums go on the same way. A game with nothing pending has the checksum it had; no test game's or stress game's recorded checksum moved. - **A game put back before a scene that `on_scene` asked for goes to it.** A `scene.load` asked for in `on_scene` waits for the end of the next step, and a snapshot taken before that step now holds that it was asked for: `game.restore`, `game.try` and `frost test --restore` went on in the old scene (and blamed a `local`). No checksum changed. - **A failed `frost test` names the files that changed since the game it is told against**: the one sentence now reads "... That is the first step that differs from the game as accepted (by `frost test --write`); changed since then: go.luau, speed.toml. If the change is meant, ...": from the accepted game's manifest (a file gone is named "(gone)"), or from git when told against the game as committed. Five names at most, then how many more. `.frost/` is not a file of the game. Nothing else changed. - **`project.remove` and `frost remove scene|script NAME` take back a `project.add`**: the name leaves `scenes` or `scripts` (its line, when the list was only it), every other comment and line as written, and the file is deleted, only while it is still exactly the engine's stub and no scene, script or library names it; otherwise `E0446` ("nothing was removed: ..."), with nothing changed. An add and its remove leave the folder byte for byte as it was: an editor's undo of "add". Nothing else changed. - **`world.series {against: "accepted"}` reads the accepted game**: the values of the game as `frost test --write` last kept it, played from those files on the recorded input, for a timeline's accepted lane beside the one now; the answer says `against`. Nothing else changed. - **`frost test --write` keeps the game as accepted, and a failing test is told against it**: `.frost/accepted/NAME/` beside the project file holds every file the game loaded (its text files whole, pictures and sounds by hash). A failure then says the first step, the value and the line that differ from what was accepted, with or without git, before it falls back to git HEAD and then to the checkpoints; `--against DIR` reads what someone kept elsewhere. The line of a `--write` ends ", kept as accepted in ...". A folder `.frost/` beside a game is new: it is yours to commit or not, and committed, a teammate without the history gets the same answer. - **A step says how much work its scripts did, as a count**: `profile.steps` and `profile.frame` count `script_work`, the calls and loop turns the Luau machine made, and `script_work NAME` for each script: the same on every machine and every run, unlike a time. Not in any checksum; a game that keeps no profile counts nothing. Nothing else changed. - **`world.apply {writes: [...]}` makes several writes as one**: `spawn`, `insert`, `set`, `remove` and `despawn`, each with its own command's parameters, in order and all or none. A refused write puts the world back to before the first, checksum and all; its error keeps the write's code and names it (`writes[2]`). `"$N"` names the entity of an earlier write, so a thing spawned can be given a part in the same call. One answer, one entry in `session.hands`. Nothing else changed. - **Data files: `data = ["levels/one.toml"]` and `data(name)`**: a TOML file the project lists is read when the game loads and handed to a script as a new plain table each call (tables, lists from 1, text, numbers, true and false), by its path or from the calling file's folder with `./` and `../`. A date or an integer past 2^53 is `E0408` with its line. A changed data file starts the game again, as a library does. A game that lists none is as before; no checksum changed. - **`library("./name.luau")` and `library("../name.luau")` are from the folder of the file that calls `library`**: a set of libraries that take each other in works from a project in any folder that lists them (`libraries = ["../shared/kit.luau", ...]`). A name without `./` or `../` is found as before, by the path the project file writes. - **Physics can step on more than one thread**: `FROST_PHYSICS_WORKERS=N` (1 to 16) makes every game `frost` plays step Box2D on N threads. The results are the same bits on any number, so no checksum moves; left out it is one thread, as before, and an exported player and a web page always use one. A number outside 1 to 16 is refused (`E0524`). - **A script may define `on_restore()`**, called once before it next runs after the game was put back to another moment (`game.restore`, `game.try`, a seek, a rollback) or a failed reload put `state` back: the place to empty what a `local` caches. `frost check` no longer warns (W0309) of a `local` that `on_restore` empties. A script without it runs as before. - **`project.add` and `frost add scene|script NAME` add a scene or a script to a game**: the file is written from the engine's stub and named in the project file's `scenes` or `scripts`, the project file edited in place with its comments kept. `E0446` (new) when the name is taken, is not a plain path, or is outside the project. It is the one command that writes a project's files, in the trusted class. Nothing a game does changed. - **A number kept in `state` that is not finite reads as `"Infinity"`, `"-Infinity"` or `"NaN"`** in `script.state`, `save.list` and `frost run --state`, where all three were `null`. Nothing a game does changed. - **`frost run --set` loads the game once**, with the values in place, where it loaded it, set the values and loaded it again: the top of each script runs once (one `print` where there were two), and what a script saves as it loads is saved once. The run itself, and its checksum, are as before. - **`bit32.mul(a, b)` and `math.roundeven(x)`**, for code ported from C, C# or JavaScript: the product of two 32-bit words wrapped as C wraps it (where `a * b` passes 2^53 and drops low bits), and rounding with halves to the even whole number (`math.round` takes them away from zero). Nothing a game does changed. - **`session.hands` says what each hand last ran, and where its code changed**: `last_run {to_step, checksum, matches_replay, n}` for a run to the end of the recording (`matches_replay` true or false only where nothing but the recording moved the game, else null), `line` on a script.reload's `last_change`, and `tag`, the editor's own name for a hand's task (`session.hello {tag}`, `frost mcp --join --tag` or `FROST_HAND_TAG`). A joined `frost mcp` that sees its session end exits with status 2, as every error of `frost` does. Nothing else changed. - **`frost test --says PART[@STEP]... [--against REV] [--json]`** holds a change to what it said: the game on disk may differ from the game at REV (HEAD) only in the parts said, as `world.checksum` names them, each from its step on, and a changed shot only where a said part differs. Without a repository, a change or a `replay` it says so (`E0523`). Nothing else changed. - **An agent can act on the game the editor shows**: `frost mcp --join 127.0.0.1:PORT --token-file PATH [--who NAME]` serves the same MCP tools for a session that runs already (`frost serve --port 0 --stdio`, `frost dev`) in place of a game of its own. It says `E0521` when it cannot join and `E0522`, and exits, when the session ends. - **A connection says who it is, and blame names it**: `session.hello {who, kind, model?}` makes the connection a hand (an MCP client's `initialize` does it by itself), and `session.hands` lists them with what each last did and who moved the game's step last (`clock`). Blame answers a client writer with `hand`, `who` and `agent` beside `trust`: hand 0, "a client", for a connection that never said. No checksum moves. - **`[export] credits = "full"` ships the source notes with the game**: each `.from.toml` note and `.terms.txt` file goes beside its file under `game/`, as well as `credits.txt`. Left out, or `"file"`, only `credits.txt` is written, as before. They are no part of what the web page downloads. `[export]` is a new table of the project file; any other value of `credits` is `E0408`, with its line. - **Source notes: `assets.from`, `assets.sources`, `credits.txt` and `W1410`.** A file of the game can have a note beside it, `NAME.EXT.from.toml`, saying which service made it, with which words and under which licence, and the service's terms as `NAME.EXT.terms.txt`; the editor writes them, the engine only reads them. `assets.from {path}` answers the note, the file's SHA-256 (`sha256:…`) and `changed` when the file is no longer what the note's `came` recorded; `assets.sources` lists every file the game loads and the `unlicensed` ones. `frost export` writes `credits.txt` beside the game when any file has a note, and warns `W1410` (new) of a file a service made or a person brought with neither a licence named nor terms saved, as `frost check` and `game.check` do; they also warn `W1411` (new) of a note whose file is gone. The notes are not copied into the exported game. Nothing changed for a game with no notes. - **`frost check --costs` and `frost export` say what a game's files cost a download**: the bytes as exported and with gzip, by kind (pictures, sounds, fonts, scripts, scenes), the five largest, and where a saving is known, one line: a picture `frost` would write smaller with the same pixels (exact), or a WAV sound of ten seconds or more as Ogg Vorbis for `music.play` (an estimate, with the web player's decoder counted). Nothing is re-encoded. `frost check --costs --json` adds the object as `costs` to the line it prints: `{bytes, gzip, kinds, files, largest}`. Nothing else changed. - **Pictures `frost` writes are smaller, with the same pixels.** A frame of at most 256 colours (`frost run --shot` and `--frames`, `frost check --shots --write-shots`, `frame.capture`) is written as a palette PNG (colour type 3, with `tRNS` when a colour is see-through) instead of eight bits a channel: the test games' 61 shots went from 648,555 bytes to 466,920, and those kept in the examples' `shots` folders were written again from their own pixels. A frame of more colours is the same file as before. A tool that reads these files with a PNG library that does not expand palettes must ask it to (the `png` crate: `Transformations::EXPAND | Transformations::ALPHA`); browsers, image viewers and `frost check --shots` read both. - **`profile.steps {totals: true}` adds up a stretch of the game**: every span of the steps whose spans are kept, each place in the tree once, ms and count summed, with the first and last step added and how many. Nothing else changed. - **`profile.steps` says where a step's time went, down to the line of a script**: each span of a step's record has `parent`, the index of the span it ran inside, and `at`, where in a script it is. Inside `script NAME` are its `step()` and `on_scene()`, and inside those each engine call they made whose cost depends on the world (`find`, `each`, `spawn`, `despawn`, `events`, `tween`, `library`, `physics.ray`, `physics.cast`, `physics.overlap` and `save`'s), added together per line that called it. `profile.frame` and `profile.frames` add the places of one name together, so they list `step()` and those calls by name too. Timing a call costs a tool about 55 ns (a game made to call `tween` 2,000 times a step steps about 5 % slower under `frost dev`, `frost serve`, `frost run` and `frost bench`); an exported game times nothing. No checksum changed. - **`game.restore` says what it does not undo**: `edits_after`, the steps of a client's changes made after the snapshot (a write to the world, `scene.load`, `saves.set`, `debug.evaluate`), which playing on with the same input does not make again, and `code_changed`, the scripts reloaded since, which run as they are now. `input.history` lists the changes on the game's line of time as `edits`. Nothing a game does changed. - **`world.series` reads a field's value over a stretch of the recording**: `{entity, component, field, from?, to?, buckets?}` answers `values`, one `{step, value}` a step (at most 3,600), or with `buckets: N` the `{from, to, min, max, last}` of N stretches, and `played_from`. It plays the stretch again aside and changes nothing of the game. - **`game.seek` goes back by keyframes.** A seek to a step behind the game used to load the files and play from step 0; it now puts back a moment the session kept on an earlier seek (one every 300 steps) and plays on from there, where that makes the same game, and loads as before where it might not (a changed file, a `script.reload`, `tuning.set` or `blame.on` since the load, a debugger attached). What a client sees differently: the session's snapshots survive such a seek (a load forgot them), `events.since` starts at the keyframe and not at step 0 (`from` says where), and a game that keeps state in a script's `local` gets warning `W0445` once and is loaded as before. `game.seek` answers `keyframes`: `{every, kept, bytes, most_bytes}`. - **`frost play DIR` plays a folder `frost export web` wrote**: it serves the folder as it is on 127.0.0.1 and prints `serving http://127.0.0.1:PORT/`, with the media types and refusals of `frost dev --web`, and no protocol, no reload and nothing written. A folder without the page, both players and `game/` is refused (`E0520`, new). Nothing else changed. - **`frost new --list` names the templates for a program**: one a line, the name, a tab and the `about` line of its `template.toml`, in the order of their names. A downloaded `frost` with no templates beside it says where they belong in one sentence (`E0519`, where it said `E0515` with "no templates were found", and no longer looks in a `templates` folder of the current folder), and `--list` then prints nothing and exits with status 2. `frost new --help` says the same. - **`frame.capture` says which part of the world its picture shows**: `view`, `{left, bottom, right, top}` in world units, as `frame.view` gives it. Nothing else changed. - **`world.insert` and `world.remove` put a component on an entity of the running game and take one off, and the entity keeps its id**: what an editor's "Add a part" and "Remove" send. An insert is held to what `world.spawn` is held to. A remove takes the tweens of the component's fields with it, and is refused with the code that says why when something else needs the component: a joint that holds the entity by its `Collider` (`E1111`), a `TileCollider` beside its `Tilemap` (`E1107`), a node in it (`E1301`). A script then sees the entity as any that lacks the component: `has` is false and `get` of it stops the step with `E0003`. Neither writes a file. - **Each of the engine's components says what it is, in a sentence**: `world.components` gives it as the component's `about`, where it was null, and `frost reference --types` as the comment above its type. It is a row of its own above the component's fields in each crate's reference table, with the field cell empty, as `Screen`'s was; the page `frost reference` prints leaves those rows off, but for `Screen`'s, to stay within its budget. Nothing a game does changed. - **A `Tween` that would stop every step is refused before the first**: one whose `component` or `field` is empty (`E1004`, new), whose field holds no number (`E1003`) or whose easing is not one (`E1002`). A scene file with one fails to load and `frost check` says which, and `world.spawn` makes no entity; before, the game loaded and stopped at a step. A tween a script makes with `tween()` is as it was. - **`profile.steps` keeps an hour of step times, and a replay hides nothing played.** Each step is kept by its number: where its time went for the last minute, its time for the last hour (an older step is told with `spans: null`). A step the engine plays again to reach another (`game.seek`, `blame.on`) no longer writes over the same step as it was played, though it gives an older step's spans back, and a `game.try` from a kept moment keeps nothing. `steps` rows say `replayed`, a list is of the last minute unless `from` says otherwise, a `to` past the game's step tells the steps still kept there, and `kept` is now a record of what is held (`{spans, steps, bytes, bytes_per_span, bytes_per_hour}`), where it was a number. `buckets: N` cuts a range of any length into N stretches with the slowest step of each. - **A turned thing's hit has its outline, and `frame.view` says what the frame shows.** A hit of `frame.at`, `frame.in` and `blame.pixel` has `turned` beside `box`: `{x, y, w, h, angle}`, the box along the thing's own sides in the frame's pixels and its turn in degrees, or null for what is not turned. `frame.view` answers the frame's size and the part of the world it shows, `{left, bottom, right, top}` in world units, as the camera looks. Nothing else changed. --- Page: changelog/6.md # Changelog, part 6 Part 6 of 7: [newer](5.md) · [older](7.md). - **`Mover.step` is new**: the highest ledge a mover walks up onto, 0 when left out, so a game that does not write it plays as before; the checksum of a game with a mover moves once, the field being new in each. The numbers on softness and swing moved from the scripting reference to `docs/physics.md`. - **`Collider.surface` is new**: a belt's speed. A game that does not write it plays as before; the checksum of a game with colliders moves once, the field being new in each. - **A game has the physics' components only when it has the physics, and `Font` only with a `[fonts]` table or a `Font` in a scene.** A game has the physics when its project file has a `[physics]` table or one of its scenes gives an entity a `Body`, `Collider`, `TileCollider`, `Mover` or `Joint`. Scripts are not read to decide it: **a game whose scripts make colliders in scenes that have none must add `[physics]`** (an empty table will do) to `game.toml`; without it the script's first use stops with the unknown-component error, which says so. No recorded game's checksum moves and none of the test games or templates needed the table. `world.components` lists fewer for a game without them, and a client naming one there is refused (E0415) with the same advice. `frost export` links the physics by the same rule. - **A field can say that its text names an entity, and `frost check` warns when it names none (`W0436`).** A game marks its own in the project file as `{ entity = "" }`; the engine's are marked: `Node.parent`, `Node.up`, `Node.down`, `Node.left`, `Node.right`, `Slider.fill`, `Slider.label`, `Choice.label`, `Toggle.mark`, `Bar.fill`, `Joint.from` and `Joint.to`. `world.components` reports `"role": "entity"` for such a field. The warning is new for games that already had a focus neighbour that is not there, or, in a scene the game does not start in, a parent, a part or a joined body that is not there. It reads the scene as its files say: an entity a script spawns later is not seen. No value and no checksum changed. - **`profile.steps` says what each step took**: the time of each of the last 3,600 steps, and the slowest of a range with where their time went (each stage, each script, the picture drawn of the step). It is kept in `frost dev`, `frost serve` and `frost mcp` whether or not anybody asks, at about a tenth of a microsecond a step; an exported game keeps nothing. No checksum and no frame changes. - **A hit of `frame.at`, `frame.in` and `blame.pixel` has its `box`**: `{x, y, w, h}` in the frame's pixels, around everything the entity draws with that component, so a tool can outline a sprite drawn at its picture's own size. Nothing else changed. - **A failing shot in `frost test` says where the game changed.** When the run holds and a picture does not, and the folder has changes git has not committed, the line leads with the first step and value that differ from the committed game, as a failed checksum does; when the world is the same at every step it says so and names the files that changed. - **`frost check` warns of a script variable a snapshot does not hold (`W0309`)**: a `local` declared outside a script's or a library's functions that a function writes, or writes a field of, with the line of the first write. Such a game goes wrong after `game.restore` and `game.try`, which `frost test --restore` finds by running it; move the variable into `state`. The game loads and runs as before. The platformer and the brick breaker templates kept their tilemap that way; they now read it once a step into `state.land` and take it out when the step ends, on the same checksums. - **A failing `frost test` says the step, the value and the line.** When the game's folder is in a git repository and has changes that are not committed, the failure is: "FAILED: at step 131 ball.Transform.x is 131.5 and was 131.0; last written by script go.luau:5 in step. That is the first step that differs from the game as committed (git HEAD a1b2c3d)." The two checksums are not printed then. The committed files are played in memory beside those on disk; nothing is stored, and a game that passes is not played twice. Without git, or with nothing changed since the commit, the message is the one it was. - **`frost test` fails a game that cannot be put back to a snapshot.** It plays one stretch of the recording twice (from the checkpoint nearest the middle to the next, put back from a snapshot in between) and both times have to come to the same worlds. A game that kept part of what it is in a script's own variable (a `local` outside its functions) passed before and fails now, with the step and what to do: move it into `state`. `frost test --restore` does the same at every checkpoint. - **`frame.at` and `frame.in` say what is drawn at a pixel and inside a box of the frame**, the one in front first, with no blame on and no picture taken: what an editor asks to pick the thing under the pointer. `blame.pixel` answers the same hits with who made and placed each, so its hits have four fields more (`tile`, `node`, `coverage`, `fills`); nothing it answered is gone. - **A node with a `Text` and no `w` or `h` has the size of its words**, where before it was a point. One anchored by its middle is where it was; one anchored by an edge (`Anchor = { y = 1, dy = -14 }`) now has that edge of its words there, not their middle: move `dx` and `dy` by half the text's size. In a stack it takes its room, and a press on it is the interface's (`Node = { pointer = false }` lets it through). - **A `Stack` or `Grid` with no `w` or `h` is as big as what is shown in it**: before, it was a point and its nodes hung from that. Write the size for the old layout. - **`Anchor.stretch_x` and `stretch_y` are read in a stack and a grid**: a node stretched across its stack fills it, those stretched along it share what is left, and one in a grid fills its cell. Before, both were ignored there. - **A fill node with an `Anchor.dx` keeps that much clear at both ends** of its slider or bar: before, only at its left, and a full bar ran past the right end by `dx`. - **A tween of the `Transform` of a node the interface places is an error** (`E1306`): before, it did nothing. Tween `Anchor.dx` or `dy`, `Scale` or `Opacity`. - **The pointer uses a button, a choice or a toggle when it lets go on it**, not when it presses: sliding off first cancels. A recording made with the pointer sends its events as many steps later as the press was held, and one that pressed here and let go there no longer uses anything. Keys and a gamepad are as they were. - **The focus is remembered.** A screen that is hidden and shown again has the focus where it was left, and when a modal node closes the focus is back on the node that had it; before, both went to `[ui] start`. A modal node still opens on `start`. For the old behaviour call `ui.focus(find("play"))` when showing the screen. - **A direction no longer jumps to a far node.** The focus goes only to a node that is level with the one it is on, or no further to the side than ahead; with none it stays, unless it is in a stack that runs that way, which still goes round. In a `Grid` it keeps to the row or the column. Where a menu relied on a far jump, name the neighbour: `Node = { down = "back" }`. - **A menu a script shows is laid out and has its focus in that same step**, not the next: the interface runs again at the end of every step. `ui.tree` never reports `focus: null` for a menu that is up, and every recorded game with a menu that opens has a new checksum. `Node` has five new fields (`locked`, `up`, `down`, `left`, `right`), so every game with a node has one too. - **`frost test --restore` finds a game that cannot be put back to a snapshot.** It plays the recording and, at each checkpoint, takes a snapshot, plays on, puts it back and plays the same steps again; a game that goes another way the second time keeps something in a script's own variable (a `local` outside its functions), which a snapshot does not hold, and the line says to move it into `state`. Nothing changes for a game that never asks for `game.restore` or `game.try`. - **`frost test --write` writes which engine wrote a `replay`** (`engine = "0.0.1 r27"`: the version, and the revision, which is how many entries this file has), also into a replay that still holds and names an older engine or none. `frost test` says, when a checksum no longer holds, whether the engine is the one that wrote it, and `frost changes 27` prints the entries added since revision 27. `frost --version` prints the revision after the version (`frost 0.0.1 r27 (commit 0123456789ab, source N)`). A project file with no `engine` is read as before. - **`blame.on` no longer plays the game again while snapshots are kept**, since that would forget them: its answer then has `whole: false` and `since` the step it was turned on at. `game.forget` first, for an answer that is whole. - **`tuning` is a name scripts are given**: the numbers of the project file's new `[tuning]` table, read as `tuning.jump`. A script that kept a global of its own called `tuning` still reads its own; one that only looked whether `tuning` was there now finds it. `local tuning = ...` is untouched. - **`game.step` answers `reached`, and `game.info` answers `scene`.** Two more fields in two protocol answers; a client that refuses fields it does not know must learn them. Nothing changes in a game. - **`frost export` from a checkout keeps the players it has built**, by their parts: two games that use different parts of the engine, exported in turn, no longer compile it each time. The eight sets used last are kept for each kind of player, about 10 MB a set for all three, under `target/players/kept/`. Its first line says `is kept from an earlier build` where it said `is built already`. - **A `frost` with a `players` folder beside it exports without building.** `frost export` copies the players that came with it (every part of the engine in each) and needs no checkout, no Rust and no Emscripten SDK; `--slim` builds a player with only what the game uses, as before. Players of another source than `frost` are refused (`E0517`), and one that lacks a part the game uses is `E0518`. A `frost` built by `cargo` has no such folder and exports as it did. `frost --version` also prints the commit and the source number. `frost new` reads its templates from a `templates` folder beside `frost` in the same way, and from the checkout when there is none. - **`frost check` warns of a game's name written only under `[web]`, or twice (`W0439`).** `title` at the top of the project file names the window, the exported program, the browser tab and now the loader too; the `[web]` one is only needed for a page named otherwise. The game loads and plays as before. - **A save keeps a table with gaps, or with numbers beside names**, as it is (`{ [3] = 41.5 }` is written `3 = 41.5`); such a table was refused. A list at the top of a slot is kept too. An error of `save.set` names the slot and the lines that called. `frost serve` and `frost mcp` take `--saves DIR`. A save that could not be read or written is a warning in `log.since`, and a browser that gives a page no storage has the player say that saves last for the visit only. - **A save that cannot be written is told of once** (`E0604`), not once a write: a game that saves in every step no longer fills the log when a disk or a browser refuses. The next failure is told of after a write has worked again. - **The Cinder template remembers its best time** in the slot `best` and shows it on the title and the end screen. A game started from the old template is not changed. - **`save` is a name the engine gives scripts**: `save.get`, `save.set`, `save.delete` and `save.slots` keep tables between runs. A script that had a global of its own called `save` now writes over the engine's; give it another name. `id` at the top of a project file and `saves` under `[input]` are new keys, and the text `input.history` returns starts with a `saves` line when the session started from saves. - **`frost serve --port N --stdio` serves standard streams and the port at once**, so a program that runs the engine on its streams can let a debugger join the same game; the address is printed on standard error. `game.info` answers one field more, `stopped`: null, or where a debugger holds a script. `game.step` answers the same field, so a client knows why fewer steps ran than it asked for. A debugger's values say which entity a number is the handle of (`entity`, `entity_name`), and its answers carry a `note` while scripts have no local names; `debug.evaluate` on such scripts fails with `E0444`, which says why, where it failed with `E0302`. - **A script can be debugged from an editor**: `frost dap` is a debug adapter (the Debug Adapter Protocol on standard streams) for any editor with a DAP client: breakpoints in the game's .luau files, steps, the stack, locals, tables, a console, and what the scripts print. It starts the game with or without a window, or joins a running `frost dev` (`frost dap --help`). - **A script can be debugged over the protocol**: the `debug.` commands of `frost dev`, `frost serve` and `frost mcp` set breakpoints, stop a script part way through a step, step it, and show its stack, its locals and what a line of Luau gives there (`frost protocol debug.attach`; the engine's `debug` example is a game to try it on). An exported game has no debugger. Nothing changes for a game nobody debugs: a debugger that is attached and stops nothing leaves every checksum and frame as it was. `log.since` reads what scripts printed and the game's warnings, each `print` with its file and line, for a client that does not read standard error. `script.reload` answers one field more, `queued`, which is false unless a debugger holds a script stopped. - **`frost export` refuses a checkout that is not the source `frost` was built from** (`E0517`, naming the commit of each): the player it would build is another engine than the one `frost run` and `frost test` are, and could come to another checksum. Build `frost` again, or pass `--any-engine` to export all the same. A project may give its name as `title = "..."`: the window, the browser tab and the exported program are named by it (before: by the folder, which is still what a project without one gets). A project with `libraries` and no `scripts` exports a player that can load it. - **`frost test` warns of a recorded game whose sound goes over full scale (`W0438`).** It is cut off there, which crackles. The game passes as before; play fewer sounds at once or turn them down. `frost run --wav` warns the same and prints the run's `peak`. - **A played sound says where it is heard from.** `audio.requests` and a session's record give each `play` a `pan` (0 is the middle, which every sound was), and `frost run --sounds` ends a line with it when it is not 0. Nothing to write. - **At most 4 of one sound are heard at once, and 32 in all.** One more takes the place of the quietest of them (the oldest of those as quiet), which is eased out; past 32 it was the new sound that was dropped. A pile of one sound in one step is quieter than it was and no longer sums past full scale. Nothing to write. - **`frost check` warns of a sound over three minutes in a project with a `[web]` table (`W0437`).** A browser holds it decoded, 21 MB a minute of stereo. The game loads and plays as before. - **In a browser, held music is stopped and started again where it stood.** It was played at no speed, which not every browser does alike. Like a desktop, the page now eases a hold, a let-go, a replaced track and `sound.volume` over a few milliseconds where it cut them. Nothing to write. - **`music.stop(seconds)` fades the music out and then stops it.** `music.stop()` stops at once, as before. A tool that reads requests sees the time on every stop: `frost run --sounds` prints `stop 0` where it printed `stop`, and `audio.requests` and a session record give a stop its `seconds`. - **A sound never moves a checksum, with one exception.** Playing, stopping, fading and panning are output only and are no part of the world. `vary` on `sound.play` is the exception: it draws the pitch from the game's random source, so adding or removing it changes what `math.random` gives afterwards, and the checksum with it. - **`frost run` prints two checksums, named apart**: `world checksum:` (the world after the last step; the line was `checksum:`) and `run checksum:` (every world from the start, the number a project's `replay` holds). A tool that read the `checksum:` line reads `world checksum:` now. `frost test` says which of the two a line is about. The protocol's `checksum` field is unchanged: it is the world's. - **`frost check` and `game.check` call `on_scene` for the scene a game starts in**, in a game of their own that is thrown away, and report a failure as an error with its line: a game that cannot start no longer checks as "no problems". A check still runs no step. An `on_scene` that is slow or prints is now slow and prints in a check. - **`frost test FOLDER` tests every project file with a `replay`**, not only those named `game.toml`: a second recording of a game kept beside it (`game-pad.toml`) is found. `frost reference --types GAME.toml` no longer needs the scripts to load, and `frost changes` prints this file. - **A bare scene names its pictures from its own folder**, not from the folder `frost` was started in, and a `Font` that asks for a text style the game does not have is found by `frost check` and as the game loads (`E0429`), not at the first step. A scene that was run from its own folder is unchanged. - **An exported game with scripts always has animation.** Before, `frost export` looked for the text `tween(` in the scripts, and a tween started under another name or from a library the search missed failed in the exported game only. `frost export desktop` lists a font file two styles share once. - **`on_scene` is called for the scene a game starts in**, as the game is loaded and before its first step (since the change "Small fixes from the second outside game, first part"). A script written before that, which fills `state` in a first-step branch of `step` and reads it in `on_scene`, stops at load with `E0302`. Fill `state` at the top of the script or in `on_scene` itself. Games made from the platformer, arena or breaker template before then are of this kind. - **The interface no longer writes `Opacity`.** What hides a node, and what a panel's `Opacity` and `Scale` do to the nodes in it, is written to a component of its own, `Inherit`, which the renderer multiplies in. A node needs no `Opacity = {}` to be hidden (`E1303` is retired; the lines can go), a node that was hidden in the scene with an `alpha` of its own comes back at that alpha and not at 1, and a panel that fades or grows takes its children with it. A script that read `Opacity.alpha` to learn whether a node is hidden reads `Node.shown`. Every recorded game that hides a node has a new checksum. - **An empty `Bar` or `Slider` hides its `fill` node** (`Node.shown`): before, the fill kept its last width. **A stick pushed both ways moves the focus or the slider, the way it is pushed further**: before, left and right always won. **The theme's `pressed` colour no longer stays on a button** whose use opened a modal node. - **The Ballast template has a pause menu** (Escape, P or Start): Resume, Restart room, Quit to title, made of `frost_ui` nodes in `common.toml` and held still by `physics.pause`. Its title has a band behind the name and its end screen three lines. A game started from the old template is not changed. --- Page: changelog/7.md # Changelog, part 7 Part 7 of 7: [newer](6.md). - **`has(entity, "Component")` says whether an entity has a component**, and false for an entity that is gone, so a script need not keep its own sets to avoid `E0003`. The protocol has `world.spawn` and `world.despawn` for the running game (no file is written), and `game.info` reports the `[window]` `background` and `filter`. Nothing changes for a game or a client that uses none of them. - **A polygon that is not convex is an error (`E1103`).** Before, its convex hull was used without a word. Write the hull's corners to get the old shape, or make the dent from convex pieces. A joint between two colliders with no moving body is still made, and warned of (`W1114`) by `frost check`, `frost run` and `game.status`. - **`frost run` and `frost test` print what only running the game finds**: `W1112`, a joint removed because one end was despawned. `frost run` prints it on standard error after the checksum, `frost test` under the game's line; neither fails for it. - **`substeps` above 4 stiffens contacts and joints.** Before, 8 and 16 gave what 4 gives. A game at the default 4, or fewer, is unchanged; one that set more runs differently (stiffer), and has no setting to go back but `substeps = 4`. - **`Mover.crushed` is true in every step of a crush**, with or without a script: from the first squeeze until the kinematic body is out of the mover. Before, it was true for a step or two and false while the body went on through. A script that counted the steps it read true counts more. - **`physics.pause(true)` holds the simulation** while scripts and the interface run; `physics.read` says `paused`. Nothing changes for a game that does not call it. - **A wheel with `spring = 0` is on a rigid axle**, as the reference said. Before, the axle slid freely along its line and the body sank onto its wheels. For an axle that slides freely between two ends: `limit = true` with `min` and `max`. - **A sensor no longer reports static colliders.** A `Collider` with `sensor = true` sent `sensor_enter` for the floor or the tilemap it rests on, in its first step. Now only dynamic and kinematic bodies and movers are reported. For the old behaviour: `senses = "all"` on that collider. Every `Collider` has the new field, so every recorded game with a collider has a new checksum. - **`physics.ray`, `physics.cast` and `physics.overlap` take an entity to ignore** after the mask. Nothing changes for a call that does not give one. - **A mover has weight.** `Mover.mass` is 1 by default: standing on a dynamic body it presses on it as a body of its size and a density of 1 would, so a seesaw tips and a rope bridge sags under the character. For the old behaviour: `mass = 0`. - **A dynamic body that moves carries the mover on it**, as a kinematic one does: a character on a rolling cart goes with the cart. There is no switch for it. - **A body rests on a mover's head.** A dynamic body that lands on a mover which cannot give way (it stands on something, or has a wall behind it) is stopped by the mover and lies on it; before, it pushed the mover into the floor. A mover is never taken through a static collider. `Mover.crushed` no longer comes from dynamic bodies. - **A standing mover's feet are exactly on its ground.** It used to rest up to a third of a unit inside or above it. A character is drawn that much higher or lower, and meets a ramp or a crate a fraction of a unit differently. - **A mover is carried from the step it lands in**, and round with a kinematic body that turns, not only along with one that slides. - **`frost new` leaves tool leftovers behind**: names that start with a dot, `__pycache__`, `stills`, `Thumbs.db`, and files ending in `.pyc`, `.pyo`, `~`, `.swp`, `.tmp` or `.orig` are not copied out of a template. --- Page: credits.md # Credits The pictures and the reel on this site show Caravan, which uses the third-party work below, each under its licence and with the changes listed. The site itself shows no other third-party work. ## Creative Commons Attribution 4.0 Credit is required. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). | Title | Author | Source | Changes made | | --- | --- | --- | --- | | Camel | E.A.Cornell (eb78) | [sketchfab.com](https://sketchfab.com/3d-models/camel-99af7daa5baf450ea7b809937937e6d5) | Hair material changed from blended to cut-out; shown 1.45 times its size | | Magic Wolf | liiceduarte | [sketchfab.com](https://sketchfab.com/3d-models/2b183ca4a3984c1385856ca864c7508c) | Its fur repainted ash (the wolf) and rust (the jackal), its markings enemy red; shown at 0.0042 of its size as a steppe wolf and 0.0032 as a jackal | | Scorpion | anthonyvanoo | [sketchfab.com](https://sketchfab.com/3d-models/scorpion-4c0fd62d33ab4d2592ee0a1d985a480d) | Its walk re-authored so the feet stay planted and a cycle carries 0.65 m; other clips, rig and mesh unchanged; shown at 0.62 of its size | | Horse | Henry S (henry_7) | [sketchfab.com](https://sketchfab.com/3d-models/a6f860e43e364619bccb174a1ac7d0c9) | Pictures made 512 across, five of its clips kept, coat graded to a wild dun; shown at 0.1 of its size | | Drugdör The Golem Animated | Phons | [sketchfab.com](https://sketchfab.com/3d-models/19c1855bdb2c4cdc89da2cfb64da48cf) | Stone greyed and warmed to sandstone; shown at 0.28 of its size; called the Pass-Keeper | | Desert City (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100564) | Cut to a loop (0 s to 78 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Tabuk (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100818) | Cut to a loop (0 s to 77 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Mystery Bazaar (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1700005) | Cut to a loop (0 s to 77 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Ibn Al-Noor (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100706) | Cut to a loop (0 s to 90 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Return of the Mummy (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1700046) | Cut to a loop (24 s to 106 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | East of Tunesia (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100246) | Cut to a loop (0 s to 91 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Drums of the Deep (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1400021) | Cut to a loop (0 s to 83 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Stoneworld Battle (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100352) | Cut to two loops (70 s to 122 s and 175 s to 214 s of the piece), each with a cross-fade at its join; levelled; Ogg Vorbis | | Curse of the Scarab (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1600014) | Cut to a loop (162 s to 243 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Tempting Secrets (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1300038) | Its opening blow (the first 10 s) as a sound, and a loop (62 s to 158 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | | Lost Time (music) | Kevin MacLeod (incompetech.com) | [incompetech.com](https://incompetech.com/music/royalty-free/index.html?isrc=USUAN1500032) | Cut to a loop (1 s to 70 s of the piece) with a cross-fade at its join; levelled; Ogg Vorbis | ## CC0 and public domain No credit is required; these are thanked. Licence: [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). | Title | Author | Source | | --- | --- | --- | | KayKit Adventurers Character Pack 1.0 | Kay Lousberg (www.kaylousberg.com) | [github.com](https://github.com/KayKit-Game-Assets/KayKit-Character-Pack-Adventures-1.0) | | KayKit Character Pack: Skeletons 1.0 | Kay Lousberg (www.kaylousberg.com) | [github.com](https://github.com/KayKit-Game-Assets/KayKit-Character-Pack-Skeletons-1.0) | | Universal Base Characters, Modular Character Outfits - Fantasy, Universal Animation Library 1 and 2 (the guards, raiders and risen dead) | Quaternius (quaternius.com) | [quaternius.itch.io](https://quaternius.itch.io) | | Rocks, plants, props and ground textures | Poly Haven and its authors | [polyhaven.com](https://polyhaven.com) | | Swishes Sound Pack | artisticdude | [opengameart.org](https://opengameart.org/content/swishes-sound-pack) | | RPG Sound Pack | artisticdude | [opengameart.org](https://opengameart.org/content/rpg-sound-pack) | | Fantasy Sound Effects (Tinysized SFX) | Vehicle (Jan Schupke) | [opengameart.org](https://opengameart.org/content/fantasy-sound-effects-tinysized-sfx) | | 150 Combat Sound Effects (sounds by Kenney and lentikula inside it) | untamedpixels | [opengameart.org](https://opengameart.org/content/150-combat-sound-effects) | | 50 RPG sound effects | Kenney (www.kenney.nl) | [opengameart.org](https://opengameart.org/content/50-rpg-sound-effects) | | 80 CC0 RPG SFX | rubberduck | [opengameart.org](https://opengameart.org/content/80-cc0-rpg-sfx) | | Fantozzi's Footsteps (Grass/Sand & Stone) | Fantozzi, cut by qubodup | [opengameart.org](https://opengameart.org/content/fantozzis-footsteps-grasssand-stone) | | Dog Snarl Grunt Grumble | qubodup | [opengameart.org](https://opengameart.org/content/dog-snarl-grunt-grumble) | | Wolf Monster Sound | CaveboyTup | [opengameart.org](https://opengameart.org/content/wolf-monster-sound) | | grunts of male death and pain | thebardofblasphemy | [opengameart.org](https://opengameart.org/content/grunts-male-death-and-pain) | | Camel Groan | AntumDeluge, from a recording by craigsmith | [opengameart.org](https://opengameart.org/content/camel-groan) | | Hurt Sound Effects | EZduzziteh | [opengameart.org](https://opengameart.org/content/hurt-sound-effects) | | wind1 | Luke.RUSTLTD | [opengameart.org](https://opengameart.org/content/wind1) | | Desert theme (music: the last light) | yd | [opengameart.org](https://opengameart.org/content/desert-theme) | ## SIL Open Font License 1.1 The letters of Caravan's interface. Licence: [SIL OFL 1.1](https://openfontlicense.org/). | Title | Author | Source | | --- | --- | --- | | Marcellus | Brian J. Bonislawsky, Astigmatic | [github.com](https://github.com/google/fonts/tree/main/ofl/marcellus) | | Alegreya Sans, Medium and Bold | Juan Pablo del Peral, Huerta Tipografica | [github.com](https://github.com/google/fonts/tree/main/ofl/alegreyasans) | The engine's own templates, Scrap Riot and Held Note use art made for them. --- Page: agents/index.md # For AI agents: start here > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. This page is for an AI agent making or changing a Coldwave game, and for the person setting one up. Everything an agent needs is offline, in `frost`, and every page of this site is also Markdown at its own address with `.md` (this page: `agents/index.md`). [llms.txt](../llms.txt) lists every page; [llms-full.txt](../llms-full.txt) is all of them in one file. If you are a person: [Claude Code and Codex](harnesses.md) shows how to point your agent at a game. The rest of this page is written to the agent. ## Read in this order 1. **The core**: `frost reference` (or [reference/core](../reference/core.md)). About 2,600 tokens: project shape, the everyday calls, the rules that save a run, and the page index. Read it once per session. 2. **One page when the task needs it**: `frost reference 3d`, `frost reference physics`, ... Each page is held under 7,000 tokens. [The index](../reference/index.md) says what each is for. 3. **One call or field**: `frost reference sound.play`, `frost reference --search point light`. 4. **One protocol command**: `frost protocol frame.at`, or `reference.read {name: "protocol.frame.at"}` over MCP. 5. **A recipe** below, for a whole task with its checks. Inside a game made by `frost new`, the same pages are installed as skills (`.claude/skills/ven-*/SKILL.md`), with an `AGENTS.md` and an `.mcp.json` that serves `frost mcp game.toml`. `frost skills --here` installs or updates them in any game. See [Claude Code and Codex](harnesses.md). ## The loop Every change, however small: ```sh frost check game.toml # loads? FILE:LINE: CODE: fix frost run --headless --steps 600 --shot shot.png game.toml # look at the picture frost test game.toml # the recorded run still holds ``` A successful load is not a working game: play it and look at a shot. When a change is meant to alter the run, accept it with `frost test --write` only after looking, and never write over a kept shot picture without its owner's approval. ## Recipes Each is a task with the exact commands, a sample project that is tested with every build of these docs, and the checks that prove it worked. | Recipe | Task | | --- | --- | | [Third-person 3D game](recipes/third-person.md) | A hero to walk with the camera behind it, under a sky with shadows | | [Profile a frame](recipes/profile-a-frame.md) | Find what a slow step spends its time on, and prove a fix | | [Debug a script](recipes/debug-a-script.md) | Stop at a line, read values, find who wrote a field | | [Prove a change](recipes/prove-a-change.md) | Prove a behaviour change when the recorded run no longer holds | | [Stream a world](recipes/streaming.md) | Cut a big world into cells that enter near the player and leave behind | | [Export](recipes/export.md) | Export to the web, desktop, iPhone and Android, and prove it is the same game | | [C# or Luau?](recipes/csharp-or-luau.md) | Choose the language for a game's scripts | ## Rules that hold everywhere - Gameplay state lives in components or `state`, never in a script's outer `local`. - Read input by action (`input.get(0, "move")`), never by device. - Random is seeded `math.random`; use `math.pow` for a power other than a written 2, 3 or 0.5. - Never hand-write what the engine generates. Fetch a declaration before using it: its required fields, trust and limits are there. - Errors have stable codes: the [error index](../reference/errors.md) links each to where it is explained. --- Page: agents/harnesses.md # Using frost with Claude Code or Codex > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. Every game `frost new` makes is ready for an AI coding agent: it comes with the reference as skills, an `AGENTS.md`, and a server the agent uses to play and inspect your game. This page shows how to connect Claude Code or Codex. Put `frost` on your PATH, then start from a working game: ```sh frost new my-game --template pong cd my-game ``` The game includes `.claude/skills/ven-core/SKILL.md` and a skill for each reference page. Claude Code discovers their short descriptions and reads a skill when the task needs it. Start with `ven-core`; examples for larger pages live in the linked `examples.md` beside the skill. The agent does not need the engine's source. `.mcp.json` registers `frost mcp game.toml` as a stdio server named `frost`. Start Claude Code in this folder and enable the project server when the harness asks. It loads a separate game session: `game_step` advances live input, `game_seek` plays a recording, and `frame_capture` shows the result. To share an editor's already-running game, configure the server to use `frost mcp --join-file PATH` with the editor's join file. Codex reads the short `AGENTS.md`, which points to the same skills and commands. To add the MCP server to Codex, run this from the game's folder: ```sh codex mcp add frost -- frost mcp game.toml ``` Launch Codex in this game's folder when using that registration; `game.toml` is relative to the server's working directory. Codex can read the installed skill files directly. To install the skills in its discovery folder, use `frost skills --out .agents/skills`. This does not register an MCP server. For an existing game, or after upgrading `frost`, run `frost skills --here` beside `game.toml`. It installs or updates the skills, `.mcp.json` and `AGENTS.md` and says which files it wrote, updated, left unchanged or kept because they were edited. Keep `.ven-skills.json`: it records exactly what `frost` wrote last time. Edited files, existing files of unknown origin, and deliberate deletions are preserved. If a configuration file is kept, add the server to it yourself after reviewing it. `frost skills --out DIR` writes only skills and their update record; plain `frost skills` uses `.claude/skills`. Ask for a concrete change: “make the player jump” or “play a sound on hit”. An agent can find a page with `reference_search {words: "point light"}`, fetch it with `reference_read {name: "3d"}`, or fetch just `sound.play`. In a shell, the same text is `frost reference --search point light` and `frost reference sound.play`. A tool's full contract is `reference_read {name: "protocol.frame.at"}`. Tool names replace dots with underscores; reference names keep the dots. After edits, run `frost check game.toml` and `frost test game.toml`. Play the new behaviour and inspect a shot with `frost run --headless --steps 600 --shot shot.png game.toml`. --- Page: agents/recipes/third-person.md # Recipe: a third-person 3D game Goal: a hero the player turns and walks, the camera behind it, on a floor with things to walk round, under a sky with shadows. Two ways: start from the finished template, or build the small sample below. ## From the template ```sh frost new mygame --template embers # a whole third-person game: hero, wardens, embers frost check mygame/game.toml frost test mygame # its 2,653-step recording holds ``` Read `mygame/game.toml`, `arena.toml` and `main.luau`, then change it. ## From nothing The third-person sample. Make an empty folder and write the three files below side by side in it (the comment at the top of each says the sample's own path; the names are what matter: `game.toml`, `yard.toml`, `main.luau`). The fourth file, `shots/walk.png`, is made by `frost test --write` from the run, below. ```toml # example: third-person/game.toml # A hero to walk round a yard with the camera behind it: the third-person recipe's game. # A and D turn, W and S walk, Space jumps. # # frost dev game.toml # frost run --headless --steps 140 --shot walk.png game.toml space = "3d" scene = "yard.toml" scripts = ["main.luau"] seed = 1 shots = [{ name = "walk", step = 140 }] replay = { steps = 240, checksum = "da9834c571080c23", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [] [window] size = [640, 360] background = 0x1b2030 # 3D physics on Jolt: the hero is a Mover, the floor and the crates are colliders. [physics] [input] actions = ["turn", "walk", "jump"] recording = [ { steps = 30 }, { steps = 80, walk = 1 }, { steps = 15, turn = -1, walk = 1 }, { steps = 1, walk = 1, jump = 1 }, { steps = 114, walk = 1 }, ] [input.keys] turn = { negative = "A", positive = "D" } walk = { negative = "S", positive = "W" } jump = "Space" ``` ```toml # example: third-person/yard.toml # The camera is the engine's: Follow keeps it behind the hero and in front of walls. [camera] Transform = {} Camera = { fov = 60, near = 0.1, far = 120 } Follow = { of = "hero", back = 6, up = 2.5 } # The afternoon sun, with shadows, and a haze that melts the far edge into the sky. [sky] Sky = { time = 15.5, shadows = true, reach = 30, haze = 20, haze_far = 60 } [floor] Transform = { y = -0.5, sx = 200, sy = 1, sz = 200 } Mesh = { file = "box", tint = 0x6f8a55 } Collider = { w = 1, h = 1, d = 1 } [crate_a] Transform = { x = 2, y = 0.5, z = 6 } Mesh = { file = "box", tint = 0xb07a45 } Collider = { w = 1, h = 1, d = 1 } [crate_b] Transform = { x = -3, y = 1, z = 9, sx = 2, sy = 2, sz = 2 } Mesh = { file = "box", tint = 0x9a6a3c } Collider = { w = 1, h = 1, d = 1 } [pillar] Transform = { x = 4, y = 2, z = 14, sx = 1, sy = 4, sz = 1 } Mesh = { file = "cylinder", tint = 0xd8d2c4 } Collider = { shape = "cylinder", w = 1, h = 1 } # The hero is a capsule the physics walks (Mover); what is drawn is a child of it. [hero] Transform = { y = 0.8 } Collider = { shape = "capsule", w = 0.6, h = 1.6 } Mover = { step = 0.3 } [hero_look] Parent = { of = "hero" } Transform = { sx = 0.6, sy = 0.8, sz = 0.6 } Mesh = { file = "capsule", tint = 0xf2364b } ``` ```lua -- example: third-person/main.luau -- Turn with A and D, walk with W and S, jump with Space. Gravity and the jump are the -- script's; walking into things, stairs and slopes are the Mover's. No camera code: -- the camera's Follow (yard.toml) keeps it behind the hero. local WALK, TURN, JUMP, GRAVITY = 4, 150, 5, 14 state.yaw = state.yaw or 0 function step(dt) local hero = find("hero") state.yaw = (state.yaw - input.get(0, "turn") * TURN * dt) % 360 local vy = 0 if not get(hero, "Mover", "grounded") then vy = math.max(get(hero, "Mover", "vy") - GRAVITY * dt, -20) elseif input.held(0, "jump") then vy = JUMP end local yaw = math.rad(state.yaw) local walk = input.get(0, "walk") * WALK set(hero, "Mover", "vx", math.sin(yaw) * walk) set(hero, "Mover", "vz", math.cos(yaw) * walk) set(hero, "Mover", "vy", vy) -- Face the way it walks: a model's front is +z, and the Follow camera turns with it. local qx, qy, qz, qw = quat.turn(state.yaw, 0, 0) place(hero, get(hero, "Transform", "x"), get(hero, "Transform", "y"), get(hero, "Transform", "z"), qx, qy, qz, qw) end ``` What matters: - `space = "3d"` and a `[physics]` table: 3D physics on Jolt, metres, y up. - The hero is a `Collider` capsule with a `Mover`: the script says the velocity it wants (`vx`, `vy`, `vz`), the engine walks it into walls, up `step` ledges and slopes, and says `grounded`. Gravity and the jump are the script's. - What is drawn is a child (`Parent = { of = "hero" }`): a scale on the collider's own thing would scale the collider too. - `Follow = { of = "hero" }` on the camera is the whole camera: behind, above, eased, kept in front of walls. Write no camera code. - `place(e, x, y, z, qx, qy, qz, qw)` turns the hero to face its yaw; a model's front is +z. - `Sky = { time, shadows = true }` is the sun, the sky and the ambient light at once. Fetch more with `frost reference 3d`, `frost reference physics`, `frost reference input`. ## Checks ```sh frost check game.toml # checked 3 files: no problems frost run --headless --steps 140 --shot walk.png game.toml # look at walk.png frost test --write game.toml # writes replay's checksum, takes shots/walk.png frost test game.toml # ok: 240 steps to run checksum ..., 1 shot the same frost test --restore game.toml # state survives being put back ``` Order matters the first time: until `frost test --write` has taken the shot, plain `frost test` fails with `1 of 1 shot changed or new`, even when the checksum holds. `--write` also writes `checkpoints`, the run's checksum at every 256th step: a 240-step run has none, so `checkpoints = []` is right. `--shot walk.png` is the picture after the last step; `--shot 140=walk.png` (as the core writes it) takes the one after step 140 of a longer run. Look at the shot before accepting: the hero in the middle, the camera behind it, and each thing's shadow on the floor, away from the sun. (From this angle the hero's own shadow falls behind it, out of view.) The sample's kept picture: ![The third-person sample at step 140](../../files/examples/third-person/shots/walk.png) ### After a change A change you meant moves the run: look at a new shot first, then accept both the run and the picture. ```sh frost run --headless --steps 140 --shot walk.png game.toml # look at it frost test --write game.toml # the new checksum (a kept shot is compared, not replaced) frost check --shots --write-shots game.toml # keep the new picture, once you have looked frost test game.toml # ok again ``` Over MCP, the same checks are `game_check`, `game_seek {step: 140}` then `frame_capture`, and `world_get {entity: "hero", component: "Mover"}` to read `grounded`. ## Next: a ground with hills The hills sample is the same yard on a height field. The floor box becomes a `Ground`, which a small TOML file and a grey PNG describe: ```toml # example: hills/art/hill.ground.toml # The yard's ground: hill.png's samples, 128 metres across x and z, black at `low` and # white at `high` metres above the Ground thing's own Transform y. heights = "hill.png" size = [128, 128] low = 0 high = 6 ``` The ground's middle is where its thing's `Transform` puts it, and its heights are measured from that `Transform`'s `y`: a black sample is `low` above it, a white one `high`, a grey one in between. With `Transform = {}` and `low = 0`, the flat black middle is at `y = 0`, where the hero stands; the same ground under `Transform = { y = 1 }` is a metre higher everywhere (measured with `ground.at`). The picture is square, its side even, 4 to 1024 samples, row 0 at -z. This one is made by a script with Python's standard library: ``` # example: hills/art/make.py #!/usr/bin/env python3 """Writes hill.png, the yard's height field: 128 by 128 grey samples, flat (black) within 18 metres of the middle and rising to hills (up to white) beyond. Python's standard library only. Run it again after changing a number: python3 make.py""" import math import struct import zlib from pathlib import Path SIDE = 128 # samples a side: even, 4 to 1024 METRES = 128.0 # the ground's size, as hill.ground.toml says def height(x, z): """0 to 1: 0 is the file's `low`, 1 its `high`.""" rise = max(0.0, min(1.0, (math.hypot(x, z) - 18) / 14)) rise = rise * rise * (3 - 2 * rise) return rise * (0.6 + 0.4 * math.sin(x * 0.15) * math.cos(z * 0.12)) rows = [] for row in range(SIDE): # row 0 is at -z z = (row / (SIDE - 1) - 0.5) * METRES line = bytearray([0]) # PNG's filter byte: none for column in range(SIDE): x = (column / (SIDE - 1) - 0.5) * METRES line.append(round(max(0.0, min(1.0, height(x, z))) * 255)) rows.append(bytes(line)) def chunk(kind, data): return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data)) png = (b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", SIDE, SIDE, 8, 0, 0, 0, 0)) + chunk(b"IDAT", zlib.compress(b"".join(rows), 9)) + chunk(b"IEND", b"")) (Path(__file__).parent / "hill.png").write_bytes(png) ``` In the sample's `yard.toml`, the floor is: ```toml [floor] Transform = {} Ground = { file = "art/hill.ground.toml", color = 0x6f8a55 } Collider = { shape = "ground" } ``` `Collider = { shape = "ground" }` makes the physics walk on the same heights, so the Mover climbs the hills. `ground.at(x, z)` (a script) and the protocol's `ground.at {x, z}` say the height there: in the sample, 0 at the middle and 5.85 at `x = 50`. Then the checks above, including "After a change". ## More - Touch controls on a phone: `[input] fingers` (`frost reference input`), as Embers does. - Look: [3D rendering](../../guides/3d-rendering.md) for lights, AO, bloom, MSAA. --- Page: agents/recipes/streaming.md # Recipe: stream a world Goal: a world bigger than what is kept alive at once, cut into cells that enter near the player and leave behind, with the run still replaying to one checksum. ## Steps 1. Keep in the base scene what is always there: the player (a follower must be there, `E0577` otherwise), the camera, the interface, and anything connected by `Parent`, `Joint` or `Node`. 2. Write each cell as an ordinary scene in world coordinates, in one folder, named by its grid place: `X_Y.toml` in 2D, `X_Z.toml` in 3D, where X is `floor(x / size)`. Thing names are unique across every cell. 3. Declare the grid with a `[stream]` table that lists every cell. 4. React to `cell.enter` and `cell.leave` events (value `"X,Y"`); `find` things of a cell again after it comes back. The stream-cells sample is all four steps: ```toml # example: stream-cells/game.toml # A road of four cells that enter ahead of the hero and leave behind it, by one rule on # every machine. The hero walks right across them, then back. # # frost dev game.toml # frost test game.toml scene = "base.toml" scripts = ["main.luau"] seed = 1 replay = { steps = 600, checksum = "c6b840469fb21a48", engine = "0.0.1 r280" } # The run's checksum on the way there, written by `frost test --write`: a test that # fails says between which two of these steps the game first went another way. checkpoints = [ [256, "d58d9b4530b1d282"], [512, "023608768c5b3d94"], ] [window] size = [320, 180] background = 0x15171c # Cells are scenes in `folder`, named by their grid place (X_Y in 2D), each `size` # units on a side. Those within `load` cells of a follower enter; those beyond `drop` # leave. At most `budget` things enter in a step. [stream] folder = "cells" cells = ["0_0.toml", "1_0.toml", "2_0.toml", "3_0.toml"] size = 160 load = 1 drop = 1 followers = ["hero"] budget = 64 [input] actions = ["move_x"] recording = [{ steps = 290, move_x = 1 }, { steps = 310, move_x = -1 }] [input.keys] move_x = { negative = "A", positive = "D" } ``` ```lua -- example: stream-cells/main.luau -- Walk the hero along the road; the camera follows. A cell's entry and leaving are -- events like any other, with the cell's "X,Y" as their value. state.entered = state.entered or 0 state.left = state.left or 0 function step(dt) local hero = find("hero") local x = get(hero, "Transform", "x") + input.get(0, "move_x") * 120 * dt set(hero, "Transform", "x", x) set(find("camera"), "Transform", "x", math.max(160, x)) for _, cell in ipairs(events("cell.enter")) do state.entered += 1 state.last = "LAST IN " .. cell.value end for _, cell in ipairs(events("cell.leave")) do state.left += 1 state.last = "LAST OUT " .. cell.value end set(find("cells"), "Text", "text", "IN " .. state.entered .. " OUT " .. state.left .. " " .. (state.last or "")) end ``` Fetch the details with `frost reference project` (its streaming section) and `frost reference stream.loaded`. ## Checks ```sh frost check game.toml # every cell is read: E0576 names a bad one frost test --write game.toml # first time: replay and checkpoints frost test game.toml # ok: 600 steps to run checksum ... frost test --restore game.toml # put back at each checkpoint, it streams on the same frost run --headless --steps 150 --state game.toml # entered and left, from state ``` Over the protocol, `stream.read` at a step says which cells are in, what is saved of the others and whether physics may step: seek to a step where the player is on a boundary and read it. `frost bench` shows the `stream` span and the `stream.entered` count: the cost of the steps where cells enter. A cell enters whole, so a slow entry is a cell with too much in it: split it. ## Pitfalls - A cell entering is whole or not at all; a cell with more things than `budget` never enters. Split it or raise the budget. - Physics waits for a cell it needs: a teleport shows queued cells for several steps. - Cell text and assets are all read at load, on the web too: streaming bounds live things and bodies, not asset memory. - Ground must cover its cell; a body must stay inside the cells kept in. --- Page: agents/recipes/profile-a-frame.md # Recipe: profile a frame Goal: find what a slow step spends its time on, change it, and prove the change made it faster without changing the game. The game's own recording is the benchmark. ## Measure ```sh frost bench game.toml # median, p99, worst a step; by stage and span frost bench --draw game.toml # and the off-screen draw: draw calls, quads frost bench --json game.toml > before.json ``` Read three lines first: the load average (over about 4, the numbers lie: measure again on an idle machine, or compare only runs under the same load), `slowest: ... at step N` (the step and where its time went), and the stage with the largest median. On the third-person sample the slowest line reads `slowest: 0.388 ms at step 127: scripts 0.173 ms, of which script main.luau 0.159 ms`: a script, not physics or drawing. ## Look at one step Over the protocol (`frost serve game.toml`, or the `frost mcp` tools with `_` for `.`): ```json {"method":"game.seek","params":{"step":127}} {"method":"profile.steps","params":{"from":100,"to":140,"worst":3}} {"method":"profile.frame","params":{"step":127}} ``` `profile.steps` names the slowest steps of the stretch with a tree from the step through its stages and scripts down to each engine call a script made, by the line that made it. That line is what to change: a `find` in a loop, an `each` over a large set every step, a table rebuilt every step. ## Change it, then prove it ```sh frost test game.toml # must still pass: same checksum, same game frost bench --json game.toml > after.json ``` Compare `before.json` and `after.json` by their medians for the span you changed, run under the same load. If `frost test` fails, the change altered the game: either it was not only an optimisation, or a `local` cache is out of date after a put back (`frost test --restore game.toml` says which step). ## Checks - `frost test game.toml` passes before and after: a faster game that plays differently is a different game. - The changed span's median fell, at a similar load average. - Report the two medians, the load averages, and the command that reproduces them. A performance claim without the run that reproduces it is not reported. More: [profiling](../../guides/profiling.md), `frost help bench`, `frost protocol profile.steps`. --- Page: agents/recipes/debug-a-script.md # Recipe: debug a script Goal: find why a value is wrong. Start with the cheap questions; stop at a line only when they do not answer. Examples use the basics sample, where a coin worth 5 is picked up at step 131. ## 1. Does it load? ```sh frost check game.toml ``` Each problem is `FILE:LINE: CODE: what and the fix`. Fix those first. ## 2. Who wrote the value? ```sh frost blame game.toml score.Text.text ``` ```text score.Text.text is "SCORE 5" at step 180 script main.luau:24 in step: step 131, 1 write, from "SCORE 0" ``` Add `--step N` to ask at another step and `--history 4` for earlier writers. Ask about a pixel with `--pixel X,Y`. Over the protocol: `blame.on`, then `blame.value {entity, component, field}`. ## 3. Stop at the line Over the protocol (or `frost dap` from an editor, which drives the same commands): ```json {"method":"debug.attach","params":{}} {"method":"debug.breakpoints","params":{"file":"main.luau","lines":[23]}} {"method":"input.set","params":{"player":0,"action":"move_x","value":1}} {"method":"game.step","params":{"steps":300}} ``` `game.step` returns at once when a script stops: `"stopped": {"file": "main.luau", "line": 23, "reason": "breakpoint"}` at step 101. Then: | Ask | With | | --- | --- | | Where am I | `debug.stack` | | What is in scope | `debug.scope {frame: 0}`, and `debug.expand` to open a table | | What is this | `debug.evaluate {text: "picked.value"}` -> `5` | | One line on | `debug.step {kind: "over"}` (or `"into"`, `"out"`) | | Go on | `debug.continue`; `debug.detach` when done | `debug.stack`, `scope`, `expand`, `evaluate`, `step` and `continue` need a stopped script (`E0442` otherwise); `debug.state` says whether one is. ## 4. Make it happen again The recording replays the bug at the same step every time: `game.seek {step: 131}` puts the game there, and `game.try {from, inputs}` plays a branch of input from a snapshot in one call, to test a guess without changing files. ## Checks ```sh frost check game.toml frost test game.toml # the fix holds the recorded run (or fails where meant) frost test --restore game.toml # nothing kept in a local that should be in state ``` When the fix changes the run on purpose, look at a shot, then `frost test --write`. More: [debugging](../../guides/debugging.md), `frost dap --help`, `frost help blame`. --- Page: agents/recipes/prove-a-change.md # Recipe: prove a behaviour change when the recording no longer holds Goal: you meant to change how the game plays, so its recorded run fails. Prove that the change does what you said and nothing else, record a run that still plays the game to its end, look at it, and only then accept it. ## 1. Read what failed ```sh frost test game.toml ``` A failure names the first step that differs, the value, what it was, and the script line that last wrote it. If that first difference is not the thing you meant to change, stop: the change does more than you think. ## 2. Say what the change changes, and hold it to that With the game in git, name the parts your change may alter and the step each may start to differ from (parts as `world.checksum` names them): ```sh frost test --says Transform.x@140 game.toml frost test --says state:main.luau game.toml ``` The game on disk is played beside the committed game on the same recorded input, and the test fails at the first step where a part you did not name differs. Over the protocol, `change.test` asks the same of a copy before it lands. ## 3. When the old input no longer plays the game A recording is only input. After a real change to the rules (a gap is wider, an enemy is faster) the same presses can fall into the gap or lose early, and the run proves nothing. Record a new one by playing: 1. Play the game with the protocol beside it: `frost dev game.toml`, or `frost serve game.toml` and drive it with `input.set` and `game.step`. 2. When the run reaches the end you want to prove, ask for `input.history`. Its `recording` is the whole `[input] recording` key, ready to paste, or to save alone in a file named by `recording = "run.toml"`. `edits` must be empty: a write to the world during the session is not in the recording. 3. Set `replay = { steps = N, checksum = "0000000000000000" }` with `N` the step you reached. ## 4. Look before you accept ```sh frost run --headless --steps 600 --state game.toml # the values at the end frost run --headless --steps 600 --shot 600=end.png game.toml # and the picture ``` Open the picture. Check the values you care about (the score, the level, who is alive). A checksum only says the run repeats; it does not say the run is right. ## 5. Accept, and keep the way back ```sh frost test --write game.toml # writes the new checksum and checkpoints frost check --shots game.toml # which kept pictures changed, the most first frost check --shots --write-shots game.toml # keep the new pictures, once you looked frost test game.toml # passes on the accepted run ``` `frost test --write` keeps the game as accepted in `.frost/accepted/`, so a later failure is compared with it. `frost test --unaccept game.toml` takes the last acceptance back. A kept picture is never replaced by a test: only `--write-shots` replaces it, and only when you ask. ## Checks that prove it worked - `frost test --says ...` passed before you recorded again: the change touched only what you said. - The new run reaches the end you meant, and you looked at its picture. - `frost test` and `frost test --restore` pass on the accepted run. --- Page: agents/recipes/export.md # Recipe: export to the web, desktop, iPhone and Android > **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release. Goal: a game that plays outside `frost`, proved to be the same game: the exported player, fed the recording, stands at the same checksum `frost run` prints. ## First, the game itself ```sh frost check --costs game.toml # what the download costs, by kind, and what could be smaller frost test game.toml # the recorded run holds frost run --headless --steps 600 game.toml # note its `world checksum` ``` ## The web Nothing to install: `frost` copies the web players that came in its download and compiles nothing. Only `--slim`, which builds a player with just what the game uses, needs the Emscripten SDK (`E0509` without it). ```sh frost export web game.toml --out web --recording frost play web --port 8080 ``` `frost export web` writes `index.html`, the game's files under `game/` and two players, `gpu/` (WebGPU) and `gl/` (WebGL2); the page picks the one the browser can run, and the command prints what each kind of browser downloads. Open `http://127.0.0.1:8080/?hold=600`: the page plays the recording 600 steps and prints `frost_player: holding at step 600 checksum X` to the console, where X must be the `world checksum` of `frost run --headless --steps 600`. `&backend=gl` or `&backend=gpu` picks a build, `&size=WxH` the canvas, `&report=/path` posts the held frame as a PNG. Leave out `--recording` for the build you ship: players play live input. ## The desktop ```sh frost export desktop game.toml --out desktop --recording desktop/NAME --hold 600 # prints the same holding line ``` The player, named after the game, with its files in `game/` beside it, for the system `frost` runs on. No installer and no signing. A game in C# has its scripts compiled ahead of time into a library beside it (a `frost` with C#; `--fetch` lets the one package it may need be fetched). ## iPhone and Android The first downloads will not have the phone players: both need a build that has them. ```sh frost export ios game.toml --out ios # NAME.app for the simulator; --device: unsigned, for an iPhone frost export android game.toml --out android # NAME.apk, arm64, Android 8.0 and later, a debug key ``` iOS needs Xcode (`E0500`) and `rustup target add aarch64-apple-ios-sim`; `xcrun simctl launch --console-pty SIM ID --hold N` prints the holding line. Android needs the Android SDK and NDK (`E0535`) and `rustup target add aarch64-linux-android`; the player prints to `adb logcat -s frost_player` and takes `--hold N` from `adb shell setprop debug.ven.args.APP_ID "'--hold N'"`. Phones are tested in the simulator and the emulator only: no real device yet, and signing for a device or a store is yours to do ([platforms and export](../../guides/export.md) says what it takes). C# does not run on phones yet. ## Checks - The holding line's checksum equals `frost run`'s `world checksum` at that step, on each target you export to. - Look at the held frame (`&report=`, or a screenshot): checksums cover the world, not the picture. - `frost check` warns of what a browser will struggle with: a model picture over 2048 on a side (`W0455`), a ground over 512 samples (`W0459`), a sound over three minutes in a game with a `[web]` table (`W0437`). --- Page: agents/recipes/csharp-or-luau.md # Recipe: choose C# or Luau Goal: choose the language for a game's scripts, knowing what each can do today. Both call the same engine and both replay to the bit; a game may mix them (Luau scripts run first, then C#, each in the project's order). ## Choose Luau when - The game must run on the web, on a phone, or over the network. Luau runs everywhere `frost` does; C# runs on the desktop only for now. - You want the shortest loop: a saved script is swapped in at once under `frost dev`, keeping the world and `state`. - You want to start from a template or a sample: they are written in Luau first. ## Choose C# when - The game is for the desktop, and you want types, a compiler and C#'s tooling. - A hot loop walks many things: `Step` takes components as columns, lent the world's own memory. In the engine's own measurements, 100,000 bunnies took a median 39.8 ms a step in C# on .NET against 90.6 ms in scalar Luau (one run each, under load). ## What C# cannot do yet | Limit | So | | --- | --- | | Desktop only; phones (through Native AOT) are in progress | Keep a phone game in Luau | | The web only through [FusionCompile](../../guides/fusion.md): no spawning, input, sound, text or scene changes there | Give those to a Luau companion | | Multiplayer refuses a game in C# (`E0543`) | Network games are Luau | | `[State]` holds only `bool`, `int`, `uint`, `float`, `double` and `Thing` | Keep the rest in components | | Libraries are compiled into each script, and a library's errors are reported at the script | In practice, one script composes the rest | | A spawned thing is seen the next step; a script cannot read an event it sent | Plan the order of a step around it | | `World.Spawn` takes at most 8 component names | Keep what a thing is spawned with to eight components | | `HashCode` and `GetHashCode` differ from run to run | Never let them decide anything in the game | `[FusionCompile]` works like Unity's `[BurstCompile]`: mark a class and its `Step` is compiled for the web. The whole C# API and its parity table with Luau: [C#](../../guides/csharp.md) and `frost reference csharp`. ## Setting up C# ```sh frost --version # from the -csharp download dotnet --list-sdks # the .NET SDK, version 10 or later ``` A script whose name ends in `.cs` is compiled by that SDK and run inside `frost`. Without C#, a game with C# is refused (`E0482`), and `frost test` says a C# game was skipped. The arena and 3D templates have also been written in C#, the arena one to the Luau one's world to the bit. ## Checks, either language ```sh frost check game.toml frost test game.toml frost test --restore game.toml ``` For C#, `frost test --json` reports `dotnet: {accepted, here}` when the game was accepted on another major version of .NET than the one it runs on now. --- Page: reference/index.md # Scripting reference Every call a script can make and every component a scene can use, a page a subject. These pages are written by the engine itself, so they always match your `frost`: `frost reference` prints the same text offline, and the editor shows it too. If you are new, read [your first game](../start/first-game.md) first, then [the core](core.md), the one short page that covers everyday game-making, and open a page below when you need it. `frost reference CALL` opens one entry. | Page | Use when | | --- | --- | | [core](core.md) | Starting or changing any game: project shape, edit, check, test, screenshots | | [scripts](scripts.md) | Writing Luau gameplay, spawning or finding entities, reading or changing fields, sharing libraries, loading data or switching scenes | | [drawing](drawing.md) | Drawing 2D sprites, rectangles or tilemaps, moving a camera, changing colour, layers, rotation or scale | | [3d](3d.md) | Building a 3D scene, placing meshes, adding a point light or sun, setting sky, ground or a following camera | | [physics](physics.md) | Making a player jump, move or collide, adding bodies or sensors, casting rays or pushing objects in 2D or 3D | | [joints](joints.md) | Connecting bodies with joints, building wheels, vehicles, ropes, hinges or 3D constraints | | [animation](animation.md) | Animating sprites or models, playing clips and poses, tweening fields, emitting particles or handling animation events | | [sound](sound.md) | Playing a sound on hit, adding sound effects or music, adjusting volume, fading or positioning audio | | [input](input.md) | Binding keyboard, mouse, touch or gamepad controls, reading player actions or setting up multiplayer input | | [ui](ui.md) | Building menus, buttons, sliders or HUD layout, changing focus, displaying text or loading fonts | | [state](state.md) | Saving progress, keeping script state, recording a playthrough, restoring snapshots or checking replay determinism | | [event-flow](event-flow.md) | Sending or reading gameplay events, handling contacts, sensors or the order events reach scripts | | [project](project.md) | Editing game.toml or scene files, declaring custom components, loading assets or sharing scene content | | [render](render.md) | Configuring bloom, materials, frame graphs or effects, or diagnosing rendering such as why a pixel is dark | | [csharp](csharp.md) | Writing gameplay in C#, checking Luau API parity or preparing the .NET tools and platform build | | [export](export.md) | Shipping a game to desktop or browser, choosing export settings or customising the web loader | | [protocol](protocol.md) | Inspecting or driving a running game through MCP or JSON-RPC, debugging a dark pixel, profiling, or testing agent edits | --- Page: reference/core.md # Making a game with Coldwave Read this once; fetch a page or one call when needed. No engine source is needed. `frost reference PAGE` opens a page below; `frost reference CALL` opens its entry; `frost reference --search words` finds ranked entries with page names. `frost reference --all` is the whole legacy reference. `frost reference --types game.toml` writes Luau definitions. In an editor use `reference.read {name: "PAGE or CALL"}`, `reference.search {words: "words"}`, or `reference.read {all: true}`; with no parameters `reference.read` returns this core and index. ## Make, play, check 1. `frost new my-game --template pong` copies a finished game; `blank` starts with a square. Run `frost new --list` to choose. Work inside the game's folder. 2. Edit `game.toml`, scenes and scripts. `frost dev game.toml` plays and reloads saves. `frost check game.toml` checks loading and reports file, line and suggested fixes. 3. Play a recording: `frost run --headless --steps 600 --state game.toml`. Add `--shot 600=shot.png` to see it; inspect the picture, not just the checksum. 4. `frost test game.toml` checks the recorded run and kept shots. For a new recording, write `replay = { steps = 600, checksum = "0000000000000000" }` in the project and use `frost test --write game.toml` to accept its checksum and checkpoints. Never overwrite an existing golden picture without its owner's approval. `frost check --shots game.toml` compares shots. `frost test --restore game.toml` checks that putting the game back restores its behaviour. ## Three kinds of file `game.toml` names the starting `scene`, `scripts`, `seed`, assets, input actions and custom `[components]`. Paths are relative to its folder. A scene names things and sets their components. A script defines `step(dt)`; time is fixed, normally 60 steps a second. `on_scene(name)` builds a scene before its first picture, including at load. ```toml # game.toml scene = "scene.toml" scripts = ["main.luau"] seed = 1 [input] actions = ["move"] [input.keys] move = { negative = "A", positive = "D" } ``` ```toml # scene.toml [hero] Transform = { x = 80, y = 90 } Rect = { w = 16, h = 16, color = 0xffffff } ``` ```lua -- main.luau state.distance = state.distance or 0 function step(dt) local hero = find("hero") if hero then local dx = input.get(0, "move") * 100 * dt set(hero, "Transform", "x", get(hero, "Transform", "x") + dx) state.distance += math.abs(dx) end end ``` ## Everyday calls - `find("hero")`: named entity or nil; `has(e, "Rect")`: component present. - `get(e, "Transform", "x")` reads; `set(e, "Transform", "x", 40)` writes a field. - `each("Transform", "Rect")`: entities with both components; iterate with `ipairs`. - `spawn({ name = "spark", Transform = { x = 40, y = 20 }, Rect = { w = 2, h = 2 } })` creates a thing; `despawn(e)` removes it and its children. - `input.get(0, "move")` reads an action; `input.held(0, "jump")` reads a button. - `send("hit", e, 1)` sends; `events("hit")` reads queued events. - `scene.load("next.toml")` changes scene at the step's end. ## Rules that save a run Keep gameplay in components or plain `state` tables. A script's outer `local` is a cache: reload, seek and rollback do not preserve it. Rebuild caches in `on_scene` and empty them in `on_restore`. `state` holds numbers, strings, booleans and plain tables only. Declare entity handles kept there with `keeps_things({"hero"})`. After a scene change old entity handles are dead; find them again in `on_scene`. Use world calls inside `step` or `on_scene`, not while loading the script. 2D: origin bottom-left, x right, y up; a rectangle's Transform is its centre. Layers draw low to high. `Rotation` and `Scale` are components, not Sprite fields. Keep drawn edges on whole frame pixels for matching pictures across backends. 3D: write `space = "3d"`; open `3d` before placing models or cameras. A field default `0.0` declares a float; `0` declares a whole number. Use the right kind in `set`. `find` may return nil. A script-only picture/model must be listed in `images`/`models`; list sounds in `sounds`. Script-only colliders need `[physics]`; script-only UI needs `[ui]`. Shared scene content belongs in `include`, not copies. Read actions, not devices. Keep long recordings in `recording = "run.toml"` under `[input]`. Random comes from seeded `math.random`; use `math.pow` for nonliteral powers. Sound is output, never game state. Animation events reach scripts next step. A successful load is not a successful game: play it and look at its shots. ## Pages - `scripts`: Use when writing Luau gameplay, spawning or finding entities, reading or changing fields, sharing libraries, loading data or switching scenes. Calls: bit32.mul, data, despawn, each, find, get, has, library, math.pow, math.random, math.roundeven, on_scene, print, scene.load, scene.name, set, spawn, step, tuning. - `drawing`: Use when drawing 2D sprites, rectangles or tilemaps, moving a camera, changing colour, layers, rotation or scale. Calls: frame.size, placed. - `3d`: Use when building a 3D scene, placing meshes, adding a point light or sun, setting sky, ground or a following camera. Calls: ground.at, place, quat.look, quat.mul, quat.rotate, quat.slerp, quat.turn, screen.project, screen.ray. - `physics`: Use when making a player jump, move or collide, adding bodies or sensors, casting rays or pushing objects in 2D or 3D. Calls: physics.cast, physics.force, physics.ground, physics.impulse, physics.mass, physics.overlap, physics.pause, physics.paused, physics.ray. - `joints`: Use when connecting bodies with joints, building wheels, vehicles, ropes, hinges or 3D constraints. Calls: physics.wheels. - `animation`: Use when animating sprites or models, playing clips and poses, tweening fields, emitting particles or handling animation events. Calls: bone, emit, tween. - `sound`: Use when playing a sound on hit, adding sound effects or music, adjusting volume, fading or positioning audio. Calls: music.pause, music.play, music.resume, music.stop, music.volume, sound.effects, sound.play, sound.volume. - `input`: Use when binding keyboard, mouse, touch or gamepad controls, reading player actions or setting up multiplayer input. Calls: input.get, input.held, input.keys, net.cancel, net.host, net.join, net.player, net.state. - `ui`: Use when building menus, buttons, sliders or HUD layout, changing focus, displaying text or loading fonts. Calls: ui.focus, ui.measure. - `state`: Use when saving progress, keeping script state, recording a playthrough, restoring snapshots or checking replay determinism. Calls: keeps_things, on_restore, save.delete, save.get, save.set, save.slots, state. - `event-flow`: Use when sending or reading gameplay events, handling contacts, sensors or the order events reach scripts. Calls: events, send. - `project`: Use when editing game.toml or scene files, declaring custom components, loading assets or sharing scene content. Calls: stream.hold, stream.loaded. - `render`: Use when configuring bloom, materials, frame graphs or effects, or diagnosing rendering such as why a pixel is dark. - `csharp`: Use when writing gameplay in C#, checking Luau API parity or preparing the .NET tools and platform build. - `export`: Use when shipping a game to desktop or browser, choosing export settings or customising the web loader. - `protocol`: Use when inspecting or driving a running game through MCP or JSON-RPC, debugging a dark pixel, profiling, or testing agent edits. --- Page: reference/scripts.md # scripts Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when writing Luau gameplay, spawning or finding entities, reading or changing fields, sharing libraries, loading data or switching scenes. # Coldwave scripting reference Everything a game's script can call, every component the engine draws or simulates, and every key of the project file. A game is a project file, scenes and Luau scripts; `docs/first-game.md` walks through making one. This page is written by `frost reference` from the engine's own text: do not edit it. ## Scripts This list is the whole API. An entity is a number; keep it, compare it, use it as a key. Every function but `print` needs the world, so it works inside `step` and not at the top level of a script, which runs when the script is loaded. | In a script | Does | | --- | --- | | `function step(dt)` | Defined by the script. Called once per fixed step; `dt` is the step in seconds | | `find("name")` | The entity that has that name, from the scene file or from `spawn`, or nil when there is none | | `get(entity, "Component", "field")` | Reads one field | | `set(entity, "Component", "field", value)` | Writes one field. The value must match the field's type | | `has(entity, "Component")` | Whether the entity has the component. False for one that is gone | | `each("A", "B", ...)` | The entities that have every named component | | `spawn("A", "B", ...)` | Creates an entity with the named components at their defaults | | `spawn("A", { B = { field = value } })` | The same with values: a table gives components by name, each with the fields to set. Names and tables mix in any order | | `spawn("A", { name = "boss" })` | The same with a name, which `find("boss")` and the protocol then find. A name a living entity has is an error (`E0006`) | | `despawn(entity)` | Removes an entity; false if it was already gone | | `math.random()`, `math.random(n)`, `math.random(m, n)` | Seeded random: 0 to 1, 1 to n, m to n | | `scene.load("level2.toml")` | Replaces every entity with those of a scene, once this step is over. See below | | `scene.name()` | The scene the game is in, as the project file names it | | `tuning` | The project's `[tuning]` numbers: `tuning.jump` | | `library("kit.luau")` | Runs a library of the project and returns what it returns. See below | | `data("levels/one.toml")` | A data file of the project as a new plain table. See below | | `print(...)` | Writes its values as one line to standard error. See below | Kinds: give each kind of thing a game spawns a component of its own that says what it is, even one with no fields (`Moth = {}` under `[components]`, then `spawn("Moth", ...)`), and give a thing there is one of a name. `each("Moth")` then finds them, and editors group a scene's entities by it. `each(..., {"Transform.x", ...})` also requires the selected numeric fields' components (`f32`, `f64`, `i32` or `u32`) and returns IDs, then one copied f64 buffer per field: eight little-endian bytes per ID. `set(ids, component, field, buffer)` writes one back in list order (duplicates too). Dense lists; metatables ignored. Spawns stay out; dead IDs error, never write reused slots. Length errors write nothing; entry errors keep earlier writes. Budget: one unit per field and copied value. Example: `local ids,xs=each("Transform",{"Transform.x"}); for i=1,#ids do local p=(i-1)*8; buffer.writef64(xs,p,buffer.readf64(xs,p)+dt) end; set(ids,"Transform","x",xs)`. Numbers: Luau uses 64-bit floats. Field defaults select storage: `0.0` is f32 (`0.1` reads back as `0.10000000149011612`); `0` is signed i32; `{ f64 = 0.0 }` keeps every double bit; `{ u32 = 0 }` holds 0..4294967295. Integer fields refuse fractions and out-of-range values. Float storage preserves NaN payloads; equality and checksums treat all NaNs alike, but distinguish signed zeros. Scene text canonicalizes NaNs; JSON inspection returns null for nonfinite floats. Tweens calculate in f32, including when targeting f64/u32. ### The language Scripts are Luau, in a sandbox: besides the API above they have Luau's `table`, `string`, `math`, `bit32`, `utf8`, `buffer`, `vector` and `coroutine` libraries and its basic functions (`pairs`, `ipairs`, `type`, `tostring`, `tonumber`, `assert`, `error`, `pcall`, `select`, `unpack`). There are no files, no clock, no network and no `require`: what a script works with is the world, and the same scripts, world and inputs play the same on every machine. `math.random` is the game's seeded source, not the machine's. All of `math` gives the same bits on every machine and in a browser (its trigonometry, `exp`, `log` and `pow` are the engine's own): turn and aim with it freely. One thing is the machine's: the `^` operator with a power other than a written `2`, `3` or `0.5`. Use `math.pow(x, y)` for those. Two are the engine's additions, for code ported from C, C# or JavaScript: `bit32.mul(a, b)`, the product of two 32-bit words, wrapped as C wraps it (a plain `a * b` of two words passes 2^53 and drops low bits); and `math.roundeven(x)`, the nearest whole number with halves to the even one (`math.round` takes them away from zero). A script cannot hang or starve the game. One run of a script is stopped after a million loop turns and function calls (`E0305`), and all scripts together may hold 64 MiB (`E0306`). Both are counted, not timed, so they fall at the same point on every machine. An error in `step` stops the game at that step with the script's name and line (`E0302`); under `frost dev` the game waits, and goes on when the file is saved again. ### Scenes `scene.load(name)` starts a scene: when the step in which it was called is over, every entity is removed and the scene's own are made, as when the game started. The name is the scene's path as the project file writes it: its `scene`, or one of its `scenes`. Loading the scene the game is in starts it again, which is how a game restarts. What several scenes share (a camera, a HUD) is written once, in a scene file the others `include` (see the project file's `scenes`). Only the entities change. Every script keeps its `state`, so a score or a level number carries over, and a script that wants a clean start clears its own. An entity number kept from before names nothing any more: look entities up again with `find`. The rest of the step that called `scene.load` still runs in the old scene, and the random source goes on from where it was. Then, still in that step, every script that defines `on_scene(name)` has it called with the scene's name and the new entities in place: spawn what the scene needs and set what it shows there, and no frame is drawn of the scene as its file alone has it. A `scene.load` called from `on_scene` waits for the end of the next step; while it waits it is in the checksum and a snapshot. The scene the game starts in gets the same call, once the game is loaded and before its first step. A name that is no scene of the game fails the step (`E0423`). ### Libraries A library is a Luau file that scripts share. The project lists it under `libraries`, and a script takes it in by the path written there: ```lua local kit = library("lib/kit.luau") ``` `library` reads no file while the game runs: the libraries were loaded with the game. The library's text is run and what it returns, usually a table of functions, is the result. It is run again for every call, so each script has its own copy and scripts share nothing through it; call it once, at the top of a script. Two calls make two copies, in two scripts or in one (two libraries that each take in a third): a table one copy makes is never `==` to one another makes, so tell such tables apart by a field, not by which table they are. A library has no `state` and no `step` of its own: its functions use the script API, and so work where the script that calls them could. A library may take in another, by the name the project file writes, or from its own folder with `./` or `../` (`library("./maths.luau")` in `lib/kit.luau` is `lib/maths.luau`), so a set of libraries that take each other in works from any project that lists them. When a library fails, the error names the script that was running, and the message starts with the library's name and line. ### Data files A data file is TOML that scripts read as a plain table: a level, a list of waves, a course. The project lists it under `data`, and a script reads it by the path written there, or from its own folder with `./` or `../`, as with `library`: ```lua local level = data("levels/one.toml") -- [[waves]] count = 3 ... is level.waves[1].count ``` A TOML table is a table with text keys, an array a list from 1, a string text, an integer or a float a number and a boolean true or false. A date is refused, and so is an integer past 2^53, which a number cannot hold exactly. Data files are read when the game loads and never while it runs; each call returns a new table, so a script may change its own. A run depends on its data as on its scripts: a changed data file starts the game again, and a replay recorded with other data gives another checksum. ### `print` `print` is for the author, not for the game: its output is not part of the simulation and no command returns it. It goes to standard error, one line per call, values separated by tabs: the terminal the program was started from (for an MCP client, wherever it shows a server's error stream), or a browser's console. Standard output is never written, because `frost serve` and `frost mcp` speak their protocol there. ### Warnings `frost check` lists warnings: what is probably a mistake though nothing failed, like `W0308`, a script with no global `step` function, which loads and never runs. --- Page: reference/drawing.md # drawing Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when drawing 2D sprites, rectangles or tilemaps, moving a camera, changing colour, layers, rotation or scale. | In a script | Does | | --- | --- | | `frame.size()` | The frame's width and height: `[window] size`, or the screen's shape for a game that fills (`fit = "fill"`), as its recording says | | `placed(entity)` | Where an entity is in the world: its own `Transform` composed with its parents' when it is under a thing with a `Transform` (its own fields are local to that one, and `get` reads them). Three numbers in 2D, x, y and its angle; seven in 3D, x, y, z and its turn. What a camera that follows a thing under a parent reads. In 2D too | ## What is drawn An entity is drawn when it has a `Transform` and one or more of `Rect`, `Sprite`, `Text` and `Tilemap`. These are the components the engine declares; a game declares its own in the project file's `[components]` table, and scripts read and write both kinds the same way. | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Transform` | `x` | number | 0 | The centre of what is drawn, in world units from the left edge | | `Transform` | `y` | number | 0 | The centre of what is drawn, in world units from the bottom edge | | `Rect` | `w` | number | 1 | Width in world units | | `Rect` | `h` | number | 1 | Height in world units | | `Rect` | `color` | whole number | `0xffffff` | The colour as `0xRRGGBB`: red, green and blue, two hex digits each. Higher bits are ignored | | `Rect` | `layer` | whole number | 0 | Drawing order: a higher layer is drawn over a lower one | | `Sprite` | `image` | text | `""` | The picture: a PNG file's path, relative to the project file, or an atlas's (a `.atlas.toml` file). Empty draws nothing | | `Sprite` | `frame` | text | `""` | The frame to show of an atlas `image` (see Atlases); `src_*` then cut a part of it, stopping at its edge. Unknown: `E0531` | | `Sprite` | `w` | number | 0 | Width in world units. 0 is the width of the part shown, one unit to an image pixel | | `Sprite` | `h` | number | 0 | Height in world units. 0 is the height of the part shown | | `Sprite` | `src_x` | whole number | 0 | The left edge of the part shown, in image pixels from the image's left | | `Sprite` | `src_y` | whole number | 0 | The top edge of the part shown, in image pixels from the image's top | | `Sprite` | `src_w` | whole number | 0 | The width of the part shown, in image pixels. 0 is everything to the right of `src_x` | | `Sprite` | `src_h` | whole number | 0 | The height of the part shown, in image pixels. 0 is everything below `src_y` | | `Sprite` | `tint` | whole number | `0xffffff` | A colour as `0xRRGGBB` that every pixel is multiplied by. White leaves the picture as it is | | `Sprite` | `flip_x` | true or false | false | Mirror the picture left to right | | `Sprite` | `flip_y` | true or false | false | Mirror the picture top to bottom | | `Sprite` | `layer` | whole number | 0 | Drawing order, shared with `Rect` and `Text` | | `Tilemap` | `image` | text | `""` | The tileset: a PNG file's path. It is cut into cells, counted along its rows from the top-left | | `Tilemap` | `tile` | whole number | 16 | The width of a cell in image pixels, and of a tile in world units | | `Tilemap` | `tile_h` | whole number | 0 | The height of both. 0: the same as `tile`, a square | | `Tilemap` | `legend` | text | `""` | Which character draws which cell: the first character the first cell, and so on. A character that is not here draws nothing | | `Tilemap` | `rows` | text | `""` | The map: one line of characters a row of tiles, the top row first | | `Tilemap` | `layer` | whole number | 0 | Drawing order, shared with the others | | `Camera` | `zoom` | number | 1 | How many frame units one world unit covers. Not above 0 is 1 | | `Pass` | `of` | text | `""` | The pass's name in `[render]`: `bright`, `add`, `panini`, `aces`: these read numbers (`frost check` warns of another, W0457) | | `Pass` | `threshold` | number | 0.6 | Its threshold, as the pass's own | | `Pass` | `strength` | number | 1 | Bloom strength, Panini distance or ACES exposure | | `Screen` | | | | Keeps the entity in place on the frame: the camera does not move it | | `Opacity` | `alpha` | number | 1 | How much of what the entity draws covers what is behind: 1 all of it, 0.5 half. Not above 0 hides the entity: nothing is drawn for it. Above 1 is 1 | | `Tint` | `color` | whole number | `0xffffff` | The colour multiplied by; white changes nothing | | `Rotation` | `angle` | number | 0 | How far the entity's rectangle and sprite are turned about `Transform`, in degrees, anticlockwise | | `Pivot` | `x` | number | 0 | The point of the entity's rectangle and sprite that stands on `Transform`, in units right of their centre | | `Pivot` | `y` | number | 0 | The same point, in units above their centre | | `Blend` | `add` | number | 1 | How much the entity is added to what is behind it instead of covering it: 1 all light, 0 the usual covering. Outside 0 to 1 is the nearer end | | `Slice` | `left` | whole number | 0 | How many pixels at the left of the sprite's picture are a border that keeps its size | | `Slice` | `right` | whole number | 0 | The same at the right | | `Slice` | `top` | whole number | 0 | The same at the top | | `Slice` | `bottom` | whole number | 0 | The same at the bottom | | `YSort` | `foot` | number | 0 | The entity sorts by height within its layer: this is where its feet are, in units above `Transform` (below is negative) | | `Scale` | `x` | number | 1 | How many times wider everything the entity draws is. Below 0 mirrors it | | `Scale` | `y` | number | 1 | How many times taller | | `Shape` | `kind` | text | `"ring"` | `"ring"`: a band inside the ellipse the rectangle holds; `"disc"`: all of it; `"line"`: a line along the rectangle's width, through its middle | | `Shape` | `w` | number | 1 | The rectangle's width in world units: a circle's diameter | | `Shape` | `h` | number | 1 | Its height. Unequal to `w`, a ring is an ellipse | | `Shape` | `width` | number | 1 | How thick a ring's band or a line is, in world units | | `Shape` | `from` | number | 0 | Where a ring or a disc starts, in degrees anticlockwise from the right: with `to` below a whole turn on, a ring is an arc and a disc a wedge | | `Shape` | `to` | number | 360 | Where it ends | | `Shape` | `dash` | number | 0 | Dashes this long with gaps as long, round a ring or along a line, in world units. 0: unbroken | | `Shape` | `color` | whole number | `0xffffff` | The colour as `0xRRGGBB` | | `Shape` | `layer` | whole number | 0 | Drawing order, shared with the others | | `Repeat` | | | | Repeats the sprite's picture where its part (`src_x` to `src_x + src_w`, and down) runs past the picture's edge, instead of stretching the edge: a scrolling belt, a tiled floor. Move `src_x` to scroll it. The whole picture repeats, not a frame of it | - **Axes.** A game sees its whole frame, with the origin at the bottom-left corner, x growing to the right and y growing up, and one world unit to one pixel of the frame (`[window] size`, 960 by 540 when left out). - **Anchor.** `Transform` is the centre of a rectangle and of a sprite: each covers `x - w/2` to `x + w/2` and `y - h/2` to `y + h/2`. For text it is the middle of the block's height, and `align` says where along a line it is. There is no scale. - **Order.** Lower layers first; layers may be negative. Within one layer the order is by entity slot, which a game does not choose: give things that overlap different layers. An entity with several of the three is drawn rectangle, sprite, then text. - **Colour.** sRGB bytes, written to the picture unchanged: `0xf2364b` reads back from a captured frame as exactly (0xf2, 0x36, 0x4b). A picture's own alpha is respected. A colour has no alpha of its own: see-through is the entity's `Opacity`. - **Rotation.** An entity with `Rotation` draws its rectangle and its sprite turned by `angle` about their centre: 90 stands a bar on end, a negative angle turns clockwise. Text and tilemaps are not turned. To point one thing at another: `set(e, "Rotation", "angle", math.deg(math.atan2(dy, dx)))` for a picture drawn facing right. A `Collider` on the entity is turned with it (see Physics), and physics gives a body that turns a `Rotation` of its own; a script that tests overlaps itself decides what a turned thing touches. Like `Opacity`, a script cannot add it later: give `Rotation = {}` in the scene file or when spawning. the engine's `turn` example draws the same picture, pixel for pixel, on Metal and in both web builds; a turned edge falls between pixels, so that is measured there and not promised for every graphics adapter. - **Shadow.** An entity with `Shadow` draws its text twice: first a copy in the shadow's colour, moved by `x` and `y`, then the text over it, so a banner stands off whatever is behind it without a second entity kept in step. It does nothing for a rectangle, a sprite or a tilemap. Give it in the scene file or when spawning: `Shadow = {}` is black, 2 right and 2 down. - **Pivot.** A rectangle or a sprite stands with its centre on `Transform`. With `Pivot` another point of it does, and `Rotation` turns it about that point: `Pivot = { x = -10 }` on a bar 20 long holds it by its left end, like an arm at the shoulder or a door at its hinge. The point is counted on the picture as drawn before it is turned. It is in units, not a share of the size, so it does not follow a size that changes: for a bar that empties towards one end, hold it by that end with `Pivot` once and shrink it with `Scale.x` (0 to 1), rather than writing `Rect.w` and `Pivot.x` together. - **Blend.** An entity with `Blend` is added to what is behind it: its colours make the picture lighter and hide nothing, which is how a glow, a flame, a spark or a beam of light is drawn. Black adds nothing, so a picture of light on black needs no alpha. `add` between 0 and 1 mixes adding with covering; `Opacity` still scales how much is drawn. Draw order is unchanged: layers, then entities. A tint can only darken a picture. To flash a sprite bright when it is hit, spawn a second entity on it with the same `Sprite` and `Blend = {}` for a few steps: the picture is added to itself, towards white. It is not a flat white shape. - **Scale.** An entity with `Scale` draws everything it draws that many times larger, across (`x`) and up (`y`), about the point that stands on `Transform`: a rectangle or a sprite about its centre or its `Pivot`, a text from where it starts, a tilemap from its corner. Below 0 mirrors. It is how a thing pops, squashes or breathes without its `w` and `h` being touched: `set(coin, "Scale", "x", 1.3)`. - **Slice.** A sprite with `Slice` is cut in nine: the four corners are drawn one unit a pixel, the edges stretch along their length and the middle fills the rest. One small picture of a frame then makes a panel, a button or a speech bubble of any `w` and `h`. `src_*` still picks the part of a sheet, and flips and `Rotation` work as on any sprite. - **YSort.** In a game seen from above, who is in front depends on who stands lower. Entities with `YSort` in one layer are drawn from the highest to the lowest, by `Transform.y + foot`, after the layer's entities that have none (the floor). Give a tall sprite its feet: `YSort = { foot = -12 }`. - **Opacity.** Everything drawn (rectangle, sprite, text, tilemap, 3D `Mesh`) uses its picture's alpha times `alpha` times every ancestor's `Opacity` (`Parent`): one root write fades a figure's parts. Below 1, 3D things join the see-through ones after opaque things, farthest first, revealing what's behind; shadows stay whole. Hide with `set(e, "Opacity", "alpha", 0)`; restore to 1. Hidden entities cost nothing to draw but still move, collide and can be found. Without `Opacity`, an entity draws in full. Scripts cannot add it later: give anything that will fade or hide `Opacity = {}` in its scene or when spawning. - **Numbers.** A number field is a 32-bit float. A scene file or a script may give it any number and gets the nearest 32-bit float back (0.1 reads back as 0.10000000149011612). A whole-number field holds 32 bits with a sign and refuses a fraction. - **Camera.** With no `Camera` the world and the frame are the same: the origin is the frame's bottom-left corner. An entity with a `Camera` and a `Transform` is the camera: its `Transform` is the world point at the middle of the frame, and `zoom` scales the world about that point. With several, the one in the lowest entity slot is used. The camera is world state like any other: a script moves it with `set`. The renderer does not round: for sharp pixel art keep the camera, and what moves, on whole units. - **Screen.** A score, a title or a backdrop that must stay put has `Screen`: its `Transform` is then in frame units from the frame's bottom-left corner, whatever the camera does. Layers order world and screen entities together. - An entity without a `Transform` is not drawn. A rectangle or sprite with a width or height of zero draws nothing. In a scene file: ```toml [player] Transform = { x = 120, y = 118 } Rect = { w = 36, h = 36, color = 0xf2364b, layer = 2 } [coin] Transform = { x = 300, y = 200 } Sprite = { image = "art/coins.png", src_w = 16, src_h = 16, w = 32, h = 32, layer = 3 } [score] Transform = { x = 480, y = 500 } Text = { text = "0", size = 4, color = 0xd9b98a, layer = 9 } ``` ### Sprites A sprite's picture is a PNG file named by its path, relative to the project file. Every sprite of one picture shares it. Animation is a script changing `src_x` and `src_y` to another part of one sheet. Pictures are sampled the way the project file's `[window] filter` says, the same for all of them: `"nearest"` for pixel art, which is the default, or `"linear"`. ### Atlases `NAME.atlas.toml` puts pictures on one page of at most 4096 by 4096, each a frame with a name: `pictures = ["hero/*.png"]` packs the PNG files its patterns match (`*` is any run of a file's name in one folder; `hero/run_0.png` is the frame `run_0`), or `sheet = "coins.png"`, `grid = [8, 8]`, `names = [...]` cuts one sheet. Errors: `E0530` frames that do not fit, `E0532` a pattern that matches nothing, `E0533` a `frame` on a sprite with a `Repeat`. More: `docs/atlases.md`. ### Tilemaps A tilemap draws a level from text. Its `Transform` is the bottom-left corner of the grid (not its centre): the last line of `rows` is the bottom row, and each character is one square of `tile` units, or `tile` wide and `tile_h` high when `tile_h` is set (bricks: `tile = 16`, `tile_h = 8`). ```toml [ground] Transform = { x = 0, y = 0 } [ground.Tilemap] image = "tiles.png" tile = 16 legend = "#=^" rows = """ .......... ....C..... ...===..^. ########## """ ``` Here `#` draws the first cell of `tiles.png`, `=` the second and `^` the third. `.` and `C` are not in the legend, so they draw nothing: a game's script can read `rows` (it is a field like any other) and put a coin where it finds a `C`, test what character is under a foot, or change a character with `set` to break a block. Lines may differ in length. The legend and the rows are ASCII. Only the tiles the camera sees are sent to the device, and a whole map is one draw call. ### Cost The whole world goes to the device as one batch. Rectangles and text cost nothing extra in draw calls beyond a change of picture: quads that follow each other in drawing order and share a picture, or have none, are one draw call. The frames of one atlas are one picture; other pictures interleaved on one layer cost a call each. --- Page: reference/3d.md # 3d Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when building a 3D scene, placing meshes, adding a point light or sun, setting sky, ground or a following camera. | In a script | Does | | --- | --- | | `screen.project(camera, x, y, z)` | World point to pointer x/y (-1 to 1, y down) and signed forward depth; positive is in front. Unclipped; the camera plane is refused (E0575) | | `screen.ray(camera, x, y)` | Pointer coordinates to world origin x/y/z and unit direction dx/dy/dz, starting at the camera. Both calls use the live 3D Camera, its parents and frame aspect; finite inputs required (E0575) | ### 3D The `screen` calls use y down, while `[input] pointer` actions use y up. Negate the pointer y when calling `screen.ray`, or negate the y returned by `screen.project` when comparing it with pointer input. A game is 3D when its project file says `space = "3d"` (left out, or `"2d"`: 2D, as always). Then its one `Transform` has ten fields: where (`x` right, `y` up, `z` towards the viewer, in metres), how it is turned (a quaternion `qx`, `qy`, `qz`, `qw`, no turn `0, 0, 0, 1`) and how it is scaled (`sx`, `sy`, `sz`, 1). Axes are right-handed, y up, as glTF's: a model faces +z, a camera and a light look along their own -z. A Transform is in the world, or local to its `Parent`'s when that one has a Transform, as in 2D. The 2D `Rotation` and `Scale` are not there in a 3D game. A scene writes a turn as the quaternion or as degrees, `turn = { x = 0, y = 90, z = 0 }`: yaw about y, then pitch about x, then roll about z, made a quaternion once as the scene loads. Numbers are 32-bit: far from the origin they lose their fine part (at 8 km a step is about a millimetre). | In a 3D game | Does | | --- | --- | | `place(entity, x, y, z, qx, qy, qz, qw)` | Writes where an entity is and how it is turned, in one call: what a script that moves many things a step uses. Scale is `set` | | `quat.turn(yaw, pitch, roll)` | The quaternion of a turn in degrees, as a scene's `turn`: four numbers | | `quat.look(x, y, z)` | The turn that points a thing's front (+z) along a direction, keeping it upright. A camera looks along -z: `quat.look(-x, -y, -z)` | | `quat.mul(ax, ay, az, aw, bx, by, bz, bw)` | Turning by `b`, then by `a`, as one turn | | `quat.slerp(ax, ay, az, aw, bx, by, bz, bw, t)` | The turn `t` of the way from `a` to `b`, the short way, at an even speed | | `quat.rotate(qx, qy, qz, qw, x, y, z)` | The vector `x, y, z` turned: three numbers | | `ground.at(x, z)` | In a 3D game, the ground under `x`, `z`: `{ entity, height, nx, ny, nz, layers }` of the lowest thing whose `Ground` is there (its surface's y, its normal, each picture layer's weight), or nil where no ground is. The protocol's `ground.at` answers the same | The `quat` functions work out each number from the same 64-bit arithmetic on every machine and in a browser, and `place` rounds to the field's 32 bits as `set` does. ### Meshes In a 3D game (`space = "3d"`) the frame graph draws meshes, lit and tested against depth, then every layer over them: with no `[render]`, a pass `meshes` then a pass `layers`, and a pass `sky` before them when a scene gives a thing a `Sky`. - `Mesh = { file = "racers/halo.glb", tint = 0xffffff }` draws the named `.glb` or `.gltf` scene's meshes, cooked at load (`E0436`: unreadable), placed by the entity's and parents' `Transform`. Corner colour is `COLOR_0` times material base colour and base colour picture times entity and ancestor `Tint`, as in 2D. Write `Tint`; legacy `Mesh.tint` still multiplies it. Linear lighting uses metal, roughness, normal, occlusion and glow pictures and factors; occlusion may share the metal/roughness picture or have its own. All pictures use the base colour picture's `KHR_texture_transform`. Masked materials omit pixels below their cutoff; blended ones use alpha, drawn after opaque things, farthest position first. A thing's faces are unsorted; intersecting see-through things draw in position order, not intersection order. All faces draw; double-sided materials light backs like fronts. Under a `Sky`, metal reflects only its zenith, horizon and ground, in the metal's colour, blurred by roughness: no sun or surroundings, no reflection without Sky. Unread: second uvs, texture samplers, other extensions. `Mesh.far` is how many metres from the eye the thing is drawn (0: the project's `[lods] far`): a brazier's fire can outlive the crates round it. Past it the thing, its shadow and what it holds are not drawn, faded out over its last tenth; the world is as it was. Override the model's look by setting `Mesh.roughness` and `Mesh.metallic` (0 to 1; below 0, the default, uses the model's) and `Mesh.blend` (`"blend"`: alpha transparency, `"opaque"`: whole, `""`: the model's), like any value. `Opacity` fades 3D as in 2D (see Opacity). Exports carry and draw cooked models (`NAME.vmsh`). `Tints = { list = "wax_seal = 0xff3020, #2 = 0x2050ff" }` beside a `Mesh` multiplies each named material's parts by a colour too (over `tint` and `Tint`); others are as they were. A material is its name in the file (bare, or in double quotes) or `#` and its place from 0; a colour is `0xRRGGBB` (no alpha: `Opacity` covers); commas part them, spaces and a last comma are allowed. `E0483`: not tints, or a material the model has not. `set(e, "Tints", "list", "...")` (C#: `World.Set`) changes it; things tinted alike or not are drawn together as before. A picture inside a model longer than 2048 on a side is halved for the web until it fits (`W0455` says which, and its size there): the checksums are the same in a browser, its frames are not, and `frost test` takes a game's shots natively only, so nothing compares them to the browser's. - **Shapes.** `Mesh = { file = "box" }` draws one of the engine's own shapes with no file: `"box"`, `"sphere"`, `"plane"`, `"capsule"` or `"cylinder"`, each one metre across about its middle so the thing's scale sizes it as it sizes a `Collider` of 1 (a plane lies flat facing up; a sphere and an upright cylinder are 1 high; a capsule is 1 across and 2 high, as `Collider = { shape = "capsule", w = 1, h = 2 }`), white and rough, so `tint` is its colour. A word with no `.glb` or `.gltf` ending names a shape, and no other is one. It is made in every program, a player too, and is no file of the game: nothing is exported for it. `assets.cooked {path = "box"}` answers its parts. - `Emission = { color = 0xffffff, strength = 0 }` beside a `Mesh` adds its own linear-light colour times `strength`, regardless of lighting, plus every ancestor's emission (`Parent`). One root write flashes a figure's parts: `set(e, "Emission", "strength", 2)`, then back to 0. Above 1, colour saturates; a blooming `[render]` graph (`bright`, threshold 0.6 unless given, then `blur` and `add`) spreads a halo: the engine's `flash` example. The default 0 adds nothing. 2D ignores `Emission` for now. As with `Opacity`, give `Emission = {}` in the scene or when spawning. - `Camera = { zoom = 1, fov = 60, near = 0.1, far = 0 }` is the eye: it looks along its turn's -z, `fov` degrees from the frame's bottom to its top, from `near` to `far` (0: no far end). The lowest entity with a Camera and a Transform sees. - `Light = { kind = "point", color = 0xffffff, energy = 1, range = 10, inner = 20, outer = 30 }`: `"ambient"` everywhere, `"sun"` along local -z, `"point"` from its place fading to nothing at `range`, `"spot"` likewise in a cone along local -z: whole within `inner` degrees, fading to nothing at `outer`. Each frame lights the 16 points/spots that give the view the most light (brightness, nearness to the eye for the range); off ones and ones reaching nothing in view take no place; ties go to the lower entity. With more, the last drawn dim toward the best left out, so none pops in or out. A sun with `shadows = true` first draws a 2048² map of the ball `range` units round the point `range` ahead of the Camera; it lights only points with nothing nearer in that map, soft over one map pixel at shadow edges. A shadowing spot uses a 1024² perspective map of its cone to `range`, equally soft. Among the lights drawn, the lowest entity spot requesting shadows with `0 < outer < 90` wins. Its near plane is range/100; closer casters are clipped. Other drawn points and spots with `shadows = true` share one 2048² atlas, the same on every device: a point six 512² faces, a spot 1024², two points and a spot at most; those giving the view most light first, the rest unshadowed, each fading as it nears the best left out. A mesh is drawn into the faces its bounds meet; posed ones, all. Off by default: no extra pass. A `Sky` controls its sun's shadows. The winning spot's `cookie = "art/mask.png"` projects a PNG across its cone (top at local +y), multiplying linear RGB and alpha with the picture filter. `""` (default) skips sampling; other lights ignore cookies. `frame.at` names the cookie unread. A point/spot with `night = true` shines as the Sky's sun goes down: none while a little up, all just under the horizon, smoothly. Its `energy` stays as written; only the picture follows time. Without Sky it always shines. - `Sky = { time = 12, turn = 0, shadows = false, reach = 30, haze = 0, haze_far = 0 }`: `time` is hours modulo 24 (scripts may add forever), determining sun direction, colour and strength, sky colours and ambient light (added to any `"ambient"` Light), without a picture. The sun rises along +x at 6, stands 50 degrees up towards -z at 12 and sets along -x at 18. `turn` rotates that path about +y in degrees. At night a dim blue moon shines from the opposite side. Sky replaces a `"sun"` Light and its shadows. `shadows = true` casts its sun/moon's shadows as that light does, `reach` replacing `range`: the same map, moving with time. With `haze_far > haze`, meshes and ground fade smoothly into the current horizon colour from `haze` units from the eye to fully at `haze_far`. Below the horizon the sky becomes horizon colour too, melting the world's edge into it. A `draw = "sky"` pass draws horizon, zenith, ground and sun disc over its whole target, before meshes. Games whose scripts alone make Sky, or with their own `[render]`, name that pass: `{ name = "sky", draw = "sky" }`. A scene's Sky with explicit passes but no sky pass is `W0458` (check and load): lit, unseen. The lowest entity's Sky wins. Like any component, `world.set`, script `set(find("sky"), "Sky", "time", 18)`, recordings and checksums see it. - `Fog = { color = 0x000000, density = 0 }`: without Sky, the lowest entity's Fog fades lit meshes and ground towards its sRGB colour by `1 - exp(-(density * distance)^2)`, distance from the eye in world units. Nonpositive density is off; try `0.058`. Sky takes precedence. Background stays unchanged; set it to the fog colour if wanted. `frame.at` explains fog; no beam scattering. Example: the engine's `torch/fog.toml` example. - `Ground = { file = "art/hill.ground.toml", color = 0x7c8a5c }` is a height field, drawn lit in one colour where its thing's Transform puts its middle (its turn and scale are not read). The file is a few lines of TOML: `heights = "hill.png"` (a grey PNG beside it, 16 bits a sample or 8, square, its side even and from 4 to 1024 samples, row 0 at -z), `size = [64, 64]` (metres across x and z), `low = 0` and `high = 4` (the heights of black and white). The cook makes it into metres once (`frost export` ships it cooked, `NAME.vgrd`); each cell is two triangles split from its corner nearest -x and -z. It is drawn in tiles of 64 by 64 cells, each only when its box is in the view (one draw a tile, which `render.passes` counts; the sun's shadow pass draws those the sun sees), with every corner, every second or every fourth: the fewest that move its surface less than half a pixel from where the eye sees it (a coarser tile hangs a skirt a metre down its edges, so no crack shows beside a finer one). Each corner keeps its normal in two 16-bit numbers and its place is worked out on the device, so a ground's picture may differ by one level in up to about one pixel in a thousand from the same ground drawn as one mesh. The protocol's `ground.at {x, z}` says the height and the slope there. `E0490`: a ground the cook cannot read. `W0459` (`frost check`, `frost export web`): a ground over 512 samples a side, said with what its tiles hold on the device with every level: about 12 MB of buffers at 1024 (one mesh of it would hold 80 MB), which a phone or a browser may need for the rest of the game. A `Collider = { shape = "ground" }` beside it makes the 3D physics collide with it (Jolt's height field, each height kept to 8 bits within its 2 by 2 block, so it is off what `ground.at` says by at most a 510th of how much the block's heights differ). `layers = [{ image = "grass.png", tile = 4 }, { image = "rock.png", tile = 6, slope = [25, 38] }, { image = "snow.png", tile = 8, height = [15, 17] }]` (at most 4) draws it in pictures, each repeating every `tile` metres over x and z, in place of its `color`: the first everywhere, each later one over those before it from none at its first number to all at its second (smoothly), by the slope in degrees (of the drawn surface, its normal mixed across each triangle) or by the height in the world. Its pictures are cooked into the ground with every level. `ground.at` says each layer's weight there by the same rule. - The 2D layers are drawn over the meshes as in a 2D game: seen from the Camera's `x` and `y` with its `zoom`, and a `Screen` thing stays where the frame puts it. `zoom` never touches the meshes' view: to frame a 3D scene, move the Camera or change `fov`. - **Materials.** `Mesh = { ..., material = "road" }` draws with a material that `[render.materials]` declares: `road = { vertex = "road.wgsl", fragment = "sea.wgsl" }`, one or both, each file one WGSL function. `fn vertex(world: vec3, p: array, 2>) -> vec3` moves a point already placed in the world; `fn fragment(world: vec3, normal: vec3, uv: vec2, color: vec4, p: array, 2>) -> vec4` is a surface's colour before it is lit. `p` is `Material = { of = "road", p0..p7 }` on one thing, which a script writes; a Mesh's own `p0..p3` are `thing` (a `vec4`) there, one heat or flash a thing. A material's function has no clock: what moves, moves because a script wrote its numbers this step, so a frame put back is the same picture. A click finds a thing where it is, not where a material draws it. At most 8. `E0437`: an undeclared material, or two things giving one its numbers. - Two surfaces at one depth (a pillar standing exactly on a floor, along its foot) are a tie that each graphics backend may break its own way: WebGL2 takes depth through GL's -1 to 1 and rounds it differently, so a picture can differ there by a pixel. Sink a thing a little into what it stands on (a hundredth of a unit) to have one picture everywhere. - With `[render] msaa = 4`, a pixel on a smoothed edge may be one level (of 255) off in WebGL2 from the native and WebGPU pictures, which are the same: the browser's GL averages the four samples itself and rounds its own way. Nothing else differs. - A model only a script names goes in the project's `models` (`E0438`: a Mesh names one not loaded; `frost check` says `E0439` of a script naming one). | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Follow` | `of` | text | `""` | The name of the thing it follows. Empty, or a name no thing has: it stays where it is | | `Follow` | `back` | number | 6 | How far behind the thing it is, in metres | | `Follow` | `up` | number | 3 | How far above the thing's place it is | | `Follow` | `aim` | number | 1 | How far above the thing's place the point it looks at is: its shoulders, not its feet | | `Follow` | `speed` | number | 5 | How much of the way to its place it closes in a second: 5 is a fifth of a second's lag. 0: at once | | `Follow` | `walls` | whole number | 65535 | The collider layers it is kept in front of: where a solid collider on one stands between the point it looks at and its place, it is put 0.2 in front of it at once, not eased (a ray, past the thing it follows; sensors are not seen). 0: none | --- Page: reference/physics.md # physics Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when making a player jump, move or collide, adding bodies or sensors, casting rays or pushing objects in 2D or 3D. With a `[physics]` table a 3D game has Jolt's physics, the same everywhere. `Body` gains `vz` and `spin_x`, `spin_y`, `spin_z` (degrees a second); `Collider.shape` is `"box"`, `"sphere"`, `"capsule"` or `"cylinder"` (upright), with depth `d`, or `"ground"`: the height field of the thing's own `Ground`, which never moves (E1102 otherwise). Physics writes `x`, `y`, `z` and the turn, never the scale, which a `Collider`'s size is multiplied by (see Scale, under Physics). Units are metres; gravity defaults to `[0, -9.81, 0]`. Events are 2D's. `physics.ray(x1, y1, z1, x2, y2, z2, mask?, ignore?)` answers `{ entity, x, y, z, nx, ny, nz, fraction }` or nil, as in 2D, and `physics.ground(mover)` too. `physics.cast(x, y, z, w, h, d, dx, dy, dz, mask?, ignore?)` answers so for the unturned box moved by `dx, dy, dz`, and `physics.overlap(x, y, z, w, h, d, mask?, ignore?)` lists what touches it, in slot order. `physics.mass(entity)`: a cube of a metre at `density` 1 weighs 1. `physics.impulse(entity, x, y, z, px?, py?, pz?)` and `physics.force` push as in 2D, a force for the fixed step's length (kept up, bit for bit an impulse of `x * dt` each step); off the middle they turn it right-handed: that cube pushed up by 1 half a metre right of its middle gets `spin_z` 171.9. A `Joint` is 2D's, with `z`, `to_z` and a hinge's or slider's `axis_x`, `axis_y`, `axis_z` (made one long; all 0 is 2D's z, or `angle` for a slider; given, it wins over `angle`). `"ball"` turns every way, with no limits yet; `"wheel"`, a weld's `spring` and a distance joint's `power` are refused at load. A `Vehicle` is a car: see Physics. A `Mover` walks as in 2D, with `vz`; `drop` is refused. Movers walk before the bodies: one standing on a body is carried by it, up, down and across, stays on it when it stops, and goes round a turning one unturned. Two movers pass through each other; a dynamic body pushes one as in 2D; it sends no `contact` (a sensor sees it). A capsule or place a script writes is the mover's from that step; a capsule with no room is refused. ## Physics An entity with a `Transform` and a `Collider` is in the simulation. What moves it is decided by what else it has: nothing (it never moves: ground, walls), a `Body` (the simulation moves it), or a `Mover` (a script walks it: a character). A `TileCollider` on a tilemap's entity makes its tiles solid, and a `Joint` joins a body to another. Each fixed step runs physics first, then the scripts, so a script reads where the step left things and what touched in it. | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Body` | `kind` | text | `"dynamic"` | `"dynamic"`: moved by gravity and by what it hits. `"kinematic"`: moves by its own `vx`, `vy` and `spin`, and nothing pushes it back (a lift, a paddle). `"static"`: never moves | | `Body` | `vx` | number | 0 | Velocity to the right, in units a second. Read it, or write it to throw the body | | `Body` | `vy` | number | 0 | Velocity upwards | | `Body` | `spin` | number | 0 | How fast it turns, in degrees a second, anticlockwise | | `Body` | `gravity` | number | 1 | How much of the project's gravity pulls on it: 0 floats, 2 falls twice as hard | | `Body` | `damping` | number | 0 | How quickly it loses speed to nothing in particular, like air. 0 never | | `Body` | `fixed` | true or false | false | It never turns: a crate that slides but does not tumble | | `Body` | `bullet` | true or false | false | Checked along its whole path against bodies that move: for a shot, which could pass through a thin crate between two steps. Static colliders stop everything either way | | `Collider` | `shape` | text | `"box"` | `"box"`, `"circle"`, `"capsule"` or `"polygon"`, centred on `Transform` | | `Collider` | `w` | number | 16 | Width in units, times the thing's scale (see Scale, below). A circle's diameter | | `Collider` | `h` | number | 16 | Height. A capsule taller than wide stands up; wider than tall lies down. Not used by a circle | | `Collider` | `points` | text | `""` | A polygon's corners about `Transform`, as `"x,y x,y x,y"`: 3 to 8, convex | | `Collider` | `sensor` | true or false | false | It stops nothing and reports what is inside it | | `Collider` | `senses` | text | `"moving"` | What a sensor reports. `"moving"`: dynamic and kinematic bodies and movers. `"all"`: static colliders and tilemaps too, so one on a floor reports the floor in its first step | | `Collider` | `one_way` | true or false | false | A platform a `Mover` jumps up through and lands on. Other bodies meet it as solid | | `Collider` | `layer` | whole number | 1 | Which of 16 layers it is on, as a bit: 1, 2, 4, 8 and so on up to 32768 | | `Collider` | `mask` | whole number | 65535 | The layers it meets, as bits added together. Two colliders meet when each is on a layer the other's mask has | | `Collider` | `friction` | number | 0.6 | 0 is ice | | `Collider` | `bounce` | number | 0 | 1 keeps all its speed in a bounce | | `Collider` | `density` | number | 1 | Mass for its size: a body of twice the density is twice as hard to push | | `Collider` | `surface` | number | 0 | A belt: the speed its surface runs at, clockwise round it, so its top goes right. Bodies and movers on it are taken along | | `TileCollider` | `solid` | text | `""` | The characters of the tilemap's `rows` that are solid | | `TileCollider` | `one_way` | text | `""` | The characters that are one-way platforms, solid along their top | | `TileCollider` | `layer` | whole number | 1 | As `Collider.layer`, for every tile | | `TileCollider` | `mask` | whole number | 65535 | As `Collider.mask` | | `TileCollider` | `friction` | number | 0.6 | As `Collider.friction` | | `TileCollider` | `bounce` | number | 0 | As `Collider.bounce` | | `Mover` | `vx` | number | 0 | The velocity the script wants this step. After the step: what was left of it (0 against a wall) | | `Mover` | `vy` | number | 0 | The same upwards. The script adds its own gravity and jump | | `Mover` | `grounded` | true or false | false | Written by the engine: it stands on something | | `Mover` | `crushed` | true or false | false | Written by the engine every step, with or without a script: true while a kinematic body squeezes it against what does not give (a lift under a ceiling, a ram against a wall) or is inside it, false once it is free. Nothing moves it out: that is the script's. Never from dynamic bodies | | `Mover` | `slope` | number | 50 | The steepest ground it walks on, in degrees. Steeper is a wall | | `Mover` | `step` | number | 0 | The highest ledge it walks up, and kerb it walks down, without leaving the ground: stairs | | `Mover` | `air` | number | 0 | Written by the engine: the seconds since it last stood. 0 on the ground | | `Mover` | `push` | number | 1 | How hard it shoves dynamic bodies in its way, as a density. 0: they stop it like walls | | `Mover` | `mass` | number | 1 | Its weight on the dynamic body it stands on, as a density: at 1, what a body of its capsule and a `density` of 1 weighs. 0: none | | `Mover` | `drop` | true or false | false | While true it falls through one-way platforms | | In a script | Does | | --- | --- | | `physics.ray(x1, y1, x2, y2, mask?, ignore?)` | The first collider on the line from the first point to the second: `{ entity, x, y, nx, ny, fraction }` (where, the surface's direction there, and how far along the line from 0 to 1), or nil | | `physics.cast(x, y, w, h, dx, dy, mask?, ignore?)` | The first collider the box centred on `x, y` meets when moved by `dx, dy`: the same answer as a ray, with `x, y` where they touch and `fraction` how much of the move it made first (0 when it touches something where it starts), or nil | | `physics.overlap(x, y, w, h, mask?, ignore?)` | A list of the entities whose colliders touch the box centred on `x, y` | | `physics.ground(mover)` | The entity a `Mover` stood on at the end of the last physics step, or nil in the air | | `physics.mass(entity)` | The mass of an entity's dynamic body, or nil when it has none. A box 32 by 32 with a `density` of 1 has a mass of 1 | | `physics.impulse(entity, x, y, px?, py?)` | Pushes a dynamic body once: its velocity changes by `x, y` divided by its mass. Made at the point `px, py` of the world it turns the body too. False for an entity with no dynamic body | | `physics.force(entity, x, y, px?, py?)` | The same for a push kept up: call it every step it lasts. An impulse of `x, y` times the step's length | | `physics.pause(on)`, `physics.paused()` | Holds the simulation or lets it go on, and whether it is held | - **Units.** Sizes and places are world units, the same as what is drawn; angles are degrees. `[physics]` in the project file sets gravity (980 units a second squared downwards when left out), how many units are a metre to the simulation (32) and the solver's sub-steps (4). The simulation is tuned for moving things between a tenth of a metre and ten metres across: 3 to 320 units at 32 to the metre. For a game of small pixels, lower `unit`. - **What is written.** After each step a body's `Transform`, `Body.vx`, `vy` and `spin` hold where it is and how it moves, and a body that has turned is given a `Rotation`. Writing `Transform` or `Rotation` puts the body there; writing the velocity sets it. Changing a `Collider` or `Body.kind` makes the body again with the new shape. - **Scale.** A collider's shape is its written size times its thing's scale in the world: its own (`Scale` in 2D; `sx`, `sy`, `sz` in 3D) times that of each parent that has a `Transform`. A box and a polygon take any scale. A circle, a sphere and a capsule take only one that is alike along every axis, and a cylinder one alike along x and z; any other, and a scale of 0, is `E0471`: at the load, at the step after a script wrote it, and at a `world.set`, which then changes nothing. Below 0 mirrors: a polygon's corners are mirrored and the other shapes are as they were. A `TileCollider` grows with its tiles from the map's corner, by scales above 0 only. A changed scale makes the body again where it is, moving as it moved: `density` stays, so its mass follows its area (in 3D its volume), and what touched it sends `contact_end`, then `contact` again. So to pop or squash a picture, scale a thing under the one that has the `Collider`, not that one. A `Mover`'s capsule is scaled, its speeds and `step` are not; a `Vehicle`'s body is, its wheels are not. - **Pushing a body.** `physics.impulse` and `physics.force` add to `Body.vx`, `vy` and `spin` at once, by the mass the last physics step knew, so they are recorded like any write. A body spawned this step is pushed from the next. A force of `physics.mass(entity) * 980` upwards holds a body up against gravity. - **Pausing.** After `physics.pause(true)` no body or mover moves and no event is sent until `physics.pause(false)`; scripts, the interface and tweens go on, for a menu over a game that holds still. Bodies go on with the speed they had. What a script spawns, moves or despawns meanwhile is still seen by questions. The pause is in the checksum and the recording, and outlasts `scene.load`. - **Static.** A `Collider` with no `Body` is static. Moving its `Transform` moves it, but it carries and pushes nothing on the way: for a platform that moves, use a kinematic `Body` and set its velocity. - **Layers.** `mask` in a question is the layers to look at; left out, all. Sensors are never returned by a question. One-way platforms and movers are. - **Ignoring the one that asks.** A ray or a cast that starts inside a collider meets it first, at `fraction` 0. `ignore` is one entity whose colliders the question passes over: `physics.ray(x, y, x, y - 40, nil, hero)` is the ground under `hero`. - **When questions are answered.** `physics.ray`, `physics.cast` and `physics.overlap` see the bodies as the physics step left them: what a script moves or spawns is seen from the next step, and what it has despawned is left out. In `on_scene` they see nothing of the scene that is starting: its bodies are made when every `on_scene` has run, so a ray asked there meets none of its walls. Ask from the first step on (a camera kept out of walls is a `Follow`, which the engine places against the new walls before the first picture). - **More.** `docs/physics.md`: how stiff stacks and joints are, how long a chain swings, belts, ledges, and a jump that forgives. - **Mistakes.** A collider that cannot be made (`E1101` to `E1108` and `E1113`: an unknown shape or kind, a size of 0, a polygon that is not 3 to 8 corners or not convex, a layer outside 16 bits, a `Mover` whose collider is not an upright capsule or that also has a `Body`, a `TileCollider` without a `Tilemap`, a `senses` that is neither word) or a joint that cannot (`E1110`, `E1111`) stops the load or the step with the entity's name and what to write. A joint between two things that never move is made, with a warning (`W1114`). ### A character A `Mover` is a character that goes where the script says and is stopped by what is solid. It needs a `Collider` that is a capsule taller than wide, and no `Body`. Each step the script writes the velocity it wants; the engine slides it along walls and ground, keeps its full speed up and down slopes no steeper than `slope`, lands it on one-way platforms, and says whether it stands. Gravity and jumping are the script's: ```luau function step(dt) local hero = find("hero") local vy = get(hero, "Mover", "vy") if get(hero, "Mover", "grounded") then vy = if input.held(0, "jump") then 400 else 0 else vy = math.max(vy - 1200 * dt, -600) end set(hero, "Mover", "vx", input.get(0, "move") * 110) set(hero, "Mover", "vy", vy) set(hero, "Mover", "drop", input.held(0, "down")) end ``` ```toml [hero] Transform = { x = 40, y = 44 } Collider = { shape = "capsule", w = 12, h = 24 } Mover = {} [level] Transform = { x = 0, y = 0 } TileCollider = { solid = "#", one_way = "-" } [level.Tilemap] image = "tiles.png" legend = "#-" rows = """ ........ ..---... ######## """ ``` Solid tiles that touch are joined into one outline, so a mover or a rolling body does not catch on the seams between tiles. A mover held up by dynamic bodies on both sides with nothing under its feet counts as standing, so it can jump out. It pushes dynamic bodies and is seen by sensors (`sensor_enter` with the mover as `other`); it sends no `contact` events: ask `physics.overlap` what is around it. To a question it is a collider like any other: a ray from inside the mover meets the mover, so give it as `ignore`. Standing, its feet are exactly on the ground (a capsule 24 high on a floor whose top is at 16 is at 28), and `physics.ground(mover)` is that ground. A body it stands on carries it, across, up and down, and round as it turns, on top of its own move; the capsule stays upright. A kinematic body carries it exactly; a dynamic one by the speed it has, above 1.6 units a second. On a dynamic body it has weight, `Mover.mass`: a seesaw goes down and a rope bridge sags as under a body of its size. Nothing takes a mover through a static collider, whatever pushes it. A dynamic body pushes a mover that is free to go. Where it cannot go (a floor or a wall is behind it, or it stands on something) the body is stopped as by a wall: a crate that falls on its head lies there, and falls when the mover walks from under it. So `crushed` comes from kinematic bodies only. A limit: a body deeper in the capsule than half its width is not put out; that takes one made there, or one faster than two capsule widths a step. the engine's `physics` example is a whole game with all of this: 200 crates, a character, two sensors, a ray and an overlap. ```toml # Optional: physics. `gravity` pulls on dynamic bodies, in units a second squared; # `unit` is how many world units are a metre to the simulation, 1 or more (lower it # for a game of small pixels); `substeps` is how many smaller steps the solver takes in # one fixed step, 1 to 16 (more is stiffer and slower). Left out: as written here. # A game has the physics when it has this table (empty will do) or a scene gives an # entity one of its components. One whose scripts alone make colliders needs the table. # A 3D game's may say `threads`, 0 to 16 (left out: 0): how many worker threads a step's # physics runs on beside the stepping thread, the same bits on any number. A machine with # fewer cores runs on its cores less one, and `frost check` says so; a web page runs on # the stepping thread. Workers slow a small game and speed up only thousands of awake # bodies: measure with the `workers` example of frost_physics. [physics] gravity = [0, -980] unit = 32 substeps = 4 ``` --- Page: reference/joints.md # joints Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when connecting bodies with joints, building wheels, vehicles, ropes, hinges or 3D constraints. | In a script | Does | | --- | --- | | `physics.wheels(car)` | A `Vehicle`'s four wheels, front left, front right, back left, back right, each `{ x, y, z, qx, qy, qz, qw, touching }` (its axle is its own x), or nil for no car | | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Joint` | `kind` | text | `"revolute"` | `"distance"`: a rod, or a spring or a rope, between two points. `"revolute"`: a hinge. `"prismatic"`: a slider along a line, which does not turn. `"weld"`: stuck together. `"wheel"`: a wheel that spins freely on an axle that slides along a line | | `Joint` | `from` | text | `""` | The name of the entity the joint holds. Empty: the entity the `Joint` is on. An entity can be nothing but a joint between two others, which is how one body gets several | | `Joint` | `to` | text | `""` | The name of the entity it is joined to. Empty: the world | | `Joint` | `x` | number | 0 | Where the joint holds the `from` entity, from its `Transform`, turning with it | | `Joint` | `y` | number | 0 | The same upwards | | `Joint` | `to_x` | number | 0 | A distance joint only: where it holds the `to` entity, from that entity's `Transform` (from 0, 0 of the world when `to` is empty). The other kinds hold the `to` entity where the `from` entity's point is when the joint is made | | `Joint` | `to_y` | number | 0 | The same upwards | | `Joint` | `angle` | number | 0 | The direction of a slider's or a wheel axle's line, in degrees, turning with the `to` entity: 0 to the right, 90 up | | `Joint` | `length` | number | 0 | A distance joint's length. 0: as far apart as its two points are when it is made | | `Joint` | `limit` | true or false | false | Whether `min` and `max` hold | | `Joint` | `min` | number | 0 | The least a hinge turns (degrees), a slider or an axle moves along its line, or a distance joint's length is (units). Turning and moving count from how the two were when the joint was made | | `Joint` | `max` | number | 0 | The most | | `Joint` | `speed` | number | 0 | The speed its motor drives at: degrees a second for a hinge or a wheel, units a second for a slider or a distance joint | | `Joint` | `power` | number | 0 | The most the motor can do to get there. 0: no motor. A force (a mass times units a second squared) for a slider or a distance joint, a turning force (that times units) for a hinge or a wheel; a body's mass is its area in square metres times its density. A motor far stronger than its load pushes a little past `limit` (500 N·m on a door of 0.2 kg: 7.5° in 3D, 11.6° in 2D) | | `Joint` | `spring` | number | 0 | Springiness, in swings a second. 0: rigid (a slider and a hinge then have no spring; a weld and a rod do not give). For a wheel it is the axle's suspension: at 0 the axle is rigid, held where it was made, unless `limit` gives it a range to slide in. For a hinge it is a spring towards how it was made | | `Joint` | `damping` | number | 0 | How quickly the spring stops swinging: 0 never, 1 without a swing | | `Joint` | `collide` | true or false | false | Whether the two joined bodies still collide with each other | | `Vehicle` | `forward` | number | 0 | The throttle, -1 (backwards) to 1. Asked the other way while it rolls, it brakes first | | `Vehicle` | `right` | number | 0 | Steering, -1 (left) to 1: that share of `steer` | | `Vehicle` | `brake` | number | 0 | The brakes on all four wheels, 0 to 1 | | `Vehicle` | `handbrake` | number | 0 | The handbrake, on the back wheels, 0 to 1 | | `Vehicle` | `speed` | number | 0 | Written by the engine: units a second along its front, negative backwards | | `Vehicle` | `revs` | number | 0 | Written: the engine's revolutions a minute | | `Vehicle` | `gear` | whole number | 0 | Written: -1 reverse, 0 none, 1 to 5 | | `Vehicle` | `touching` | whole number | 0 | Written: how many wheels are on something | | `Vehicle` | `wheel`, `width`, `track`, `front`, `back`, `hang`, `travel`, `spring`, `damping`, `steer`, `drive`, `torque`, `rpm`, `brakes`, `handbrakes` | number, `drive` text | 0.3, 0.2, 1.6, 1.25, -1.25, -0.2, 0.2, 1.5, 0.5, 35, `"front"`, 500, 6000, 1500, 4000 | What it is made of, in its own frame, never scaled with the thing (changing one makes it again): a wheel's radius and width; from the left wheels to the right; the front and back axles' z; a wheel's middle y with its spring in, and how far it hangs below that; the springs' swings a second and damping; the most it steers, in degrees; the driven wheels, `"front"`, `"back"` or `"all"`; the engine's most turning force (a mass times units squared a second squared) and revolutions a minute; the most the brakes and the handbrake do | - **Joints.** A `Joint` joins `from` to `to`: put it on the entity it holds and name the other, or, for a second joint on the same body (a chain, a bridge fixed at both ends), on an entity of its own that names both. Both ends need a `Collider`, and neither is a `Mover`. It is made where the two are when both have bodies, and made again from where they are then when a `Collider`, a `Body.kind` or any of its own fields but `speed` and `power` changes: those two a script writes freely, to drive a motor, without its limits moving. When either end is despawned the joint goes with it: the `Joint` is taken off its entity and the game is told once, as a warning (`W1112`). - **A car.** In a 3D game a `Vehicle` beside a `Collider` and a dynamic `Body` is a car, its front its own +z: its wheels are the physics' own, on springs, with an engine and gears. The defaults fit a `Collider` of 1.8 by 0.6 by 4 at `density` 280, in metres. A script drives it by `forward`, `right`, `brake` and `handbrake`, and draws its wheels where `physics.wheels(car)` says. Anything else stops the load or the step with what to do: a 2D game (`E0459`), a body that is not dynamic (`E0460`), no `Collider` (`E0461`), a field no car has (`E0462`). --- Page: reference/animation.md # animation Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when animating sprites or models, playing clips and poses, tweening fields, emitting particles or handling animation events. | In a script | Does | | --- | --- | | `bone(entity, "joint")` | World x, y, z, qx, qy, qz, qw of a unique model node, including this step's writes, without drawing; E0574 for a missing/ambiguous joint or invalid rig. See Bone | | `emit(entity, n)` | Emits n specks with the entity's `Emitter` look; returns one `Burst`. `E0560`: over 4096 alive at once; `E0561`: no `Emitter`; `E0562`: n is not a whole number from 1 | | `tween(entity, "Transform", "x", to, seconds, { ease = "out_quad" })` | Takes one number field of an entity from what it is to `to` over `seconds`, a little each step, and returns the tween (an entity: `despawn` it to stop). Options: `ease`, `from`, `loop` (`"restart"`, `"pingpong"`), `done` (an event sent when it ends). See Animation | ## Animation Two components move things without a line of script per step. Both are stepped after the scripts, so what a script decides in a step is on the frame drawn after it. | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Clip` | `name` | text | `""` | The clip to play, by its name under `[clips]` in the project file. Empty plays nothing | | `Clip` | `time` | number | 0 | Seconds into the clip. Set it to 0 to start again | | `Clip` | `speed` | number | 1 | How fast time passes: 0 holds the frame, 2 plays twice as fast. Less than 0 is 0 | | `Clip` | `frame` | whole number | 0 | The frame showing, counted from 0. Written by the engine: read it, do not write it | | `Tween` | `slot` | whole number | 0 | With `generation`, the entity whose field changes. `tween()` fills both | | `Tween` | `generation` | whole number | 0 | See `slot` | | `Tween` | `component` | text | `""` | The component that holds the field | | `Tween` | `field` | text | `""` | The field: a number or a whole number (which gets the nearest) | | `Tween` | `from` | number | 0 | The value it starts from | | `Tween` | `to` | number | 0 | The value it ends on, exactly | | `Tween` | `time` | number | 0 | Seconds since it began | | `Tween` | `seconds` | number | 1 | How long it takes. 0 or less is at once | | `Tween` | `ease` | text | `"linear"` | How it gets there: see Easings | | `Tween` | `loop` | text | `""` | `""` once, `"restart"` from the start again for ever, `"pingpong"` there and back for ever | | `Tween` | `done` | text | `""` | The event sent, about the changed entity, when it ends. Empty sends none | - **Clips.** A clip is a run of frames on one picture, equal cells from left to right, declared once in the project file: `run = { image = "art/hero.png", frame = [16, 16], at = [0, 16], count = 6, fps = 12 }`. An entity with a `Sprite` and `Clip = { name = "run" }` shows it: the engine writes the sprite's `src_x`, `src_y`, `src_w`, `src_h` (and its `image`, when the clip names one) each step. A clip loops unless it says `loop = false`; then it stays on its last frame. To change clip, set `name` and set `time` to 0; setting only `name` carries on from the same moment, which is how a run and a run-with-sword stay in step. A name that is no clip stops the step with `E1001`. - **Clip events.** A clip may send events as frames come up: `events = [{ frame = 2, name = "footstep" }]` sends `footstep` about the entity, with the frame as its value, each time frame 2 comes up. `end = "landed"` on a clip that does not loop sends `landed` once, when its last frame has had its time. Scripts read them with `events("footstep")` in the next step, since animation runs after scripts. - **Tweens.** A tween changes one number of one entity from a value to another over a time. Start one with `tween(entity, "Transform", "x", 200, 0.5, { ease = "out_quad" })` (see the script API). It is an entity of its own with a `Tween`, so an entity can have several at once, they are in the checksum, and `despawn` on what `tween` returned stops one. When it ends it writes `to`, sends its `done` event if it names one, and is gone. A tween whose entity is gone goes too. Two tweens on one field both write, and the later-made one wins. - **Easings.** `linear`, `in_quad`, `out_quad`, `in_out_quad`, `in_cubic`, `out_cubic`, `in_out_cubic`, `out_back` (past the end, then back) and `out_bounce`. `in` starts slow, `out` ends slow. Another name stops the step with `E1002`. ### Scripted joints A 3D `Bone` overrides a model node after clip blending, or its rest without `Pose`. Ordinary `set` writes it in Luau and C#; removing it restores clip/rest. Overrides are world components: checksum, snapshots and replay keep them. `bone(thing, "hand")` reads the world pose; `world.bone` reads it over the protocol. `Parent.joint` attaches a tool using its Transform as the socket offset. Unevenly scaled turns have Parent's usual shear limitation. the engine's `pose` example has a script-only arm, held box and tip light. Things with overrides or joint attachments advance their model clips before scripts; their clip events are therefore readable then. They draw the exact pose before shadows, without crowd rounding or rest-box culling. First adding one during a step holds its clip clock until the next step. Other clips retain their normal stage. Reads see all writes made so far; later scripts, tweens, Spin or Follow can still move things. ```toml # Optional: animation clips, which an entity plays with `Clip = { name = "run" }`. A clip # is `count` frames of `frame` image pixels each, left to right from `at` on `image` # (left out: the sprite's own picture), shown at `fps` a second (left out: 10). It loops # unless `loop = false`. `events` are sent as a frame comes up, and `end` when a clip # that does not loop is over. See Animation. [clips] run = { image = "art/hero.png", frame = [16, 16], at = [0, 16], count = 6, fps = 12, events = [{ frame = 2, name = "footstep" }] } land = { frame = [16, 16], at = [0, 32], count = 3, loop = false, end = "landed" } ``` ```toml # Optional: what a model's clip sends as a 3D thing's `Pose` plays it, by the clip's name: # each event's name and the moment of the clip it is sent at (`at`, in seconds), about the # thing, with the moment as its value; read by scripts in the next step with # `events("step")`, in Luau and C# alike (a script plays a sound on it). `seconds` is the # clip's length in the model (`assets.picture` lists it), and `loop` whether it goes round # (left out: true; one that does not sends nothing once it holds its end), in every model # the game loads with a clip of that name, whatever the cook found: a model's clip goes # round when each joint ends within a millimetre, two degrees and a thousandth of its size # of where it began, and is bent so it ends there exactly (no tick as it starts again). A game that loads a model whose clip of that name lasts another length # is refused (E0486). `frost check` says (W0461) of a clip a `Pose` plays that holds its end # though it nearly goes round (no joint off by more than ten times that), which joint and # how far: a cycle exported a little off, which a line here has go round. [poses] walk = { seconds = 1.0, events = [{ at = 0.25, name = "step" }, { at = 0.75, name = "step" }] } ``` | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Parent` | `joint` | text | `""` | Local to this model node of `of`; empty keeps ordinary parenting. E0574 for a missing or ambiguous joint. Uses the current pose, including Bone overrides | | `Bone` | `of` | text | `""` | Skinned thing's name. One override entity per joint; give it Parent.of too to despawn it with that thing | | `Bone` | `joint` | text | `""` | Unique model node name, including unweighted sockets; duplicates or matrix-only nodes are refused (E0574) | | `Bone` | `qx` | number | 0 | Absolute local quaternion x; finite components, nonzero quaternion, normalised when sampled | | `Bone` | `qy` | number | 0 | Quaternion y | | `Bone` | `qz` | number | 0 | Quaternion z | | `Bone` | `qw` | number | 1 | Quaternion w | | `Bone` | `translation` | true or false | false | Override local translation too; otherwise keep the clip/rest translation | | `Bone` | `x` | number | 0 | Absolute local translation x, metres; finite | | `Bone` | `y` | number | 0 | Translation y | | `Bone` | `z` | number | 0 | Translation z | | `Spin` | `rate` | number | 0 | Degrees a second, anticlockwise seen from the end of its axis. In 2D it turns `Rotation.angle`, kept from 0 to 360 | | `Spin` | `axis_x` | number | 0 | In 3D, the axis it turns about, in its own frame: x | | `Spin` | `axis_y` | number | 0 | Its y | | `Spin` | `axis_z` | number | 1 | Its z: about its own z, the way a 2D thing turns | | `Pose` | `clip` | text | `""` | The clip, by its name in the model (`assets.picture` lists them). Set it to play another: `set(thing, "Pose", "clip", "run")`, read it to know which plays. Empty, or a name the model has not, is the rest | | `Pose` | `time` | number | 0 | Seconds into the clip. Set it to 0 to start again; left, a new clip goes on from the same moment. A clip that ends where it began goes round (each joint within a millimetre, two degrees and a thousandth of its size; `[poses]` `loop` says otherwise), any other holds its end, in the picture and in the joints `bone` reads and a `Parent.joint` hangs from alike | | `Pose` | `speed` | number | 1 | How fast its time passes: 0 holds it. Less than 0 is 0 | | `Pose` | `fade` | number | 0 | Seconds a change of clip mixes the pose it was in into the new one; 0 changes at once | | `Pose` | `from` | text | `""` | Written by the engine: the clip a fade is from, empty when none runs | | `Pose` | `from_time` | number | 0 | Written by the engine: that clip's time, going on under the fade | | `Pose` | `blend` | number | 1 | Written by the engine: how far the fade has gone, 1 done | | `Pose` | `was` | text | `""` | Written by the engine: the clip it played last step, which a change is seen against | | `Pose` | `then` | number | 0 | Written by the engine: the time it ended the last step at, which a fade starts from | | `Gait` | `idle` | text | `"idle"` | The clip below `walk_at` | | `Gait` | `walk` | text | `"walk"` | The clip from `walk_at` | | `Gait` | `run` | text | `"run"` | The clip from `run_at` | | `Gait` | `walk_at` | number | 0.3 | Metres a second from which it walks | | `Gait` | `run_at` | number | 3 | Metres a second from which it runs | | `Gait` | `walk_speed` | number | 1.4 | Metres a second the walk clip was made to go at | | `Gait` | `run_speed` | number | 4 | Metres a second the run clip was made to go at | | `Gait` | `fade` | number | 0.2 | Seconds each change of clip fades over | | `Gait` | `x` | number | 0 | Written by the engine: where it was last step, across | | `Gait` | `z` | number | 0 | Written by the engine: and in depth | | `Gait` | `seen` | true or false | false | Written by the engine: whether it has been seen a step yet | | `Gait` | `speed` | number | 0 | Written by the engine: metres a second it went over the ground this step | | `Emitter` | `fired` | whole number | 0 | Engine-written total specks emitted, used to number them. Game state, in the checksum | | `Emitter` | `seed` | whole number | 0 | Picks speck directions and speeds: equal seeds emit equal patterns | | `Emitter` | `life` | number | 1 | Seconds a speck lives | | `Emitter` | `speed` | number | 3 | Initial speck speed, units a second: between half and all of this value | | `Emitter` | `spread` | number | 30 | Maximum degrees from the thing's up at emission: either side in 2D, all around in 3D. 180: every way | | `Emitter` | `gravity` | number | 0 | Units a second squared a speck falls by along y: below 0 falls | | `Emitter` | `size` | number | 0.2 | Initial speck width and height, in units | | `Emitter` | `size_end` | number | 0 | Its size at the end of its life, grown or shrunk evenly to it | | `Emitter` | `add` | number | 1 | 2D light addition versus covering, 0 to 1; 3D specks always add | | `Emitter` | `color` | whole number | `0xffd080` | Its colour as it leaves | | `Emitter` | `color_end` | whole number | `0x000000` | Final colour: black fades an added speck out | | `Emitter` | `layer` | whole number | 0 | 2D speck draw layer | | `Burst` | `first` | whole number | 0 | First speck's number: emitter's `fired` at emission | | `Burst` | `count` | whole number | 0 | Speck count | | `Burst` | `seed` | whole number | 0 | The emitter's `seed` | | `Burst` | `time` | number | 0 | Seconds since emission, engine-written | | `Burst` | `life` | number | 1 | Emitter's `life` at emission | | `Burst` | `speed` | number | 3 | Emitter's `speed` at emission | | `Burst` | `spread` | number | 30 | Emitter's `spread` at emission | | `Burst` | `gravity` | number | 0 | Emitter's `gravity` at emission | | `Burst` | `size` | number | 0.2 | Emitter's `size` at emission | | `Burst` | `size_end` | number | 0 | Emitter's `size_end` at emission | | `Burst` | `add` | number | 1 | Emitter's `add` at emission | | `Burst` | `color` | whole number | `0xffd080` | Emitter's `color` at emission | | `Burst` | `color_end` | whole number | `0x000000` | Emitter's `color_end` at emission | | `Burst` | `layer` | whole number | 0 | Emitter's `layer` at emission | --- Page: reference/sound.md # sound Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when playing a sound on hit, adding sound effects or music, adjusting volume, fading or positioning audio. | In a script | Does | | --- | --- | | `sound.play("hit.wav", { volume = 1, pitch = 1, vary = 0, at = entity })` | Plays a sound once. The table and its keys are optional; in 3D `near` and `far` too (see Sound) | | `sound.volume(level)` | Sets the gain of everything heard, 0 to 1 | | `sound.effects(level)` | Sets the gain of all that `sound.play` plays, 0 to 1 | | `music.play("theme.ogg", { volume = 1 })` | Loops a sound as the one music track, in place of the track before | | `music.stop(seconds)` | Stops the music, fading out evenly over `seconds` (left out, or held: at once) | | `music.pause()`, `music.resume()` | Holds the music where it is, and lets it go on. Sounds play on. `music.play` lets go of a hold | | `music.volume(level, seconds)` | Moves the music's own volume, 0 to 1, to `level` evenly over `seconds` (left out: at once). It outlasts the track | ### Sound Sound is output: a script cannot read what was heard, and a request is not in the world, the checksum or a snapshot. A sound is named as the project lists it under `sounds`: a WAV or Ogg Vorbis file. An Ogg file over ten seconds is decoded as it plays: only `music.play` takes it. A volume is 0 to 1 and a pitch is a speed, 0.25 to 4; outside its range is an error, not a clamp. `vary = 0.1` draws each play's pitch within a tenth of `pitch` from the game's random source, so adding it to a script moves the `math.random` numbers after it. `at = entity` or `x = 40` puts a play left or right by that world x against the camera, once. In 3D, `at = entity` uses the thing's position relative to the viewing camera at request time (`Follow` placed it at the previous step's end). Pan follows distance along camera-right: behind-left stays left regardless of camera direction. The distance fade multiplies `volume`: full within `near` metres, silent past `far`, linear between. Defaults: `[sound]`, else 2 and 30; overrides in a play's table: `near = 1, far = 12`. Requests carry computed results: recordings sound the same on every machine and in a browser. At most 4 of one sound and 32 in all are heard: one more eases out the quietest, the oldest on a tie. A playing sound has no handle and no stop. The calls work at a script's top level too, which a reload runs again. Volumes multiply. A settings screen's sliders write `music.volume` and `sound.effects`. To cross from one track to the next: `music.stop(1)`, then a second later `music.play("next.ogg")`. A fade is at most 60 seconds. ```toml # Optional 3D `sound.play` range for `at`: full within `near` metres of the viewing # camera, silent past `far`, linear between. Per-play `near` and `far` override these # defaults. [sound] near = 2 far = 30 ``` --- Page: reference/input.md # input Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when binding keyboard, mouse, touch or gamepad controls, reading player actions or setting up multiplayer input. | In a script | Does | | --- | --- | | `input.get(player, "action")` | A player's value for an action this step. Players count from 0 | | `input.held(player, "action")` | Whether a player holds a button action | | `input.keys("action", player?)` | List of unique key/pad control names bound to the action for the last-used device; player defaults to 0. Before input, keyboard/pointer. Empty if unbound on that device; unknown actions are errors. Device changes are recorded and restored. Network play uses keyboard labels on all peers | | `net.host()`, `net.join(address)`, `net.cancel()`, `net.state()`, `net.player()` | A menu's requests to play over a network, done after the step, and where it stands. Refused once the game plays with others. See docs/multiplayer.md | ### Input A script reads actions, never a device: `input.get(0, "move_x")`. The project file says which keys drive which action (`[input.keys]`); a recording, a test or a protocol client drives the same actions, so the game cannot tell them from a hand. The pointer (a mouse, or a finger on a touch screen) is actions too. Its buttons are keys, bound like any key, and a finger is `"MouseLeft"`: `fire = ["Space", "MouseLeft"]`. Its place goes to the two actions the project names with `pointer` under `[input]`, each -1 to 1 across the frame. In frame units, the units of an entity with `Screen`: ```lua local x = (input.get(0, "aim_x") + 1) / 2 * 320 -- the frame's width local y = (input.get(0, "aim_y") + 1) / 2 * 180 -- its height ``` On a touch screen a game can follow two thumbs at once: each finger slot under `[input] fingers` is a part of the frame, and a finger that comes down in it drives that slot's three actions (its place and its press) until it lifts. They are read like any actions: `input.get(0, "move_x")`, `input.get(0, "move")`. A gamepad is bound in the same table: a button is a key, and a stick is an axis by its name alone, with a dead centre. The project file's `[input.keys]` lists every name: ```toml [input.keys] move_x = [{ negative = "A", positive = "D" }, "PadLeftX", { negative = "PadLeft", positive = "PadRight" }] jump = ["Space", "PadA"] ``` ```toml # Optional: the actions that drive the game's menus and controls, each one of the # `actions` under `[input]`, and each optional. `x` and `y` are axes that move the # focus (and a slider), `accept` uses the node with the focus, `back` goes back out of # a menu, and `press` is the pointer's button; the pointer's place is player 0's # `[input] pointer`. The game may play with the same actions. `[ui.theme]` gives the colours (0xRRGGBB) a usable node takes: `normal`, # `focus`, `pressed`, `off` and `locked`; one left out is not written. `start` names # the node a menu opens on, if it is shown then; left out, the highest. Only a game with this table, or with a `Node` in a scene, has the # interface's components. See Interface. [ui] # fit = 720 # Optional design height: screen-space drawing scales with the frame. x = "move_x" accept = "jump" start = "play" ``` ```toml # Optional: the picture. `size` is the frame in pixels, each side from 1 to 4096; one # world unit is one pixel, the origin is the bottom-left corner, x grows to the right # and y grows up. `background` is the colour behind everything, as 0xRRGGBB. Left # out: 960 by 540 and 0x15171c. A window may be any size: the frame keeps its shape, with the background beside it. # `filter` is how every picture is sampled when a sprite shows it at another size # than its own: "nearest" keeps pixels sharp, for pixel art; "linear" blends them. # Left out: "nearest". # `orientation` is how a phone holds the game: "landscape" or "portrait"; left out, # landscape when the written frame is wider than tall. `fit` is what the frame does on a # screen of another shape: "letterbox" (left out) keeps the frame's size and shape, with # background bars beside it; "fill" takes the screen's shape (on a phone its safe part), # keeping the height and growing the width, or keeping the width for a tall frame. # `frame.size()` reports that frame; anchored UI follows its edges and cameras see more. # A recording says the frame it was made in (`[input] frame`), so it comes to the same # checksum anywhere. [window] size = [960, 540] background = 0x15171c filter = "nearest" orientation = "landscape" fit = "letterbox" ``` ```toml # Optional: how the game is played over a network by rollback (docs/multiplayer.md; # the protocol's net.host, net.join and net.run). How many players it has is # [input] players, 2 to 8 for a network. `delay` is how many steps a player's input # waits before its step, 0 to 8; `window` how many steps may be played on predicted # input and so played again, 1 to 16; `sync_every` how many steps apart the peers # compare the world's checksum, 1 to 600. Left out: as written here. [net] delay = 2 window = 8 sync_every = 30 ``` ```toml # Optional: the keys that drive the actions when the game runs in a window (`frost dev`, # the player) or in a browser. A key is named by what a US keyboard prints on it: # "A" to "Z", "0" to "9", "Space", "Enter", "Tab", "Escape", "Left", "Right", "Up", # "Down", and the pointer's buttons "MouseLeft", "MouseRight", "MouseMiddle" (a finger # on a touch screen is "MouseLeft"). A gamepad is written the same way: its buttons # are "PadA", "PadB", "PadX", "PadY" (A at the bottom), "PadL1", "PadR1", "PadL2", # "PadR2", "PadSelect", "PadStart", "PadL3", "PadR3" (the sticks pressed), "PadUp", # "PadDown", "PadLeft", "PadRight", and a stick is an axis by its name alone: # "PadLeftX", "PadLeftY", "PadRightX", "PadRightY", with right and up as 1. A player's # pad is the one with the player's number. A key name alone is a button for player 0: 1 while the key is down. A table # is a button (`key`) or an axis (1 while `positive` is down, -1 while `negative` # is), for `player` (left out: player 0). A list of them binds the action for several # players on the one keyboard, or gives one player several keys for it: any of them # presses a button, and an axis is the sum of its bindings, held to -1 to 1. # # Optional, beside `actions`: the two actions that are told where the pointer is (the # mouse, or a finger): pointer = { x = "aim_x", y = "aim_y" }, for `player` (left out: # player 0). Each is an axis like any other: x is -1 at the frame's left edge and 1 at its right, y is -1 at the # bottom and 1 at the top, and a pointer outside the frame is at the nearest edge. In # frame units that is (x + 1) / 2 * width and (y + 1) / 2 * height. # # Optional: finger slots for a touch screen, up to 4, each a `region` and three declared # actions: fingers = [{ region = { x = -1, y = -1, w = 1, h = 2 }, x = "move_x", # y = "move_y", press = "move" }] (that region is the left half), for `player` (left out: # player 0). A region is in the units of the pointer's place: x, y its corner nearest -1, # -1, then its width and height, the whole frame being 2 by 2; the frame is the game's own, # as the pointer's is, and a finger over the bars beside it is at its nearest edge. A # finger that comes down takes the first free slot, in the list's order, whose region holds # its place (regions may overlap), and keeps it until it lifts, wherever it goes: the slot's # `x` and `y` hold its place, -1 to 1 like the pointer's, and `press` is 1 while it is down. # A finger in no free slot's region is no slot's. Slots are actions, so a recording, a test # and a protocol client play them as they play keys. The first finger is still also the # pointer with "MouseLeft": a menu under a slot's region sees both, so keep a game's buttons # out of its slots' regions, or read one of the two. # With `stick = 0.2` a slot's `x` and `y` are how far the thumb is from where it came # down, over that fraction of the frame's height, kept within a unit circle; lifted, both # are 0. A slot with no `x` and `y` is a button: `press` alone. # `shown = true` draws the slot: a disc with its `label` on it (left out: the name of its # `press` action), or a stick's ring and the knob that follows the thumb, resting in the # region's lower outer corner. A shown control is the size of a thumb, in points, inside # the screen's safe area, translucent at rest and brighter while pressed, and never over # a UI node that shows. It is part of the player's picture and of nothing else: no # entity, not in the world, a checksum or a shot. `while_hidden = "panel"` draws a slot # and gives it touches only while the node of that name is hidden, and `while_shown` only # while it shows (a title's START, the stick of the play under it). # `[input] controls = { color = 0xffffff, alpha = 0.35, size = 64 }` styles every slot: # `size` is a button's width in points, and `alpha = 0` hides them all. [input.keys] jump = "Space" move_x = [ { negative = "A", positive = "D" }, { player = 1, negative = "Left", positive = "Right" }, ] ``` --- Page: reference/ui.md # ui Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when building menus, buttons, sliders or HUD layout, changing focus, displaying text or loading fonts. | In a script | Does | | --- | --- | | `ui.measure("text", "style"?)` | Width and height in design units at Text.size 1, using the declared font style; omit style for the built-in font. Unknown styles are errors | | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Text` | `text` | text | `""` | What to write. `\n` starts a new line | | `Text` | `size` | whole number | 1 | World units to one font pixel: a glyph is 5 by 8 font pixels, the next starts 6 further on and the next line 10 down, so a line of n letters is `(6n - 1) * size` wide. Less than 1 is 1 | | `Text` | `color` | whole number | `0xffffff` | The colour as `0xRRGGBB` | | `Text` | `align` | number | 0.5 | Where `Transform.x` is along each line: 0 its left end, 0.5 its middle, 1 its right end | | `Text` | `layer` | whole number | 0 | Drawing order, shared with `Rect` and `Sprite` | | `Shadow` | `color` | whole number | `0x000000` | The colour of the copy of the entity's text drawn under it | | `Shadow` | `x` | number | 2 | How far right of the text the copy is drawn, in the text's units | | `Shadow` | `y` | number | -2 | How far up; below the text is negative | | `Font` | `style` | text | `""` | The text style the entity's `Text` is written in: a name under `[fonts]` in the project file. `""` is the built-in font | | `Wrap` | `w` | number | 0 | The entity's `Text` starts a new line before a word that would pass this width, in units. 0: it does not | | `Wrap` | `ellipsis` | true or false | false | Truncate each explicit line to `w` with `...` instead of wrapping; dots shorten when the width cannot fit them | ### Text One font is built in: 5 by 8 pixels a glyph, the printable ASCII characters, drawn for this engine (760 bytes). A character it does not have is drawn as `?`. It has one width for every glyph, 6 font pixels from one to the next, and lines are 10 apart. `size` is a whole number, and each line starts on a whole unit, so in a frame with one unit to a pixel every font pixel is a sharp square. This is enough for a score and a title. **A game's own fonts.** The project file names *text styles* under `[fonts]`: each is a size in pixels and one or more TrueType or OpenType files (`.ttf`, `.otf`). A `Text` on an entity that also has `Font = { style = "body" }` is written in that style: ```toml # game.toml [fonts] body = { files = ["fonts/Inter.ttf", "fonts/NotoSansSC.otf"], size = 24 } # a scene [greeting] Transform = { x = 160, y = 90 } Text = { text = "Hello, 你好" } Font = { style = "body" } ``` - Each character is drawn from the first file of the style that has it, so a second file adds an alphabet the first lacks. One that none has is the first file's sign for a missing glyph (often a box). - The style's `size` is the height of the font's em in pixels, 4 to 200, as in a drawing program. `Text.size` multiplies it and stays a whole number: 1 is the style as it is, sharp; 2 is the same glyphs drawn twice as large and blended. For large sharp letters make a second style at the larger size. - Letters have their own widths and pairs like `AV` close up (kerning). Lines are the font's own distance apart. `align`, `color`, `layer`, `Shadow`, `Opacity` and `Scale` work as for the built-in font, and each glyph stands on whole pixels. - Not here: joining letters (Arabic, Devanagari), right-to-left lines, emoji in colour, and marks that combine with the letter before them. - A glyph is drawn once, the first time a text shows it, and kept: a page of 512 by 512 pixels holds a few hundred letters at 24 pixels, and more pages are made as needed (1 MB each). A game that shows thousands of different large characters uses memory for each. - Fonts are the game's own files and ship with it. Never let a player or a server supply one: the reader (stb_truetype) trusts what a font file says about itself. - A game with no `[fonts]` is exported without any of this. ## Interface Menus and controls are entities in the scene file. An entity with a `Node` is a box; boxes sit in boxes; a `Button`, a `Slider`, a `Choice` or a `Toggle` on a node is used by a person, and a `Bar` shows a number. The engine lays the boxes out and drives them from input actions each step, before the scripts, which read what was pressed in that step. Set `[ui] fit = 720` to author the interface at a design height of 720. Layout, Anchor offsets, Node sizes, Stack/Grid spacing, and `ui.tree` use design units. Everything with `Screen` (including text, shapes and Slice borders without a Node) is drawn at frame height / 720 in both 2D and 3D. The pointer uses the same layout. Omit `fit` to keep pixel units. `frame.size()` still reports frame pixels. `local width, height = ui.measure("Hello", "body")` measures text in a declared font style, in design units at Text.size 1. Omit the style for the built-in pixel font. Multiply both results by Text.size for a larger text. Unknown styles are errors. `Wrap = { w = 240 }` wraps text; `Wrap = { w = 240, ellipsis = true }` truncates each explicit line with `...`, shortened further if even the dots cannot fit. | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Node` | `parent` | text | `""` | The node this one is in, by name. Empty: the frame | | `Node` | `w` | number | 0 | Its box's width. 0: that of its `Text`, or of what its `Stack` or `Grid` holds | | `Node` | `h` | number | 0 | Its box's height, the same way | | `Node` | `order` | whole number | 0 | Its turn in its stack or grid, lower first; equal ones go by name | | `Node` | `shown` | true or false | true | False hides it and every node in it | | `Node` | `focus` | true or false | true | False: keys and a gamepad cannot reach it, only the pointer | | `Node` | `min_w` | number | 0 | The least width of its box | | `Node` | `min_h` | number | 0 | The least height | | `Node` | `back` | text | `""` | The event sent, about this node, on back with the focus on or in it | | `Node` | `modal` | true or false | false | True: while shown, only nodes in it can be used | | `Node` | `locked` | true or false | false | True: it takes the focus and refuses to be used | | `Node` | `up` | text | `""` | The node, by name, the focus goes to going up. Empty: the rules say | | `Node` | `down` | text | `""` | Going down | | `Node` | `left` | text | `""` | Going left | | `Node` | `right` | text | `""` | Going right | | `Node` | `pointer` | true or false | true | False: the pointer goes through it, and a press on it is the game's | | `Anchor` | `x` | number | 0.5 | Which point of the node sits on the same point of what it is in: 0 left edges, 0.5 middles, 1 right edges | | `Anchor` | `y` | number | 0.5 | The same from the bottom: 0 bottom edges, 1 top edges | | `Anchor` | `dx` | number | 0 | Units right of there | | `Anchor` | `dy` | number | 0 | Units up from there | | `Anchor` | `stretch_x` | true or false | false | True: from the left edge of what it is in to the right, less `dx` at each end | | `Anchor` | `stretch_y` | true or false | false | The same from bottom to top, less `dy` at each end | | `Stack` | `dir` | text | `"down"` | Which way its nodes follow one another: `"down"`, `"up"`, `"right"` or `"left"` | | `Stack` | `gap` | number | 0 | The space between one and the next | | `Stack` | `pad` | number | 0 | The space kept clear inside its edges | | `Stack` | `align` | number | 0.5 | Where each sits across the stack: 0 left or bottom, 0.5 middle, 1 right or top | | `Grid` | `columns` | whole number | 2 | Cells in a row. They share the width equally | | `Grid` | `row` | number | 0 | A row's height | | `Grid` | `gap` | number | 0 | The space between cells, both ways | | `Grid` | `pad` | number | 0 | The space kept clear inside its edges | | `Button` | `event` | text | `""` | The event sent, about the button, when it is used | | `Button` | `off` | true or false | false | True: it cannot be used or take the focus | | `Slider` | `value` | number | 0 | Where it stands, `min` to `max` | | `Slider` | `min` | number | 0 | Its least value | | `Slider` | `max` | number | 1 | Its greatest | | `Slider` | `step` | number | 0.1 | How far apart its values are. 0: any value, and a key moves it a tenth of the way | | `Slider` | `event` | text | `""` | The event sent, with its new value, when a person moves it | | `Slider` | `fill` | text | `""` | A node, by name, kept as wide as the slider is full | | `Slider` | `label` | text | `""` | The entity, by name, whose `Text` reads the value, with the decimals of `step` | | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Choice` | `options` | text | `""` | What can be chosen, `\|` between: `"Low\|Medium\|High"` | | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Choice` | `index` | whole number | 0 | Which is chosen, from 0 | | `Choice` | `event` | text | `""` | The event sent, with the new `index`, when a person changes it | | `Choice` | `label` | text | `""` | The entity, by name, whose `Text` reads the chosen option. Empty: the choice's own `Text` | | `Toggle` | `on` | true or false | false | Whether it is on | | `Toggle` | `event` | text | `""` | The event sent, with the new `on`, when a person switches it | | `Toggle` | `mark` | text | `""` | A node, by name, shown only while it is on: a tick | | `Bar` | `value` | number | 0 | What it shows, `min` to `max` | | `Bar` | `min` | number | 0 | The value at which it is empty | | `Bar` | `max` | number | 1 | The value at which it is full | | `Bar` | `fill` | text | `""` | A node, by name, kept as wide as the bar is full | | `Inherit` | `alpha` | number | 1 | The interface's to write: what a node takes from those it is in. Multiplies its `Opacity`; 0 while hidden | | `Inherit` | `x` | number | 1 | Multiplies its `Scale.x` | | `Inherit` | `y` | number | 1 | Multiplies its `Scale.y` | - **Boxes.** A node's box has its middle on the node's `Transform` and is `w` by `h`. Its `Rect` or `Sprite` is drawn that size (with a `Slice`, a panel of any size): write the size once, in `Node`. A button's words are its own `Text`. An icon inside a box is a node of its own with the box as its `parent`. Give interface entities `Screen`, so the camera does not move them. - **Sizes nobody writes.** A node with a `Text` and no `w` or `h` is as big as its words are drawn (`Wrap = { w = 120 }` breaks them into lines), so an `Anchor` places it by its edges. A `Stack` or `Grid` with none is as big as what is shown in it. - **Where a node goes.** Where the `Stack` or `Grid` of what it is in puts it; else where its `Anchor` says; else where its `Transform` is. A node in nothing is anchored to the frame: `Anchor = { x = 1, y = 1, dx = -8, dy = -8 }` is eight units in from the top right corner. - **Stretching.** `Anchor = { stretch_x = true, dx = 8 }` makes a node as wide as what it is in, less eight units at each side; with `stretch_y` too it fills the box: a backdrop is a node in nothing with both, and `pointer = false` unless it should swallow presses. A node stretched across its stack fills it from pad to pad, those stretched along it share what the rest leave, and one in a grid fills its cell. - **Stacks and grids.** A stack puts its nodes one after another by their `order`, from the edge its direction leaves. Give each its `order` (1, 2, 3): a scene file's entities are kept by name, not as written. A grid fills rows from the top, left to right, each node in the middle of its cell. A node that is not shown takes no room. - **Showing and hiding.** `set(find("pause"), "Node", "shown", true)` shows a menu and everything in it. A node's `Opacity` and `Scale` are its children's too. What a script changes is laid out, and the focus given, at the end of that step. - **Focus.** One node that can be used has the focus. A direction moves it to the nearest node that way: one level with it first, else one no further to the side than ahead. With none, a node of a stack that runs that way goes round to the stack's other end, and any other stays. In a grid it goes along the row or the column, past cells that cannot be used, and leaves by an edge only for a node beyond it; coming back, it returns to the cell it left. Where these guess wrong, a node names its neighbour: `up`, `down`, `left`, `right`. A held direction counts again after 24 steps and then every 7. An axis counts past 0.5; a stick pushed both ways goes the way it is pushed further. - **Where it starts.** When nothing has the focus, the node that last had it among those usable now takes it: a screen shown again is where it was left. Else the `[ui]` `start` node, else the highest usable node, the leftmost of those level. `ui.focus(entity)` gives it to a node that can be used. - **Modal nodes.** While a node with `modal = true` is shown, only the nodes in it can be used. Of several, the one with the highest `order` has the interface. It opens as new each time; when it is hidden the focus is back where it was. - **Using a node.** The accept action uses the node with the focus: a button sends its event, a choice goes to its next option, a toggle switches. Left and right move a slider by its step and turn a choice; up and down still move the focus. The pointer gives the focus to the node it moves onto; a press takes hold of that node and letting go on it uses it, so sliding off first cancels. A pressed slider follows the pointer until it lets go. The pointer finds only nodes with `Screen`. A node with `locked = true` takes the focus and is not used: `ui_locked` is sent about it instead. An `off` button is not there at all. - **A press on the interface is the interface's.** When the pointer's press begins on a shown node's box (any with a `w` and an `h`), or anywhere while a modal node is shown, scripts read the `[ui]` `press` action as 0 until it is let go. - **Bars.** A `Bar` is a slider nobody moves: a script sets its `value` and its `fill` node follows, hidden when the bar is empty. A fill with an `Anchor.dx` keeps that much clear at both ends. - **Events.** A use sends the event the node names, about the node, and scripts read it in the same step with `events`. A slider's event carries its value, a choice's its index and a toggle's whether it is on. `ui_moved` is the engine's: about the node a person just moved the focus to. A script that sets a `value`, an `index` or an `on` sends nothing. - **Going back.** The back action sends the event named by the `back` of the node with the focus, else of the nearest node it is in that names one, about that node: give a menu `back = "closed"` and every control in it goes back the same way. With none, `ui_back` is sent about the node with the focus. - **Colours.** With a `[ui.theme]`, a usable node takes the colour of its state each step: in its `Rect.color`, else its `Sprite.tint`, else its `Text.color`. - **Errors** are `E1301` to `E1306`. `E1306`: a tween cannot move the `Transform` of a node the interface places; tween its `Anchor.dx`, `Scale` or `Opacity`. A menu in the middle of the frame, in a scene file: ```toml [menu] Transform = {} Screen = {} Node = {} Anchor = {} Stack = { gap = 4 } [start] Transform = {} Screen = {} Node = { parent = "menu", w = 120, h = 28 } Rect = { color = 0x334455, layer = 10 } Text = { text = "START", layer = 11 } Button = { event = "start" } ``` ```toml # Optional: text styles, which a text is written in with `Font = { style = "body" }` # beside its `Text`. A style is a size in pixels (4 to 200) and one to eight TrueType or # OpenType files; each character is drawn from the first that has it. The files ship # with the game. Left out: every text is in the built-in pixel font. See Text. [fonts] body = { files = ["fonts/Inter.ttf", "fonts/NotoSansSC.otf"], size = 24 } title = { files = ["fonts/Inter.ttf"], size = 64 } ``` ```toml [ui.theme] focus = 0xf2a53b ``` --- Page: reference/state.md # state Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when saving progress, keeping script state, recording a playthrough, restoring snapshots or checking replay determinism. | In a script | Does | | --- | --- | | `state` | The script's own table. It survives a reload and is saved with the world; see below | | `keeps_things({ "path", ... })` | Says which numbers the script keeps in `state` are things, at its top level: each a path of keys with a dot between, `*` for any key (`keeps_things { "hero", "bits.*.e" }`). A test of a change (`copy.land`, `change.test`) then holds such a number to the same thing, by name, however a thing added to the scene moved it, and any other kept number to the same number. Keeps nothing and moves no checksum. Called anywhere else, it is an error | | `function on_restore()` | Defined by the script, if it keeps a cache. Called before it next runs when the game was put back to another moment; see `state` | | `save.get("slot")`, `save.set("slot", table)`, `save.delete("slot")`, `save.slots()` | What a game keeps between runs | ### `state` `state` is where a script keeps what must outlive a step and is not a component: counters, timers, a list of entities. At the end of every step the host copies it into the world, so it is part of every snapshot and of the checksum, a protocol client can read it (`script.state`), and a world that is rolled back hands the script its old `state` again before the next step. What a game is belongs in the world or in `state`, and nowhere else. A `local` at the top of a script is a cache: it is not saved, not in the checksum, and empty again after a reload, so keep there only what can be built again from the world and `state` (a lookup table, a list of entities found with `each`), and build it in `on_scene` or when it is first needed. `state` costs every step for what it holds: the engine walks it at the end of each step to keep the world's copy exact (about 50 ns an entry on a fast desktop), so a big table that never changes, such as the handles of 900 pieces laid once, is cheaper in such a `local`, built again in `on_scene` and `on_restore`. When the game is put back to another moment (`game.restore`, `game.try`, a seek, a rollback) `state` comes back as it was then, its tables new ones, and such a `local` still holds what it had in the future the game came back from. A script that defines `on_restore()` has it called once, before it next runs, after every such put back (and after a reload that failed and put `state` back): empty its caches there (`cache = nil`, `table.clear(seen)`) and they are built again when next needed. It must change nothing of the game, only what a `local` keeps; `frost test --restore` finds one that does. A `local` that `on_restore` empties is a cache to `frost check`, which does not warn of it. So `state` holds only what can be stored: numbers, strings, true and false, and tables of those with numbers or strings as keys. Anything else is refused at the end of the step that put it there, with the error `E0307` naming the place: a function, a coroutine, a buffer, a vector, a table with a metatable, a table that holds itself or nests deeper than 32, a string that is not UTF-8. A table reachable by two paths is stored once for each. Read as JSON (`script.state`, `frost run --state`), a table with keys 1 to n is a list and any other table an object; a table with nothing in it is always `{}`, never `[]`, so a reader of a list that may be empty accepts both. An entity kept in `state` is its number: `generation * 4294967296 + index`, where the protocol writes the same entity `eINDEX.GENERATION` (`4294967299` is `e3.1`). It is always a whole number below 2^53, so JSON and every language that reads it keep it exactly. ### Saves `save.set("profile", { best = 120 })` replaces a slot's table, kept between runs; `save.get("profile")` returns a copy or nil; `save.delete` empties a slot; `save.slots()` lists the names. A save holds numbers, strings, true and false, and tables of those, gaps too (`{ [3] = 41.5 }`); a number key is whole. A component's number is a 32-bit float: 0.4 saves as 0.4000000059604645. A slot's name is a to z, digits, `-` and `_`; a slot is at most 64 KB as TOML, a game at most 32 slots. A shipped game keeps its slots in the player's data folder, or a browser's `localStorage`, under the project's `id`; `frost dev`, in `saves/` by the project. A changed slot is written once, after its step. Saves are input, not in the world or the checksum: `frost run`, `frost test`, `frost check` and replays start from the `saves` their recording declares, or none, and write nothing. Read a save in `on_scene`: a script's top runs again on a reload. ```toml # Optional: the frames the game is judged by. Each is the picture after `step` fixed # steps of the recorded input, kept as `shots/NAME.png` beside this file; a name is # letters, digits, `-` and `_`. `frost check --shots` takes them again and says which # changed. `frost test --write` takes a shot's first picture when none is kept; a kept # one only `frost check --shots --write-shots` writes over. With `overlay = "physics"` a shot has every collider, joint and contact # drawn over it (as `frame.capture` draws them): a picture of what collides. shots = [{ name = "title", step = 60 }, { name = "mid-level", step = 1960 }] # Optional: what the recorded game comes to. `frost test` plays the recording for `steps` # steps and requires this checksum: 16 hex digits that sum the whole run, the world # before the first step and after every one. `frost test --write` writes it, and beside # it `checkpoints`: the same sum at every 256th step and at each step a scene started, # so a test that fails says between which two the game first went another way. Write # neither by hand. With no `checkpoints`, `checksum` is the world's own after the last # step, as `frost run` prints it: all an older project says, and all it is held to. # Left out: the game has no recorded run, and `frost test` says so (`no recorded run`, # `state: "no_replay"` with `--json`): it has not passed, and nothing failed. replay = { steps = 3509, checksum = "89573f90dd5c32f7" } checkpoints = [[256, "0f5c1d2e3a4b5c6d"], [512, "7e8f9a0b1c2d3e4f"]] ``` ```toml [input] actions = ["move_x", "jump"] # the names scripts read input by players = 2 # how many players have input, 1 to 16. Left out: 1 # Optional recorded input. Each stretch lasts `steps` fixed steps and holds the listed # actions at the given values, from -1 to 1; an action left out is at rest (0). # `player` says whose input it is; left out, player 0. Each player's stretches are # played in the order written, one after another, from step 0, alongside the other # players'. After a player's last stretch that player's actions are at rest. # To replay binding hints, player = { id = 0, device = "pad" } selects pad labels; # a numeric or omitted player selects keyboard labels. The last device stays held. # `input.history` returns a played session in exactly this form. recording = [ { steps = 20 }, { steps = 55, move_x = 1.0 }, { steps = 2, move_x = 1.0, jump = 1.0 }, { player = 1, steps = 77, move_x = -1.0 }, ] # Optional: the saves the recording starts from, each slot with its table. saves = { profile = { best = 120 } } # Optional: the frame the recording was made in, when that is not `[window] size` (a game # that fills, played on a phone): it is replayed in that frame, and `input.history` writes # it. Left out: `[window] size`. frame = [1060, 540] # Or the name of a file that holds those keys and nothing else, as `input.history` # returns it: recording = "run.toml". It is read when the game is first stepped on # its recording (`frost run`, a test) and by `frost check`; a window or a web page plays # live input and never reads it, and an export does not copy it. ``` --- Page: reference/event-flow.md # event-flow Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when sending or reading gameplay events, handling contacts, sensors or the order events reach scripts. | In a script | Does | | --- | --- | | `send("event", entity?, value?)` | Queues a world event. A number is sent as a 32-bit float | | `events("event")` | The queued events of that name, each `{ entity = ..., value = ... }`, and `other` for an event between two entities (see Physics) | | `events("contact")`, `events("contact_end")` | Two colliders began or stopped touching this step, one or both on a dynamic body: `{ entity, other }` | | `events("sensor_enter")`, `events("sensor_exit")` | Something came into or left a sensor: `entity` is the sensor, `other` the visitor. A static collider or a tilemap is no visitor unless the sensor's `senses` is `"all"` | - **Order.** Events come sorted by kind, then by the two entities' slots, `entity` being the lower slot for a contact; a list from `physics.overlap` is in slot order. The same game gives the same events in the same order on every machine and in a browser. --- Page: reference/project.md # project Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when editing game.toml or scene files, declaring custom components, loading assets or sharing scene content. | In a script | Does | | --- | --- | | `stream.loaded(x, z)` | Whether the cell at this world position is fully resident; false without streaming. In 2D use x/y. Finite coordinates required (E0577) | | `stream.hold(x, z, on?)` | Hold the cell at a world position at the next step boundary; false releases, omitted means true. Holds are booleans, not counted; unknown cell is E0579. See project streaming | ## The project file `game.toml` is everything about a game that is not a scene or a script. Every key, with what it means: ```toml # Paths are relative to the folder the project file is in. scene = "demo.toml" # required: the scene to load space = "2d" # or "3d" for a 3D game (see 3D). Left out: "2d" scripts = ["demo.luau"] # Luau scripts, stepped in this order # A saved test (a copy of a project file with its own recording) says which game it tests: # `frost test --write` writes it. It plays nothing differently. Left out: the folder's game.toml. # test_of = "game.toml" # Optional: more scenes, which a script starts with scene.load("level2.toml"). `scene` # itself can be loaded the same way, to start it again. scenes = ["level2.toml"] # What the game's saves are kept under on a player's machine: 1 to 64 of a to z, digits, # `-`, `_` and `.`. Changing it orphans players' saves. Left out: an export warns # and uses the folder's name. id = "com.example.demo" # A scene file may begin with `include = ["common.toml"]`: it starts with those # scenes' entities (paths from this folder), then adds its own. A name written in # both is an error (E0106), and an included scene includes nothing itself (E0426). # Optional: Luau files the scripts share. A script takes one in by the path written # here: local kit = library("lib/kit.luau"). libraries = ["lib/kit.luau"] # Optional: TOML files of values the scripts read, a level or a list of waves, each as # a new plain table: local level = data("levels/one.toml"). Read when the game loads; # a change starts the game again. A date, or an integer past 2^53, is E0408. data = ["levels/one.toml"] title = "Held Note" # optional: the game's name, on its window, tab and exported program seed = 0 # where `math.random` starts: 0 to 4294967295. Left out: 0 # Pictures (PNG files) to load besides those the scene's sprites name: the ones only # a script puts in a `Sprite.image`. A sprite can show loaded pictures only. images = ["art/coin.png"] # Models (.glb, .gltf) only a script puts in a `Mesh.file`, loaded with the game. models = ["kit/drum.glb"] ``` ```toml # Optional: the sounds scripts play, each a WAV or Ogg Vorbis file named by its path # from this file. A script names a sound by the same path: sound.play("sfx/hit.wav"). # With [web], a sound over 3 minutes is a warning (W0437): a browser holds it whole, # 21 MB a stereo minute. sounds = ["sfx/hit.wav", "music/theme.ogg"] ``` ```toml # Optional: the numbers the game is tuned by. A script reads `tuning.jump`; a name the # project does not have is an error in a script, not nil, and a script cannot write one. # An entry is a number, or a table with `value` and any of `min` and `max` (a value set # outside them is E0435) and `step` (how far apart the values worth trying are). # `frost run --set tuning.jump=300` and the protocol's `tuning.set` change one without # touching a file. A value set stays set through a reset and a seek, which load the game # with it in place, so a script that copies it as it loads (`local JUMP = tuning.jump`) # reads the one set; set while the game runs, it reaches such a copy at the next load. # The values are not in the checksum; `input.history` lists every one set, with its step. [tuning] jump = { value = 280, min = 100, max = 500, step = 20 } gravity = 900 ``` ```toml # The game's own components: a name and its fields with their defaults. The default # fixes the field's type, as in a scene: 0.0 is a number, 0 a whole number, true or # false a boolean, "" a string. For f64/u32 see Numbers; wrappers also fit `value`. `{ color = 0xRRGGBB }` is a whole number that an # editor shows as a colour. `{ entity = "" }` is a string that names an entity: an editor picks one, and `frost check` warns of a scene where it names none (W0436). `{ value = 0.5, min = 0, max = 1, step = 0.1 }` is a number with the # range it is meant to stay in (`step` is optional): an editor makes it a slider and # `frost check` warns of a scene that leaves it (W0427); a script may write any value. The engine declares its own (`Transform`, `Sprite` and the rest of this page). # An editor shows the `#` lines above a component, or a field under # `[components.Player]`; nothing checks them. [components] Player = { vy = 0.0, grounded = false, glow = { color = 0xffec27 }, health = { value = 3, min = 0, max = 5 } } Note = {} ``` ```toml # Optional: levels of detail and the far cut, the picture's alone (no checksum moves). A # model `x.glb` with `x.lod1.glb` and `x.lod2.glb` beside it (either may be left out: the # nearest present is drawn) is drawn at level 1 below the first of `sizes` (parts of the # picture's height, by its box at rest) and level 2 below the second (left out: 0.25 and # 0.08). Nothing pops: within `band` either way of a size (a part of it; left out 0.10; # 0 changes level at once) both levels are drawn, each through a screen door that keeps # its share of the pixels; shadows and ambient occlusion draw both whole. Nothing farther than `far` metres from the eye is drawn, nor its shadow, nor what # it holds (0, or left out: no cut), each faded out through the door over the last tenth. # A rigged level must have its model's joints (E0491); `frost check` says (W0462) of a level # painted with other materials than its model. the engine's `lods` example is its game. [lods] sizes = [0.25, 0.08] far = 120 band = 0.10 ``` A file whose top-level `scene` key is not a table is a project. Any other file is a bare scene: it is loaded with no scripts, no input actions and no components of its own. Every game has parts of the engine's own besides those above: what a thing is under, what turns at a steady rate, and in a 3D game what follows another (a third-person camera), and how its model is posed. | Component | Field | Type | Default | Meaning | | --- | --- | --- | --- | --- | | `Parent` | `of` | text | `""` | The name of the entity it is under. Under one with a `Transform` its own `Transform` is local to that one's; under a group (a named entity with no `Transform`) or nothing, in the world. Despawning that entity despawns this one. The tree shows siblings in the order the scene writes them; scripts walk things in the order they were made, and what is drawn over what is `layer`'s to say, never the tree's. Where it is in the world is drawn, picked, looked from (a `Camera` under a parent), heard (`sound.play` at it) and read by `placed` and world.entities; `get` reads its own fields. Under a parent flipped by a negative scale its turn is mirrored too. A `Collider` with no `Body` is held there too, moved and turned with its parents each step (its size is not scaled). A `Body`, `Mover` or UI `Node` under a thing with a `Transform` is refused, by the scene and at the next step after a script or an edit puts it there | | `Tags` | `list` | text | `""` | The words, apart by commas or spaces: `"pushable, heavy"`. A tag is one whole word of it | ### Streaming cells A project may add one grid, active in every scene: ```toml [stream] folder = "cells" cells = ["0_0.toml", "1_0.toml"] # explicit finite manifest; missing files are errors size = 64 # world units, positive load = 1 # square radius in cells, default 1 drop = 2 # hysteresis radius, >= load, default 2 followers = ["hero"] # union; omitted/empty: lowest placed Camera budget = 256 # things entered per step, default 256 ``` Each cell is an ordinary scene with globally unique thing names and world coordinates. `X_Z.toml` names its signed grid coordinate (X_Y in 2D); floor(position/size) selects it, including negative positions. Only listed cells exist; gaps are empty world. Cell files cannot include scenes. Each cell's things must fit the budget; split a larger cell or raise it. Connected things (Parent, Joint, Node) belong in the base scene in this version. Cell assets follow the existing scene cook; cell text and assets are read at game load, including on the web. This version bounds live things and bodies, not asset memory or I/O. After input, before physics, cells enter in coordinate order, static things before bodies, names sorted within each group. A whole cell enters or waits for the next step's budget. Physics waits while any requested cell is pending; scripts still run and may gate travel on `stream.loaded`. An initial scene has no cells until step 1. Followers are read at the start of the step, so script movement affects the next boundary. Missing followers fail (E0577); keep them in the base scene. A teleport may show queued cells for several steps. Changes and deletions of owned things are kept when their cell drops, including Body velocities. Dormant bodies do not simulate; re-entry rebuilds their physics from those fields (solver contacts and sleeping timers start fresh). A thing crossing its cell's boundary becomes world-owned permanently, never duplicated on re-entry. Its current cell and immediate neighbours stay required, even off camera. Script-spawned things are always world-owned. Crossing the finite manifest's edge has no ground guarantee. Ground geometry must cover the cell and bodies must fit the loaded margin; choose radii for their speed. `cell.enter` and `cell.leave` are ordinary events with the string `"X,Z"` as `value`, no entity, visible to scripts in that step. Enter means all rows exist; leave means they have been saved and removed. Use `find` again after re-entry: old entity handles are dead. `stream.loaded(x,z)` queries residency; `stream.hold(x,z,on?)` keeps/releases a cell. C#: `Scene.Loaded`, `Scene.Hold`, and `Events.Count`/`Events.At` read the same events. Holds, ownership and deltas are in world state: replay, snapshots and moments preserve them. `scene.load` resets them with the world. `stream.read` reports that state; the `stream` profiler span times the boundary, `stream.cells` and `stream.entered` count work. Errors: E0576 invalid grid/cell content (fix the named file); E0577 absent/unplaced follower or nonfinite/out-of-range position (keep followers placed inside the grid); E0578 a name collision at entry (use unique spawned names); E0579 holding an undeclared cell (add it to the manifest). Ordinary scene/type/file errors retain their existing codes. --- Page: reference/render.md # render Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when configuring bloom, materials, frame graphs or effects, or diagnosing rendering such as why a pixel is dark. ```toml # Optional frame graph. Omitted: all layers into `frame` in 2D; sky if present, # meshes, then layers in 3D. Named `targets`: `format` "rgba8" (default), "rgba16f" # or "depth"; `size` "frame" (default), "frame/N" (N 2..16), or a pixel side length. # Each named pass writes `into` a target (default `frame`) and either draws or runs # an effect on its `read` targets. Draws: "layers", from `from` to `to` inclusive # (default all); in 3D, "meshes" (lit, tested against its `depth` target) or "sky" # (the world's Sky over the target; put before meshes). First writes clear; work # never reaching `frame` is dropped. `render.passes` lists the running graph. # Effects: "copy"; "bright", above `threshold` (0.6); "blur"; "add", second target # added `strength` times (1) to first (float targets keep values above 1); "panini", distance `strength` (0 none), # bending a wide 3D view to fill, keeping its middle. A `Pass` sets numbers each frame. # `bright` into rgba16f keeps radiance above a nonnegative threshold, including 1. # Into rgba8 its threshold must be below 1; it normalizes by (1 - threshold). # "aces": exposure `strength` (default 1, nonpositive 0), then ACES fitted curve, # then sRGB. Requesting it enables linear mesh/sky output above 1 into rgba16f, # including emission, fog and blending. Without it, existing graphs stay unchanged. # Draw sky/meshes into rgba16f, read that with aces, draw layers afterward (UI/text # unchanged): the engine's torch/tonemap.toml. example WebGL2 needs renderable/filterable/blendable # half-float support (E0208 otherwise). frame.at names presentation unread. # `materials` (3D, alone or with passes): `vertex` and/or `fragment` WGSL files for # Mesh (see Meshes). `bloom = { threshold = 0.85, strength = 1.5 }` (defaults; alone # or with materials) softens brightness above threshold (0..1), adding it strength # times. Generated passes `bright`, `soften`, `bloom` accept Pass numbers. All 2D # blooms; in 3D, sky/meshes bloom, overlay layers do not. Custom passes cannot use # this shorthand: place bright/blur/add there yourself. # `ao = { radius = 1, strength = 1 }` (defaults; 3D, alone or with any of the above, # custom passes included): ambient occlusion. Where surfaces within `radius` metres # (0..100] close a point in (a corner, a crate on a floor), the ambient light and the # sky a metal mirrors darken, up to `strength` (0..1). Sun, lamps, shadows, emission # and layers are untouched. It adds passes `ao_seen`, `ao_occlude` (a Pass sets radius # and strength) and `ao_soften` before the first meshes pass, with targets `ao`, # `ao_distance`, `ao_depth`, `ao_rough`. Fixed sample pattern: no shimmer, one picture # every run. Screen-space: what is hidden or off screen shades nothing; see-through and # masked parts shade nothing. frame.at names it unread. See the engine's ao. example # `effects` (up to 8): `name = { file = "x.wgsl", reads = 1 }` (1 or 2). The file's # `fn effect(at: vec2, size: vec2, threshold: f32, strength: f32) -> vec4` # returns colour at pixel centre `at` in target `size` (pixels), in the target's encoding. # Read helpers: one(px), two(px) (whole pixels, same bytes across backends), # under_one(at), under_two(at), one_size(), one_soft(uv), two_soft(uv) (between pixels), # lens(). No clock: animate via Pass numbers. Start from the engine's functions # in crates/frost_gfx/src/effects/. Compilation errors name file/line (E0456). [render] # Optional: msaa = 4 (default 1); sky/meshes first, resolve before effects/UI. # A smoothed edge's pixel may be one level off in WebGL2 (its own rounding). # cull = true and samplers = true follow glTF sides and filters (both default false). # HDR resolves rgba16f before aces, then UI; see the engine's edges/tonemap.toml. example targets = { scene = {}, glow = { size = "frame/4" }, soft = { size = "frame/4" } } passes = [ { name = "world", draw = "layers", to = 99, into = "scene" }, { name = "bright", effect = "bright", read = ["scene"], into = "glow" }, { name = "soften", effect = "blur", read = ["glow"], into = "soft" }, { name = "bloom", effect = "add", read = ["scene", "soft"] }, { name = "ui", draw = "layers", from = 100 }, ] ``` --- Page: reference/csharp.md # csharp Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when writing gameplay in C#, checking Luau API parity or preparing the .NET tools and platform build. # Writing a game in C# A game's scripts can be C# as well as Luau: a script whose name ends in `.cs` is compiled by the .NET SDK on the machine (version 10 or later) and run by the .NET runtime inside `frost`. It is for `frost` with C#: Coldwave's download whose name ends in `-csharp`, or a `frost` built with its `dotnet` feature (`cargo build -p frost_cli --features dotnet`). A game in C# is exported to the desktop with its scripts compiled ahead of time (below); the web does not run C#. the engine's `csharp/vigil` example is the arena template, Vigil, written in C#: played on its recording it is the Luau Vigil to the bit at every step, but for what each script keeps. the engine's `csharp/embers` example is Embers, the 3D template, the same way: a mover on Jolt, sensors, chasers, the interface and the engine's `Follow` camera, with no camera code in either language. An angle kept from 0 to 360 is `a - Math.Floor(a / 360) * 360` in C#, Luau's `%`: C#'s `%` keeps the sign of `a`. ## A script ```csharp using Ven; [State] // the one struct the script keeps between steps public struct Game { public int Score; public Thing Hero; // a thing of the game, or Thing.None } public static class Main { public static void OnScene(string scene, ref Game game) { game.Hero = World.Spawn("Transform", "Sprite", name: "hero"); World.Set(game.Hero, "Sprite", "image", "art/hero.png"); } public static void Step(float dt, TransformColumns transform, ref Game game) { int row = transform.Row(game.Hero); if (row >= 0) transform.X[row] += Input.Get(0, "move_x") * 90 * dt; if (Input.Held(0, "fire")) Sound.Play("sounds/pew.wav", vary: 0.1); } } ``` `Step` takes the components it walks as columns: each is lent the world's own memory for the length of the step, a span per number or true-or-false field (`transform.X[row]`), with `Rows`, `Thing(row)` (the thing at a row), `Row(thing)` (a thing's row, -1 for none) and `Slot`/`Row(slot)` to join two components. That is Luau's `each`, `has`, `get` and `set` as reads of memory, and the fast path. Everything else is a call: the table below. Custom `{ f64 = 0.0 }` fields lend `Span` columns; `{ u32 = 0 }` lends `Span`. `World.Get` and `World.Set` carry both through a double without rounding. Snapshots preserve bits; as with f32, equality and checksums canonicalize NaNs while distinguishing signed zeros. The struct marked `[State]` is in the world under the script's name, as Luau's `state` is: in the checksum, in a snapshot, read by `script.state`. It holds `bool`, `int`, `uint`, `float`, `double` and `Thing` fields. A `static` field is the script's own and is not saved, as a Luau `local` is not: `frost test --restore` finds one that changes the game. ## Writes are done when the step returns The columns a step holds are the world's own memory, so nothing changes the world's shape while it runs. A call reads the world as it is; what a call changes (`Set`, `Spawn`, `Despawn`, `Send`, `Tween`, `Place`, `Ui.Focus`, `Scene.Load`) is done when the script's `Step` (or `OnScene`) returns, in the order it was asked, before the next script steps. The world then goes through the same changes in the same order as the same calls in Luau, so it reaches the same slots and the same checksum (`tests/csharp_api.rs` plays one game in both for 240 steps and holds the two worlds equal at every step). What that means: - A thing `World.Spawn` makes is a thing to come: `Set`, `Despawn`, `Tween` and `Send` take it, and the `[State]` struct holds it as the thing it became. Columns do not have it until the next step (`Row` gives -1), and `Get` and `Has` refuse it. - `World.Get` reads the world as the step found it, with what the step's spans wrote; a `World.Set` earlier in the step is not seen yet. - A Luau loop over `each` after a `spawn` finds the new thing; a C# loop over a column does not. Make things after walking the ones there are. `Bone` overrides use ordinary generated columns or `World.Set`. `World.Bone`, `World.Placed`, `Screen.Project` and `Screen.Ray` include queued writes from this step; other reads retain their documented column semantics. Spatial reads currently copy the world when writes are pending. A number written to a whole-number field must be whole; a call that cannot be done throws `Ven.EngineError` with the engine's sentence, and the step stops with `E0302` on the script's own line and column (`frost` compiles scripts without the optimiser so that the line is right). ## The API against Luau's Every call a Luau script has, and what a C# script calls for it. `tests/csharp_parity.rs` holds this table to both sides: it fails when Luau gains a call this table lacks, or C# gains one (a public method of `World`, `Input`, `Events`, `Sound`, `Net`, `Music`, `Scene`, `Frame`, `Screen`, `Tuning`, `Quat`, `Ui`, `Physics`, `Save` or `Data`) that no row names. A component's fields are no calls: a field (`Mesh.roughness`, a 3D thing's `Opacity.alpha`) is read and written by `World.Get` and `World.Set` as Luau's `get` and `set` do, so it needs no row. The call numbers keep `World.Emit` at 52; `NetHost`, `NetJoin`, `NetCancel`, `NetState` and `NetPlayer` are 53, 54, 55, 56 and 57. `Bone`, `ScreenProject` and `ScreenRay` are 58, 59 and 60. `COUNT` and the Rust `OPS` table's length are 63. `StreamLoaded` and `StreamHold` are 61 and 62. | Luau | C# | | --- | --- | | `step` | `Step(float dt, ...)` | | `state` | the `[State]` struct | | `keeps_things` | a `Thing` field of the `[State]` struct: its type says it is a thing | | `on_scene` | `OnScene(string scene, ref State state)` | | `on_restore` | `OnRestore()`, called before the next step after the game was put back: empty a static cache there | | `find` | `World.Find` | | `get` | `World.Get`, `World.GetBool`, `World.GetText`; a column's span | | `set` | `World.Set`; a column's span | | `has` | `World.Has`; a column's `Row(thing) >= 0` | | `each` | a component's columns: `Rows`, `Thing(row)` | | `spawn` | `World.Spawn` | | `despawn` | `World.Despawn` | | `emit` | `World.Emit` | | `send` | `World.Send` | | `events` | `Events.Count`, `Events.At` | | `tween` | `World.Tween` | | `place` | `World.Place` | | `placed` | `World.Placed` | | `bone` | `World.Bone` | | `screen.project` | `Screen.Project` | | `screen.ray` | `Screen.Ray` | | `print` | `World.Print` | | `tuning` | `Tuning.Get` | | `library` | a `.cs` file under the project's `libraries`, compiled into every C# script: its classes are the script's | | `data` | `Data.Get`, a `Table` | | `math.random` | `World.Random` | | `math.roundeven` | C#'s own Math.Round(x, MidpointRounding.ToEven) | | `bit32.mul` | C#'s own unchecked((int)(a * b)) | | `input.get` | `Input.Get` | | `input.held` | `Input.Held` | | `input.keys` | `Input.Keys` | | `sound.play` | `Sound.Play` (its `near` and `far` too, by name) | | `sound.volume` | `Sound.Volume` | | `sound.effects` | `Sound.Effects` | | `music.play` | `Music.Play` | | `music.stop` | `Music.Stop` | | `music.pause` | `Music.Pause` | | `music.resume` | `Music.Resume` | | `music.volume` | `Music.Volume` | | `net.host` | `Net.Host` | | `net.join` | `Net.Join` | | `net.cancel` | `Net.Cancel` | | `net.state` | `Net.State`, a `NetState` (`Player` -1 while unknown) | | `net.player` | `Net.Player`, -1 while unknown | | `stream.loaded` | `Scene.Loaded` | | `stream.hold` | `Scene.Hold` | | `scene.load` | `Scene.Load` | | `scene.name` | `Scene.Name` | | `frame.size` | `Frame.Size` | | `ui.focus` | `Ui.Focus` | | `ui.measure` | `Ui.Measure` | | `quat.turn` | `Quat.Turn` | | `quat.look` | `Quat.Look` | | `quat.mul` | `Quat.Mul` | | `quat.slerp` | `Quat.Slerp` | | `quat.rotate` | `Quat.Rotate` | | `save.get` | `Save.Get`, a `Table` or null | | `save.set` | `Save.Set` | | `save.delete` | `Save.Delete` | | `save.slots` | `Save.Slots` | | `physics.ray` | `Physics.Ray` | | `physics.cast` | `Physics.Cast` | | `physics.overlap` | `Physics.Overlap` | | `physics.ground` | `Physics.Ground` | | `physics.mass` | `Physics.Mass` | | `physics.wheels` | `Physics.Wheels` | | `ground.at` | `Ground.At` | | `physics.impulse` | `Physics.Impulse` | | `physics.force` | `Physics.Force` | | `physics.pause` | `Physics.Pause` | | `physics.paused` | `Physics.Paused` | A `Table` is a Luau table as C# holds one: flat, each value under its path, the keys on the way with a `.` between, so `level.waves[1].count` in Luau is `Data.Get("levels/one.toml").Number("waves.1.count")` in C#, and `Count("waves")` is `#level.waves`. `new Table().Set("best", 120)` is what `Save.Set` keeps; a table of tables is written the same way (`Set("best.time", 31.5)`). What reads the machine's clock or draws chance of its own is refused as the script compiles (`VEN105`, in `E0309`): `DateTime.Now`, `UtcNow` and `Today` (and `DateTimeOffset`'s), `Environment.TickCount`, a `Stopwatch`, `new Random()` with no seed, `Random.Shared` and `Guid.NewGuid()`. A game reads nothing but its inputs, so that a replay, a rollback and another player's machine play it the same: time is the steps, and the `dt` each `Step` is given; chance is `World.Random`. A `Random` with a seed is the script's to use. Luau's `%` is floored and C#'s is not: `-30 % 360` is 330 in Luau and -30 in C#. An angle kept from 0 to 360 is `a - Math.Floor(a / 360) * 360` in C# to give Luau's bits. A model's clip is a field like any: Luau plays one with `set(arm, "Pose", "clip", "lift")` and asks which plays with `get(arm, "Pose", "clip")`; C# with `World.Set(arm, "Pose", "clip", "lift")` and `World.GetText(arm, "Pose", "clip")` (or the `Pose` columns' spans). Luau's `math` (sine and its kin, `pow`, `log`) is `Maths` in C#, the same bits on every machine; `System.Math.Sin` and its kin are refused (`VEN104`), because they give other answers on other machines. ## Saving, errors, the debugger - Saving a `.cs` file under `frost dev` swaps the code and keeps the world and the `[State]` struct; code that does not compile is refused (`E0309`, with its line) and the old code runs on. - `frost check` writes a project a C# language server is started on (`game.info`'s `csharp.solution`). - `World.Print` lines carry the file and line of the call, a script's or a library's, as Luau's `print` does (`log.since`); an error in a C# library names the library's file and line; `game.info`'s `csharp.scripts` says of each script `ahead` or `runtime`. - `frost dap` debugs a game in C# with the person's own netcoredbg (on the path, or named by `FROST_NETCOREDBG`; `frost` installs none): it starts the engine as for Luau, attaches netcoredbg to it and hands it the editor's requests. Breakpoints go in the game's own `.cs` files (the compiled script's symbols name them), and a stop shows .NET's threads, stack, locals and expressions. A game in both Luau and C# is refused. netcoredbg's own command line (`--interpreter=cli`) waits for ever on any expression that reads a frame (`print dt`, `print v.T`) at such a stop, where `print 1+2` answers: use an editor, or `frost dap`. ## Shipping a game in C# `frost export desktop GAME.toml --out DIR` compiles a game's C# scripts ahead of time, with .NET's own Native AOT, into one native library beside the game (`game/csharp/scripts.dylib`), which the exported player opens: the person who plays the game needs no .NET. The library holds every script, each compiled as `frost` compiles it (with the project's C# libraries, statics of its own, and its classes named as it likes), the engine's side of them, and one runtime under them all; it links only the system's own libraries. Each script in it is stamped with what it was compiled from (the script, the libraries and the components), and a player refuses one whose stamp is not its game's: export again after changing a script. `frost` plays an exported game's library too (`frost run` says so), and compiles a script again whose stamp is not its own; played on the recording, every C# game of the engine's fixtures, compiled ahead of time, comes to the very run it comes to compiled by `frost` (`tests/csharp_aot.rs`). Every project the export writes is held to .NET's analyzers of what trimming and Native AOT cannot keep (`IsAotCompatible`, with the trim and AOT analyzers on): what they or the compiler warn of is said after the library, and the engine's fixtures and its own side (`Aot.cs`) have no warning. The packages are restored first, from the SDK's own folders alone, and compiled with `--no-restore`. Native AOT needs the ILCompiler package for the machine. A .NET SDK that has it beside itself (Homebrew's does, in its `library-packs` and `packs` folders) is all that is read, and nothing is fetched. On one that has it not, the export stops (`E0311`), names the package, and says it is fetched once from nuget.org and kept in frost's cache: `frost export desktop ... --fetch` allows that. A web export of a game in C# is refused (`E0482`): no web player runs C#. ## Not yet in C# - Playing with other machines (`net.*`, `docs/multiplayer.md`): a game in C# is refused (`E0543`). Half of what lifts it is done: the clock and unseeded chance are refused as a script compiles (`VEN105`). The other half waits: a second kind of CPU playing Vigil in C# to the bit (an x86_64 library compiled ahead of time, under Rosetta, which needs one package the owner has not yet allowed). ## Fusion on the web With a `frost` built with `--features dotnet`, `frost export web GAME.toml --out DIR` accepts C# scripts whose `Step` classes are all marked `[FusionCompile]`. Export runs the same generator and semantic walk used by desktop C#, then Coldwave's own emitter. It writes one `game/compiled.wasm` and replaces each exported `.cs` file with its script description. Source files in your project remain the source of truth. The SDK is needed on the exporting machine; the browser downloads no .NET runtime. An unmarked C# Step still refuses web export and names Fusion as the web route. Both WebGPU and WebGL2 players instantiate that module before starting the game, sharing the player's memory. The player reserves its first 64 KiB for the module. Each step lends the world's columns and entity indices directly; boolean columns use the same byte staging as hosted C#. Kept fields use the same world state as .NET, so replay and restore include them. The description's schema is checked before the first call; changed fields require a new export. A checked index or arithmetic failure stops with the script name and C# line. C# scripts still run after Luau scripts, in their own project order, on both hosts. Desktop `frost dev` and headless runs continue executing the marked class under .NET. Desktop export continues using Native AOT. Web Fusion is an export path; editing a C# source in an exported page requires exporting and reloading it. The Fusion module does not call hosted APIs such as `World.Random`, `Input`, spawning, sound, text or scene changes. Use a Luau companion to prepare columns for those operations. Heap arrays, `[Engine]` math routines, and `uint` kept state remain outside this emitter's current game door. the engine's `csharp/fusion` example is a recorded parity game: every world from step 0 through 60 is held to `checksums.txt`, under .NET and under Node running the exported door. It includes two scripts, different row orders, entity replacement, input, booleans, integers and kept `Thing` state. Run: ```sh nice -n 10 cargo test --offline -j 6 -p frost_remote --features dotnet --lib session::fifth -- --nocapture ``` the engine's `bunnymark-fusion` example carries the original Luau Bunnymark from the unmerged `demos` branch and a Fusion motion loop. Its companion prepares seeded floor kicks. Positions, velocities and random state match the original at every recorded step; whole-world checksums differ because the helper column/component and script names are also state. See the engine's `RESULTS-fusion.md` example for measurements and their boundaries. --- Page: reference/export.md # export Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when shipping a game to desktop or browser, choosing export settings or customising the web loader. ```toml # Optional: the page a web export shows while the player downloads. "default" is the # engine's mark over a thin line of real progress and the size of the download; # "none" shows nothing of the engine's at all. With a `title`, the title stands in # place of the mark and names the browser tab. `background` is the page's colour, also # around a frame that does not fill the window (left out: the window's background); # `accent` is the progress line's colour (left out: 0xf2364b). Both are 0xRRGGBB. # The page opened with `?mute` plays no sound at all and the game runs the same. [web] loader = "default" title = "Held Note" background = 0x1d2b53 accent = 0xffec27 ``` ```toml # Optional: what `frost export` writes beside the game. A file of the game may have a # source note beside it (`art/slime.png.from.toml`, and the service's terms as # `art/slime.png.terms.txt`), which the editor writes; the export always writes # `credits.txt` from them. "file" (the default) leaves the notes out of the game; # "full" copies each note and terms file beside its file too. `icon` is a square PNG for # the app `frost export ios` and `frost export android` make, 1024 pixels a side for the # stores; left out, the system's plain icon. `title` names the app. [export] credits = "file" icon = "art/icon.png" ``` ## Shipping a game `frost export desktop game.toml --out build` writes the player and `game/` beside it. The player starts that game with no arguments. No installer or signing is supplied. `frost export web game.toml --out site` writes a static site with WebGPU and WebGL2 players; the page chooses what the browser supports. `frost play site` serves it locally. `frost dev game.toml --web` serves with reload. A checkout export needs the Emscripten SDK and the wasm32-unknown-emscripten Rust target; `frost help export` lists options. Exports copy required assets and leave recorded input out unless requested. Browser sound waits for a key press, click or touch. The frame keeps its aspect ratio and input is measured within it. Configure the browser loader under `[web]` below. --- Page: reference/protocol.md # protocol Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new. Use when inspecting or driving a running game through MCP or JSON-RPC, debugging a dark pixel, profiling, or testing agent edits. ## Read, drive and inspect `frost dev game.toml` plays and exposes a local protocol port. `frost serve game.toml` serves JSON-RPC, one object per line on standard input/output; `frost mcp game.toml` serves the same catalogue as MCP tools. Join an editor's session with `frost mcp --join-file PATH`. A planning hand can read documentation without changing its game. Use the join file the editor supplies; tokens belong to that session. `frost protocol` lists commands; `frost protocol world.get` describes one. `frost reference protocol.world.get` fetches the same declaration. Inside the editor: `reference.read {name: "protocol.world.get"}`. Script names and protocol names can differ: `get` is a script call, `protocol.world.get` is the protocol declaration. Start with `game.info`, `world.entities`, `world.components`, `world.get` and `script.state`. `input.set` holds actions and `game.step` advances; `game.seek` replays the project's recording. `frame.capture` takes a picture; `frame.at` picks what is there. `game.check` checks files. `game.snapshot` and `game.restore` support trials. `blame.on`, `blame.value` and `profile.steps` explain writes and time. Fetch each declaration before using it: required fields, trust and limits are there. ## Command names - `protocol.reference.read` - `protocol.reference.search` - `protocol.game.info` - `protocol.game.check` - `protocol.game.step` - `protocol.game.seek` - `protocol.game.time` - `protocol.game.reset` - `protocol.game.snapshot` - `protocol.game.restore` - `protocol.game.forget` - `protocol.game.try` - `protocol.tuning.set` - `protocol.input.set` - `protocol.input.keys` - `protocol.input.history` - `protocol.stream.read` - `protocol.world.entities` - `protocol.world.get` - `protocol.world.bone` - `protocol.world.series` - `protocol.world.query` - `protocol.world.set` - `protocol.world.spawn` - `protocol.world.move` - `protocol.world.despawn` - `protocol.world.insert` - `protocol.world.remove` - `protocol.world.apply` - `protocol.world.components` - `protocol.world.checksum` - `protocol.change.test` - `protocol.copy.make` - `protocol.copy.list` - `protocol.copy.drop` - `protocol.copy.land` - `protocol.copy.rebase` - `protocol.copy.landed` - `protocol.copy.queue` - `protocol.copy.flush` - `protocol.copy.events` - `protocol.copy.claim` - `protocol.copy.diff` - `protocol.copy.park` - `protocol.copy.give` - `protocol.scene.load` - `protocol.script.reload` - `protocol.script.state` - `protocol.save.list` - `protocol.save.set` - `protocol.project.add` - `protocol.project.remove` - `protocol.project.refs` - `protocol.project.rename` - `protocol.project.undo` - `protocol.project.redo` - `protocol.frame.capture` - `protocol.frame.at` - `protocol.frame.in` - `protocol.frame.view` - `protocol.render.passes` - `protocol.events.read` - `protocol.events.since` - `protocol.physics.read` - `protocol.ground.at` - `protocol.ui.tree` - `protocol.ui.focus` - `protocol.blame.on` - `protocol.blame.value` - `protocol.blame.entity` - `protocol.blame.gone` - `protocol.blame.pixel` - `protocol.audio.requests` - `protocol.assets.from` - `protocol.assets.sources` - `protocol.assets.cooked` - `protocol.assets.picture` - `protocol.script.reloads` - `protocol.debug.attach` - `protocol.debug.detach` - `protocol.debug.breakpoints` - `protocol.debug.pause` - `protocol.debug.continue` - `protocol.debug.step` - `protocol.debug.state` - `protocol.debug.stack` - `protocol.debug.scope` - `protocol.debug.expand` - `protocol.debug.evaluate` - `protocol.log.since` - `protocol.graph.uses` - `protocol.script.complete` - `protocol.profile.frame` - `protocol.profile.frames` - `protocol.profile.steps` - `protocol.session.hello` - `protocol.session.hands` - `protocol.session.writes` - `protocol.session.mode` - `protocol.session.token` - `protocol.net.host` - `protocol.net.join` - `protocol.net.run` - `protocol.net.condition` - `protocol.net.status` - `protocol.net.desync` - `protocol.net.leave` --- Page: reference/protocol-commands.md # Protocol commands The protocol is how a program talks to a running game: step it, press its keys, read and change its world, take a picture. The editor, the command line and AI agents all use these same commands, so anything you can do by hand a program can do too. Send them as JSON-RPC over standard streams or a local port (`frost serve`), or as MCP tools (`frost mcp`, where dots become underscores). This list is written by the engine: `frost protocol NAME` prints one command, and [the protocol](../concepts/protocol.md) explains the ideas. | Group | Commands | | --- | --- | | reference | [`reference.read`](protocol/reference.md#referenceread), [`reference.search`](protocol/reference.md#referencesearch) | | game | [`game.info`](protocol/game.md#gameinfo), [`game.check`](protocol/game.md#gamecheck), [`game.step`](protocol/game.md#gamestep), [`game.seek`](protocol/game.md#gameseek), [`game.time`](protocol/game.md#gametime), [`game.reset`](protocol/game.md#gamereset), [`game.snapshot`](protocol/game.md#gamesnapshot), [`game.restore`](protocol/game.md#gamerestore), [`game.forget`](protocol/game.md#gameforget), [`game.try`](protocol/game-2.md#gametry) | | tuning | [`tuning.set`](protocol/tuning.md#tuningset) | | input | [`input.set`](protocol/input.md#inputset), [`input.keys`](protocol/input.md#inputkeys), [`input.history`](protocol/input.md#inputhistory) | | stream | [`stream.read`](protocol/stream.md#streamread) | | world | [`world.entities`](protocol/world.md#worldentities), [`world.get`](protocol/world.md#worldget), [`world.bone`](protocol/world.md#worldbone), [`world.series`](protocol/world.md#worldseries), [`world.query`](protocol/world.md#worldquery), [`world.set`](protocol/world.md#worldset), [`world.spawn`](protocol/world.md#worldspawn), [`world.move`](protocol/world.md#worldmove), [`world.despawn`](protocol/world.md#worlddespawn), [`world.insert`](protocol/world.md#worldinsert), [`world.remove`](protocol/world.md#worldremove), [`world.apply`](protocol/world.md#worldapply), [`world.components`](protocol/world.md#worldcomponents), [`world.checksum`](protocol/world-2.md#worldchecksum) | | change | [`change.test`](protocol/change.md#changetest) | | copy | [`copy.make`](protocol/copy.md#copymake), [`copy.list`](protocol/copy.md#copylist), [`copy.drop`](protocol/copy.md#copydrop), [`copy.land`](protocol/copy.md#copyland), [`copy.rebase`](protocol/copy.md#copyrebase), [`copy.landed`](protocol/copy.md#copylanded), [`copy.queue`](protocol/copy.md#copyqueue), [`copy.flush`](protocol/copy-2.md#copyflush), [`copy.events`](protocol/copy-2.md#copyevents), [`copy.claim`](protocol/copy-2.md#copyclaim), [`copy.diff`](protocol/copy-2.md#copydiff), [`copy.park`](protocol/copy-2.md#copypark), [`copy.give`](protocol/copy-2.md#copygive) | | scene | [`scene.load`](protocol/scene.md#sceneload) | | script | [`script.reload`](protocol/script.md#scriptreload), [`script.state`](protocol/script.md#scriptstate), [`script.reloads`](protocol/script.md#scriptreloads), [`script.complete`](protocol/script.md#scriptcomplete) | | save | [`save.list`](protocol/save.md#savelist), [`save.set`](protocol/save.md#saveset) | | project | [`project.add`](protocol/project.md#projectadd), [`project.remove`](protocol/project.md#projectremove), [`project.refs`](protocol/project.md#projectrefs), [`project.rename`](protocol/project.md#projectrename), [`project.undo`](protocol/project.md#projectundo), [`project.redo`](protocol/project.md#projectredo) | | frame | [`frame.capture`](protocol/frame.md#framecapture), [`frame.at`](protocol/frame.md#frameat), [`frame.in`](protocol/frame-2.md#framein), [`frame.view`](protocol/frame-2.md#frameview) | | render | [`render.passes`](protocol/render.md#renderpasses) | | events | [`events.read`](protocol/events.md#eventsread), [`events.since`](protocol/events.md#eventssince) | | physics | [`physics.read`](protocol/physics.md#physicsread) | | ground | [`ground.at`](protocol/ground.md#groundat) | | ui | [`ui.tree`](protocol/ui.md#uitree), [`ui.focus`](protocol/ui.md#uifocus) | | blame | [`blame.on`](protocol/blame.md#blameon), [`blame.value`](protocol/blame.md#blamevalue), [`blame.entity`](protocol/blame.md#blameentity), [`blame.gone`](protocol/blame.md#blamegone), [`blame.pixel`](protocol/blame.md#blamepixel) | | audio | [`audio.requests`](protocol/audio.md#audiorequests) | | assets | [`assets.from`](protocol/assets.md#assetsfrom), [`assets.sources`](protocol/assets.md#assetssources), [`assets.cooked`](protocol/assets.md#assetscooked), [`assets.picture`](protocol/assets.md#assetspicture) | | debug | [`debug.attach`](protocol/debug.md#debugattach), [`debug.detach`](protocol/debug.md#debugdetach), [`debug.breakpoints`](protocol/debug.md#debugbreakpoints), [`debug.pause`](protocol/debug.md#debugpause), [`debug.continue`](protocol/debug.md#debugcontinue), [`debug.step`](protocol/debug.md#debugstep), [`debug.state`](protocol/debug-2.md#debugstate), [`debug.stack`](protocol/debug-2.md#debugstack), [`debug.scope`](protocol/debug-2.md#debugscope), [`debug.expand`](protocol/debug-2.md#debugexpand), [`debug.evaluate`](protocol/debug-2.md#debugevaluate) | | log | [`log.since`](protocol/log.md#logsince) | | graph | [`graph.uses`](protocol/graph.md#graphuses) | | profile | [`profile.frame`](protocol/profile.md#profileframe), [`profile.frames`](protocol/profile.md#profileframes), [`profile.steps`](protocol/profile.md#profilesteps) | | session | [`session.hello`](protocol/session.md#sessionhello), [`session.hands`](protocol/session.md#sessionhands), [`session.writes`](protocol/session.md#sessionwrites), [`session.mode`](protocol/session.md#sessionmode), [`session.token`](protocol/session.md#sessiontoken) | | net | [`net.host`](protocol/net.md#nethost), [`net.join`](protocol/net.md#netjoin), [`net.run`](protocol/net.md#netrun), [`net.condition`](protocol/net-2.md#netcondition), [`net.status`](protocol/net-2.md#netstatus), [`net.desync`](protocol/net-2.md#netdesync), [`net.leave`](protocol/net-2.md#netleave) | --- Page: reference/protocol/reference.md # Protocol: reference The `reference` 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). ## reference.read `reference.read {name?: text, all?: value} -> {text: text}` · read, read-only Reads the game-making core and index, a page, a script call, a component field, or a protocol.COMMAND declaration. Same text as frost reference. Changes nothing; available to planning hands. | Parameters | Type | Meaning | | --- | --- | --- | | `name?` | text | A page or exact entry name, such as drawing, sound.play, Sprite.image or protocol.world.get. Left out: core and index. | | `all?` | value | true: the complete legacy scripting reference, as frost reference --all. Cannot be combined with name. | | Result | Type | Meaning | | --- | --- | --- | | `text` | text | The reference in Markdown, with stable ordering and no timestamps. | ## reference.search `reference.search {words: text} -> {text: text}` · read, read-only Finds reference entries matching every query word, ranked by exact name, name matches, then body matches; lexical ties. One line per entry with its page, as frost reference --search. Changes nothing. | Parameters | Type | Meaning | | --- | --- | --- | | `words` | text | Words to find, separated by spaces. Empty text returns no matches. | | Result | Type | Meaning | | --- | --- | --- | | `text` | text | Ranked entries, one line each with page names; empty when no entry matches. | --- Page: reference/protocol/game.md # Protocol: game, part 1 of 2 The `game` 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). ## game.info `game.info {} -> {project: text, title: text, step: integer, checksum: text, scripts: [text], scenes: [text], scene: text, tuning: [record], poses: [record], actions: [text], players: integer, seed: integer, width: integer, height: integer, background: integer, filter: text, warnings: [text], stopped: record, failed_step: integer, whole: value, csharp: record, cooked: record}` · read, read-only Describes the loaded game and where its simulation stands. | Result | Type | Meaning | | --- | --- | --- | | `project` | text | The file the game was loaded from, as the engine was given it, with / between its parts. | | `title` | text | What the game is called: the project's `title`, or null when it gives none. | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `scripts` | [text] | The scripts' names: their paths as the project wrote them. | | `scenes` | [text] | The scenes scene.load can start: the project's `scene`, then its `scenes`. | | `scene` | text | The scene the game is in now, by its name in scenes. Empty for a bare scene file, which has no name. | | `tuning` | [record] | One {name, value, default, min, max, step} per number of the project's [tuning] table, in name order: what a script reads as tuning.NAME now, what the project file says, and the least, the most and the spacing the project gives it, each null when it gives none. | | `poses` | [record] | One {clip, seconds, loops, events: [{at, name}]} per clip of the project's [poses], in name order: what a model's clip of that name sends as a Pose plays it (each event's name and the moment of the clip it is sent at), with the clip's length and whether it goes round, as the project file says them (the length as the models the game loads have it: E0486 otherwise; whether it goes round the project's word, over the models'). [] for a project with none. Here beside tuning because it is the project's, not a model's: one entry serves every model with a clip of that name. | | `actions` | [text] | The input actions input.set accepts. | | `players` | integer | How many players have input. They count from 0. | | `seed` | integer | The seed the random source started from at step 0. | | `width` | integer | The frame's width in pixels; one world unit is one pixel. | | `height` | integer | The frame's height in pixels. | | `background` | integer | The colour behind everything, as 0xRRGGBB: the project's `background` under `[window]`. | | `filter` | text | How pictures are sampled at another size: "nearest" or "linear", the project's `filter` under `[window]`. | | `warnings` | [text] | What is probably a mistake though the game loaded, each line starting with a code. | | `stopped` | record | null while the game can step. While a debugger holds a script stopped part way through a step: {file, line, reason}, where it stands and why, as debug.state says them. game.step, game.seek and scene.load are refused with E0441 until a debugger's client lets it go on (debug.continue); everything that reads is answered. | | `failed_step` | integer | The step that failed when the last step did (a script's error, E0302 and the like): `step` is then that one, counted though it did not finish, and the step before it was the last good one. null when the last step finished, and after the game is put back to a moment (game.seek, game.restore, game.reset) that has none. | | `whole` | value | true when the world is as a step left it whole; false when it is as the failed step left it part way, its later stages not run: game.seek {step: failed_step - 1} brings back the last good world where the game is on its recording. | | `csharp` | record | null for a game with no C# script, and for an engine built without C#. For a game with one: {solution, dotnet, compiler}. solution is the path of the file a C# language server is started on for this game (game.slnx, in the engine's cache: the engine writes it and the project beside it whenever the game is loaded or checked, and an editor writes neither); dotnet is the major version of the .NET the engine runs scripts on, as text ("11"); compiler is the version of the engine's C# compiler ("5.12.0"), which a language server's own must not be older than. game.info adds scripts: each C# script's name with "ahead" when it runs compiled ahead of time (an exported game's, from its csharp/ folder) or "runtime" when the .NET runtime runs it, compiled as the game loaded. | | `cooked` | record | What loading the game cooked, and drawing it (a model's pictures are cooked at the first frame), as {fresh, cached, ms, why}: fresh is how many models, pictures and atlases were cooked now, cached how many were taken from the cook's cache, ms how long the load and the draws that cooked took in milliseconds. why says why any were cooked now, one of "importers" (the engine's importer for them changed since a program last cooked in this cache, so each is cooked again once), "files" (the game's files are new or changed), "first" (the cache is new) or "off" (there is no cache: FROST_CACHE=off); null when none were. A reset or a reload does not change it. | ## game.check `game.check {} -> {errors: integer, warnings: integer, problems: [record], csharp: record}` · read, read-only Checks the game's files as they are now, without touching the running game: what loading them would refuse, and what it would warn of. The files are loaded into a second game that is thrown away, which runs what a load runs: each script's top level, and on_scene for the scene the game starts in. No step is run, no sound is played and no file is written. What only running the game finds (W1112, a joint that lost an end to a despawn) is in game.status, and frost run and frost test print it. | Result | Type | Meaning | | --- | --- | --- | | `errors` | integer | How many problems would stop the game from loading. | | `warnings` | integer | How many are probably mistakes though the game loads. | | `problems` | [record] | Errors first: {severity, code, file, line, message}. severity is "error" or "warning"; file is the file's path from the project file's folder, with / between its parts on every system; file and line are null when the problem has none; message is what loading the game would say: it carries the code and what to do. A project file and a scene file are each read up to their first mistake. | | `csharp` | record | null for a game with no C# script, and for an engine built without C#. For a game with one: {solution, dotnet, compiler}. solution is the path of the file a C# language server is started on for this game (game.slnx, in the engine's cache: the engine writes it and the project beside it whenever the game is loaded or checked, and an editor writes neither); dotnet is the major version of the .NET the engine runs scripts on, as text ("11"); compiler is the version of the engine's C# compiler ("5.12.0"), which a language server's own must not be older than. game.info adds scripts: each C# script's name with "ahead" when it runs compiled ahead of time (an exported game's, from its csharp/ folder) or "runtime" when the .NET runtime runs it, compiled as the game loaded. | ## game.step `game.step {steps?: integer, until?: record} -> {step: integer, checksum: text, reached: value, stopped: record}` · write Advances the simulation by fixed steps of 1/60 s, using the input held by input.set, not the project's recording: game.seek plays the recording to a step, as frost run and frost test do, so the same step of the two can show the game at different places. When a debugger stops a script it returns at once, with the steps so far and `stopped` saying where. | Parameters | Type | Meaning | | --- | --- | --- | | `steps?` | integer | How many steps to run, from 1 to 36000. Left out: 1. | | `until?` | record | A goal to stop at, looked at after each step: {scene: NAME} (the game is in that scene), {event: NAME} (the step sent that event), {field: "Component.field", op, value, entity} (an entity's field compares so; entity left out: any entity's) or {state: "key", op, value, script} (a key of a script's state compares so, with dots for keys inside tables; script left out: any script's). op is one of = != < <= > >= and may be left out for =. Left out: every step is run. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `reached` | value | true when the goal of until was met: the stepping stopped there, and step is the step that met it. false when the steps ran out first, or no goal was given. | | `stopped` | record | null while the game can step. While a debugger holds a script stopped part way through a step: {file, line, reason}, where it stands and why, as debug.state says them. game.step, game.seek and scene.load are refused with E0441 until a debugger's client lets it go on (debug.continue); everything that reads is answered. | ## game.seek `game.seek {step: integer} -> {step: integer, checksum: text, keyframes: record, from: integer, started: text, replayed: integer, ms: number}` · write Puts the game at a step of the project's recording, as frost run --steps reaches it: for scrubbing a recorded game, and for showing a change before and after on the same input. A game only its recording has moved runs on from where it is; going back, or after game.step, world.set, scene.load, script.reload or a seeded reset, the game is put back to a moment of the recording the server kept on an earlier seek (one every 300 steps) and played on from there, or else loaded again from its files (a script changed with script.reload is then the file's again). It is loaded whenever that could make another game: a file of the game changed, or since the last load there was a script.reload, a tuning.set or blame.on, or a debugger is attached. Put back, the game's snapshots are kept, events.since starts at that moment and not at step 0 (from says where), and log.since has the lines printed before it. | Parameters | Type | Meaning | | --- | --- | --- | | `step` | integer | The step to stand at, from 0 to 36000. Past the end of the recording every action is at rest. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `keyframes` | record | What the server keeps of the recording to go back by: {every, kept, steps, bytes, most_bytes}. A keyframe is taken every `every` steps (300) while a seek plays the recording; once they would take more than most_bytes (64 MiB) every other one goes and every doubles. kept is how many there are now, steps their steps in order (what a timeline marks as the places a seek starts from) and bytes about what they take: each is a snapshot of the game, game.snapshot's bytes. None are kept while one could be another game (see above). | | `from` | integer | The step this seek played on from: where the game stood, a keyframe's step, or 0. | | `started` | text | How it got to `from`: "here" (it ran on from where it stood), "keyframe" (put back to a keyframe) or "load" (the game loaded again from its files). | | `replayed` | integer | How many steps it played from `from`: what the seek cost, with ms. | | `ms` | number | How long the seek took, in milliseconds of the server's clock. Not part of the game: it differs from run to run. | ## game.time `game.time {rate?: number} -> {step: integer, rate: number}` · write Sets how fast the game runs by itself, where a clock runs it (frost dev, a browser tab): 1 is sixty steps a second, 0 is paused, 0.5 is half speed. game.step steps a paused game. Sound is never slowed or paused. Where time moves only by game.step (frost serve, frost mcp) the rate is kept and changes nothing. | Parameters | Type | Meaning | | --- | --- | --- | | `rate?` | number | 0 to pause, or from 0.1 to 4. Left out: the rate stays as it is. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `rate` | number | The rate now. | ## game.reset `game.reset {seed?: integer, width?: integer, height?: integer} -> {step: integer, checksum: text, seed: integer}` · write Loads the game again from its files: step 0, the scene as written, every input at rest. Saves are kept: a game whose saves have a place (frost dev) starts from what is kept there, any other from the saves its recording declares. To empty a slot, save.set with no data. | Parameters | Type | Meaning | | --- | --- | --- | | `seed?` | integer | Where the random source starts, from 0 to 4294967295. Left out: the project's seed. | | `width?` | integer | With `height`: the frame's size from now on, in place of the project's, each from 1 to 4096. To see a game's interface at another shape. Left out: the size it has. | | `height?` | integer | See `width`. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `seed` | integer | The seed the game now runs from. | ## game.snapshot `game.snapshot {} -> {id: integer, bytes: integer, step: integer, checksum: text}` · write Keeps the game as it stands, in the server's memory, to go back to with game.restore or to play from with game.try: for trying many inputs from one moment without playing the way there each time. It holds the world, the physics' own memory, the clock, the held input and the input so far, so a game put back goes on bit for bit as it did the first time. It does not hold what a script keeps in a `local` (keep what the game is in the world or in `state`), the scripts' code, or sound. The server keeps at most 4096 snapshots and 512 MiB of them (E0434 past either); game.reset, a game.seek that goes back and a changed project or scene file forget them all. | Result | Type | Meaning | | --- | --- | --- | | `id` | integer | What game.restore, game.try and game.forget know the snapshot by. Ids count from 1 and are never given twice. | | `bytes` | integer | About how many bytes the server uses to keep it. | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | ## game.restore `game.restore {id: integer, again?: value} -> {step: integer, checksum: text, edits_after: [integer], code_changed: [text], changes: [record], again: integer}` · write Puts the game back to a snapshot, which stays kept: the step, the world, the physics, the held input and the input so far are the snapshot's, and so are the game's saves (where the session keeps them in a place on disk, the place follows at the next step). What a client changed after the snapshot was taken is not made again by playing on with the same input (edits_after), and a script reloaded since then runs as it is now, never as it was (code_changed): a tool that scrubs takes a snapshot after each change it makes. With again, the changes are brought into the moment put back, as one: each command that made them is made again in it, in order, by the hand that sent it. | Parameters | Type | Meaning | | --- | --- | --- | | `id` | integer | A snapshot's id, from game.snapshot. E0433 when none has it. | | `again?` | value | true: makes the changes of edits_after again in the moment put back (a change no command made, like one a refused command left, is left out). An entity a change made is named by its new id in the changes after it. When one is refused now, the answer is its refusal and the game is as it was before the restore, to the bit. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `edits_after` | [integer] | The step count at each change a client made after the snapshot was taken that is not input: a write to the world (world.set, world.spawn, world.despawn and the like), scene.load, saves.set, debug.evaluate. Empty when stepping on with the same input goes where it went. | | `code_changed` | [text] | The scripts whose code was swapped since the snapshot was taken (script.reload, a saved file): they go on as they are now. | | `changes` | [record] | {step, what, hand, who, name}: each command that made the changes of edits_after, once, in order: the step it was made at, the command (null for a change no command is known to have made), the hand that sent it and its name (as session.hands gives them; 0 and null for a connection that said nothing) and what it changed, by the name the client gave (an entity, a scene, a slot). None writes a file, so none has a line: the line a client wrote is the client's. | | `again` | integer | How many of changes were made again: 0 without again. | ## game.forget `game.forget {id?: integer} -> {kept: integer, bytes: integer}` · write Lets go of a snapshot, or of all of them, and says what is still kept. | Parameters | Type | Meaning | | --- | --- | --- | | `id?` | integer | The snapshot to let go of. Left out: every snapshot. | | Result | Type | Meaning | | --- | --- | --- | | `kept` | integer | How many snapshots are kept now. | | `bytes` | integer | About how many bytes they take together. | --- Page: reference/protocol/game-2.md # Protocol: game, part 2 of 2 The `game` 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). ## game.try `game.try {from?: integer, inputs: [record], read?: [record], until?: record, keep?: value} -> {step: integer, checksum: text, reached: value, reads: [record], id: integer}` · write Plays a stretch of input from a snapshot and answers what came of it, in one call: the game is put back to the snapshot, stepped through the inputs (to the goal, when one is given), read, and kept as a new snapshot when asked. The game is left where the try ended, with the last step's input held. For a search: one call a branch. | Parameters | Type | Meaning | | --- | --- | --- | | `from?` | integer | The snapshot to start from, as game.snapshot or an earlier try gave it. Left out: the game as it stands. | | `inputs` | [record] | The input to play, as a project's recording is written: one {steps, ACTION: value, ..., player} per stretch, each action from -1 to 1 and at rest when not named; player left out is player 0. A player's stretches follow one another, and two players' run side by side. At most 36000 steps. An empty list plays nothing. | | `read?` | [record] | What to read where the try ends: one {command, params} per read, each a read-only command of this protocol with its parameters. Left out: nothing. | | `until?` | record | A goal to stop at, looked at after each step: {scene: NAME} (the game is in that scene), {event: NAME} (the step sent that event), {field: "Component.field", op, value, entity} (an entity's field compares so; entity left out: any entity's) or {state: "key", op, value, script} (a key of a script's state compares so, with dots for keys inside tables; script left out: any script's). op is one of = != < <= > >= and may be left out for =. Left out: every step is run. | | `keep?` | value | true to keep the game where the try ends as a snapshot. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | | `reached` | value | true when the goal of until was met: the stepping stopped there, and step is the step that met it. false when the steps ran out first, or no goal was given. | | `reads` | [record] | One {command, result} per read, in the order asked. | | `id` | integer | The snapshot kept of the end, for keep; 0 when none was asked for. | --- Page: reference/protocol/tuning.md # Protocol: tuning The `tuning` 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). ## tuning.set `tuning.set {name: text, value: number} -> {name: text, value: number, step: integer, applies: text}` · write Sets one number of the project's [tuning] table without touching a file: what a script reads as tuning.NAME from now on. It stays set through game.reset and game.seek, which load the game with it in place, so a script that reads it as it loads reads the new value; a local that copied the old one keeps it until then. A snapshot holds the values, and game.restore puts them back. | Parameters | Type | Meaning | | --- | --- | --- | | `name` | text | The value's name under [tuning], as game.info lists them. | | `value` | number | What it is to be, inside the entry's min and max when it has them. | | Result | Type | Meaning | | --- | --- | --- | | `name` | text | The name. | | `value` | number | The value now. | | `step` | integer | How many fixed steps have run. | | `applies` | text | When the game sees it, in words: at once where a script reads tuning.NAME as it uses it, and at the next load (game.reset, game.seek) where a script copied it into a variable of its own. | --- Page: reference/protocol/input.md # Protocol: input The `input` 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). ## input.set `input.set {player: integer, action: text, value: number} -> {player: integer, action: text, value: number}` · write Holds one player's value for an input action until it is set again. | Parameters | Type | Meaning | | --- | --- | --- | | `player` | integer | The player, counting from 0. | | `action` | text | An input action name, as game.info lists them. | | `value` | number | An axis from -1 to 1, or a button: 1 held, 0 released. A value outside -1 to 1 is refused. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player. | | `action` | text | The action. | | `value` | number | The value now held. | ## input.keys `input.keys {} -> {keys: [record], names: [record], pointer: record, fingers: [record]}` · read, read-only Lists the keys the project binds to input actions, and every key name the engine knows. | Result | Type | Meaning | | --- | --- | --- | | `keys` | [record] | One {action, player, key, negative, positive} per binding, as the project file writes them under [input.keys]. A binding that names a gamepad's button or stick is read from the pad with the player's number. A button has key (the action is 1 while it is down) and null for the other two; an axis has negative and positive (-1 and 1 while each is down) and null for key. A name is given as written, also one that is not a key. | | `names` | [record] | Every key name there is, one {name, code}: name is what a project file writes ("A" to "Z", "0" to "9", "Space", "Enter", "Tab", "Escape", "Left", "Right", "Up", "Down", and the pointer's buttons "MouseLeft", "MouseRight", "MouseMiddle"; a finger on a touch screen is "MouseLeft"; a gamepad's sixteen buttons "PadA" to "PadRight"; and last the four directions of its sticks, "PadLeftX", "PadLeftY", "PadRightX", "PadRightY", each an axis by itself with right and up as 1) and code is what a browser reports for that key in KeyboardEvent.code ("KeyA", "Digit0", "Space", "ArrowLeft"; a button's code is its name). | | `pointer` | record | The {x, y, player} the project writes as pointer under [input]: the two actions that are told where the pointer (the mouse, or a finger) is, x from -1 at the frame's left edge to 1 at its right and y from -1 at its bottom to 1 at its top, and the player they are set for. null when the project names none. A client moves the pointer with input.set on those two actions. | | `fingers` | [record] | One {region, x, y, press, player} per finger slot the project writes as fingers under [input], in the order a finger looks for a free slot: region {x, y, w, h} is the part of the frame a finger takes the slot in, in the units of the pointer's place (-1 to 1, y up); x and y are the actions that hold the slot's finger's place, press the action that is 1 while it is down. Empty when the project has none. A client plays a finger with input.set on those three actions. | ## input.history `input.history {} -> {step: integer, seed: integer, recording: text, tuning: [record], edits: [integer]}` · read, read-only Returns the input of every step so far in the form a project file records it, to save and replay. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `seed` | integer | The seed the session started from; a replay needs the same one. | | `recording` | text | The whole key as a project file writes it under `[input]`, from `recording = [` to the closing `]`, after a `saves` line when the session started from saves: paste it there as it is, or save it alone in a file for frost run --input and for `recording = "run.toml"`. With it and the seed, frost run reaches this step with this checksum, unless world.set or script.reload changed the game on the way. | | `tuning` | [record] | One {step, name, value} per tuning value set since the game was loaded, in order; one set before the game was loaded again is at step 0. Empty for a game on the project's own values. A replay sets them again: frost run --set tuning.NAME=VALUE for those at step 0, tuning.set at its step for one set later. | | `edits` | [integer] | The step count at each change a client made to the game that is not input (a write to the world, scene.load, saves.set, debug.evaluate), oldest first, on the line of time the game is on: one made after a snapshot that game.restore put back is not here. The recording does not hold them: a replay of it goes another way from the first of these steps on. Empty when the recording is the whole of the run. | --- Page: reference/protocol/stream.md # Protocol: stream The `stream` 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). ## stream.read `stream.read {} -> {step: number, stream: record}` · read, read-only Reads streaming state at this step. Coordinates are grid x,z (x,y in 2D). active lists resident cells and their owned handles; saved holds dormant rows and tombstones; escaped lists promoted world things. ready says whether required cells are all in and physics may step. | Result | Type | Meaning | | --- | --- | --- | | `step` | number | Current step. | | `stream` | record | Streaming state, null without [stream]. | --- Page: reference/protocol/world.md # 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](../protocol-commands.md). ## 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. | --- Page: reference/protocol/world-2.md # Protocol: world, part 2 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](../protocol-commands.md). ## world.checksum `world.checksum {only?: [text], without?: [text], paired?: value} -> {step: integer, checksum: text}` · read, read-only Answers the checksum of the world, or of the parts of it named: two moments that differ only in what was left out have the same, which is how a search tells a place it has been from a new one. A part is "Component", "Component.field", "state" (what every script keeps), "state:SCRIPT", "state:SCRIPT:KEY" (one key of one script's state), "entities" (which are alive), "names", "random" (the random source), or one thing's component or field by the thing's name, "ball.Transform" and "ball.Transform.x", or a whole thing, "ball" (that it is there, its name and every part): left out, the same field of every other thing is still covered (a component's name is read first). | Parameters | Type | Meaning | | --- | --- | --- | | `only?` | [text] | The parts to cover. Left out: every part. | | `without?` | [text] | The parts to leave out, of those only covers. Left out: none. | | `paired?` | value | true: things told apart by name, not by slot: the named in the order of their names, then the others in the order of their slots, what scripts keep as it is written, so two worlds that differ only in which slot each thing is in, and keep no thing's number, have the same checksum (a thing added to a scene moves every thing made after it). A test of a change compares two games so; a number a script keeps is compared as a number, so a game that keeps a thing's number in state differs where the thing moved slot. A whole thing named as a part ("ball") is always paired. Left out: false, by slot, the checksum every other command answers. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The checksum of the parts covered, 16 hex digits. With neither only nor without it is the checksum every other command answers. | --- Page: reference/protocol/change.md # Protocol: change The `change` 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). ## change.test `change.test {says: [text], against?: text, folder?: text, copy?: text, with?: [record], before?: record} -> {passes: value, said: [record], differs: record, shots: [record], game: text, line: text, warnings: [text], stages: [record], steps: integer, on: record, hands: [record], ms: number}` · read, read-only Holds a change to what it said it changes, as `frost test --says` does: the game's files on disk are played beside the same game at a commit, on the recorded input, step by step, and may differ only in the parts said, each from its step on, and in no shot but where a said part differs. With folder, no commit and no repository: the folder's files, read over the served game's files (a file it lacks is the game's), are played beside the game's own; with, folders of changes both sides have under it; before, a folder holding the whole game unchanged, played in place of the game's own files, which are then the changed side. With copy, a copy's changes (copy.make), played as such a folder; a hand in a copy that gives no folder tests its own. For an editor's landing line and an agent's report without a shell: the same answer either way. It reads the files, not the running game (a script.reload not saved is not in it), plays the reference and changed recordings beside each other, and changes nothing. With with, a first differing component field also reports each change alone and a five-step value history (differs.comparison); each returned run is replayed only after that difference is known, only to that step and without pictures. A folder that cannot be one of these is refused in words (E0472). | Parameters | Type | Meaning | | --- | --- | --- | | `says` | [text] | What the change changes: parts as world.checksum names them (Transform.x, state:ball.luau, entities, or one thing's, ball.Transform.x), each as PART or PART@STEP, from its step on. With folder or before it may be empty: the change says it changes nothing the run shows. | | `against?` | text | The commit to hold the change against. Left out: HEAD. Not with folder or before. | | `folder?` | text | A folder of changed files, each at its path from the project file's folder (scripts/go.luau): the change, tested against the game as served with no repository. | | `copy?` | text | A copy of the game (copy.list names them): its changes, every file it changed or added since it was made, played over the game as served, as a folder would be, and every file it took away taken away; the copy then keeps what it said and what the test came to (copy.list's says and test). Not with folder or before. Left out by a hand in a copy that gives neither folder nor before: its own copy. Another copy than its own is refused (E0474). | | `with?` | [record] | Changes the test plays on both sides, under folder (or the copy): each {folder: PATH} or {copy: NAME}, a copy's changes, each on top of the ones before it. To ask whether two changes that pass alone pass together. | | `before?` | record | {folder: PATH}: the game unchanged, whole, with its project file, played as the unchanged side in place of the game's files on disk (an editor's game as last kept). | | Result | Type | Meaning | | --- | --- | --- | | `passes` | value | Whether the game differs only where it said. | | `said` | [record] | One {part, from, first_differs} per part said: first_differs the first step it differed at, null when it never did (a warning: the change did less than it said). | | `differs` | record | The first difference where nothing was said: {step, entity, component, field, value, was, writer}, or null. For a component field with with, adds comparison: {window: 5, from, to, alone, together, extra_steps}. from = max(0, step - 4), to = step; each run has {present, value, writer, samples, error}, samples at most five {step, present, value, writer} in step order, including step 0 when in range. Scalars have the same JSON types as world.get; writer is blame.value's structured writer, or null when unknown or absent. present false means the thing, component or field is absent; null with error means that standalone run could not load or reach the step, or its own replay ends earlier (samples empty). alone is in hands order, each with folder or copy and who, each on its OWN recording; with changes alone use before when supplied, otherwise the served game; the final hand uses the served game plus folder; together is the changed test run. These observations do not certify that an alone test passes: read its own change.test verdict. was remains the test reference, never a substitute for alone. Passing tests take no field snapshots. After a field difference, each returned run is replayed once through to with writer tracking, sampling only that field in the window; extra_steps counts all attempted comparison steps, at most (hands + 1) * to. At most five samples and one final value/writer per returned run are retained; one replay session is live at a time. No history is cached across requests. No comparison for non-field differences, a passing test or a test without with. | | `shots` | [record] | One {name, step, changed, passes} per shot taken beside the commit's. | | `game` | text | The project file, as `frost test` names it. | | `line` | text | The line `frost test --says` prints: "differs from the game as committed only where it said: ..." or what failed; of a folder, "differs from the game as served ...". | | `warnings` | [text] | Its warnings: a part said that never differed. | | `stages` | [record] | Of folders only (a test against a commit does not answer it): {name, passes, line} for loads (the changed files load), plays (no step of the change fails), said (it differs only where it said) and pictures (each shot as said), in that order; passes null for a stage the test did not reach. | | `steps` | integer | Of folders only (a test against a commit does not answer it): the steps of the recording played. | | `on` | record | Of folders only (a test against a commit does not answer it): {landing, with}: what the change was played on top of, with the folders of with as given and a copy by its name; landing the number of the game's last landing (0 before any; copy.landed). | | `hands` | [record] | Of folders only (a test against a commit does not answer it): {folder, lines: [{path, from, to}]} for each of with and then folder (or the copy), or {copy, who, lines} for a copy, who its hand's name: the lines each changed, by its file's lines against the files under it (from and to null for a file that is not text; a file a copy took away is {path, from: null, to: null, gone: true}). With before and no folder, the game's own files against before. | | `ms` | number | Of folders only (a test against a commit does not answer it): how long the test took in the engine. | --- Page: reference/protocol/copy.md # Protocol: copy, part 1 of 2 The `copy` 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). ## copy.make `copy.make {name?: text, for?: text, mode?: text, at?: integer, about?: text, of?: [text]} -> {copy: text, hand: integer, file: text, folder: text, base: record, bytes: integer, parked: text, ms: number}` · write Makes a copy of the game, from the session's owner only (its standard streams or its own token; E0474 from anyone else): every file of the game copied into .frost/copies/NAME/ beside the project file (a folder whose name starts with a dot is left out, as the game's own listing leaves it out), and that folder loaded as a game of its own on a thread of its own, started from the person's game as it stands (put in as game.restore puts a moment back) or at a step of the recording. With for, a hand is made for it with a token of its own, written to a join file beside the session's as session.token writes one: a connection that comes by that token is in the copy, and every command it sends (game.step, world.set, frame.capture, blame.value, project.rename, ...) acts on the copy with no new parameter; the owner sends copy: NAME on any command instead. A file saved in the copy's folder is taken in at the copy's next command, as frost dev takes in a save: a script is swapped and keeps its state, a picture is shown as it is now, anything else loads the copy's game again. Nothing a copy does moves the person's game, its step, checksum, snapshots, keyframes, log, hands or files; a copy has no debugger (E0475) and no place for saves. Refused in words (E0476), with nothing left behind: a game handed to the program, a name taken or a folder of that name there from before (never reused or removed: copy.list lists it), a copy that does not load. Refused (E0480), with nothing made, for a tag whose hand works in another copy already, naming that copy: a hand is in one copy, as copy.give holds it. When 16 copies are live, the one idle longest that is not busy is parked first (copy.park); with 256 kept, live and parked, another is refused naming the one idle longest (E0479). Its base and what it is about are kept on disk beside its folder (.frost/copies/NAME.json, which holds no token), so the game served again finds it, parked. | Parameters | Type | Meaning | | --- | --- | --- | | `name?` | text | The copy's name: 1 to 64 letters, digits, - and _. Left out: copy1, copy2, ..., the first free. | | `for?` | text | The tag of the hand the copy is for, 1 to 64 characters, as session.token takes one: the hand is made (or found, for a tag given before) with a token of its own and a join file, and is in this copy from then on; refused (E0480) when that hand works in another copy, which the refusal names. Needs a session that writes join files (frost serve --join-file). Left out: no hand; the owner reaches the copy with copy: NAME. | | `mode?` | text | The hand's mode: "plan" (it only reads, in its copy too), "ask", "trial" or "free". Left out: "trial". | | `at?` | integer | A step of the recording: the copy is played there on its own files, as game.seek plays it. Left out: the person's game as it stands now. | | `about?` | text | What the copy was made to do, at most 200 characters: kept and given back by copy.list, never read. | | `of?` | [text] | Copies to see together: a together copy, the game as it stands with each one's changes since its base merged on top in this order, as copy.land merges them (a scene or project file by thing, part and field), refused (E0477) naming what two changed two ways. It is read with copy: NAME as any copy; it has no hand and is never landed, rebased, queued or given (E0552); it is parked like any copy, keeps no record and goes with the session; it goes as soon as one of its copies changes: a request for it looks first and is refused naming that copy (E0552), and copy.list and copy.events find it gone within a few requests. Not with for or at. | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy's name. | | `hand` | integer | The hand made for it, or null without for. | | `file` | text | The hand's join file, for frost mcp --join-file, or null without for. | | `folder` | text | The copy's folder: a whole game, for the hand's own file tools to read, search and change. | | `base` | record | What the copy started from: {landing, step, checksum}, the number of the game's last landing (0 before any; copy.landed), and the step and the world's checksum its game started at (the person's, when it was made from the game as it stood). | | `bytes` | integer | The bytes of the files copied. | | `parked` | text | The copy parked to make room for it, or null. | | `ms` | number | How long making it took in the engine: the files copied, the game loaded and started. | ## copy.list `copy.list {summary?: value, group?: text, after?: text, limit?: integer} -> {landing: integer, queued: [text], next: text, copies: [record]}` · read, read-only Lists the copies of the game, live and parked, for everyone: each with its hand, where its game stands and what it changed against what it was made from. The copies kept in the game's folder by an earlier session are found and listed too, parked, with their bases; a folder there with no record of its base is listed with base, files and behind null, and is never woken, landed or rebased (E0481) until copy.drop takes it away. | Parameters | Type | Meaning | | --- | --- | --- | | `summary?` | value | true: counts and groups, no rows, from what the session holds (no folder read): {landing, queued, count, states: {live, parked, busy}, behind: {"0", "1-9", "10+"}, tests: {passes, failed, none}, groups: [{group, count, live, behind}], claims: the copies that claim anything}, a group a hand's tag up to a / (red/a is in red), else the first word of about, behind in a group the copies behind any landing. For an editor showing hundreds of agents. Left out: false. | | `group?` | text | Only the copies of this group, as summary names groups. Left out: all. | | `after?` | text | Only the copies made after this one: the next of the page before it. Left out: from the first. | | `limit?` | integer | At most this many copies; next then names the last listed, to ask after it. Left out: 100, and next when there are more. | | Result | Type | Meaning | | --- | --- | --- | | `landing` | integer | The number of the game's last landing: 0 before any. | | `queued` | [text] | The copies whose landings are in the landing queue (copy.queue), in the order asked. | | `next` | text | With limit, the last copy listed when more come after it: ask with after: next. Else null. | | `copies` | [record] | One {copy, hand, who, about, mode, state, busy, held, moment, shared, step, checksum, base, behind, files, says, test, tests, last_change, last_run, bytes, idle_s, folder} per copy, in the order they were made. hand, who and mode are its hand's (null for a copy made without for); state is "live" or "parked" (its game let go: the next command that reaches it wakes it); held is, for a parked copy, the bytes it holds beyond its folder (its moment, and what it knows of its files by hash), null for a live one; shared is, for a parked copy with a moment, how many parked copies share that one moment (copies made from one moment of the game share it while they have not moved; held then counts its share), null for a live one; moment is, for a parked copy, whether it keeps a moment of its game (false for one found again after the game was served again: it wakes at its step, played on the recording), null for a live one. busy is true while its game is carrying out a command: the copy is listed without waiting for it, step, checksum, last_change and last_run as they were when it last finished one. step and checksum are where its game stands. base is copy.make's, its landing moved by copy.rebase (to the game's last) and by its own landing (whose changes are then no longer its own to land); behind counts the landings of other copies since, which it does not play until its copy.rebase. files is what its folder changed from what was copied: one {path, line, added, removed} per file changed, added or taken away, line the first line, from 1, that is not as it was, added and removed the lines it adds and takes away (all three null for a file that is not text). says and test are what its last change.test said and came to: test {passes, on, line, first: [{part, step}], n}, first the step each said part first differs at, or null before any test; tests {run, failed} counts its tests, a landing's among them. last_change is the last file it took in: {what: "file", name, line, step, n, error}, line the first line of it that is not as it was before, error why it could not be taken in (the copy runs on as it was) or null. last_run is its last game.step, game.seek or game.try that left its game at the end of the recording: {to_step, checksum, n}. n counts the copy's changes, runs and tests, so a run whose n is above the last change's is a run after it, and a test whose n is below it is of an older change. claims is its claim (copy.claim), {things, files, about}, or null. of is, for a together copy (copy.make {of}), the copies it is of, null for any other. bytes is what its folder holds (files and bytes are read again only when the copy's folder, by each file's length and time, or its base is not as when last listed); idle_s the seconds since anything was asked of it; folder where it is. | ## copy.drop `copy.drop {copy?: text} -> {dropped: text, copies: integer, busy: value, bytes: integer, problem: text}` · write Drops a copy, live or parked: its game stops and its folder and record are removed. A copy busy with a command is not waited for: it is gone from the list at once, and its folder is removed when that command ends. The owner drops any copy; a hand in a copy drops its own (E0474 for another). The hand stays the copy's: what it sends from then on is refused (E0473), never carried out in the person's game. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy to drop. Left out: the hand's own. | | Result | Type | Meaning | | --- | --- | --- | | `dropped` | text | The copy dropped. | | `copies` | integer | How many copies are kept now, live and parked. | | `busy` | value | Whether it was busy with a command: its folder is then removed when that command ends. | | `bytes` | integer | The bytes its folder held. | | `problem` | text | Null, or why its folder could not all be removed. | ## copy.land `copy.land {copy?: text, says?: [text]} -> {landed: value, landing: integer, change: integer, wrote: [record], waits: text, line: text, test: record, reloaded: value, problem: text, claimed: [record], ms: number}` · write Lands a copy's changes in the person's game. What the copy changed since its base (copy.list's files) is merged onto the game's files as they are now: a scene or project file (.toml) by thing, part and field, so changes to other things, other parts or other fields of one part all land (things and parts added or taken away as a set, the order of things kept by name; a value written over lines, a tilemap's rows, merged by its lines; the run frost test --write writes, replay and checkpoints, the game's, written again by the landing), and any other text, or a .toml that cannot be read so, line by line. The same field changed on both sides in two ways (or lines, or touching lines, of another text) is refused naming the file and, for a field, its thing, part and field and the base's value and each side's (E0477, each clash in data.clashes as {path, thing, part, field, base, ours, theirs, lines: {ours, theirs}, by}), nothing written. The merged files are played over the game beside it on the recording and held to what the copy says, as change.test {copy} holds them; when a landing since the copy's base said a part this one says too (one thing's part, mark_3.Rect.color, and another thing's never overlap), a third game plays the copy alone (its whole folder), and that part must be in the merged game what it is there, from its step on, or the landing is held saying where, with both values and that landing. A change that passes is written as one change of the session's journal (project.undo takes it back byte for byte), with the recorded run it now comes to in the project file and each shot it changed as said in shots/, so frost test passes after; each saved test of the game (another project file beside it that records a run, its test_of this game's or none) is held the same way on its own recording, and the run it now comes to is written in the same change, so it passes after too; a saved test that moves where the copy did not say holds the landing, naming it; one whose run did not hold before is left as it was; the game is loaded again from its files. The owner lands any copy; a copy's hand lands its own in the mode free only, and otherwise is told it waits for the person, with the test, and nothing is written. Every landing and every one held is kept in the landing log (copy.landed). Other copies play it only at their own copy.rebase. E0478: nothing to land, or a file that could not be written (nothing is). | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy to land. Left out: the hand's own. | | `says?` | [text] | What the change changes, as change.test's says. Left out: what the copy's last change.test said. | | Result | Type | Meaning | | --- | --- | --- | | `landed` | value | Whether it was written. | | `landing` | integer | The landing's number, from 1, or null. | | `change` | integer | The change of the session's journal it made (project.undo), or null. | | `wrote` | [record] | One {path, sha256} per file written, sha256 null for one taken away: the merged files, the project file when the run moved, each saved test whose run moved, and the shots it changed. | | `waits` | text | "the person" when the test passes and the hand may not land by itself; else null. | | `line` | text | What became of it, in a sentence: landed, held (the test's sentence, and for two that fail together the landing it is on top of and copy.rebase), or waiting. | | `test` | record | The test, as change.test {copy} answers it, on: {landing} the game it was played on; with the stage tests and saved, one {run, passes, held, wrote, line} per saved test of the game: run its project file, passes whether it differs only where the copy said on its recording, held whether its run held before (one that did not is not held to the change), wrote whether its new run is written. | | `reloaded` | value | When landed: whether the game loaded again from its files. | | `problem` | text | When landed: null, or why the game did not load again (it runs on as it was). | | `claimed` | [record] | When landed: other copies' claims (copy.claim) on the things or files it landed, {thing \| file, copy, about} each; it landed all the same. | | `ms` | number | How long the landing took in the engine. | ## copy.rebase `copy.rebase {copy?: text} -> {copy: text, base: record, merged: [text], untouched: [text], ms: number}` · write Puts a copy on what has landed: the game's files as they are now, with the copy's changes since its base merged onto them as copy.land merges them (a scene or project file by thing, part and field), are written into the copy's folder, and taken in by its game at its next command, as a save is. Its base is then the game's files and its landing the last (behind 0). A field (or lines of another text) changed on both sides in two ways is refused naming it, as copy.land refuses it (E0477, data.clashes), nothing written. A copy never takes a landing in by itself. The owner rebases any copy; a copy's hand its own. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy to rebase. Left out: the hand's own. | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy. | | `base` | record | {landing}: the landing it is on now. | | `merged` | [text] | The files of its folder written: the game's changes, merged with its own where it had any. | | `untouched` | [text] | The files it changed that the game did not: its own as they were. | | `ms` | number | How long it took in the engine. | ## copy.landed `copy.landed {after?: integer} -> {landing: integer, entries: [record]}` · read, read-only The landing log of the game, for everyone: each landing and each one held, oldest first. It is kept on disk (.frost/landings.json beside the project file), so the game served again goes on numbering its landings; an entry of an earlier session has change and undone null, since the journal project.undo takes changes back from is the session's. | Parameters | Type | Meaning | | --- | --- | --- | | `after?` | integer | Only the entries after this n. Left out: all. | | Result | Type | Meaning | | --- | --- | --- | | `landing` | integer | The number of the game's last landing: 0 before any. | | `entries` | [record] | One {n, landing, copy, who, about, files, says, first, verdict, line, by, at, tests, change, undone, stages} per landing or landing held: n its place in the log, landing its number (null when held), files the lines it changed of the game ({path, from, to, added, removed}, added and removed its lines, as copy.diff counts them), says what it said, first the step each said part first differed at ({part, step}), verdict "landed" or "held", line the sentence, by "the person" (the owner's) or "itself" (a free hand's own), at the seconds since 1970 it was asked, tests {run, failed} the copy's tests until then, change the journal's change and undone whether project.undo took it back (kept for this session even after the inverse leaves the 64-change journal), stages each stage its test answered ({name, passes, line}). | ## copy.queue `copy.queue {copy?: text, says?: [text]} -> {copy: text, place: integer, queued: integer}` · write Puts a copy's landing in the landing queue, at its end: the queue keeps the order landings were asked in, and copy.flush lands them, many at a time, each test run shared by a batch. The owner queues any copy; a copy's hand its own in the mode free only (E0550 otherwise). A copy already in the queue is refused (E0550). Nothing is merged or tested until copy.flush; copy.list's queued lists the queue. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy whose landing to queue. Left out: the hand's own. | | `says?` | [text] | What the change changes, as copy.land's says. Left out: what the copy's last change.test said. | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy. | | `place` | integer | Its place in the queue, from 1. | | `queued` | integer | How many landings the queue holds now. | --- Page: reference/protocol/copy-2.md # Protocol: copy, part 2 of 2 The `copy` 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). ## copy.flush `copy.flush {max?: integer} -> {landed: [record], held: [record], refused: [record], batches: [record], runs: integer, max: integer, line: text, ms: number}` · write Lands the landing queue, the session's owner only (E0550 otherwise), in the order it was asked. From its head, a batch is the longest run of queued landings, up to max, that merge onto the game and onto each other as copy.land merges (by thing, part and field) and whose parts said overlap no other member's (one thing's part and another thing's never do); the batch is merged in queue order and tested once over the game, as copy.land tests one copy, saying every part its members say, with the saved tests once. Passing, each member is written as a change of its own in the session's journal and a landing of its own in the log (copy.landed), with its own lines, in queue order (the last also carries the run and the shots the test wrote), so project.undo takes back the last member alone, as after landings one by one; each copy is on what it landed. Failing, the batch is cut in two and each half tested on the game as it is then, the first half landed before the second is tried, down to the landing that fails, which is held with its test's sentence: a batch of K with one landing that fails costs at most 1 + 2 log2(K) runs. A landing that clashes with the game is refused (E0477, its sentence in refused), one with nothing to land too (E0478); one that another landing since its base said a part of is played alone too, so it lands by itself, as copy.land lands it. The same requests in the same order land the same way. | Parameters | Type | Meaning | | --- | --- | --- | | `max?` | integer | The most landings one batch holds, 1 to 256. Left out: 64, a chosen number, not a measured one: a batch of 64 with one landing that fails costs at most 13 runs. Each flush answers its runs and what it held, so a real party's rate of failure can set it. | | Result | Type | Meaning | | --- | --- | --- | | `landed` | [record] | One {copy, landing, change} per landing written, in the order landed. | | `held` | [record] | One {copy, line} per landing whose test failed: what it differs in that it did not say. | | `refused` | [record] | One {copy, code, line} per landing not tried: a clash with the game (E0477), nothing to land (E0478), a copy that is gone (E0473). | | `batches` | [record] | One {copies, runs, split} per batch: its members in queue order, the test runs it took, and split the sentence of each test of more than one landing that failed, after which they were cut in two. | | `runs` | integer | How many test runs the flush took in all. | | `max` | integer | The most landings a batch held in this flush (max, or 64). | | `line` | text | What it came to, in a sentence. | | `ms` | number | How long the flush took in the engine. | ## copy.events `copy.events {after?: integer, limit?: integer} -> {n: integer, started: number, next: integer, events: [record]}` · read, read-only What the party did, in order, for an editor's Party column and anyone watching it work: one event per copy made, working, asked to land, tested, landed, held, refused, queued, rebased, parked, given or dropped. working is found as the events are asked: a copy whose folder was saved since it was last seen, with the files, things and fields it changed of its base. Ask with after: the n of the last event seen, to have only what came since. The session keeps the last 10,000, in memory: served again, the stream starts again from n 0 with a later started, so a client that sees started change (or n below the after it asked with) lists afresh (copy.list {summary}). | Parameters | Type | Meaning | | --- | --- | --- | | `after?` | integer | Only the events after this n. Left out: from the first kept. | | `limit?` | integer | At most this many events, up to 500; next then says where to go on. Left out: 500. | | Result | Type | Meaning | | --- | --- | --- | | `n` | integer | The number of the last event: ask after it next. | | `started` | number | When this session's stream began, in seconds since 1970: another than before means the game was served again and the stream started again. | | `next` | integer | When more events come after these: the n of the last given, to ask after it. Else null. | | `events` | [record] | One {n, at, copy, who, what, ...} per event, oldest first: at the seconds since 1970, who the copy's hand's tag or null, what one of made {about}, working {files, things, fields}, asked {says}, tested {passes, line}, landed {landing, change, things, fields, claimed; batch when a queue landed it}, held {line}, refused {code, line, clashes}, queued {place}, rebased {landing, merged}, parked, given {hand, from, mode}, dropped, claimed {things, files, about}, released. things are the scene things it changed, fields each as thing.part.field (thing.part for a value that is not an inline table's field). | ## copy.claim `copy.claim {copy?: text, things?: [text], files?: [text], about?: text, release?: value} -> {copy: text, claims: record, others: [record]}` · write Puts a light claim of a copy on scene things and files, so two agents do not build the same thing: advisory. Everyone sees it (copy.list's claims, copy.events' claimed); a landing that touches a thing or file another copy claims lands as ever and says whose it was (copy.land's claimed); nothing waits on a claim, so a party cannot deadlock. Each call adds to the copy's claim; release ends it. It ends too when the copy lands what it claimed (that thing or file), or is dropped. In memory: the session's: served again, every claim is gone while the copies stay, and a client that sees copy.events' started change claims again. The owner claims for any copy; a copy's hand for its own. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy that claims. Left out: the hand's own. | | `things?` | [text] | Scene things, by name, added to its claim. | | `files?` | [text] | Files, by their path from the project file's folder, added to its claim. | | `about?` | text | What it is doing with them, in a few words. | | `release?` | value | true: ends the copy's claim. | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy. | | `claims` | record | Its claim now, {things, files, about}, or null when it has none. | | `others` | [record] | Other copies' claims on the same things or files: {thing \| file, copy, about} each. Nothing is refused for them. | ## copy.diff `copy.diff {copy?: text, landing?: integer, context?: integer} -> {files: [record], truncated: value, copy: text, landing: integer, undone: value}` · read, read-only What a copy changed, or what a landing wrote, line by line, for everyone (an editor's Landing panel): for copy, each file it changed, added or took away against its base, the files copy.list's files counts; for landing, each file that landing wrote against the files just before it, read from the texts the landing log keeps (.frost/copies/.texts, by hash), so it is answered after the game is served again too, with undone when project.undo took it back. Bounded: 400 lines in all and 400 characters a line, a line cut marked cut and truncated true when anything was left out (added and removed always count every line); a file that is not text gives its sizes, in bytes, and no hunks. Nothing is written. The texts of the most recent 256 landings are kept (about 27 KB a landing of Ballast: a chosen number); an older landing's diff, its texts let go as later ones landed, is refused in words saying so (E0551), its copy.landed entry with its counts and stages staying. A landing that is not there, or whose kept texts are gone (an older engine's, or removed), is refused in words (E0551), never guessed. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy whose changes to show. Left out with no landing: the hand's own. | | `landing?` | integer | The landing whose writes to show, as copy.landed numbers them: in place of copy. | | `context?` | integer | Lines kept as they were shown around each change, 0 to 3. Left out: 0. | | Result | Type | Meaning | | --- | --- | --- | | `files` | [record] | One {path, added, removed, binary, hunks} per file: added and removed its lines (bytes for one that is not text), hunks [{old_from, new_from, lines: [{op, text, cut?}]}] with op "+", "-" or " " and old_from, new_from the first line of each side, from 1. | | `truncated` | value | Whether lines, or the end of a line, were left out. | | `copy` | text | The copy, or the copy whose landing it was. | | `landing` | integer | For a landing: its number. | | `undone` | value | For a landing: whether project.undo took it back, retained in this session after journal eviction; null for one of an earlier session. | ## copy.park `copy.park {copy?: text} -> {copy: text, parked: value, was: text, step: integer, checksum: text, held: integer, ms: number}` · write Parks a copy: its game is let go, and its folder, its base and one moment of its game are kept (under 100 KB beyond its folder); the next command that reaches it wakes it from that moment, its game loaded again from its folder, as making one does, so it goes on as it would have. A copy is parked by itself too: idle ten minutes (looked at as each request is taken in), or the one idle longest when a seventeenth would be live. A copy busy with a command is not parked (E0481). The owner parks any copy; a copy's hand its own. | Parameters | Type | Meaning | | --- | --- | --- | | `copy?` | text | The copy to park. Left out: the hand's own. | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy. | | `parked` | value | true. | | `was` | text | "live", or "parked" when it was parked already. | | `step` | integer | The step its game stood at. | | `checksum` | text | The world's checksum there. | | `held` | integer | The bytes it holds parked beyond its folder: the moment, and what it knows of its files, by hash. | | `ms` | number | How long parking it took in the engine. | ## copy.give `copy.give {copy: text, to: text, mode?: text} -> {copy: text, hand: integer, file: text, from: integer, mode: text}` · write Gives a copy to the hand of a tag, from the session's owner only (E0474 from anyone else): the hand is made (or found, for a tag given before) with a token of its own and a join file, as copy.make {for} makes one, and is in the copy from then on. The hand the copy had is in no game from then on: what it sends is refused (E0480), never carried out in the person's game. Refused (E0480) for a hand that is in another copy, and (E0481) for a copy found with no record. A copy found again after the game was served again has no hand until it is given one. | Parameters | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy to give. | | `to` | text | The tag of the hand to give it to, 1 to 64 characters. | | `mode?` | text | The hand's mode: "plan", "ask", "trial" or "free". Left out: "trial". | | Result | Type | Meaning | | --- | --- | --- | | `copy` | text | The copy. | | `hand` | integer | The hand it is given to. | | `file` | text | That hand's join file, for frost mcp --join-file. | | `from` | integer | The hand it had, or null. | | `mode` | text | The hand's mode. | --- Page: reference/protocol/scene.md # Protocol: scene The `scene` 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). ## scene.load `scene.load {name: text} -> {scene: text, step: integer, checksum: text}` · write Starts one of the game's scenes now, as a script's scene.load does: the entities are replaced, scripts keep their state and have on_scene called. For jumping to a level; a replay of input.history does not repeat it. | Parameters | Type | Meaning | | --- | --- | --- | | `name` | text | The scene, as game.info lists them. | | Result | Type | Meaning | | --- | --- | --- | | `scene` | text | The scene that started. | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | --- Page: reference/protocol/script.md # Protocol: script The `script` 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). ## script.reload `script.reload {name: text, source: text} -> {name: text, step: integer, queued: value}` · trusted-project-only Swaps one script's code while the game runs, keeping the world and the script's state. | Parameters | Type | Meaning | | --- | --- | --- | | `name` | text | The script's name, as game.info lists them. | | `source` | text | The new source: Luau, or C# for a script whose name ends in .cs. If it does not load, the old code stays, and the error's data has its line and column. | | Result | Type | Meaning | | --- | --- | --- | | `name` | text | The script that was swapped. | | `step` | integer | How many fixed steps have run. | | `queued` | value | false: the code is swapped. true: the debugger holds a script stopped, and the code is swapped when that step is over; script.reloads then says whether it loaded. | ## script.state `script.state {name?: text} -> {step: integer, states: record, kinds: record}` · read, read-only Reads what scripts keep between steps: each script's `state` table, as it was stored with the world at the end of the last step. | Parameters | Type | Meaning | | --- | --- | --- | | `name?` | text | Only this script. Left out: every script. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `states` | record | Each script's name with its state. A Luau table with keys 1 to n is a list; any other table is an object, a number key written as text; an empty table is always {}. An entity is the number generation * 4294967296 + index, a whole number below 2^53 (4294967299 is e3.1). A number that is not finite is the text "Infinity", "-Infinity" or "NaN". | | `kinds` | record | What a kept value is, where it is more than the plain value it reads as: a script's name with {key: kind} for each such key of its state, a key inside a table written with dots ("boss.target"). A key that is not here is a plain value, and a script with none is not here: {} for a game of Luau scripts, whose values say what they are. The one kind is "thing": a C# script's `Thing` field, whose number is an entity as above, or -1 for no thing. | ## script.reloads `script.reloads {} -> {reloads: [record]}` · read, read-only Lists the latest script reloads: which worked, which failed and why, and how long each took to reach the screen. | Result | Type | Meaning | | --- | --- | --- | | `reloads` | [record] | Up to 32, oldest first: {number, script, step, source, ok, error, ms_to_step, ms_to_screen, ms_from_save}. source is "file" for a saved file and "command" for script.reload. A reload is finished when ok is false or ms_to_step is a number: a step has run the new code, in that time from the change being noticed. ms_to_screen and ms_from_save (from the save itself) are null until a window has shown a frame that ran the new code, which a hidden or covered window does not do; wait on ms_to_step, not on them. | ## script.complete `script.complete {file: text, source?: text, line: integer, column: integer} -> {from: integer, items: [record], read: text, columns: text}` · read, read-only Says what names the engine knows go at a place in a script: inside the quotes of a name passed to the engine (a part, a field of the part before it, a thing, an event, an input action, a sound, a scene, a library) or after `tuning.`, those of this game that begin with what is written. For an editor's completion as a person types, and for an agent writing a script. Reads `source` when given, so a buffer not yet saved is answered; nothing changes. | Parameters | Type | Meaning | | --- | --- | --- | | `file` | text | The script, from the project file's folder: what is read when `source` is left out. | | `source?` | text | The script's text as it is in the editor now. Left out: the file's. | | `line` | integer | The line of the place, from 1. | | `column` | integer | The column of the place, from 1, in UTF-16 code units: the place is before the character there. | | Result | Type | Meaning | | --- | --- | --- | | `from` | integer | The column where the name being written begins: a completion replaces from there to the place. | | `items` | [record] | One {label, kind, detail, about} per name that fits: label the name, kind part, field, thing, event, action, tuning, sound, scene or library, detail what it is (a part's fields; a field's part, type and default as a script writes it, "Foe.health: whole number = 3"; a tuning value), about one sentence. None where the engine knows no names go. | | `read` | text | How the answer was read: "text", the scripts' text and the scene and project files, not the values it runs with. A call to the engine through another name (`local f = get; f(e, "Body", "vx")`) is not seen, and a local that shadows an engine function is taken for it. | | `columns` | text | The unit columns count in: "utf16", UTF-16 code units from 1, as an editor's text model and the Language Server Protocol count them (a letter outside the Basic Multilingual Plane is two). Lines count from 1. | --- Page: reference/protocol/save.md # Protocol: save The `save` 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). ## save.list `save.list {} -> {step: integer, place: text, slots: record}` · read, read-only Reads the game's saves: every slot that holds something, as the scripts' save.get would read it now. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `place` | text | Where the saves are kept: a folder. null when they are kept nowhere and end with the session, as under frost serve, frost mcp and frost run without --saves DIR. | | `slots` | record | Each slot's name with what it holds, written as script.state writes a table. | ## save.set `save.set {slot: text, data?: record} -> {step: integer, place: text, slots: record}` · write Makes a slot hold a table, as a script's save.set does, or empties it. The change is written where the saves are kept. It is not input: a recording does not carry it. | Parameters | Type | Meaning | | --- | --- | --- | | `slot` | text | The slot's name: 1 to 32 of a to z, the digits, `-` and `_`. | | `data?` | record | What the slot is to hold: an object of numbers, strings, true or false, lists and objects, at most 64 KB as TOML. Left out: the slot is emptied. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `place` | text | Where the saves are kept: a folder. null when they are kept nowhere and end with the session, as under frost serve, frost mcp and frost run without --saves DIR. | | `slots` | record | Each slot's name with what it holds, written as script.state writes a table. | --- Page: reference/protocol/project.md # Protocol: project The `project` 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). ## project.add `project.add {kind: text, name: text} -> {file: text, project: text}` · trusted-project-only Adds a scene or a script to the game: writes the file from the engine's own stub (a scene with nothing in it; a script with an empty on_scene and step) and names it in the project file's `scenes` or `scripts`, after the last one, every comment and line of the project file kept as written. The running game is not changed: game.reset loads it with the new file, and frost dev, which watches the project file, does that by itself. Refused (E0446), with nothing written, when the name is taken (the project names it, or a file is there), is not a plain path, or is outside the project; and for a game a web page handed to the server. | Parameters | Type | Meaning | | --- | --- | --- | | `kind` | text | "scene" or "script". | | `name` | text | Its path from the project file's folder, `/` between folders, of letters, digits, `-`, `_` and `.`, with or without `.toml` or `.luau`: "level2", "ai/boss". | | Result | Type | Meaning | | --- | --- | --- | | `file` | text | The file written, by its path from the project file's folder: "level2.toml". | | `project` | text | The project file that now names it. | ## project.remove `project.remove {file?: text, maybe?: value, unlist?: value, kind?: text, name?: text} -> {file: text, project: text, unlisted: [text], wrote: [record], maybe: [record], change: integer, kept: text}` · trusted-project-only Given `file`, removes any file of the game: it leaves every list of the project file that names it (`scenes`, `scripts`, `libraries`, `data`, `images`, `sounds`, `fonts`, `models`; every other comment and line kept as written) and is taken out of the game. It is one change, numbered by `change`, as a project.rename is: the file is moved into `.frost/removed/N/` beside the game (answered as `kept`), so project.undo puts it and the project file back byte for byte and project.redo removes it again; the folder is the engine's own and may be deleted to let the file go for good. Refused (E0446), with nothing changed, while anything else names it for certain (another key of the project file, a saved test, a scene, a script: the places project.refs lists with followed true), and for the project file itself. `unlist: true` also takes it out of the project file's other keys and lists in the same change (a key's whole line, as `recording = "run.toml"` under `[input]`; an item of a list), every other line and comment kept; refused in words for the scene the game starts in (`scene`), for a place that is not a line of its own, and when the project file would no longer load without it. A place that only may name it (a script's call whose name is made as it runs, followed false) refuses too, unless `maybe: true` says to remove it although those remain; the answer lists them. Given `kind` and `name`, takes back a project.add: the scene or script leaves the project file's `scenes` or `scripts` (every other comment and line kept as written) and its file is deleted. Only while the file is still exactly the engine's stub and nothing else in the game names it, so nothing a person wrote is lost: an editor's undo of adding one, not a delete. The running game is not changed. Refused (E0446), with nothing changed, when the project does not name it, it is the scene the game starts in, its file has changed since it was added, or a scene, script or library names it; and for a game a web page handed to the server. | Parameters | Type | Meaning | | --- | --- | --- | | `file?` | text | Any file of the game, by its path from the project file's folder with `/`: "art/old.png". Given it, leave out `kind` and `name`. | | `maybe?` | value | With `file`, true: remove it although places that only may name it remain (project.refs's followed false); they are answered as `maybe`. A place that names it for certain still refuses. Left out: such a place refuses. | | `unlist?` | value | With `file`, true: take its name out of the project file's keys and lists beyond the eight lists, in the same change. Left out: such a place refuses. | | `kind?` | text | "scene" or "script", with `name`: the undo of a project.add. | | `name?` | text | Its path from the project file's folder, as project.add was given it or answered it: "level2", "ai/boss.luau". | | Result | Type | Meaning | | --- | --- | --- | | `file` | text | The file deleted, by its path from the project file's folder. | | `project` | text | The project file that no longer names it. | | `unlisted` | [text] | The project file's lists it was taken out of, once for each time it was named: ["images"]; with unlist, the other keys too, each by its path: ["input.recording"]. | | `wrote` | [record] | {path, sha256} of the project file when it was rewritten, else empty. | | `maybe` | [record] | With `file`: {path, line, column, text, followed, why}, as project.refs gives them: the places that may name the file and were left as they are; empty when there is none. Left out with `kind` and `name`. | | `change` | integer | With `file`: the change's number, for project.undo. Left out with `kind` and `name`, which is no change of its own. | | `kept` | text | With `file`: where the removed file is kept for project.undo, from the project file's folder: ".frost/removed/1/art/old.png". | ## project.refs `project.refs {file: text} -> {file: text, refs: [record], read: text, columns: text}` · read, read-only Lists every place in the game that names one of its files: the project file's lists, a scene's fields that hold a path (a picture, a sound, a font), a saved test's scene and test_of, and a script's library, data, scene.load, sound.play and music.play, and any other plain string a script or a file of values (`data`) writes that is the file's path. A name is the file however it is spelled (`./art/hero.png`, and another case of its letters on a disk that takes both for one file). A script's call whose argument is not a literal string cannot be followed without running it: it is listed with followed false, never guessed at. What an editor asks before it renames or removes a file. Changes nothing. | Parameters | Type | Meaning | | --- | --- | --- | | `file` | text | The file, by its path from the project file's folder with `/`: "art/hero.png". Refused (BadParams) when it is not in the game's folder, or is in .ven or export. | | Result | Type | Meaning | | --- | --- | --- | | `file` | text | The file, as named. | | `refs` | [record] | {path, line, column, text, followed, why}: each place, by its file from the project file's folder, its line and the UTF-16 column the name's text begins at (both from 1), the line's text trimmed, and followed false for a script's call whose file is made as it runs; why says in a word why a place is not followed ("made": the name is made as the script runs, so this place may name the file or may not), and is null for one that is. In the order: the game's project file, the other project files beside it (saved tests), its scenes, its scripts. | | `read` | text | "text": the files were read as text, not run. | | `columns` | text | "utf16": how columns are counted. | ## project.rename `project.rename {from: text, to: text, dry?: value, force?: value} -> {from: text, to: text, rewrote: [record], left: [record], moved: [record], runs: [record], change: integer, dry: value, reloaded: value, problem: text}` · trusted-project-only Renames or moves one file of the game and writes its new name over the old at every place project.refs lists: the project file's lists and keys, the saved tests beside it, the scenes' fields, the files of values, and the plain strings of the scripts (library, data, scene.load, sound.play, music.play and any other), each between its own quotes and in the spelling it had (`./art/hero.png` becomes `./art/knight.png`), every comment and line kept as written; an atlas's `sheet` too. The file's source note and terms (`NAME.from.toml`, `NAME.terms.txt`) go with it. It is one change, numbered by `change`: project.undo puts every file back byte for byte, and project.redo makes it again. The session then loads the game again from its files, as game.reset does (step 0). `dry: true` answers the same and changes nothing. One file at a time: a folder is not renamed. Refused in words, with nothing changed: `to` is taken (E0463); there is no file `from`, or it is a folder (E0464); a path leaves the game's folder, is not plain, or `to` has a part that is not letters, digits, `-`, `_` and `.` (E0465); the ending would change, which says what the file is (E0466); a place names the file and cannot be written over (E0467): a script's call whose argument is made as it runs, a string written with an escape, an atlas's pattern, a model's `uri`, a line of C#, each named in the sentence, unless `force` is true, which renames and answers them as `left`; the game's project file, or a saved test into another folder (E0468); a game a web page handed to the server (E0469). A hand that is planning is refused as for every write (E0447), a dry run too. A renamed scene leaves a recorded run's checksum as it was. A renamed script keeps its recorded runs: a script's `state` is kept under its file's name, which the checksum covers, so each project file at the top of the game's folder that plays the script and records a run (the game's, its saved tests) is played once before anything is written, its run summed as it is and as it is with the new name; when the first is what the file records, the second is written over it in the same change (only the digits of each sum), and the game as accepted beside it (`.frost/accepted/NAME`) is carried too while it is the game on disk, so frost test passes after and project.undo takes all of it back. A run that did not hold before the rename is left as it was (`written: false`). A dry run plays none. A script renamed by hand still fails its test, saying it was renamed. A renamed picture (any file but a script or a scene) keeps its recorded runs the same way: the world holds its name as a text (a `Sprite`'s `image`), so each run is summed with every text the rename writes over read as it is written now, unless a place was left as it was (`force`), when no run is carried and frost test --write accepts it again. | Parameters | Type | Meaning | | --- | --- | --- | | `from` | text | The file, by its path from the project file's folder with `/`: "art/hero.png". | | `to` | text | Its new path, the same way, each part of letters, digits, `-`, `_` and `.`, with the ending `from` has: "art/knight.png". Folders that are not there are made. | | `dry?` | value | true: answer what would be done and change nothing. | | `force?` | value | true: rename although places that name the file cannot be written over, and answer them as `left`. | | Result | Type | Meaning | | --- | --- | --- | | `from` | text | The file as the disk names it. | | `to` | text | Its new path. | | `rewrote` | [record] | {file, line, was, now}: each name written over, by the file it is in (as it was named before the change), its line from 1, and the name as it was spelled and as it is now. | | `left` | [record] | {file, line, text, why}: each place that names the file and was not written over, with the line's text and why; empty unless `force` (or `dry`) let them be. | | `moved` | [record] | {from, to}: the file, then its source note and terms when it has them. | | `runs` | [record] | {file, was, now, written, accepted}: each project file whose recorded run keeps the renamed script's state, or holds the renamed picture's name, with the run's checksum before the rename and after it, whether the new one was written (false when the run did not hold before the rename), and whether the game as accepted beside it was carried; empty for a scene, a file no world holds and a dry run. | | `change` | integer | The change's number, for project.undo; null for a dry run. | | `dry` | value | Whether nothing was changed. | | `reloaded` | value | Whether the game was loaded again from its files; false for a dry run, and when it no longer loads (it then runs on as it was). | | `problem` | text | Why the game did not load again, as its error says it; null when it did. | ## project.undo `project.undo {change?: integer, landing?: integer} -> {change: integer, landing: integer, from: text, to: text, wrote: [text], moved: [record], reloaded: value, problem: text}` · trusted-project-only Takes back the latest change of the project's files this session made and has not undone (a project.rename, or a project.remove of a file): every file it wrote is put back byte for byte, every file it moved goes back to its place, and a folder it made is taken away when empty. The session then loads the game again from its files. Refused (E0470), with nothing changed, when there is no such change, when `change` names another than the latest, or when a file is no longer as the change left it (the sentence names it): nothing written since is lost. The session keeps its latest 64 changes; they are not kept past the session. Instead of change, landing selects one landing from that journal to reverse around later independent edits, using the landing field/line merge and testing against its original says before any project file is written. Its replay sums and changed shots are accepted together; a game with shots requires a graphics adapter. A clash, a failed test, an unknown, expired or already-undone landing, or both selectors is E0470. The inverse is a new journal change (change in the answer), so ordinary undo/redo takes back/makes again the inverse; copy.landed and copy.diff report the original landing as undone while the inverse stands, even after it leaves the 64-change journal. Shots added by that landing are removed with their entries; temporary undo staging is removed after success or refusal. copy.events emits undone with landing and change. See docs/party.md for a headless example. | Parameters | Type | Meaning | | --- | --- | --- | | `change?` | integer | The number the change answered, to be sure which is undone; left out: the latest. | | `landing?` | integer | Instead of change: reverse this landing while preserving later independent edits, as a new tested change. E0470 on a clash or a landing outside this session's journal. | | Result | Type | Meaning | | --- | --- | --- | | `change` | integer | The change undone. | | `landing` | integer | For a selective undo, the landing reversed; change is the new inverse, which ordinary undo/redo takes back/makes again. | | `from` | text | The file the change renamed, as it is named again. | | `to` | text | The name the change gave it. | | `wrote` | [text] | The files whose text was put back. | | `moved` | [record] | {from, to}: each file moved back. | | `reloaded` | value | Whether the game was loaded again from its files. | | `problem` | text | Why it did not load again; null when it did. | ## project.redo `project.redo {change?: integer} -> {change: integer, from: text, to: text, wrote: [text], moved: [record], reloaded: value, problem: text}` · trusted-project-only Makes again the change project.undo took back last, while no other change was made since: the same files written and moved. The session then loads the game again from its files. Refused (E0470), with nothing changed, when nothing is undone, when `change` names another, or when a file is no longer as the undo left it. | Parameters | Type | Meaning | | --- | --- | --- | | `change?` | integer | The number of the change to make again; left out: the one undone last. | | Result | Type | Meaning | | --- | --- | --- | | `change` | integer | The change made again. | | `from` | text | The file the change renames. | | `to` | text | The name it has again. | | `wrote` | [text] | The files whose text was written again, as they are named now. | | `moved` | [record] | {from, to}: each file moved. | | `reloaded` | value | Whether the game was loaded again from its files. | | `problem` | text | Why it did not load again; null when it did. | --- Page: reference/protocol/frame.md # Protocol: frame, part 1 of 2 The `frame` 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). ## frame.capture `frame.capture {width?: integer, height?: integer, overlay?: text, target?: text, view?: record, eye?: record, pose?: record, step?: integer, from?: integer, inputs?: [record], steps?: integer, fill?: value, fast?: value, times?: value} -> {png: png, width: integer, height: integer, view: record, view_size: record, view_projection: [number], game_rect: record, took: record}` · read, read-only Draws the game as it is now, off-screen, and returns the picture: whole, or shrunk to fit inside a width and a height for a client that shows it small. | Parameters | Type | Meaning | | --- | --- | --- | | `width?` | integer | The most pixels across, 1 or more. The picture keeps its shape, the smaller of the two bounds decides, and it is never larger than the frame. A project with filter = "linear" is shrunk smoothly, any other to hard pixels. Left out: no bound. With eye: the picture's width, exactly, 1 to 4096, drawn at that size and never shrunk; left out, the frame's. | | `height?` | integer | The most pixels down, 1 or more. Left out: no bound. With eye: the picture's height, exactly, 1 to 4096; left out, the frame's. | | `overlay?` | text | "physics": every collider's outline, every joint and every contact drawn over the frame, one pixel wide, from what physics.read answers. Grey is static, blue kinematic, green dynamic, yellow a mover, pink a sensor, orange a one-way platform, white a joint and red a contact. "skeleton": the bones of every thing a 3D game poses (a Pose on a model with bones), as the pose drawn places them, a pose asked for the picture's too: a yellow (ffec27) line from each bone to the bone above it and a white 3-pixel square at each joint, over everything, one pixel wide; refused in a game with no rigged model. Left out: the frame alone. | | `target?` | text | One of the frame graph's own targets, by its name in the project's [render], as the frame left it, in place of the frame: what a pass drew before an effect read it. A 16-bit float target is cut to 0 to 1. Not with overlay, and not with eye, whose picture keeps none. Left out: the frame. render.passes lists the targets. | | `view?` | record | {left, bottom, right, top}: a rectangle of the world in world units, y upwards as frame.view gives it, drawn in place of what the game's camera shows: what an editor that sees more than the camera, or less, shows. The picture is the rectangle's shape, at the frame's own pixels to a world unit as the camera's zoom gives them, its longer side at most 4096 (then smaller, keeping its shape), before width and height shrink it. What is on the screen (the interface, a Screen thing) is drawn on the camera's rectangle at the camera's scale, never stretched over the view. The game is not changed: the same step, the same checksum. Not with overlay or target. In a 3D game E0449: it is looked at from an eye. Left out: what the camera shows, as ever. | | `eye?` | record | In a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle. | | `pose?` | record | In a 3D game, {entity, clip, time?}: one thing (by name or id, with a Mesh whose model has clips) drawn time seconds (0 or more; left out 0) into one of its model's clips, for this answer alone, in place of what its Pose says: what an editor scrubbing a clip on a thing in the game shows. Nothing is written: the world, its checksum, its Pose and what the recording replays are as they were, and the next answer without it draws the Pose again. A clip that goes round is drawn round, one that does not holds its end, as a Pose plays it. Picking (frame.at, frame.in) meets things by their box at rest, with or without it. Refused (BadParams) for a thing with no Mesh, a model with no clips, or a clip its model has not, naming its clips. | | `step?` | integer | A step to draw in place of the game as it stands: the picture a `game.seek` to that step would show, without seeking. The run is the one a seek winds through, the game loaded from its files and stepped on its recording (at rest past its end), not input held live; the engine plays it aside from the moment it keeps nearest at or before the step (else from the start, on a game loaded aside from the same files) and draws that world, with eye, pose, view and the rest as for any picture. The game is not moved: its step, world, checksum and kept moments and snapshots are as they were. Refused past the furthest of the steps the session has played, its recording's end and its replay's. Its cost is the replay: about a step's time a step from the moment it starts at. | | `from?` | integer | A snapshot's id (game.snapshot): draw the game a game.try of `inputs` from it would leave, without moving the game, byte for byte what that try then a capture shows. Played aside: the game's step, world, checksum, kept moments and snapshots are as they were, and eye, pose, view and overlay combine as for any picture. Refused when the game has had a change since the snapshot that playing the inputs does not make again: a client's change at a step inside the stretch (named, with its step and command), or a script's code swapped since. Not with `step`. Its cost is the replay: a step's time a step, and a copy of the world each way. | | `inputs?` | [record] | With `from`: the input to play from the snapshot, as game.try takes it, one {steps, ACTION: value, ..., player} per stretch. Left out: none, every player at rest. | | `steps?` | integer | With `from`: how many steps to play, each player at rest past their own inputs. Left out: as many as the longest player's inputs come to. | | `fill?` | value | true: the game's own camera draws the frame into a picture of exactly width by height pixels (both needed, 1 to 4096) with no bars: the frame in the middle, as large as fits at its own shape, its interface laid out in it as ever, and beside it what the same camera sees on (in 3D, its meshes, the camera's field of view held within the frame), so the frame's part is the game's own picture. game_rect says where it is. Not with eye, view, target or overlay. Left out: false. | | `fast?` | value | true: the PNG is written 25 to 35 times faster and is a tenth to a fifth larger, with the same pixels; for a picture shown live and thrown away. Left out: as small as it can be. | | `times?` | value | true: the answer says what the picture took, as took. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `png` | png | The frame as a PNG file, in base64. | | `width` | integer | The picture's width in pixels. | | `height` | integer | The picture's height in pixels. | | `view` | record | The part of the world the picture shows, {left, bottom, right, top} in world units, as frame.view gives it: the world at the picture's edges, whatever size it is shrunk to. With view, the view asked: the rectangle the picture shows, to its edges. null with eye: its picture shows no rectangle of a flat world, and view_projection says what it shows. | | `view_size` | record | {width, height}: with view, the picture's size in pixels as it was drawn, before width and height shrink it: the frame's own pixels to a world unit at the camera's zoom, unless the longer side would pass 4096 (then fewer, the same each way). Pixels of frame.at, frame.in and blame.pixel with the same view are of this size. null without view. | | `view_projection` | [number] | In a 3D game, the 16 numbers the meshes of this picture were drawn with: the matrix from the world to clip space, its four columns one after another (column-major), multiplied with a point (x, y, z, 1) on the right. After the divide by w, clip x and y from -1 to 1 span the whole picture, bars included, x to the right and y up, so a point is at the pixel ((x + 1) / 2 * width, (1 - y) / 2 * height); depth is reversed, 1 at the camera's near plane and 0 at its far one (or towards 0 for ever with no far plane), and a point behind the camera has w at or below 0. It is the camera of the step drawn, paused or sought to as it is; a pass that bends the picture (panini) moves its pixels from where this puts them. Left out in a 2D game, whose view says it. | | `game_rect` | record | With fill: {x, y, w, h}, where the frame stands in the picture, in whole pixels from its top left; the rest is what the camera sees beside it. Left out without fill. | | `took` | record | With times true: {draw, read, encode, text}, what the picture took in milliseconds: its drawing, submitted (the device's wait is in read); its read back from the device, with the physics drawn over it and its shrinking; its PNG; and its base64 text. Time is not part of the game and differs from run to run. Left out without times. | ## frame.at `frame.at {x: integer, y: integer, view?: record, eye?: record, pose?: record, width?: integer, height?: integer} -> {step: integer, x: integer, y: integer, hits: [record], drawn: record}` · read, read-only Says what is drawn at a pixel of the frame: every entity that draws there, the one in front first. It asks the batch a frame is drawn from, so it needs no graphics device, takes no picture and changes nothing. In a 3D game it also says each thing the ray through the pixel meets, by its collider or else its mesh's box, the nearest first. What an editor asks to pick the thing under the pointer. | 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. | | `eye?` | record | In a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle. | | `pose?` | record | In a 3D game, {entity, clip, time?}: one thing (by name or id, with a Mesh whose model has clips) drawn time seconds (0 or more; left out 0) into one of its model's clips, for this answer alone, in place of what its Pose says: what an editor scrubbing a clip on a thing in the game shows. Nothing is written: the world, its checksum, its Pose and what the recording replays are as they were, and the next answer without it draws the Pose again. A clip that goes round is drawn round, one that does not holds its end, as a Pose plays it. Picking (frame.at, frame.in) meets things by their box at rest, with or without it. Refused (BadParams) for a thing with no Mesh, a model with no clips, or a clip its model has not, naming its clips. | | `width?` | integer | With eye: the width in pixels of the picture it is asked about, 1 to 4096, as a frame.capture with the same eye, width and height draws it: the pixels counted, the boxes and view_projection are that picture's. Left out: the frame's. Without eye it is refused: the game's own picture is the frame's size. | | `height?` | integer | With eye: the picture's height in pixels, 1 to 4096. Left out: the frame's. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `x` | integer | The column asked. | | `y` | integer | The row asked. | | `hits` | [record] | One {entity, name, kind, tile, node, layer, alpha, coverage, added, fills, box, turned, pass, material} per entity that draws at the pixel, the one in front first; none where only the background shows. kind is the component it draws there with: "Rect", "Sprite", "Text", "Tilemap" or "Shape"; an entity that draws with two is there twice. A sprite counts only where its picture is not clear, a text where a letter has ink. tile is null, or for a Tilemap {column, row} of the tile there: column 0 is the left one and row 0 the first line of `rows`. node is true for an interface node (an entity with a Node; ui.tree says what it is). layer is the layer it is drawn in. alpha is how much it covers of what is behind it at the pixel, 1 to 255: its colour, its Opacity and its picture there; nothing that covers 0 is listed. coverage is its picture's own alpha at the pixel, 1 to 255, and 255 for what draws with no picture: a client that wants to pass through nearly clear pixels compares this. added is true when it is added to what is behind and hides nothing. fills is the share of the frame, 0 to 1, that the box around everything the entity draws with that component covers: a backdrop is near 1. box is that box, {x, y, w, h} in the frame's pixels with x and y its top-left corner, counted as the pixel asked is: it stands upright around a thing that is turned, is not cut at the frame's edges (x and y may be below 0), need not be whole numbers, and for a Tilemap is around the tiles that touch the frame. turned is for a thing that is turned (a Rotation): {x, y, w, h, angle}, the box around the same, measured along its own sides as it would stand unturned about its own middle and counted as box is, and the turn about that middle in degrees, anticlockwise as the picture shows it, above -180 and up to 180, to three places. Turned so, it is where the thing is drawn, its Scale and Pivot in it: an editor draws it as the thing's outline. turned is null for what is not turned (a whole turn is none), for a Text and a Tilemap, and where what the entity draws with that component is not all turned alike: then box is its outline. pass is the frame graph's pass that draws its layer (render.passes lists them), null when none does; material is what it is drawn with: "sprite", the built-in material every quad has. In a 3D game the things themselves come after what the layers draw over the meshes, the nearest first: each thing the ray through the pixel's middle meets between the camera's near plane and its far one, by its Collider as physics.read gives it (kind "Collider"), else by the box around its Mesh's model where its parents put it (kind "Mesh"); a thing with neither is not met, nor one the ray starts inside. Such a hit has projected true, point, [x, y, z] where the ray meets it in the world, and distance, from the camera to there; its box is around what frame.view's view_projection makes of the box about it, cut at the near plane and the far one only, so a thing that passes the camera has a very large one; layer is 0, alpha and coverage 255, tile and turned null, pass the meshes' pass for a thing with a Mesh and else null, material its Mesh's or null; box, fills, point and distance are to three places. It also has part: for kind "Mesh", {index, mesh, primitive, material, point, distance}, the first triangle of the model the same ray meets, whichever way it faces, as the model stands in its file (nothing moves its corners): index the part among the model's parts as they are drawn (its primitives of one material are one part), mesh the name of the mesh the triangle came from (its node's name in the glTF file, else its mesh's, else "mesh N"), primitive that primitive's place in the mesh, material its material's name in the file ("material N" where the file names none, null for a primitive with no material), point and distance where the triangle is met, at or behind where the box is; null when the ray is in the box and meets no triangle, so nothing of the model is drawn at the pixel, and null for kind "Collider". | | `drawn` | record | In a 3D game, what is drawn at the pixel: of every thing with a Mesh, the triangle the ray through the pixel's middle meets first past the near plane, as the thing is drawn (its matrix, its pose's shapes), whatever colliders the game has: {entity, name, part (its place among the model's parts as drawn), mesh and primitive (of its file), triangle (its place among the primitive's), material (its name, or null), masked (its material cuts out under an alpha, which is not looked at), lod (the level of detail drawn at the pixel: 0 the model's own file, 1 or 2 its `.lod1`/`.lod2` beside it; in a band where two are drawn, the one whose screen door keeps this pixel), point, distance}. The device decides a pixel on a triangle's very edge. And how it is lit, as the lit pass works it out (frost_gfx::lit, the pass's twin, held to the device's pixel within one level): light, one {name, kind, share, why} for every light of the game (ambient, sky, sun, point, spot; reflection for the sky mirrored by metal; glow for the surface's own and inherited emission; fog, an independent Fog without Sky, or haze, the Sky's, when it fades the point into its horizon: its share is how far, the lights' theirs of what it leaves), share its part of the pixel's brightness before it is cut to 1 (they sum to 1), why the frame's words ("in shadow" from the sun's shadow map read where the pass reads it, "faces away", "out of its reach", how far, "outside its cone", "not drawn" for a point or spot light not among the sixteen the picture chose); color, the pixel the twin works out [r, g, b]; Material roughness, metal, inherited tint and emission follow the shader. With transparency, color is the premultiplied sRGB surface contribution, cover is its coverage, and light shares describe only that surface; the destination behind it remains unread. unread names the missing calculations and texture samples (white or a flat normal is used for a missing sample), so color and shares are partial while unread is nonempty. Null where no mesh is drawn; a 2D game's answer has none. | --- Page: reference/protocol/frame-2.md # Protocol: frame, part 2 of 2 The `frame` 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). ## frame.in `frame.in {x: integer, y: integer, w: integer, h: integer, view?: record, eye?: record, pose?: record, width?: integer, height?: integer} -> {step: integer, x: integer, y: integer, w: integer, h: integer, hits: [record]}` · read, read-only Says what is drawn inside a box of the frame: every entity that draws something whose box touches it, the one in front first. By boxes only: a sprite is there though its picture is clear where the box is. In a 3D game it also says each thing whose box, as the camera projects it, touches the box asked. What an editor asks to select with a rubber band. | Parameters | Type | Meaning | | --- | --- | --- | | `x` | integer | The box's left column, a pixel of the frame as frame.at counts them. | | `y` | integer | The box's top row. | | `w` | integer | Its width in pixels, 1 or more. A box that runs past the frame is cut at its edge. | | `h` | integer | Its height in pixels, 1 or more. | | `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. | | `eye?` | record | In a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle. | | `pose?` | record | In a 3D game, {entity, clip, time?}: one thing (by name or id, with a Mesh whose model has clips) drawn time seconds (0 or more; left out 0) into one of its model's clips, for this answer alone, in place of what its Pose says: what an editor scrubbing a clip on a thing in the game shows. Nothing is written: the world, its checksum, its Pose and what the recording replays are as they were, and the next answer without it draws the Pose again. A clip that goes round is drawn round, one that does not holds its end, as a Pose plays it. Picking (frame.at, frame.in) meets things by their box at rest, with or without it. Refused (BadParams) for a thing with no Mesh, a model with no clips, or a clip its model has not, naming its clips. | | `width?` | integer | With eye: the width in pixels of the picture it is asked about, 1 to 4096, as a frame.capture with the same eye, width and height draws it: the pixels counted, the boxes and view_projection are that picture's. Left out: the frame's. Without eye it is refused: the game's own picture is the frame's size. | | `height?` | integer | With eye: the picture's height in pixels, 1 to 4096. Left out: the frame's. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `x` | integer | The box's left column. | | `y` | integer | Its top row. | | `w` | integer | Its width, cut at the frame's edge. | | `h` | integer | Its height, cut at the frame's edge. | | `hits` | [record] | One record per entity and component, as frame.at gives them, with coverage and tile null: no one pixel is meant, and alpha is the most the entity's own colour and Opacity give, without its picture. In a 3D game, also every thing whose projected box, as frame.at gives it, touches the box asked, the nearest part first, with projected true and no point or distance. | ## frame.view `frame.view {eye?: record, width?: integer, height?: integer, fill?: value} -> {step: integer, width: integer, height: integer, passes: [text], view: record, view_projection: [number], game_rect: record}` · read, read-only Says how big the frame is and which part of the world it shows, as the game's camera looks now. It draws nothing, needs no graphics device and changes nothing. With eye, in a 3D game, as it is looked at from there. What an editor asks to put a point of the world on the picture, or a pixel of the picture in the world. | Parameters | Type | Meaning | | --- | --- | --- | | `eye?` | record | In a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle. | | `width?` | integer | With eye: the width in pixels of the picture it is asked about, 1 to 4096, as a frame.capture with the same eye, width and height draws it: the pixels counted, the boxes and view_projection are that picture's. Left out: the frame's. Without eye it is refused: the game's own picture is the frame's size. | | `height?` | integer | With eye: the picture's height in pixels, 1 to 4096. Left out: the frame's. | | `fill?` | value | true: the game's own camera draws the frame into a picture of exactly width by height pixels (both needed, 1 to 4096) with no bars: the frame in the middle, as large as fits at its own shape, its interface laid out in it as ever, and beside it what the same camera sees on (in 3D, its meshes, the camera's field of view held within the frame), so the frame's part is the game's own picture. game_rect says where it is. Not with eye, view, target or overlay. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `width` | integer | The frame's width in pixels, as frame.at counts them and frame.capture draws them at full size; with fill, the picture's. | | `height` | integer | The frame's height in pixels. | | `passes` | [text] | The frame graph's passes that run, in order, by name: one, "layers", for a project with no [render]. render.passes says what each does. | | `view` | record | {left, bottom, right, top}: the world's x at the frame's left and right edges and its y at its bottom and top edges, in world units, y growing upwards. A point of the world at x, y is at the pixel ((x - left) / (right - left) * width, (top - y) / (top - bottom) * height). With no Camera the world and the frame are the same; with one, the Camera's Transform is at the frame's middle and its zoom, when above 0, shows that many times less. What is on the Screen is placed in the frame's own pixels: the camera does not move it. | | `view_projection` | [number] | In a 3D game, the 16 numbers a frame.capture of the frame at its own shape draws its meshes with now: the matrix from the world to clip space, its four columns one after another (column-major), multiplied with a point (x, y, z, 1) on the right. After the divide by w, clip x and y from -1 to 1 span the whole picture, bars included, x to the right and y up, so a point is at the pixel ((x + 1) / 2 * width, (1 - y) / 2 * height); depth is reversed, 1 at the camera's near plane and 0 at its far one (or towards 0 for ever with no far plane), and a point behind the camera has w at or below 0. It is the camera of the step drawn, paused or sought to as it is; a pass that bends the picture (panini) moves its pixels from where this puts them. Left out in a 2D game, whose view says it. With fill, the filled picture's. | | `game_rect` | record | With fill: {x, y, w, h}, where the frame stands in the picture, in whole pixels from its top left; the rest is what the camera sees beside it. Left out without fill. | --- Page: reference/protocol/render.md # Protocol: render The `render` 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). ## render.passes `render.passes {} -> {step: integer, declared: value, passes: [record], culled: [text], targets: [record], textures: integer, pipelines: [record]}` · read, read-only Says how the frame is drawn: the frame graph as it runs, compiled from the project's [render] (or the one pass of a project without it), the passes it dropped, the targets and which share a texture, and the pipelines built for it before the first frame, with the draws each pass made and the milliseconds it took on the CPU in the last picture drawn. It draws nothing and needs no graphics device. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `declared` | value | true when the project has a [render] table; false for the implicit graph. | | `passes` | [record] | One per pass that runs, in order: {name, into, read, clears, bars, pipeline} and, for a pass that draws, draws = "layers" with from and to (null for no bound), "meshes" or "sky", or for an effect, effect with threshold and strength. into is the target written ("frame" for the frame), read the targets read, clears whether it is the first pass into its target, bars whether it draws the bars beside a frame of another shape last, pipeline a place in pipelines. draw_calls is how many draws the pass made in the last picture drawn (a frame.capture, or a frame in a window): one a run of quads with one picture, one a run of one mesh in one material, one the sky (none with no Sky), one an effect; null before any picture is drawn. cpu_ms is the milliseconds the pass took on the CPU in that picture: the engine recording its commands and handing them to the device, measured by the clock, so another run says another number (a measurement, never part of a checksum or a picture); null before any picture is drawn. The GPU's own time is not said: the passes of a frame are handed to the device together and run after, and the device's timestamps need a feature not every device has. | | `culled` | [text] | The passes dropped because nothing they write reaches the frame. | | `targets` | [record] | One {name, format, size, texture, shares} per target declared: format "rgba8" or "rgba16f"; size "frame", "frame/N" or pixels; texture the texture it is drawn into, null when every pass using it was dropped; shares the other targets in the same texture, never alive at once with it. | | `textures` | integer | How many textures the targets take. | | `pipelines` | [record] | One {draws: "quads", "shapes", "meshes" or "sky"} or {effect} per pipeline, with the format it writes: all made when the graph was made ready, none while playing. | --- Page: reference/protocol/events.md # Protocol: events The `events` 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). ## events.read `events.read {name?: text} -> {step: integer, events: [record]}` · read, read-only Reads the events the last step sent. They stay readable until the next step starts. | Parameters | Type | Meaning | | --- | --- | --- | | `name?` | text | Only events with this name. Left out: every event. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `events` | [record] | One {name, entity, other, value} per event, in the order sent. entity, other and value may be null; other is the second entity of a contact or a sensor event. | ## events.since `events.since {step?: integer, after?: integer, name?: text, to?: integer, against?: text, run?: text} -> {step: integer, from: integer, made: integer, events: [record], against: text, run: text}` · read, read-only Reads the events of every step after a given one, each with its step: what was sent during a game.step of many steps or a game.try. The log is of one line of time: game.reset starts it again at step 0 and game.restore at the snapshot's step, and it keeps the latest 65536 events. | Parameters | Type | Meaning | | --- | --- | --- | | `step?` | integer | Events of steps after this one are returned: pass the step of the last answer you had. Left out: every event the log keeps. | | `after?` | integer | Only events whose `n` is greater: pass the `made` of the last answer you had to get each event once, whatever the step. When `made` comes back smaller than the one you hold, the log was started again (game.reset, game.seek that loaded, game.restore): start from 0. | | `name?` | text | Only events with this name. Left out: every event. | | `to?` | integer | Only events of steps up to this one. Left out: up to the step the game is at. | | `against?` | text | "accepted": the events of the game as it was last accepted (`frost test --write` keeps it in .frost/accepted beside the project file), played aside from its own files on the recording from step 0 to `to` (left out: the step the game is at): what a timeline draws as the accepted run's events beside the ones now. The game being served is not touched. Left out: the game's own log. | | `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. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `from` | integer | The step the answer starts after: the one asked for (0 when none was), or a later one when the log does not go back that far. | | `made` | integer | How many events were sent since the log was started: the `n` of the newest. | | `events` | [record] | One {n, step, name, entity, other, value} per event, in the order sent. n counts the events from 1. step is how many steps had run when the step that sent it ended, as events.read would have said it. | | `against` | text | "accepted" when the events are of the accepted game, else null. | | `run` | text | The run asked, as it was named; null for the game's own log. | --- Page: reference/protocol/physics.md # Protocol: physics The `physics` 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). ## physics.read `physics.read {} -> {step: integer, paused: value, shapes: [record], contacts: [record], joints: [record], vehicles: [record]}` · read, read-only Reads every collider's shape, every point where bodies touch, every joint and every vehicle's wheels, as the last step left them, in world units, each shape as large as its thing's scale makes it: what an editor draws over the game. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `paused` | value | true while a script holds the simulation with physics.pause(true): nothing moves, and the answer stays as the last step that ran left it. | | `shapes` | [record] | One {entity, body, points, radius, closed, sensor, one_way} per shape, in entity order. body is "static", "kinematic", "dynamic" or "mover". points are [x, y] pairs: one with a radius is a circle, two with a radius a capsule, more an outline that joins up when closed is true. In a 3D game (`space = "3d"`) one {entity, body, shape, size, at, turn, sensor} instead: shape is "box", "sphere", "capsule" or "cylinder", size its width, height and depth, at its middle [x, y, z] and turn a quaternion [x, y, z, w]; contacts are empty there, and each joint is {entity, kind, a, b, axis}: where it holds what it is joined to and its own entity, [x, y, z] each, and a hinge's axle or a slider's line one long ([0, 0, 0] for the rest). | | `contacts` | [record] | One {a, b, at, normal} per point where a moving body touches something: the two entities, the point, and the unit direction from a to b. | | `joints` | [record] | One {entity, kind, a, b} per joint, in entity order: the entity that has the Joint, its kind, the point it holds on what it is joined to and the point it holds on its own entity. The two are the same point for every kind but "distance", unless the joint is being pulled apart. | | `vehicles` | [record] | One {entity, wheels} per `Vehicle` of a 3D game, in entity order: the entity that has it, and its four wheels, front left, front right, back left, back right, each {x, y, z, qx, qy, qz, qw, touching}: its middle, its turn as a quaternion (the car's, then its steering, then its rolling: that of a wheel shaped in the car's own frame, its axle along x) and whether it is on something. Empty in a 2D game. | --- Page: reference/protocol/ground.md # Protocol: ground The `ground` 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). ## ground.at `ground.at {x: number, z: number} -> {step: integer, entity: text, height: number, normal: [number], layers: [number]}` · read, read-only Reads the ground under a point: of the things with a Ground (a height field, `.ground.toml`) the lowest whose field is under x and z, the height of its surface there and its normal, as the cooked heights have it: each cell two triangles, split from its corner nearest -x and -z, the way the physics splits it. A Ground is placed by its thing's Transform (x, y, z; its turn and scale are not read). Nothing is changed. | Parameters | Type | Meaning | | --- | --- | --- | | `x` | number | Metres along x, in the world. | | `z` | number | Metres along z, in the world. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `entity` | text | The thing whose ground is there, by its name (or id); null where no ground is. | | `height` | number | The surface's y there, in the world; null where no ground is. | | `normal` | [number] | The surface's normal there, [x, y, z], one long and up; null where no ground is. | | `layers` | [number] | Each of the ground's picture layers' weight there, in their order, adding up to 1 (the rule its pictures are drawn by); empty for a ground with no layers, drawn in its colour. | --- Page: reference/protocol/ui.md # Protocol: ui The `ui` 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). ## ui.tree `ui.tree {} -> {step: integer, focus: text, modal: text, nodes: [record]}` · read, read-only Reads the game's interface as it is laid out now: every node's box, what it is, its value and which has the focus. What a client reads to see a menu without a picture, and to know where to press. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `focus` | text | The entity that has the focus, by its name when it has one and its id otherwise. null: none has. | | `modal` | text | The shown modal node that has the interface, named the same way: only the nodes in it can be used. null: none is shown. | | `nodes` | [record] | One {entity, name, parent, x, y, w, h, shown, kind, value, off, locked, text} per entity with a Node, in entity order. parent is the id of the node it is in, or null. x and y are the middle of its box and w and h its size, in frame units for a node with Screen. shown is false for a hidden node and everything in one. kind is "box", "button", "slider", "choice", "toggle" or "bar"; value is a slider's or a bar's value, a choice's index, whether a toggle is on, and null for the rest. off is true for a button that is off, locked for a node that takes the focus and refuses to be used. text is what the node reads: its own Text, or that of the entity its label names; null when it has neither. A game with no interface has no nodes. | ## ui.focus `ui.focus {entity: text} -> {step: integer, focus: text}` · write Gives a node the interface's focus, as a script's ui.focus does: at once, with no step. A node that cannot have it now (it is hidden, off, not something a person uses, or shut out by a modal node) is not given it, and the answer says where the focus is. | 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. | | `focus` | text | The entity that has the focus now, by its name when it has one and its id otherwise. null: none has. | --- Page: reference/protocol/blame.md # 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. | --- Page: reference/protocol/audio.md # Protocol: audio The `audio` 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). ## audio.requests `audio.requests {since?: integer} -> {step: integer, made: integer, sounds: [text], requests: [record], music: record}` · read, read-only Lists what the game asked to be heard. Sound is output only: requests are written down whether or not anything plays them, and are never part of the world or its checksum. | Parameters | Type | Meaning | | --- | --- | --- | | `since?` | integer | Only requests made in this step or a later one. Left out: all that are kept. To follow a game, ask again with the step of the last answer plus one. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `made` | integer | How many requests the game has made since it was loaded. Only the latest 256 are kept, which a busy game makes in a few seconds: read every few steps to miss none. | | `sounds` | [text] | The sounds the game loaded: the names a request can use. | | `requests` | [record] | The latest 256, oldest first: {step, request, name, volume, pitch, pan, seconds}. request is "play", "music", "stop" (after fading out over seconds), "volume" (of everything), "effects" (the volume of sounds played once), "pause", "resume" or "fade" (the music's own volume moving to a level over seconds); step is the step it was made in, 0 for one made while loading; pan is where a played sound is heard from, -1 left to 1 right; name, volume, pitch, pan and seconds are null where the request has none. game.reset starts the list again, and game.restore puts it back as it was at the snapshot. | | `music` | record | The music playing now, as the requests say: {name, since, paused}, since the step it was asked for in (0 while loading) however long ago, paused while a pause is not resumed. null before music is asked for, and once it is stopped. Put back with the game by game.restore, and by a seek as the steps played again ask. | --- Page: reference/protocol/assets.md # Protocol: assets The `assets` 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). ## assets.from `assets.from {path: text} -> {path: text, note: record, note_file: text, hash: text, came: text, changed: value, by: text, problem: text}` · read, read-only Says where one file of the game came from: its source note (the `.from.toml` file beside it, which the editor writes when a person keeps a service's result or says where a brought file came from), the file's hash now, and whether it changed since the note recorded it as it came. A file with no note was made by hand. A note that does not parse is a problem here, never a reason the game does not load. The engine never writes a note and never calls a service. | Parameters | Type | Meaning | | --- | --- | --- | | `path` | text | The file's path from the project file's folder, as the game names it: art/slime.png. | | Result | Type | Meaning | | --- | --- | --- | | `path` | text | The file asked about. | | `note` | record | The note's fields as written (service, through, model, asked, like, try, seed, made, kept, terms, licence, cost, from, came, changed, by, and any other), a date and time as its text. null when the file has no note or it does not parse. | | `note_file` | text | The note's path, the file's whole name and .from.toml: art/slime.png.from.toml. null when there is none. | | `hash` | text | The file as it is now: sha256: and 64 hexadecimal digits. | | `came` | text | The hash the note recorded of the file as it arrived, or null. | | `changed` | value | true when the note recorded a hash and the file no longer has it. | | `by` | text | How it was made: "service", "brought" or "hand": the note's own by, else service when it names one, brought when it says where from, hand with no note. | | `problem` | text | Why the note could not be read, as FILE:LINE: what; null when it was, or there is none. | ## assets.sources `assets.sources {} -> {files: [record], unlicensed: [text]}` · read, read-only Lists every file the game loads, in the order an export copies them, with how it was made and its licence as its note says, and the files a service made or a person brought with neither a licence in the note nor the service's terms saved beside it (warning W1410, which frost check and frost export give too; saved terms are enough, since the engine cannot judge them). For the editor's Sources and the export's credits.txt. | Result | Type | Meaning | | --- | --- | --- | | `files` | [record] | {path, by, service, model, licence, terms, noted, changed, problem}: by as assets.from gives it; service, model and licence as the note says, empty when it says none; terms the path of the terms file saved beside it (art/slime.png.terms.txt, or the one the note names), empty when none is there; noted whether a note was read; changed and problem as assets.from gives them. | | `unlicensed` | [text] | The paths of the files a service made or a person brought with neither a licence named nor terms saved. | ## assets.cooked `assets.cooked {path: text} -> {path: text, importer: text, key: text, picture: record, frames: [record], parts: [record], clips: [record], bones: [record], problem: text}` · read, read-only Says what the cook makes of one file of the game, as the game loads it: for a picture its size, for an atlas (a .atlas.toml file) its page and every frame on it, for a model each part with its vertices, triangles and the triangles the cook left out. Cooked through the program's cache when it keeps one, so a second ask finds it there; a changed key says the file was cooked again. A file not cooked yet is cooked by the ask itself: no answer means "not cooked yet". Every field is in every answer, null where it does not apply. A file the cook refuses is still an answer, a success, with `problem`: never a failed command. A path the game does not load is refused (BadParams), naming the files assets.sources lists. | Parameters | Type | Meaning | | --- | --- | --- | | `path` | text | The file's path from the project file's folder, with `/`, as assets.sources gives it: art/hero.atlas.toml. | | Result | Type | Meaning | | --- | --- | --- | | `path` | text | The file asked about. | | `importer` | text | The importer that cooks it: "image", "model" or "atlas"; null for a file the game reads as written (a script, a scene, a sound). | | `key` | text | The cache key it is kept under, 64 hexadecimal digits: another key means it was cooked again. null when the program keeps no cache or the cook refused it. | | `picture` | record | {width, height, levels, srgb}: a picture's size in pixels and how many levels it has; for an atlas, its one page (an atlas is one page at most: E0530). srgb is whether it is sampled as a colour (true) or as data, a normal map's numbers (false); a 2D picture and an atlas's page are one level, a colour. null for a model. | | `frames` | [record] | An atlas's frames, {name, x, y, w, h}: in pixels on its page, x from the page's left and y from its top, downward; in the atlas's order (by name, for patterns). A sprite names one by its name in Sprite.frame. null for what is not an atlas. | | `parts` | [record] | A model's parts, {mesh, part, vertices, triangles, left_out, material}: each mesh's parts counted from 0; triangles at the whole level; left_out the file's triangles with a vertex twice once welded, which the cook does not keep, 0 when none; material its name, or null; paint what that material is, or null: {base_color, base_color_texture, metallic, roughness, metallic_roughness_texture, normal_texture, normal_scale, occlusion_texture, occlusion_strength, emissive_texture, emissive, alpha_mode, alpha_cutoff, double_sided, uv}, the factors as the model gives them (base_color with alpha and emissive times its strength, in linear light; normal_scale and occlusion_strength 1 where the model says none), alpha_mode "opaque", "mask" or "blend", uv the base colour picture's texture transform {offset, rotation, scale} that every picture of it is read through, each picture by its path in the game when it is beside the model or #N for the model's Nth picture inside it, null for none. A model's whole count left out is the sum over its parts. null for what is not a model. | | `clips` | [record] | A model's clips, {name, seconds, loops}, from the rig the cook keeps in it (its glTF animations): what a Pose plays, by name; seconds the last key of any channel, loops whether it ends where it began. [] for a model with none; null for what is not a model. | | `bones` | [record] | A model's bones, {name, parent}: the joints of its skins in the order they name them, parent the joint each is under (null for a root). [] for a model with no skin; null for what is not a model. | | `problem` | text | Why the cook refuses the file, as one sentence with its code first (E0526: ..., E0527 a part left with no triangle, E0530 frames that do not fit a page, E0532 an atlas's pattern that matches nothing); null when it cooks. | ## assets.picture `assets.picture {path: text, width: integer, height: integer, yaw: number, pitch: number, distance?: number, clip?: text, time?: number, skeleton?: value} -> {png: png, width: integer, height: integer, view: record, bounds: record, clips: [record], bones: [record]}` · read, read-only Draws one model file of the game alone, off-screen, for an asset viewer: apart from the served game, in a world and on a graphics device of its own, so the game's world, step, checksum, device and what render.passes last counted are untouched, whether the game is stopped or playing. The model is framed to its box at rest unless a distance is asked, seen from yaw and pitch round the box's middle, lit by a fixed plain light (a light that is everywhere at 0.35 and a white sun from the eye's upper left, 40 degrees above and 30 to the side, whichever way the eye looks) in front of a dark grey (1d2027), at a moment of one of its clips when asked (a glTF animation of its nodes: a mesh its node moves is moved, a skinned mesh is bent by its joints), with its skeleton over it when asked. A model is kept while its file and buffers are the same, so a second ask draws and reads back only. A picture (.png) or an atlas (.atlas.toml) is answered as itself (an atlas's page), shrunk to fit inside width and height and never made larger, with view and bounds null. A file that is not one of those is refused in words, as is a clip the model has not. | Parameters | Type | Meaning | | --- | --- | --- | | `path` | text | The file's path from the project file's folder, with `/`: art/hero.glb. Any file of the game's folder, loaded by the game or not. | | `width` | integer | The picture's width in pixels, 1 to 4096, exactly (a picture or an atlas: the most). | | `height` | integer | The picture's height in pixels, 1 to 4096. | | `yaw` | number | Degrees the eye goes round the box's middle about +y: 0 looks at the model's front (from +z, along -z), 90 from +x. | | `pitch` | number | Degrees the eye is above the box's middle, looking down at it: -89 to 89. | | `distance?` | number | How far the eye is from the box's middle, in the model's units. Left out: far enough that the ball round the box fits the picture both ways, with a twentieth to spare. | | `clip?` | text | One of the model's clips by name, as the answer's clips give them. Left out: the model at rest, as a game draws it. | | `time?` | number | Seconds into the clip, 0 or more: a time past its end shows its end. Only with clip. Left out: 0. | | `skeleton?` | value | true: the model's bones drawn over it, a white line one pixel wide from each joint to the joint it is under and a yellow (ffec27) square of 5 pixels on each, as bones answers them; where the model is between the eye and the bone, a third as strong over it, so a skeleton inside a body reads as inside. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `png` | png | The picture as a PNG file, in base64, as frame.capture gives one. | | `width` | integer | The picture's width in pixels. | | `height` | integer | The picture's height in pixels. | | `view` | record | {at, turn, fov, near, distance, view_projection}: where the eye was ([x, y, z] in the model's units) and how it was turned (a quaternion, x y z w), as frame.capture's eye takes them; fov 40 degrees from bottom to top; the near plane; its distance from the box's middle; and the 16 numbers of the matrix from the model to clip space, as frame.capture's view_projection. null for a picture or an atlas. | | `bounds` | record | {min, max}: the box round the model at rest, [x, y, z] each, which it is framed to (the same at every moment of a clip, so a clip played does not move the eye). null for a picture or an atlas. | | `clips` | [record] | The model's clips, {name, seconds, loops}, in the file's order: seconds the last key of any of its channels, loops whether it ends where it began (each channel's last key is its first). Empty for a model with none, a picture and an atlas. | | `bones` | [record] | The joints of the model's skins, {name, parent, at, pixel}, in the order the skins name them: parent the joint it is under (null for a root), at where it is at the moment drawn, [x, y, z] in the model's units, and pixel where that is in the picture, [x, y] from its top left (null behind the eye). Empty for a model with no skin. | --- Page: reference/protocol/debug.md # Protocol: debug, part 1 of 2 The `debug` 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). ## debug.attach `debug.attach {scripts?: text, errors?: text} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · write Attaches the script debugger: from then on breakpoints, debug.pause and an error a script raises stop the scripts' `step`, part way through the game's step. A game runs the same, checksum for checksum, with a debugger attached that stops nothing. Scripts are compiled with the names of their locals only while it is attached: a game nothing has moved yet (step 0) is loaded again that way at once; one that has run keeps its code, and `named` is false until its scripts are loaded again. It stays attached, with its breakpoints, across game.reset. Not in an exported game. | Parameters | Type | Meaning | | --- | --- | --- | | `scripts?` | text | "keep" (the default): the code that is loaded runs on untouched. "reload": every script is compiled again now, as script.reload would, so its top level runs again and what it keeps in local variables of its own starts over. | | `errors?` | text | "stop" (what it is when first attached): a script stops where it raises an error nothing catches. "pass": such an error ends the step as it does with no debugger. Left out: as it was. Attach again to change it. | | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | ## debug.detach `debug.detach {scripts?: text} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · write Detaches the debugger and forgets its breakpoints. A stopped script first runs to the end of its step; if that step fails, this fails with its error and the debugger is detached all the same. Scripts loaded from then on are compiled exactly as an exported game compiles them; those already loaded run on as they are until then. | Parameters | Type | Meaning | | --- | --- | --- | | `scripts?` | text | "keep" (the default): the code that is loaded runs on untouched. "reload": every script is compiled again now, as script.reload would, so its top level runs again and what it keeps in local variables of its own starts over. | | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | ## debug.breakpoints `debug.breakpoints {file: text, lines: [integer]} -> {file: text, breakpoints: [record]}` · write Makes the given lines the breakpoints of one file, in place of those it had, and says where each was set. They are kept and set again when the file is reloaded and when the game is reset. | Parameters | Type | Meaning | | --- | --- | --- | | `file` | text | A script's name as game.info lists it, or a library's as the project lists it. | | `lines` | [integer] | The lines to stop at, from 1. An empty list clears the file's breakpoints. | | Result | Type | Meaning | | --- | --- | --- | | `file` | text | The file. | | `breakpoints` | [record] | One {asked, line} per line asked for, in order. line is where the breakpoint is: asked itself, or the next line that has code when asked has none (a comment, a blank line), or null when no code follows or no loaded code is from that file. | ## debug.pause `debug.pause {} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · write Asks the scripts to stop at the first line of a `step` that runs next. Nothing stops until the game steps: by itself under frost dev, by game.step elsewhere. | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | ## debug.continue `debug.continue {} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · write Lets the stopped script run on. It returns when a script stops again or the step is over: the scripts after it and the rest of the step (animation, sounds, a scene change) then run once, and what the step fails with is this command's error. | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | ## debug.step `debug.step {kind: text} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · write Runs the stopped script to its next line and stops it there. When the script's `step` ends first, the game's step finishes as after debug.continue and the scripts stop at the first line that runs next. | Parameters | Type | Meaning | | --- | --- | --- | | `kind` | text | "over": the next line of this function, running what the line calls. "into": the next line, inside a function the line calls. "out": the line this function returns to. | | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | --- Page: reference/protocol/debug-2.md # Protocol: debug, part 2 of 2 The `debug` 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). ## debug.state `debug.state {} -> {attached: value, named: value, process: integer, state: text, step: integer, reason: text, file: text, line: integer, column: integer, nil: record, last_entity: text, last_entity_name: text, error: text, stops: integer, errors: text, note: text, pending_reload: [text]}` · read, read-only Says whether the game is running or a script is stopped, and where and why. The server sends nothing by itself: ask again to follow the game. | Result | Type | Meaning | | --- | --- | --- | | `attached` | value | true when the debugger is attached, false when not. | | `named` | value | true when every loaded script is compiled with the names of its locals, so debug.scope can show them: it was loaded, reloaded or reset while the debugger was attached. false otherwise, and when no debugger is attached. | | `process` | integer | The engine's own process id on this machine: where the game's scripts run, for a debugger of the machine to attach to. `frost dev` prints the same number on the line after the one that says where it listens, as `process PID`. | | `state` | text | "running", or "paused" while a script is stopped part way through a step. | | `step` | integer | How many fixed steps have run. | | `reason` | text | Why it stopped: "breakpoint", "step", "pause" or "error". null while running. | | `file` | text | The script or library it is stopped in, as the project names it. null while running. | | `line` | integer | The line it stands on, which has not run yet; for an error, the line that raised it. null while running. | | `column` | integer | The column on that line, from 1 in UTF-16 code units: the line's first code, as Luau stops at lines; for an error, where on the line it failed (the name that was nil, the call to error or assert). null while running. | | `nil` | record | For an error that indexed or called a nil: {name, how, key, also, since}, the expression that was nil as written ("state.boss", "t.go", "t:go"), "index" or "call", the key it was indexed with or null, the other expressions on the line it may have been, and since (null here: a failed game.step says it). null otherwise. | | `last_entity` | text | The id of the entity the script last read, wrote or removed in this step, like "e3.0": one of the many a script may touch, and most often the one an error is about. null when it touched none, and while running. | | `last_entity_name` | text | That entity's scene name, or null. | | `error` | text | The error's message when the reason is "error", else null. | | `stops` | integer | How many times a script has stopped since this server started: it counts up at every stop, so a client that polls can tell a new stop from the one it knew, though file and line be the same. | | `errors` | text | "stop": a script stops where it raises an error. "pass": the error ends the step as with no debugger. null when no debugger is attached. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | | `pending_reload` | [text] | The scripts whose new code waits for the stopped step to end: saved, or sent with script.reload, while a script was stopped. Empty otherwise. | ## debug.stack `debug.stack {} -> {frames: [record], note: text}` · read, read-only Lists the functions the stopped script is in, the innermost first. | Result | Type | Meaning | | --- | --- | --- | | `frames` | [record] | Up to 64 {frame, file, line, column, function}: frame is the number debug.scope and debug.evaluate take, from 0; column is where on its line, from 1 in UTF-16 code units: the stop's for the innermost (debug.state's column), the line's first code for the others (Luau keeps no column of a call); function is the function's name, or null for one without a name. The engine's own functions are left out. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | ## debug.scope `debug.scope {frame?: integer} -> {frame: integer, locals: [record], upvalues: [record], note: text}` · read, read-only Lists the local variables in scope in one function of the stopped script, and the variables of enclosing functions it uses. | Parameters | Type | Meaning | | --- | --- | --- | | `frame?` | integer | The function, as debug.stack numbers them. Left out: 0, the innermost. | | Result | Type | Meaning | | --- | --- | --- | | `frame` | integer | The function. | | `locals` | [record] | One {name, type, value, ref, entity, entity_name} per local in scope, those of the innermost block first. entity is null, or for a number that is the handle of a living entity, its id like "e3.0", with its scene name or null in entity_name: a script holds an entity as a number, so a plain number that happens to equal a handle shows one too. type is the Luau type; value is the value as text, a string quoted and cut at 200 characters; ref is a number for debug.expand when the value is a table, else null. | | `upvalues` | [record] | The same for the variables of enclosing functions that this function uses. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so their locals have no names, and what to do about it. | ## debug.expand `debug.expand {ref: integer, from?: integer} -> {ref: integer, from: integer, entries: [record], more: value}` · read, read-only Lists the entries of a table of the stopped script, by the reference it was handed out under. | Parameters | Type | Meaning | | --- | --- | --- | | `ref` | integer | The ref of a table, from debug.scope, debug.expand or debug.evaluate since the script last stopped. | | `from?` | integer | How many entries to pass over first: the `from` of the last answer plus the entries it held, to read on where it ended. Left out: 0. | | Result | Type | Meaning | | --- | --- | --- | | `ref` | integer | The reference. | | `from` | integer | How many entries were passed over. | | `entries` | [record] | Up to 100 entries as {name, type, value, ref, entity, entity_name}, in the order Luau walks the table: name is the key, a key that is not a string in square brackets. | | `more` | value | true when the table has entries after these, else false. | ## debug.evaluate `debug.evaluate {text: text, frame?: integer} -> {type: text, value: text, ref: integer, entity: text, entity_name: text, step: integer, note: text}` · trusted-project-only Runs Luau where the stopped script stands and returns what it gives. The text sees the function's locals and upvalues and everything the script sees, and may call the script API and change the game; assigning to a local changes a copy, not the script's variable. It runs under a script's limits of time and memory. | Parameters | Type | Meaning | | --- | --- | --- | | `text` | text | An expression, or statements (their `return` gives the value). | | `frame?` | integer | The function whose variables it sees, as debug.stack numbers them. Left out: 0. | | Result | Type | Meaning | | --- | --- | --- | | `type` | text | The Luau type of the first value it gave; "nil" when it gave none. | | `value` | text | The value as text. | | `ref` | integer | A number for debug.expand when the value is a table, else null. | | `entity` | text | null, or the id of the living entity the value is the handle of, as debug.scope says it. | | `entity_name` | text | That entity's scene name, or null. | | `step` | integer | How many fixed steps have run. | | `note` | text | null, or a sentence to show the person: the scripts were loaded before the debugger attached, so a local named in the text read as nil. Text that fails then fails with E0444, which says the same. | --- Page: reference/protocol/log.md # Protocol: log The `log` 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). ## log.since `log.since {step?: integer, after?: integer} -> {step: integer, from: integer, made: integer, lines: [record]}` · read, read-only Reads what the game said in every step after a given one: the lines its scripts printed, each with the file and line of the `print`, and the warnings game.info lists, each once when it first appears. Scripts print to standard error, which a client does not read; this is the same text. Lines printed by a script the debugger holds stopped are there at once, so a client that polls while stopped passes `after`. The log is of one line of time: game.reset starts it again, empty, and it keeps the latest 4096 lines. | Parameters | Type | Meaning | | --- | --- | --- | | `step?` | integer | Lines of steps after this one are returned: pass the step of the last answer you had. Left out: every line the log keeps, those the scripts printed while loading (step 0) among them. | | `after?` | integer | Only lines whose `n` is greater: pass the `made` of the last answer you had to get each line once, whatever the step. When `made` comes back smaller than the one you hold, the game was loaded again: start from 0. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `from` | integer | The step the answer starts after: the one asked for (0 when none was), or a later one when the log does not go back that far. | | `made` | integer | How many lines the game has said since it was loaded: the `n` of the newest. | | `lines` | [record] | One {n, step, kind, file, line, text} per line, in the order said. n counts the lines from 1. step is how many steps had run when the step that said it ended. kind is "print" or "warning". file and line are where the `print` was called, a script or a library of the game; null for a warning. | --- Page: reference/protocol/graph.md # Protocol: graph The `graph` 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). ## graph.uses `graph.uses {kind: text, name: text, part?: text} -> {uses: [record], read: text, columns: text}` · read, read-only Finds every place the game names a part, a field, a thing, an event, an input action, a tuning key or a clip: each call of a script or library that names it to the engine with a string (get, set, has, each, spawn, find, send, events, tween, input.get, input.held, and tuning.NAME), and each line of a scene or the project file that declares or uses it. A clip's uses are who plays it: the [clips] key that declares it, each scene thing whose Clip starts with it, and each script line that sets a Clip's name to it or spawns a thing with it, where the name is written out; a name that comes through a variable is not found. For a rename's dry run, the uses of a name, and the game graph's text edges. It reads the files as they are and changes nothing. | Parameters | Type | Meaning | | --- | --- | --- | | `kind` | text | What the name is: part, field, thing, event, action, tuning or clip. | | `name` | text | The name, as written. | | `part?` | text | For a field, the part it is of. Left out: the field of any part. | | Result | Type | Meaning | | --- | --- | --- | | `uses` | [record] | One {file, line, column, how} per place, scripts and libraries first, then the project file, then the scenes: file from the project file's folder, the line and column where the name's text begins, and how it is named there: the engine function a script passes it to ("get", "input.held", "tuning"), "scene" or "project". | | `read` | text | How the answer was read: "text", the scripts' text and the scene and project files, not the values it runs with. A call to the engine through another name (`local f = get; f(e, "Body", "vx")`) is not seen, and a local that shadows an engine function is taken for it. | | `columns` | text | The unit columns count in: "utf16", UTF-16 code units from 1, as an editor's text model and the Language Server Protocol count them (a letter outside the Basic Multilingual Plane is two). Lines count from 1. | --- Page: reference/protocol/profile.md # Protocol: profile The `profile` 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). ## profile.frame `profile.frame {step?: integer} -> {frame: integer, step: integer, total_ms: number, spans: [record], counters: [record], recorded: value, ms: number, stopped: value, replayed: value}` · read, read-only Returns the timed spans and counters of the last finished frame that drew a picture, and which step it was of: a request that only reads draws none and changes nothing of the answer. With step, where that step's time went as it was played, as profile.steps tells a step, with recorded. | Parameters | Type | Meaning | | --- | --- | --- | | `step?` | integer | A step, 1 or more: its record as profile.steps gives one in worst, from the time it was played (recorded true) while that is kept, as it is for the last 3,600 step numbers and for the 16 slowest steps of the run however old; else as the engine last played it again, or its time alone (recorded false). Left out: the last frame that drew. | | Result | Type | Meaning | | --- | --- | --- | | `frame` | integer | How many frames had finished when it did. With a window a frame is one picture; without one, one request. 0 before a frame drew. Without step. | | `step` | integer | The step the picture was of: null before a frame drew. With step, the step asked. | | `total_ms` | number | How long the frame lasted, from the end of the one before. Without step. | | `spans` | [record] | One {name, count, total_ms, max_ms} per span that ran in the frame. With step, one {name, ms, count, parent, at} per place a span ran in the step, as profile.steps gives them, or null when none is kept. | | `counters` | [record] | One {name, value} per counter that was added to in the frame. With step, an object of the step's counters, as profile.steps gives them, or null. | | `recorded` | value | With step: true when spans and counters are as the step was played, false when they are of the engine playing it again or none are kept. | | `ms` | number | With step: the time inside the step, as profile.steps gives it, or null when nothing of it is kept. | | `stopped` | value | With step: as profile.steps gives it. | | `replayed` | value | With step: as profile.steps gives it. | ## profile.frames `profile.frames {from?: integer, to?: integer} -> {from: integer, to: integer, kept: integer, median_ms: number, max_ms: number, spans: [record]}` · read, read-only Sums up a range of finished frames: the median and the longest, for the whole frame and for each span. One slow frame does not move a median. | Parameters | Type | Meaning | | --- | --- | --- | | `from?` | integer | The first frame, as profile.frame numbers them. Left out: the oldest kept. | | `to?` | integer | The last frame. Left out: the latest. | | Result | Type | Meaning | | --- | --- | --- | | `from` | integer | The first frame the numbers cover: the range asked for, cut to the frames kept. 0 when there is none. | | `to` | integer | The last frame they cover. | | `kept` | integer | How many finished frames are kept at most. | | `median_ms` | number | The median length of a frame in the range. | | `max_ms` | number | The longest frame. | | `spans` | [record] | One {name, frames, median_ms, max_ms} per span: in how many frames of the range it ran, and the median and the most it took in one of those. | ## profile.steps `profile.steps {from?: integer, to?: integer, worst?: integer, spans?: value, buckets?: integer, totals?: value} -> {step: integer, from: integer, to: integer, steps: [record], buckets: [record], worst: [record], totals: record, kept: record}` · read, read-only Says what each step took, and names the slowest with where their time went: each stage, each script, and the picture drawn of the step. What a timeline shows as a cost row, and what a click on a spike asks. Every step's time is kept for an hour of steps and where it went for a minute, whether or not anybody asks, by step number: a step played again is told as it last ran, the engine playing steps again to reach another (game.seek, blame.on) never hides a step as it was played, and a game.try from a kept moment keeps nothing. Time is not part of the game: it is in no checksum and no snapshot, and differs from run to run. | Parameters | Type | Meaning | | --- | --- | --- | | `from?` | integer | The first step. Left out: 3,599 steps before `to`, so that the range is the last minute. | | `to?` | integer | The last step. Left out: the step the game is at. Steps after it are of a run the game came back from: they are told, while they are kept, only when asked for. | | `worst?` | integer | How many of the slowest steps of the range to name, 0 to 60. Left out: 5. | | `spans?` | value | true to give every step of the range its spans and counters, as `worst` has them: for a range of at most 120 steps. Left out: false. | | `buckets?` | integer | Cut the range into this many stretches, 1 to 2,000, as equal as whole steps allow, and give the slowest step of each in place of the list: what a cost row of a long run draws, one stretch a column. With it, `from` left out is the oldest step kept, and the range may be of any length. Left out: the steps are listed. | | `totals?` | value | true to add up every span of the range, each place in the tree once, as far as the steps' spans are kept: what a profiler shows of a stretch of the game. Left out: false. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `from` | integer | The first step the answer covers: the range asked for, cut to the steps kept. 0 when there is none. | | `to` | integer | The last step it covers. | | `steps` | [record] | One {step, ms, replayed} per step of the range that is kept, in step order, at most 3,600: ms is the time inside the step, all its stages together, and replayed is as in worst. With spans true each is a whole record, as in worst. null with buckets. | | `buckets` | [record] | With buckets: one {from, to, ms, step} per stretch of the range, in step order, no more of them than the range has steps: its first and last step, and its slowest step and that step's ms (of two as slow, the earlier), both null when no step of it is kept. null without buckets. | | `worst` | [record] | The slowest steps of the range, the slowest first: one {step, ms, stopped, replayed, spans, counters} each. spans is one {name, ms, count, parent, at} per place a span ran in from the step's beginning to the next step's, count saying how many times it ran there. They are a tree: parent is the index in the same list of the span it ran inside, which comes before it, or null at the top. "step" is the whole step; inside it "input", "ui", "physics", "scripts", "animation", "layout" and "events" its stages; inside a stage what that stage does ("physics.solve"); inside "scripts" "script NAME", one script's part; inside that "step()" or "on_scene()", the function it called; and inside a function each engine call it made whose cost depends on the world (find, each, spawn, despawn, events, tween, library, physics.ray, physics.cast, physics.overlap and save's), added together per line that called it. at is where in a script a span is, as "FILE:LINE": the line a function starts on, and the line that made a call (a call made through pcall is at the line that handed it over); null for the rest. One name may be in many places; get, set, has and the like are not timed, and are in the time of the function that called them. What the tool did before the next step began is there too, and is no part of ms: the picture drawn of the step (such as "render.build" and "gpu.submit"; of a step drawn more than once, as a paused game is, the last picture, once) and, under frost dev, the requests answered ("protocol"). counters is an object of what was counted in the same time, such as draw_calls and quads when a picture was drawn (of a step drawn more than once, as a paused game is, the last picture's, not their sum), and script_work: the work the scripts did, as the Luau machine counts its calls and loop turns, the same on every machine and every run (unlike ms), so steps can be ranked by it; "script_work NAME" is one script's part of it. stopped is true when a debugger stopped a script in the step: the wait is in no span, so ms is what the step computed, and pictures drawn while it waited are counted in its draw spans. replayed is true when the numbers are of the engine playing the step again on the way to another (game.seek, blame.on), which draws nothing. A replay is kept over anything but the same step as it was played: a step played more than a minute ago and sought to again has its spans, and its ms, from the replay, while steps keeps the time it was played. A step older than the last 3,600 step numbers, not sought to since, keeps its time and no more (stopped, spans and counters are null), unless it is one of the 16 slowest steps the game played, which keep theirs as played for as long as the run goes on. | | `totals` | record | With totals true: {from, to, steps, spans}, every span of the steps from `from` to `to` (as asked, or the defaults of the list or of buckets) whose spans are still kept, added together, each place in the tree once in the shape of a step's spans, ms and count summed. from and to are the first and last step added, steps how many (0, 0 and 0 when none is kept): spans are kept for the last 3,600 step numbers. null without totals. | | `kept` | record | What is kept: {spans, steps, bytes, bytes_per_span, bytes_per_hour}. spans is how many of the last step numbers keep where their time went, 3,600 (a minute at sixty steps a second); steps how many keep their time, 216,000 (an hour). bytes is what is held now: bytes_per_span for each span or counter that has run in a kept step, and bytes_per_hour for an hour of steps, held as the run grows. A shipped game keeps nothing. | --- Page: reference/protocol/session.md # Protocol: session The `session` 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). ## session.hello `session.hello {who: text, kind: text, model?: text, tag?: text, mode?: text} -> {hand: integer, who: text, kind: text, mode: text}` · read, read-only Says who this connection is, so that what it writes names it: blame answers its writes as this hand, and an editor can show an agent's hand and put its change on trial. Said once; said again, it renames. A connection that never says is hand 0, "a client". The session keeps its hands for its life: the same who on a new connection is the same hand again. Over MCP an agent never has to call it: initialize's clientInfo says it (frost mcp --join --who too). | Parameters | Type | Meaning | | --- | --- | --- | | `who` | text | The name a person knows this client by, 1 to 64 characters: "Claude", "Ana". | | `kind` | text | "person" for someone at the editor, "agent" for a program that acts for one. | | `model?` | text | For an agent, the model it runs on, as it names it. Left out: none said, or the one said before. | | `tag?` | text | The editor's own name for what this hand is doing (a conversation, a task), at most 64 characters: kept and given back by session.hands, never read. The same who with another tag is the same hand; the tag shown is the last said. Left out: the one said before. | | `mode?` | text | "plan", "ask", "trial" or "free": the editor's mode for this hand (frost mcp --mode). The engine holds "plan": a planning hand's command that is not read-only is refused (E0447), and it stays planning under any name its connection says next and under its name on any connection, until the editor's session.mode changes it (E0448 for a hello that asks another). Left out: the one said before, or "free". | | Result | Type | Meaning | | --- | --- | --- | | `hand` | integer | This connection's hand from now on: 1 and up, the same for the same who all session long. | | `who` | text | The name, as kept. | | `kind` | text | "person" or "agent". | | `mode` | text | The hand's mode now. | ## session.hands `session.hands {} -> {step: integer, hands: [record], clock: record}` · read, read-only Lists everyone who said who they are in this session, connected or not, with what each last did to the game: for an editor to show who is at work on the game and what they changed. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `hands` | [record] | One {hand, who, kind, model, tag, mode, connected, since, writes, last_write, last_change, last_run} per hand, in the order they first said hello. connected is whether a connection is that hand now. since is the step it first said hello at. writes is how many commands that write it has carried out. last_write is the field its last world.set wrote, {entity, component, field, step}, the entity as it named it, or null. last_change is the last of its script.reload, world.set, world.spawn, world.despawn, scene.load, tuning.set and save.set: {what, name, line, step, n, mode}, name being what it changed (the script, the entity, the scene, the tuning name or the save slot), line for a script.reload the first line, from 1, of the new code that is not as the code it replaced (null when that code is not known, or for another command), and n a count for the whole session of changes and runs, so that they can be put in order; or null. last_run is its last game.step, game.seek or game.try that left the game at the end of its recording (its replay's steps, or where the recorded input ends): {to_step, checksum, matches_replay, n}, checksum the world's there. matches_replay is true when the run comes to the run checksum the project's replay records and false when it does not, both only when nothing but the recording had moved the game from step 0 (no game.step on held input, world.set, input.set, script.reload, tuning.set or other change on the way); null otherwise, and when the game has no replay or was played past it. It is worked out the first time it is asked, by playing the recording again aside: a pane that asks once a second pays for it once a run. A last_run whose n is above its last_change's n is a run of the game after the change. | | `clock` | record | Who moved the game to the step it is at: {hand, what, step, n}, the hand (0 for a connection that never said who it is), the command (game.step, game.seek, game.reset, game.try or game.restore), the step it left the game at and n as in last_change; null when nobody has. One game has one clock: requests are carried out one at a time in the order they arrive, so the later of two seeks wins, whoever sent each. An editor that sees another hand here knows the game was moved under the person's scrub. | ## session.writes `session.writes {hand?: integer, since?: integer} -> {step: integer, writes: [record], next: integer, kept: integer, missed: integer}` · read, read-only Lists every change the hands made since a point, oldest first: what session.hands gives as each hand's last_change, all of them, so that an editor can mark each edit of a hand and none is lost between two asks. | Parameters | Type | Meaning | | --- | --- | --- | | `hand?` | integer | Only this hand's changes. Left out: every hand's. | | `since?` | integer | The `next` of the ask before: only the changes since. Left out: every change kept. | | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `writes` | [record] | One {n, hand, what, name, line, step, mode, at_ms} per change, oldest first: n, what, name, line, step and mode (the hand's mode when it was made) as session.hands says last_change (n counts the session's changes and runs, so two hands' changes are in order); hand is whose; at_ms when it was made, in milliseconds from the first change kept, by the server's clock. | | `next` | integer | What to send as `since` next time to get only what comes after. | | `kept` | integer | How many changes are kept at most, the latest (4,096). | | `missed` | integer | When `since` is older than the oldest change kept: about how many changes since it are gone (counted by n, so runs and clock moves are in it too); else null. | ## session.mode `session.mode {hand: integer, mode: text} -> {hand: integer, who: text, mode: text}` · read, read-only Sets a hand's mode, from the editor only: the program that started the session, on its standard streams (frost serve --stdio). A hand in "plan" reads and does not change the game: every command of it that is not read-only (a step, a seek, a try, a write, a restore, a reload, project.*) is refused with E0447, while reads, pictures and world.series stay open. A connection that came with the port's read-only token is planning under any name until this lets the hand it says it is (a mode other than plan), and planning again when this sets plan. Asked by any other connection: E0448. | Parameters | Type | Meaning | | --- | --- | --- | | `hand` | integer | The hand, as session.hands numbers it, from 1. | | `mode` | text | "plan", "ask", "trial" or "free". Only "plan" changes what the engine does; the others are the editor's to show. | | Result | Type | Meaning | | --- | --- | --- | | `hand` | integer | The hand. | | `who` | text | Its name. | | `mode` | text | Its mode now. | ## session.token `session.token {tag: text, mode?: text} -> {tag: text, hand: integer, mode: text, file: text}` · read, read-only Gives the hand of a tag a token of its own, from the editor only (the session's standard streams; E0448 from anyone else): writes a join file for that hand alone, for this user only and removed when the session ends, which frost mcp --join-file takes as it takes the session's. A connection that sends that token is that hand, before it says anything and under any name or tag it says, and no other connection is: a name never joins it. The hand changes the game or only reads it as its mode says: session.mode {hand, mode: "plan"} holds every connection that came by its token, the ones open and the ones made later, to reads (E0447 on the rest), and another mode lets them write again. Asked again for the same tag, it answers the same hand and token and writes the file again. The session's own token stays the editor's. A hand's token sent to a session that never gave it is refused at the port (E0458). | Parameters | Type | Meaning | | --- | --- | --- | | `tag` | text | The editor's own name for the conversation or task this hand is, 1 to 64 characters: one hand and one token per tag. | | `mode?` | text | "plan", "ask", "trial" or "free": the hand's mode from now. Left out: "free" for a new hand, as it is for one given before. | | Result | Type | Meaning | | --- | --- | --- | | `tag` | text | The tag. | | `hand` | integer | The tag's hand, as session.hands numbers it: what session.mode takes. | | `mode` | text | Its mode now. | | `file` | text | The join file written: the session's own join file's name with .handN after it, holding {address, token, game, engine, pid, read_only: false, tag, hand}. The token is in the file only. | --- Page: reference/protocol/net.md # Protocol: net, part 1 of 2 The `net` 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). ## net.host `net.host {address?: text, delay?: integer, window?: integer, sync_every?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · write Opens a session to play the game with other peers, as its host (peer 0, player 0), on a UDP socket: a game with 2 to 8 players ([input] players), each peer one player. Refused for a game of one player or with no actions (E0545), in C# (E0543, not yet), or whose moment put back does not go on the same on its recording (E0540), and while a session is open (E0544). The game begins at the first net.run once every player has joined. delay, window and sync_every are the project's [net] table's when left out. | Parameters | Type | Meaning | | --- | --- | --- | | `address?` | text | Where to listen, IP:PORT. Left out: 127.0.0.1:0, a free port on this machine only. | | `delay?` | integer | Steps of input delay, 0 to 8. | | `window?` | integer | Steps of rollback, 1 to 16. | | `sync_every?` | integer | Steps between checksums, 1 to 600. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | ## net.join `net.join {address: text, token?: integer, timeout_ms?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · write Joins the session a host opened, and waits until it has every player (the host takes peers in its net.run): answers this peer's player. The game's files must be the host's, file for file (E0541). A game under way takes a late joiner into an open seat (net.run's begin_with): the next net.run fetches the game's confirmed moment and catches up; refused with no seat open or while another joins (E0546), or for a moment over 1,000,000 bytes (E0568). A host that does not answer in timeout_ms is E0549. | Parameters | Type | Meaning | | --- | --- | --- | | `address` | text | The host's address, as net.host answered it: IP:PORT. | | `token?` | integer | The token of the seat this player had (net.status's token), to come back to it in the game under way: a seat whose player left is refused to anyone without it (E0569). | | `timeout_ms?` | integer | How long to wait. Left out: 10000. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | ## net.run `net.run {steps: integer, input?: text, timeout_ms?: integer, begin_with?: integer, until?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · write Plays the game with its peers for a number of steps, as fast as their inputs come: this peer's player's input is its held input (input.set) or, with input "recorded", the project's recording for that player. Missing inputs are predicted and rolled back when they come. It returns once the steps are played and confirmed and every peer holds this peer's inputs of them, or once two worlds were found to differ (desync). A peer silent for timeout_ms is E0549. | Parameters | Type | Meaning | | --- | --- | --- | | `steps` | integer | How many steps to play, from 1 to 36000. | | `input?` | text | "held" (the default) or "recorded". | | `timeout_ms?` | integer | How long a peer may be silent, and a late joiner the host serves. Left out: 10000. | | `begin_with?` | integer | The host's, before the game begins: begin once this many players are in, the others' seats open to a late joiner (net.join to a game under way). Left out: every player. | | `until?` | integer | Play to this step, in place of steps more than the steps played: a late joiner's run, which begins at the moment it was sent. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | --- Page: reference/protocol/net-2.md # Protocol: net, part 2 of 2 The `net` 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). ## net.condition `net.condition {latency_ms?: integer, jitter_ms?: integer, loss?: number, seed?: integer, cut_after_ms?: integer, cut_for_ms?: integer} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · write For tests: makes what this peer sends from now on worse, by a seeded choice so a test is the same every run: each datagram held back latency_ms, give or take jitter_ms, or dropped with the chance loss. | Parameters | Type | Meaning | | --- | --- | --- | | `latency_ms?` | integer | Milliseconds each datagram is held back. Left out: 0. | | `jitter_ms?` | integer | Milliseconds more or less, at random. Left out: 0. | | `loss?` | number | The chance a datagram is dropped, 0 to 1. Left out: 0. | | `seed?` | integer | The seed of the choices. Left out: 1. | | `cut_after_ms?` | integer | With cut_for_ms: nothing at all is sent for cut_for_ms from this many milliseconds after now, as a cut cable; what comes in still comes. | | `cut_for_ms?` | integer | How long the cut lasts. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | ## net.status `net.status {sums?: value} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · read, read-only Reads the session: the peers, the steps played and confirmed, the rollback's counters, the link's, and the first difference found between two worlds. E0544 with no session. | Parameters | Type | Meaning | | --- | --- | --- | | `sums?` | value | true: the checksum of every confirmed step too. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | ## net.desync `net.desync {step: integer, entity?: text, component?: text, field?: text} -> {player: integer, players: integer, host: value, address: text, started: value, played: integer, confirmed: integer, delay: integer, window: integer, sync_every: integer, counters: record, link: record, peers: [record], desync: record, token: integer, open: [record], join: record, words: text, sums: [text]}` · write For tests: changes this peer's world after a step, every time that step is played, as a game that is not deterministic would (the field named grows by one; left out, the first thing with a Transform moves one unit along x, and the random source is drawn from where there is none), written as a client's write, so the peers find the worlds differ and name it. | Parameters | Type | Meaning | | --- | --- | --- | | `step` | integer | The step after which it is changed. | | `entity?` | text | The thing whose field is changed by one, with component and field. Left out: the first thing with a Transform, along x. | | `component?` | text | Its component. | | `field?` | text | Its field: a number. | | Result | Type | Meaning | | --- | --- | --- | | `player` | integer | The player this peer owns: its peer number. The host is 0. | | `players` | integer | How many players the game has: [input] players. | | `host` | value | Whether this peer opened the session. | | `address` | text | Where this peer's socket is, 127.0.0.1:PORT. | | `started` | value | Whether the game has begun: every player is in and a net.run has played. | | `played` | integer | The steps played: the step the game stands at, some of it predicted. | | `confirmed` | integer | The newest step every player's real input is in for: never played again, its checksum final. | | `delay` | integer | Steps between a local input and the step it is for. | | `window` | integer | The most steps played ahead of the confirmed one. | | `sync_every` | integer | Steps between two exchanges of the world's checksum. | | `counters` | record | {steps, rollbacks, replayed, deepest, wrong, stalls, late_sounds, stray_sounds, slowest_us}: steps played for the first time; times the game was put back; steps played again; the most one rollback played again; real inputs that differed from what was predicted; times the next step waited for the window; sounds a correction asked for, played late; sounds only a wrong prediction asked for, let finish; the slowest frame of rollback in microseconds. | | `link` | record | {sent, dropped, received, latency_ms, jitter_ms, loss}: datagrams sent, dropped on purpose by net.condition, received, and the condition. | | `peers` | [record] | One {player, address, acked, heard_ms, left} per other peer: the newest step of this peer's player it holds every input up to, and how long since it was heard. | | `desync` | record | null while every checksum exchanged agreed. Else {code, step, player, here, there, part, thing, value_here, value_there, written_here, written_there}: code is E0542; the first confirmed step whose checksum differed from the peer's, both checksums, the first part of the world that differs (as world.checksum names parts: "Transform.x", "state:main.luau:score", "entities", "random"), and for a field the first thing whose value differs with both values, and who last wrote it on each side as blame.value's writer says it ({kind: "script", file, line, function} for a script's line, a system, or a client), found by playing the game again from the last moment both agreed on with blame on. | | `token` | integer | This peer's seat's token, given by the host: what it shows (net.join's token) to come back to its seat after it was dropped or left. It is sent in clear: it keeps a seat from a stranger who asks by mistake, not from one who reads the datagrams. | | `open` | [record] | One {player, from} per seat the game began without (net.run's begin_with): from is the step a late joiner's own input counts from, null while the seat is open. The host plays an open seat at rest. | | `join` | record | null, or what a late join measured on this end: {player, step, bytes, chunks, resent, asked, from, ms, gave_up}: the seat, the moment's step and size in bytes and in chunks of 1,183 bytes, the chunks the host sent again and the joiner asked for again, the step the joiner's own input counts from, the milliseconds from its asking to being given that step (the joiner's), and whether the host gave up on a joiner gone silent. | | `words` | text | What a window says about the session now, the line its title shows: players to wait for, a peer silent and for how long, one that left, worlds that differ. null when there is nothing to say. | | `sums` | [text] | With sums: true, the checksum after every confirmed step since the game began, 16 hex digits each; else empty. | ## net.leave `net.leave {} -> {step: integer, checksum: text}` · write Says goodbye to every peer and closes the session and its socket. The game stays where it stands; input.history is the confirmed inputs of every player, a recording frost test holds. | Result | Type | Meaning | | --- | --- | --- | | `step` | integer | How many fixed steps have run. | | `checksum` | text | The world's checksum at this step, 16 hex digits: what frost run prints as `world checksum`. Equal checksums mean equal worlds, on any machine. A project's `replay` holds another number, the checksum of a whole run (`run checksum`), which sums the world at every step. | --- Page: reference/cli.md # Command line Every command `frost` has, as `frost --help` prints it: how to call it, then what it does. Start with [your first game](../start/first-game.md) for the everyday ones: `new`, `dev`, `check`, `test` and `export`. - [`frost budgets`](cli.md#frost-budgets) - [`frost new`](cli.md#frost-new) - [`frost add`](cli.md#frost-add) - [`frost remove`](cli.md#frost-remove) - [`frost check`](cli.md#frost-check) - [`frost cook`](cli.md#frost-cook) - [`frost projects`](cli.md#frost-projects) - [`frost test`](cli.md#frost-test) - [`frost bench`](cli.md#frost-bench) - [`frost run`](cli.md#frost-run) - [`frost dev`](cli.md#frost-dev) - [`frost export`](cli.md#frost-export) - [`frost play`](cli.md#frost-play) - [`frost serve`](cli.md#frost-serve) - [`frost mcp`](cli.md#frost-mcp) - [`frost blame`](cli-2.md#frost-blame) - [`frost dap`](cli-2.md#frost-dap) - [`frost protocol`](cli-2.md#frost-protocol) - [`frost skills`](cli-2.md#frost-skills) - [`frost reference`](cli-2.md#frost-reference) - [`frost changes`](cli-2.md#frost-changes) ## `frost budgets` ```sh frost budgets [--root DIR] [--native EXPORTED] [--web EXPORTED] [--scripted-native EXPORTED] [--scripted-web EXPORTED] ``` Measure every budget and compare it to budgets.toml. With --native, the native size budget is measured from a folder written by `frost export desktop`; with --web, the web download budget from one written by `frost export web`. The --scripted ones print the size of an exported game with a script beside them, which no budget holds: the empty game's player has no Luau in it, every real game's has ## `frost new` ```sh frost new NAME [--template TEMPLATE] ``` Start a game: make the folder NAME as a copy of a template, a finished small game to change. Templates: pong (the default), platformer, arena, breaker, shooter, ballast, blank. They are read from the `templates` folder beside `frost`, or else from the checkout `frost` was built in ```sh frost new --list Name every template, one a line: its name, a tab and what ``` it is, for a program to read. `frost new --help` says more ## `frost add` ```sh frost add scene NAME [GAME.toml] frost add script NAME [GAME.toml] ``` Add a scene or a script to a game: write the file from the engine's stub and name it in the project file's `scenes` or `scripts`, every comment kept (left out: game.toml here). NAME is a path from the project file's folder, with or without .toml or .luau. Refused (E0446) when the name is taken, is not a plain path, or is outside the project ## `frost remove` ```sh frost remove scene NAME [GAME.toml] frost remove script NAME [GAME.toml] ``` Take back what `frost add` made: the name leaves the project file and the file is deleted, only while it is still the engine's stub and nothing else names it (E0446 otherwise) ## `frost check` ```sh frost check [--json] [--costs] [--shots [--write-shots]] GAME.toml ``` List what is wrong with a game without stepping it: the project file, the scene, the scripts, the pictures and the key names. It runs what loading the game runs, in a game that is thrown away: each script's top level, and `on_scene` for the scene the game starts in; never a step, and no file is written. One problem a line, as FILE:LINE: MESSAGE. Exit status 1 when the game would not load. --shots then takes the frames the project lists under `shots` and compares each with its picture in shots/, the most changed first; --write-shots keeps the frames as they are now instead; with --json, the line carries `shots` ({path, step, outcome} each) and `wrote` ({path, sha256} of each picture written). Every --json line carries `took_ms`, the engine's own time for the run in milliseconds: the one field that differs from run to run, so compare two answers without it. --costs then says what the game's files cost a player who downloads them: bytes and bytes with gzip by kind, the five largest, and what could be smaller (a picture written with a palette, a long WAV as Ogg Vorbis), as estimates; nothing is changed. With --json, the line carries it as `costs`. `frost export` prints the same at its end ## `frost cook` ```sh frost cook (GAME.toml | FILE.png | FILE.glb | FILE.gltf) [--profile desktop|web] [--cache DIR] [--check] ``` Make the game's assets into what a player loads and keep them in the cache, each under the SHA-256 of everything that went into it: a second cook of unchanged files cooks nothing. Pictures (PNG to a texture) and models (glTF to a model, placed, welded, with its materials); other files are read as written. One file alone is cooked and described. The cache is --cache, FROST_CACHE, or the system's folder for caches. --check cooks every file again in an empty cache and requires the same bytes. Every command that loads a game reads its pictures through the same cache; FROST_CACHE=off decodes them ## `frost projects` ```sh frost projects [DIR] [--json] ``` List the project files at the top of a folder (. when none is named), in the order frost test walks them: each .toml whose `scene` is a string, with its space (2d when it says none) and how many scenes it lists. With --json, [{file, space, scenes}]; a folder with none is [] ## `frost test` ```sh frost test --unaccept RUN.toml [--json] ``` Undo the last Accept (--write) of a run as far as the engine's copy goes: once the run's project file has its bytes from before that Accept back, put back the game as accepted then (.frost/accepted/NAME.before, one level); after the game's first Accept, take the copy away with the folders that Accept made, to the byte. Refused, changing nothing, when nothing is kept or the project file is not as it was. --json says what it wrote ```sh frost test [--write | --restore] [--against DIR] [--json] [GAME.toml | FOLDER]... ``` Test every game.toml under a folder (left out: this one), and every other project file there that has a `replay`: load it, play its recorded input for the steps its `replay` gives and require that checksum of the whole run, and compare its `shots` with their pictures. One line a game; exit status 1 when one failed. A game with no `replay` has no recorded run: its line says so, it is counted apart from those that pass, and it fails nothing. One stretch in the middle is played twice, put back from a snapshot in between, and has to go the same way both times. A failed checksum in a folder with changes not yet committed to git is told the first step, value and script line that differ from the committed game. --write writes the checksum and its `checkpoints` into the project file instead, and keeps the game as accepted in .frost/accepted/NAME: a later failure is told the first step, value and line that differ from it, before git HEAD (--against DIR: kept in DIR). --json prints one line for the whole test: each run's result (`state`: passed, failed or no_replay, counted as `passed`, `failed` and `no_replay`), length, what it was told against and the first difference as values, for a program to read; for a run that names no step, the stretch it first differs in, why, and whether accepting it is sound, and `took_ms`, the engine's own time for the whole test (the one field that differs from run to run) --restore asks instead whether the game can be put back to a snapshot: at each checkpoint it takes one, plays on, puts it back and plays again, and fails a game that goes another way (a script keeps state in a `local`, not in `state`) ```sh frost test --says PART[@STEP]... [--against REV] [--json] [GAME.toml | FOLDER]... ``` Hold a change to what it said it changes: the game on disk is played beside the game at REV (left out: HEAD) on its recorded input, and must differ from it only in the parts said, each from its step on (parts as world.checksum names them: Transform.x, state:ball.luau, entities). Fails at the first step where another part differs, with the value and the line that wrote it, and at a shot whose picture changed where no part said does. A part said that never differs is a warning. --says is given once a part, or with parts joined by commas. Needs a git repository with changes (E0523, status 2) ## `frost bench` ```sh frost bench [--steps N] [--warm N] [--draw] [--sound] [--json] [--check] [GAME.toml | FOLDER]... ``` Measure a game: play its recorded input (for its `replay` steps, or N, or 600) and print how long a step takes, as the median, the 99th percentile and the worst over the steps: the whole step, each stage of it (input, ui, physics, scripts, animation, events) and the spans inside them; steps a second; the process's memory and the scripts'. The first 30 steps warm up and are not measured (--warm). --draw draws each step off-screen too and adds the renderer's spans, quads and draw calls; --sound mixes each step's sound as --wav does and prints its peak. --json prints one JSON object. --check holds each game to `perf.NAME_step_ms` and `perf.NAME_draw_ms` in budgets.toml (NAME is the game's folder), and the exit status is 1 when one is over. The load average is printed: a busy machine's numbers lie ## `frost run` ```sh frost run --headless --steps N [--shot [STEP=]FILE.png]... [--frames DIR [--from N] [--to M] [--every K]] [--overlay physics] [--input FILE.toml] [--reload STEP=FILE.luau] [--sounds] [--wav FILE.wav] [--state] [--record FILE.jsonl] [--saves DIR] [--size WxH] [--set tuning.NAME=VALUE]... ``` GAME.toml Run a game for N fixed steps with no window and print the step count and two numbers: `world checksum`, of the world after the last step (what `game.info` reports), and `run checksum`, of every world from the start to there (what a project's `replay` holds when N is its `steps`, and `frost test --write` writes). The lines are `steps:`, `world checksum:` and `run checksum:`, in that order: read one by its name, since options add lines after. GAME.toml is a project file (scene, Luau scripts, components, recorded input) or a bare scene. --shot writes the last frame as PNG, or the frame after step STEP as STEP=FILE.png, and can be given more than once. --frames writes every frame into DIR, or those from step N to step M, every Kth. --overlay physics draws every collider, joint and contact over each picture written: a bare scene whose bodies have no Rect or Sprite is black without it. --input plays the recording in FILE.toml (the `recording` text that input.history returns) in place of the project's. --reload swaps in the code of the script with that file name just before step STEP. --sounds also prints each sound the game asks for, with its step (nothing is played: a run has no sound output). --wav writes what the run would sound like as a WAV file: 16-bit stereo, 48,000 moments a second, 800 to a step, the same bytes every run; and prints its peak, where 1 is all a machine can play and more is cut off (W0438). --state prints what the scripts keep in `state` at the end, as one line of JSON after `state: `, by script. --record writes the session record: JSON lines of the input, events, sounds and reloads of each step, and a checksum every 60 steps, on the game's clock. A run starts from the saves its recording declares (`saves` beside `recording`), or none, and writes none; --saves reads them from DIR instead and writes them there. --set runs the game with one number of its [tuning] table changed, and can be given more than once. --size runs the game in a frame of W by H in place of the project's, to see its interface at another shape; a game whose scripts read frame.size() plays its recording differently there (W0456 says so) ```sh frost run --headless (--host [IP:PORT] | --join IP:PORT) --seconds S [--condition LATENCY_MS,JITTER_MS,LOSS] [--sums FILE] [--shown] GAME.toml ``` The same with no window, 60 steps a second by the clock, each player's input its recording: prints the steps played and confirmed, the rollback's counters and how many frames a window would have shown of a world later taken back (with --shown, how many of their pixels differ from the confirmed picture). --sums writes the checksum of every confirmed step, one a line. --condition makes what this peer sends late, uneven and lossy, for a test. ## `frost dev` ```sh frost dev GAME.toml [--port N] [--exit-after SECONDS] ``` Play the game in a window with the keys the project binds, serve the protocol on 127.0.0.1 (the port is printed; 0, the default, picks a free one), and reload a script the moment its file is saved, keeping the game running. A game whose scripts save keeps its saves in saves/ beside the project ```sh frost dev GAME.toml (--host [IP:PORT] | --join IP:PORT) [--port N] ``` Play the game with other players over the network, by rollback (docs/multiplayer.md): --host waits in its window for the others and prints the address they join with, 127.0.0.1 and a free port unless one is given; --join plays as the next player. The title bar says which player this is and, when the game waits for someone, who and for how long. Closing the window says goodbye: that player's input is at rest from then on, alike on every machine. ```sh frost dev GAME.toml --web [--port N] [--exit-after SECONDS] ``` The same in a browser: export the game for the web, serve it at http://127.0.0.1:PORT/, and send each saved script to the open tabs, which swap it in and keep playing ## `frost export` ```sh frost export web GAME.toml --out DIR [--recording] [--slim] [--any-engine] ``` Write the folder a static web host serves: the page, the game's files and two builds of the player (WebGPU, WebGL2), and print what each kind of browser downloads. A `frost` with a `players` folder beside it (a download) copies the players from there (for a 3D game with physics, the ones with 3D physics) and needs nothing else; --slim builds them instead, with only what the game uses. Without that folder, or with --slim, they are built: that needs a checkout of the engine, Rust, and the Emscripten SDK on PATH. Either way the players must be of the source this `frost` was built from: when they are not, the export is refused (E0517), since such a player would play another engine than `frost run` does. --any-engine exports all the same. A recording kept in a file of its own is left out, since players play live input; --recording exports it too. Saves are kept in the browser's localStorage, by the project's `id` (left out: the folder's name). To hold an export to `frost run`: export with --recording, serve DIR (`frost play DIR`) and open /?hold=N. The page plays the recording for N steps, stands still and prints to the console `frost_player: holding at step N checksum X`, where X is the `world checksum` of `frost run --headless --steps N` (the world at that step, not the run's). More options: &backend=gl or &backend=gpu picks the build, &size=WxH the canvas, &mute plays no sound at all (no audio is opened, so a script cannot turn it on: open the page again without it to hear it), and &report=/path POSTs the held frame (a PNG) to that path on the same host, with the printed lines in the header X-Ven-Lines (percent-encoded) and the build in X-Ven-Backend ```sh frost export desktop GAME.toml --out DIR [--recording] [--slim] [--any-engine] [--fetch] ``` Write a folder for this system: the player, named after the game (the project's `title`, or its folder), and the game's files beside it. Started with no arguments it plays that game. The player comes from where the web ones do. With --recording, `DIR/NAME --hold N` plays the recording for N steps and prints the same line as the page. Saves are kept in the system's folder for a person's data, by the project's `id` (left out: the folder's name). A game in C# (a frost with C#) has its scripts compiled ahead of time into one library beside it, with no .NET under it; --fetch lets the one package that needs be fetched when the SDK has it not ```sh frost export ios GAME.toml --out DIR [--device] [--recording] [--any-engine] ``` Write DIR/NAME.app for the iPhone simulator (--device: an iPhone, unsigned): the player, Info.plist and the game's files. Built from a checkout; needs Xcode (E0500) and `rustup target add aarch64-apple-ios-sim`. Prints the app's id. `xcrun simctl launch --console-pty SIM ID --hold N` prints the same line as the page. docs/export.md ```sh frost export android GAME.toml --out DIR [--recording] [--any-engine] ``` Write DIR/NAME.apk for arm64 Android 8.0 and later, signed with a debug key: a NativeActivity with no Java, the game in its assets. Built from a checkout; needs the Android SDK and NDK (E0535) and `rustup target add aarch64-linux-android`. The player prints to `adb logcat -s frost_player` and takes its arguments from `adb shell setprop debug.ven.args.APP_ID "'--hold N'"` ## `frost play` ```sh frost play DIR [--port N] [--exit-after SECONDS] ``` Play a folder `frost export web` wrote: serve it as it is at http://127.0.0.1:PORT/ (printed; 0, the default, picks a free port) for a browser to open. Only that folder is served, on this machine only; there is no protocol and no reload, and nothing is written ## `frost serve` ```sh frost serve GAME.toml [--port N [--stdio]] [--join-file PATH [--read-join-file PATH]] [--saves DIR] ``` Serve the game over the protocol: JSON-RPC 2.0, one object per line, on standard input and output, or with --port on a TCP socket bound to 127.0.0.1 (0 picks a free port). With --stdio too, on both at once, for any number of clients of the port; the address is then printed on standard error. With --saves the game's saves are kept in DIR, and a game.reset is one more launch from it; without, they end with the session. --join-file serves both (port 0 unless --port says) and writes PATH, for this user alone, with the address and token before it says it listens; it is removed when the session ends. --read-join-file writes another with the read-only token: an agent that joins by it changes nothing in the game (E0447) until the editor's session.mode lets its hand. The editor's session.token {tag} writes PATH.handN, a join file for one hand alone: whoever joins by it is that hand, and writes or only reads as session.mode last set it ## `frost mcp` ```sh frost mcp GAME.toml [--saves DIR] ``` Serve the game to an AI agent: the Model Context Protocol on standard input and output, the same commands as tools ```sh frost mcp (--join-file PATH | --join 127.0.0.1:PORT --token-file PATH) [--who NAME] [--tag TAG] [--mode plan|ask|trial|free] ``` The same tools for the game a running session plays (an editor's `frost serve --port 0 --stdio`, or `frost dev`): the agent and the person act on one game, and every write the agent makes names it (session.hello: --who, or the MCP client's own name). --join-file reads the file `frost serve --join-file` writes, waiting up to ten seconds for it, so the agent's arguments are the same at every start of the game; with --join, PATH holds the token the session printed. --tag (or FROST_HAND_TAG) is the editor's own name for the agent's task, kept with its hand. --mode is the editor's mode for it: in plan the session refuses all it asks but reads (E0447). When the session ends this says so (E0522) and exits --- Page: reference/cli-2.md # Command line, part 2 of 2 Back to [all commands](cli.md). ## `frost blame` ```sh frost blame GAME.toml [--input RUN.toml] [--step N] (ENTITY.COMPONENT.FIELD [--history N] | --pixel X,Y) [--json] ``` Say why a value is what it is at step N of the recorded input: the scene line, script line, system or client that wrote the field last, and what it was before. With --pixel, say what is drawn at a pixel of the frame, who made it and who put it there. `frost help blame` has the whole of it ## `frost dap` ```sh frost dap Debug a game's scripts from an editor: the Debug Adapter ``` Protocol on standard input and output. The editor's launch request names the game. `frost dap --help` says how to set an editor up ## `frost protocol` ```sh frost protocol [COMMAND] List the protocol's commands, or describe one in full. ``` The script debugger is its `debug.` commands, served by dev, serve and mcp: debug.attach, debug.breakpoints, then debug.state, debug.stack, debug.scope, debug.step and debug.continue. It is never in an exported game ## `frost skills` ```sh frost skills [--out DIR | --here] Install reference skills and agent harness files ``` ## `frost reference` ```sh frost reference [PAGE|CALL] Read the small game-making core, a page or one entry frost reference --search WORDS ``` Find ranked entries with page names ```sh frost reference --all Print the whole scripting reference frost reference --types [GAME.toml] ``` Print the script API as Luau types, with the game's components, for an editor's language server (luau-lsp) ## `frost changes` ```sh frost changes [REVISION] Print what changed between versions that a game's author ``` notices, newest first, with what to write to have the old behaviour: the engine's CHANGES.md, as this `frost` was built. With a revision (`r27` in a replay's `engine`), what was added since frost --version Print the version, the revision and the commit (with `+` when it was built from changes not committed) frost --help, frost help Print this help frost COMMAND --help, frost COMMAND -h, frost help COMMAND Print what one command takes, and exit 0; a command that is not built exits 2. `frost help blame` has the whole of blame, `frost help new` and `frost help dap` theirs FROST_PHYSICS_WORKERS=N Step each game's physics on N threads (1 to 16; left out: 1) in every verb that plays one. The results are the same bits on any number; a step of many bodies is shorter. An exported player and a web page always use one Not built yet: profile, migrate, ship. --- Page: reference/errors.md # Error and warning codes When something is wrong with a game, `frost` tells you with a code, the file and line, what is wrong and how to fix it: `FILE:LINE: CODE: what and the fix`. A code starting with `E` stops the game or the command; one starting with `W` is a warning. Codes are stable and never reused, so you can search for one. Find yours below and follow the link to the page that explains it. Codes E0001 to E1003 here; [E1004 to W1411](errors/2.md). | Code | Explained in | | --- | --- | | `E0001` | [Changelog](../changelog.md#changelog) | | `E0003` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [Changelog, part 7](../changelog/7.md#changelog-part-7), [Protocol: world, part 1 of 2](protocol/world.md#worldremove) | | `E0004` | [Protocol: world, part 1 of 2](protocol/world.md#worldseries) | | `E0006` | [Things and components](../concepts/things.md#names-and-parents), [scripts](scripts.md#scripts-2), [Protocol: world, part 1 of 2](protocol/world.md#worldspawn) | | `E0106` | [Things and components](../concepts/things.md#names-and-parents), [Scenes](../concepts/scenes.md#sharing-what-several-scenes-have) | | `E0208` | [Changelog](../changelog.md#changelog) | | `E0302` | [Gameplay in C#](../guides/csharp.md#while-you-work), [Changelog, part 6](../changelog/6.md#changelog-part-6), [scripts](scripts.md#the-language) | | `E0305` | [Gameplay in Luau](../guides/luau.md#numbers-and-the-same-bits-everywhere), [scripts](scripts.md#the-language) | | `E0306` | [Gameplay in Luau](../guides/luau.md#numbers-and-the-same-bits-everywhere), [scripts](scripts.md#the-language) | | `E0307` | [Gameplay in Luau](../guides/luau.md#state-and-what-a-local-is-for), [state](state.md#state-2) | | `E0309` | [Gameplay in C#](../guides/csharp.md#differences-from-luau-worth-knowing), [csharp](csharp.md#the-api-against-luaus) | | `E0311` | [Gameplay in C#](../guides/csharp.md#shipping-a-c-game), [Changelog, part 2](../changelog/2.md#changelog-part-2), [csharp](csharp.md#shipping-a-game-in-c) | | `E0401` | [Changelog, part 4](../changelog/4.md#changelog-part-4) | | `E0408` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0413` | [Protocol: world, part 1 of 2](protocol/world.md#worldinsert) | | `E0415` | [Changelog, part 6](../changelog/6.md#changelog-part-6) | | `E0420` | [Atlases: frames by name](../guides/atlases.md#a-sprite-on-a-frame) | | `E0423` | [scripts](scripts.md#scenes) | | `E0426` | [Scenes](../concepts/scenes.md#sharing-what-several-scenes-have) | | `E0429` | [Changelog, part 6](../changelog/6.md#changelog-part-6) | | `E0430` | [Audio](../guides/audio.md#files) | | `E0433` | [Protocol: game, part 1 of 2](protocol/game.md#gamerestore) | | `E0434` | [Protocol: game, part 1 of 2](protocol/game.md#gamesnapshot) | | `E0436` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [3d](3d.md#meshes) | | `E0437` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [3d](3d.md#meshes) | | `E0438` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [3d](3d.md#meshes) | | `E0439` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [3d](3d.md#meshes) | | `E0441` | [Protocol: game, part 1 of 2](protocol/game.md#gameinfo) | | `E0442` | [Recipe: debug a script](../agents/recipes/debug-a-script.md#3-stop-at-the-line) | | `E0444` | [Changelog, part 6](../changelog/6.md#changelog-part-6), [Protocol: debug, part 2 of 2](protocol/debug-2.md#debugevaluate) | | `E0445` | [Changelog, part 3](../changelog/3.md#changelog-part-3) | | `E0446` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [Protocol: project](protocol/project.md#projectadd), [Command line](cli.md#frost-add) | | `E0447` | [The protocol](../concepts/protocol.md#you-and-an-agent-on-one-game), [Changelog, part 3](../changelog/3.md#changelog-part-3), [Changelog, part 4](../changelog/4.md#changelog-part-4) | | `E0448` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [Protocol: session](protocol/session.md#sessionhello) | | `E0449` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Changelog, part 4](../changelog/4.md#changelog-part-4), [Protocol: frame, part 1 of 2](protocol/frame.md#framecapture) | | `E0452` | [Changelog, part 4](../changelog/4.md#changelog-part-4) | | `E0455` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: world, part 1 of 2](protocol/world.md#worldmove) | | `E0456` | [Changelog, part 3](../changelog/3.md#changelog-part-3) | | `E0458` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: session](protocol/session.md#sessiontoken) | | `E0459` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [joints](joints.md#joints) | | `E0460` | [joints](joints.md#joints) | | `E0461` | [joints](joints.md#joints) | | `E0462` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [joints](joints.md#joints) | | `E0463` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: project](protocol/project.md#projectrename) | | `E0464` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: project](protocol/project.md#projectrename) | | `E0465` | [Protocol: project](protocol/project.md#projectrename) | | `E0466` | [Protocol: project](protocol/project.md#projectrename) | | `E0467` | [Protocol: project](protocol/project.md#projectrename) | | `E0468` | [Protocol: project](protocol/project.md#projectrename) | | `E0469` | [Protocol: project](protocol/project.md#projectrename) | | `E0470` | [Undo one agent's change](../guides/undo-landing.md#what-it-does-and-when-it-is-refused), [Changelog](../changelog.md#changelog), [Changelog, part 3](../changelog/3.md#changelog-part-3) | | `E0471` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [physics](physics.md#physics-2), [Protocol: world, part 1 of 2](protocol/world.md#worldset) | | `E0472` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: change](protocol/change.md#changetest) | | `E0473` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: copy, part 1 of 2](protocol/copy.md#copydrop), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copyflush) | | `E0474` | [Protocol: change](protocol/change.md#changetest), [Protocol: copy, part 1 of 2](protocol/copy.md#copymake), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copygive) | | `E0475` | [Protocol: copy, part 1 of 2](protocol/copy.md#copymake) | | `E0476` | [Changelog, part 3](../changelog/3.md#changelog-part-3), [Protocol: copy, part 1 of 2](protocol/copy.md#copymake) | | `E0477` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 1 of 2](protocol/copy.md#copymake), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copyflush) | | `E0478` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 1 of 2](protocol/copy.md#copyland), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copyflush) | | `E0479` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 1 of 2](protocol/copy.md#copymake) | | `E0480` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 1 of 2](protocol/copy.md#copymake), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copygive) | | `E0481` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 1 of 2](protocol/copy.md#copylist), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copypark) | | `E0482` | [Gameplay in C#](../guides/csharp.md#what-you-need), [Changelog, part 2](../changelog/2.md#changelog-part-2), [Recipe: choose C# or Luau](../agents/recipes/csharp-or-luau.md#setting-up-c) | | `E0483` | [3d](3d.md#meshes) | | `E0486` | [Protocol: game, part 1 of 2](protocol/game.md#gameinfo) | | `E0490` | [3d](3d.md#meshes) | | `E0500` | [Put your game on a phone](../guides/export.md#ios), [Recipe: export to the web, desktop, iPhone and Android](../agents/recipes/export.md#iphone-and-android), [Command line](cli.md#frost-export) | | `E0501` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0509` | [Recipe: export to the web, desktop, iPhone and Android](../agents/recipes/export.md#the-web) | | `E0515` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0517` | [Changelog, part 6](../changelog/6.md#changelog-part-6), [Command line](cli.md#frost-export) | | `E0518` | [Changelog, part 6](../changelog/6.md#changelog-part-6) | | `E0519` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0520` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0521` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0522` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [Command line](cli.md#frost-mcp) | | `E0523` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [Command line](cli.md#frost-test) | | `E0524` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0525` | [Changelog, part 5](../changelog/5.md#changelog-part-5) | | `E0526` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [Protocol: assets](protocol/assets.md#assetscooked) | | `E0527` | [Changelog, part 4](../changelog/4.md#changelog-part-4), [Protocol: assets](protocol/assets.md#assetscooked) | | `E0528` | [Things and components](../concepts/things.md#the-engines-components-and-your-own), [Changelog](../changelog.md#changelog) | | `E0529` | [Put your game on a phone](../guides/export.md#android) | | `E0530` | [Atlases: frames by name](../guides/atlases.md#the-page), [Changelog, part 4](../changelog/4.md#changelog-part-4), [drawing](drawing.md#atlases) | | `E0531` | [Atlases: frames by name](../guides/atlases.md#a-sprite-on-a-frame), [Changelog, part 4](../changelog/4.md#changelog-part-4), [drawing](drawing.md#what-is-drawn) | | `E0532` | [Atlases: frames by name](../guides/atlases.md#patterns), [Changelog, part 4](../changelog/4.md#changelog-part-4), [drawing](drawing.md#atlases) | | `E0533` | [Atlases: frames by name](../guides/atlases.md#a-sprite-on-a-frame), [Changelog, part 4](../changelog/4.md#changelog-part-4), [drawing](drawing.md#atlases) | | `E0534` | [Put your game on a phone](../guides/export.md#on-a-phone) | | `E0535` | [Put your game on a phone](../guides/export.md#android), [Recipe: export to the web, desktop, iPhone and Android](../agents/recipes/export.md#iphone-and-android), [Command line](cli.md#frost-export) | | `E0540` | [Multiplayer](../guides/networking.md#make-a-game-for-two-or-more), [Protocol: net, part 1 of 2](protocol/net.md#nethost) | | `E0541` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Protocol: net, part 1 of 2](protocol/net.md#netjoin) | | `E0542` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Protocol: net, part 1 of 2](protocol/net.md#nethost), [Protocol: net, part 2 of 2](protocol/net-2.md#netcondition) | | `E0543` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Gameplay in C#](../guides/csharp.md#what-c-cannot-do-yet), [What works today](../status.md#c) | | `E0544` | [Multiplayer](../guides/networking.md#host-and-join-from-your-own-menu), [Protocol: net, part 1 of 2](protocol/net.md#nethost), [Protocol: net, part 2 of 2](protocol/net-2.md#netstatus) | | `E0545` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Protocol: net, part 1 of 2](protocol/net.md#nethost) | | `E0546` | [Multiplayer](../guides/networking.md#join-a-game-already-under-way), [Protocol: net, part 1 of 2](protocol/net.md#netjoin) | | `E0547` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Changelog](../changelog.md#changelog) | | `E0548` | [Multiplayer](../guides/networking.md#when-something-is-refused) | | `E0549` | [Multiplayer](../guides/networking.md#when-something-is-refused), [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: net, part 1 of 2](protocol/net.md#netjoin) | | `E0550` | [Protocol: copy, part 1 of 2](protocol/copy.md#copyqueue), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copyflush) | | `E0551` | [Changelog, part 2](../changelog/2.md#changelog-part-2), [Protocol: copy, part 2 of 2](protocol/copy-2.md#copydiff) | | `E0552` | [Protocol: copy, part 1 of 2](protocol/copy.md#copymake) | | `E0560` | [Animation and posing](../guides/animation.md#specks), [animation](animation.md#animation) | | `E0561` | [animation](animation.md#animation) | | `E0562` | [animation](animation.md#animation) | | `E0565` | [Multiplayer](../guides/networking.md#when-something-is-refused) | | `E0566` | [Multiplayer](../guides/networking.md#when-something-is-refused) | | `E0567` | [Multiplayer](../guides/networking.md#when-something-is-refused) | | `E0568` | [Multiplayer](../guides/networking.md#join-a-game-already-under-way), [Changelog](../changelog.md#changelog), [Protocol: net, part 1 of 2](protocol/net.md#netjoin) | | `E0569` | [Multiplayer](../guides/networking.md#join-a-game-already-under-way), [Changelog](../changelog.md#changelog), [Protocol: net, part 1 of 2](protocol/net.md#netjoin) | | `E0574` | [animation](animation.md#animation) | | `E0575` | [3d](3d.md#3d) | | `E0576` | [Streaming worlds](../guides/streaming.md#checks-and-costs), [project](project.md#streaming-cells) | | `E0577` | [Streaming worlds](../guides/streaming.md#a-road-of-four-cells), [Recipe: stream a world](../agents/recipes/streaming.md#steps), [project](project.md#project) | | `E0578` | [Streaming worlds](../guides/streaming.md#checks-and-costs), [project](project.md#streaming-cells) | | `E0579` | [Streaming worlds](../guides/streaming.md#checks-and-costs), [project](project.md#project) | | `E0604` | [Changelog, part 6](../changelog/6.md#changelog-part-6) | | `E1001` | [animation](animation.md#animation-2) | | `E1002` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [animation](animation.md#animation-2), [Protocol: world, part 1 of 2](protocol/world.md#worldspawn) | | `E1003` | [Changelog, part 5](../changelog/5.md#changelog-part-5), [Protocol: world, part 1 of 2](protocol/world.md#worldspawn) | --- Page: reference/errors/2.md # Error and warning codes, E1004 to W1411 Codes E1004 to W1411 here; [E0001 to E1003](../errors.md). | Code | Explained in | | --- | --- | | `E1004` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [Protocol: world, part 1 of 2](../protocol/world.md#worldspawn) | | `E1101` | [physics](../physics.md#physics-2) | | `E1102` | [physics](../physics.md#physics) | | `E1103` | [Changelog, part 7](../../changelog/7.md#changelog-part-7) | | `E1107` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [Protocol: world, part 1 of 2](../protocol/world.md#worldremove) | | `E1108` | [physics](../physics.md#physics-2) | | `E1110` | [physics](../physics.md#physics-2) | | `E1111` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [physics](../physics.md#physics-2), [Protocol: world, part 1 of 2](../protocol/world.md#worldremove) | | `E1113` | [physics](../physics.md#physics-2) | | `E1301` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [ui](../ui.md#interface), [Protocol: world, part 1 of 2](../protocol/world.md#worldremove) | | `E1303` | [Changelog, part 6](../../changelog/6.md#changelog-part-6) | | `E1306` | [Animation and posing](../../guides/animation.md#tweens), [Changelog, part 6](../../changelog/6.md#changelog-part-6), [ui](../ui.md#interface) | | `W0308` | [scripts](../scripts.md#warnings) | | `W0309` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [Changelog, part 6](../../changelog/6.md#changelog-part-6) | | `W0312` | [Changelog, part 2](../../changelog/2.md#changelog-part-2) | | `W0313` | [Changelog, part 2](../../changelog/2.md#changelog-part-2) | | `W0436` | [Changelog, part 6](../../changelog/6.md#changelog-part-6) | | `W0437` | [Audio](../../guides/audio.md#files), [Changelog, part 6](../../changelog/6.md#changelog-part-6), [Recipe: export to the web, desktop, iPhone and Android](../../agents/recipes/export.md#checks) | | `W0438` | [Audio](../../guides/audio.md#hearing-a-run-without-speakers), [Changelog, part 6](../../changelog/6.md#changelog-part-6), [Command line](../cli.md#frost-run) | | `W0439` | [Changelog, part 6](../../changelog/6.md#changelog-part-6) | | `W0445` | [Changelog, part 5](../../changelog/5.md#changelog-part-5) | | `W0455` | [3D rendering](../../guides/3d-rendering.md#every-backend-one-picture), [Changelog, part 4](../../changelog/4.md#changelog-part-4), [Recipe: export to the web, desktop, iPhone and Android](../../agents/recipes/export.md#checks) | | `W0456` | [Changelog, part 3](../../changelog/3.md#changelog-part-3), [Command line](../cli.md#frost-run) | | `W0457` | [Changelog, part 3](../../changelog/3.md#changelog-part-3), [drawing](../drawing.md#what-is-drawn) | | `W0458` | [3d](../3d.md#meshes) | | `W0459` | [Changelog, part 2](../../changelog/2.md#changelog-part-2), [Recipe: export to the web, desktop, iPhone and Android](../../agents/recipes/export.md#checks), [3d](../3d.md#meshes) | | `W0460` | [What works today](../../status.md#rendering), [Changelog](../../changelog.md#changelog) | | `W1112` | [Changelog, part 7](../../changelog/7.md#changelog-part-7), [joints](../joints.md#joints), [Protocol: game, part 1 of 2](../protocol/game.md#gamecheck) | | `W1114` | [Changelog, part 7](../../changelog/7.md#changelog-part-7), [physics](../physics.md#physics-2) | | `W1410` | [Changelog, part 5](../../changelog/5.md#changelog-part-5), [Protocol: assets](../protocol/assets.md#assetssources) | | `W1411` | [Changelog, part 5](../../changelog/5.md#changelog-part-5) | --- Page: soon/physical-sky.md # Physical sky > **Coming next.** This feature is not in `frost` yet. The page is written ahead so you can plan for it; until it ships, nothing here works in the `frost` you have. A sky worked out from a real atmosphere, with clouds, a moon and stars, that you turn on with one field. The engine's `Sky` today is a painted day: the hour picks the sun, the sky's colours and the ambient light. The physical sky works them out from an atmosphere instead: the scattering of air, haze and ozone over a round Earth, twilight, a sun and a moon with phases, stars, two sheets of cloud with their shadows, and light and reflections from that same sky, on every backend. A game opts in; a game that does not keeps its picture and its checksums. ## Opting in One field of `Sky` turns it on: `model = "physical"`, or a named `look`, or a `picture`. | Write | Gives | | --- | --- | | `Sky = { model = "physical", time = 17.75 }` | The clear preset at a quarter to six | | `Sky = { look = "desert", time = 17.75 }` | Dust in the air, pale ground | | `Sky = { look = "alpine", time = 9 }` | Thin clear air, morning | | `look = "overcast"`, `look = "storm"` | Heavy cloud | | `Sky = { picture = "art/sky.png" }` | An equirectangular PNG as the sky, lighting and reflections from it | `time`, `turn`, `shadows` and `reach` mean what they mean today. Shadows follow the sun; moonlight casts none. ## Tuning a look Each preset can be changed a field at a time; a field left at -1 keeps the preset's: | Field | Range | Is | | --- | --- | --- | | `turbidity` | 1 to 10 | How much haze and dust the air holds | | `albedo` | 0 to 0.95 | How much light the ground gives back | | `tint` | sRGB | A tint of the atmosphere and clouds | | `altitude` | metres | The ground's height above the sea | | `cloud_coverage`, `cloud_density`, `cloud_height` | 0 to 1, 0 to 4, metres | The low sheet of cumulus | | `cirrus_coverage`, `cirrus_density`, `cirrus_height` | 0 to 1, 0 to 4, metres | The high sheet of cirrus | | `wind_x`, `wind_z` | metres a second | How the clouds drift | | `moon_phase` | 0 to 1 | 0 new, 0.5 full | | `seed` | whole number | Which stars | With a physical sky the haze becomes the atmosphere's own: distant things take its colour by distance (`haze_far` sets how far it is sampled). The sun's disc stays bright enough to bloom. Clouds are for views from the ground; flying into or above them is not supported. ## Cost and determinism The atmosphere's tables are worked out on the CPU with portable arithmetic, so every machine makes the same sky. A small change of the sun reuses them; a larger one rebuilds them in fixed slices, one a step, and cross-fades over 30 steps, so time of day can move every step without a hitch. A still capture settles the sky first, so a shot is the same picture whatever came before it. Wind and twinkling stars move with the step, so a held frame is held. `frame.at` names the sky's light, the moon's, the light through clouds and the atmosphere's haze in its account of a pixel. When it ships, it gets a sample of its own and a section in the [3D rendering guide](../guides/3d-rendering.md). --- Page: soon/gpu-skinning.md # GPU skinning > **Coming next.** This feature is not in `frost` yet. The page is written ahead so you can plan for it; until it ships, nothing here works in the `frost` you have. Crowds of animated characters get cheaper to draw, with nothing for you to change. Today a posed model (a `Pose`, a clip playing on a rigged glTF) is bent on the CPU. With GPU skinning the CPU works out the model's joints once a pose, and the graphics device bends the model's own meshes by them, four joints a corner, in the picture and in every shadow map: natively, in WebGL2 and in WebGPU. ## What changes for a game Nothing to write: a game with a rigged model gets it as it loads. - **Cheaper crowds.** Every thing on one model is one instanced draw a part, so many figures of one model cost about what one does on the CPU side. - **Shared poses.** A thing held at a joint (`Parent.joint`) shares its pose with every thing at the same moment of the same clip; a thing with a `Bone` of its own keeps its own. - **The same game.** Checksums are unchanged: skinning is drawing, never simulation. An unposed mesh is the same picture to the byte. A posed one is within one level of the CPU's picture, but for a rare pixel on an edge. - **No hitch.** The pipelines for posed meshes are made as a game with a rigged model loads, never while it plays. ## Checks `frost test` holds a game's checksum as before, and its shots compare as before; a shot of a posed figure may need to be taken again once (one edge pixel differs). `frost bench --draw` shows the drawing's spans and draw calls, which fall for a crowd of one model. When it ships, [animation](../guides/animation.md) gets a section on it. --- Page: soon/effects.md # Engine effects: cards, flipbooks and blend modes > **Coming next.** This feature is not in `frost` yet. The page is written ahead so you can plan for it; until it ships, nothing here works in the `frost` you have. Fire, smoke, sparks and glows made from pictures on cards, without writing a shader. Three components and two fields of `Mesh`, in every 3D game. ## Cards `Billboard = { picture = "art/flame.png", facing = "up", blend = "additive" }` is a picture on a card turned to the eye. Every card of one picture is one draw, however many there are. `Flipbook = { cols = 4, rows = 4, fps = 12 }` beside a `Billboard` (or a `Mesh`) plays a grid of frames from its picture; which frame a card shows is a number of its own, so a hundred flames need not flicker together. `Stretch` lengthens a card along its thing's motion: a spark that streaks. ## Blend modes on a mesh `Mesh.blend` takes `"alpha"` (the same as today's `"blend"`), and three new ones: `"additive"`, `"multiply"` and `"premultiplied"`. Those three are drawn among the see-through things, the farthest first, write no depth and cast no shadow; what an additive one writes into a blooming frame blooms. `Mesh.shadows = false` makes a thing cast no shadow: a glow, a ghost, a light's bulb. ## Materials get time and pictures A material's functions may read `time` (the game's steps, in seconds: still the simulation's clock, so a frame put back is the same picture) and call `picture(uv)` and `second(uv)`. And the alpha a material's `fragment` returns is honoured: it cuts a masked part and covers by a see-through one. ## If you already have a game - A game's own component named `Billboard`, `Flipbook` or `Stretch` must be renamed. - A material that named its own `time`, `picture`, `second`, or anything beginning `fx_` or `FX_`, must rename it. - A `fragment` that returns an alpha other than `color.a` on a masked or see-through part draws differently: return `color.a` there for the old picture. - A `[stream]` game's checksum moves once, as its kept rows leave out a field the engine added later: play it, then `frost test --write`. No other game behaves differently and no other checksum moves. When it ships, a campfire sample shows it and [3D rendering](../guides/3d-rendering.md) gets a section on it.