The Lua reference
Every call a Cinderfox script can make, and every component it can put on an
entity — written from Cinderfox’s own list of them, the same list an agent
reads through the script_api tool, so nothing here is invented and nothing
is left out. Scripts are Luau, Roblox’s Lua: ordinary Lua 5.1, plus +=,
-= and friends, continue, and optional types. Scripting
is the gentler way in.
How a game is laid out
my-game/
project.ron the window, the start scene, the controls
scenes/main.ron entities and their components
scripts/*.luau the rules (subfolders are fine: scripts/lib/…)
art/ sounds/ pictures (svg/png) and sounds (ogg/wav/mp3/flac)
Controls are named in project.ron, and scripts ask for them by name.
Axes are made of those names, and buses are extra mixer channels:
input: {
"left": ["ArrowLeft", "KeyA"],
"right": ["ArrowRight", "KeyD"],
"fire": ["Space", "PadSouth"],
},
axes: { "steer": (minus: Some("left"), plus: Some("right"), stick: Some("left_x")) },
buses: ["voice"],
A script runs because an entity carries it — or several, each with its
own self. In a scene file:
(name: "player", components: {
"Transform": (position: (480.0, 270.0)),
"Sprite": (width: 48.0, height: 48.0, texture_name: Some("art/player.svg")),
"Script": ["scripts/player.luau", "scripts/health.luau"],
"Ship": (speed: 300.0),
}),
In the editor: select the entity, and the Inspector’s Script section adds, reorders, opens and takes off scripts.
The shape of a script
A script is a file that returns a table of functions. Cinderfox calls them;
self is per-entity storage you can put anything in, and self.entity is the
entity the script is on.
-- scripts/player.luau
component("Ship", { speed = 300.0, cooldown = 0.0, aim = vec(1, 0) })
local M = {}
function M.start(self)
self.shots = self.shots or 0 -- `or`: start re-runs on every save
end
function M.update(self, dt)
local t = world.edit(self.entity, "Transform") -- a live handle
t.position += vec(input.axis("steer") * 300 * dt, 0)
-- saved for you when update returns
end
function M.on_contact_began(self, contact)
events.emit("player_hit", { by = contact.other }) -- any script can listen
end
return M
Traps worth knowing first
- Positions are vectors.
t.position.x,t.position + vec(5, 0),vec(x, y)to make one. They are VALUES:t.position.x = 3is an error — writet.position = vec(3, t.position.y). Rotations and colours stay arrays of numbers (color[4]is alpha). world.getreturns a copy;world.edita live handle. A change to whatworld.getgave you does nothing untilworld.set.world.edit(e, "Ship")is saved when your function returns —world.edit(e, "Ship").hp -= 1is the whole of it. A handle kept past that errors and says to ask again.- Declaring a component doesn’t add it.
component("Ship", …)makes the type exist; an entity only has one once a scene file, the Inspector’s + Component, or aworld.spawnputs it there. startruns again every time you save the script. Writeself.x = self.x or 0, notself.x = 0, or a save resets the game.- Code that waits is a task:
task.spawn(function() … task.wait(1.5) … end). A hook cannot wait. A field that glides is a tween:tween.to(e, "Sprite", "color", {1, 1, 1, 0}, 0.4). - Scripts talk with events:
events.emit("player_died")reaches every script withM.on_player_died(self, payload);events.send(e, …)one entity’s. Asendnothing handles is an error, so typos show. - A best score belongs in
store, not a save:store.set("best", n)survives Stop, a new game and a restart.saveis for a whole run. requireonly works at the top of a file, not insideupdate.- The top of a file runs once, as it loads, before any frame. Every
library is there (
shop ~= nilis true), but what needs a frame — the world, the input, the screen — is lent while a hook runs, and calling it at the top says so. Ask instartorupdate.store,vec,feel,review,games,shareandsitework there, and a library kept in a local at the top (local W = world) works in every hook after. - What you spawn belongs to the current scene, so
scene.replaceclears it away. Give anything that must survive a level change thePersistentmarker:world.spawn({ Name = "session", Persistent = true }). - Find things by name. Give entities a
Name, thenworld.find("player"). - A field you leave out takes its default, for built-in components and for ones you declare.
- When something breaks, the editor marks the entity’s row in the Scene
dock — hover for the error — and
print()goes to the editor’s Output tab.
Everything below is the full reference, section by section.
Callbacks — functions Cinderfox calls on your script
M.start(self)
Returns: nothing
Called once per entity when the script first loads AND after every hot-edit (saving the file while the game runs). Use self.x = self.x or default so hot-edits don’t reset running state.
M.update(self, dt)
Returns: nothing
Called every tick. dt is the frame delta in seconds (~0.016 at 60fps). The order of a pass: scheduled hooks (world.after), then a Button’s and a TextField’s hooks, then every update, then tweens, tasks waking from task.wait, events, and contact callbacks last. Scripts run in archetype order, not entity id order — do not depend on who runs first.
M.on_contact_began(self, contact)
Returns: nothing
Collision callback. contact is a table: contact.other is the OTHER entity involved, contact.point and contact.normal are vectors (contact.point.x) or nil for a sensor, contact.phase is “began”, and when one side is a Tilemap contact.cell is the cell touched (a vector of column and row; nil otherwise). BOTH entities receive this call for the same contact. Runs AFTER all update calls — contact hooks always see the final frame state. Read the other entity’s components with world.get(contact.other, "...") to decide what happened. E.g. checking world.get(contact.other, "Foe") tells you it was an enemy.
M.on_contact_ended(self, contact)
Returns: nothing
The partner of on_contact_began: two bodies that were touching have separated. Same contact table, with contact.phase “ended”; point and normal are nil, since nothing is touching any more. For leaving a zone, stepping off a platform, or a button released by what stood on it.
M.on_animation_finished(self, clip)
Returns: nothing
A one-shot 3D clip has reached its end — an Animator3d with looping = false — and holds its last pose. clip is its name. For going on to the next thing: a landing over, so the hero can stand (world.edit(self.entity, "Animator3d").clip = "idle"). Heard on the pass after the clip ends, once; a looping clip is never heard. To play a one-shot again, set its time to 0 and running to true.
M.on_click(self, pointer)
Returns: nothing
On an entity with a Button: the pointer was pressed on it and let go over it — a click, or a tap. pointer is { pos, screen }, vectors in the world and on the screen. Called before update, so this pass’s update sees what it did. A button is pressable where its Sprite is DRAWN — a pinned screen sprite in its corner — or over its own size; enabled = false greys it out.
M.on_pointer_down(self, pointer)
Returns: nothing
On a Button: the pointer was pressed on it — the moment to show it pushed in.
M.on_pointer_up(self, pointer)
Returns: nothing
On the Button the pointer was pressed on: it was let go, wherever it is now. A click follows only if it is still over this button.
M.on_pointer_enter(self, pointer)
Returns: nothing
On a Button: the pointer came over it — the moment to highlight it. Only the topmost button under the pointer is over-ed.
M.on_pointer_exit(self, pointer)
Returns: nothing
On a Button: the pointer left it, or another button came on top of it.
M.on_change(self, text)
Returns: nothing
On an entity with a TextField: what the player typed changed it — a character added, or one taken off with Backspace. text is all of it now.
M.on_submit(self, text)
Returns: nothing
On a TextField: Enter was pressed while it was focused. It lets go of focus as it submits. A TextField ("TextField": (placeholder: "Your name", max: Some(12))) is focused by pressing it, so it carries a Button for its area; its Text shows what is typed with a caret, or the placeholder while empty; Escape or a press elsewhere lets go. Typing still reaches input too — a game whose actions are letters checks the field’s focused before moving.
M.on_enable(self)
Returns: nothing
Called when an entity switched off with world.set_active(e, false) is switched back on — after start and before that tick’s update, so a thing that has come back can re-arm itself first. Never called for an entity that was never switched off.
M.on_pause(self, dt, why)
Returns: nothing
Called on every script that defines it when the player is taken away from the game: why is "interrupted" when the system took the audio (a call ringing — whose banner may not even cover the game — Siri, an alarm) and "inactive" when the game is no longer in front (the call screen, the Control Centre, the home screen). Pause here: open the pause card, stop judging a song nobody can hear. A phone does not run the game while it is not in front, so a pause that happened then arrives as the game comes back, just before on_resume. In the editor, the phone tool’s interrupt pretends a call.
M.on_resume(self, dt)
Returns: nothing
Called on every script that defines it when the player is back after on_pause, and the sound with them. The game is not resumed for it — a player back from a call wants the pause card they left, not the song carrying on — so this is for what needs putting back (a bus volume, a timer), and the player’s own tap resumes play.
Globals inside a callback
require("scripts/shared.luau")
Returns: any
Load another script file and return what it returns, for SHARING CODE between scripts rather than copying it. The path is relative to the game’s asset root, like a Script component’s. Module scope only — not inside update. The result is cached, so a constants file required by four scripts is compiled once, and the required file is watched, so editing it hot-reloads everything that required it.
vec(x, y, z?)
Returns: vector
A vector — what every position, velocity, contact point and pointer is. Read .x .y .z; add, subtract, and multiply or divide by a number (t.position += vel * dt); compare with ==. A 2D position has z = 0. Vectors are VALUES, like numbers: t.position.x = 3 is an error — write t.position = vec(3, t.position.y). Luau’s vector library has the rest: vector.magnitude(v), vector.normalize(v), vector.dot(a, b). Colours and 3D rotations stay arrays, being four numbers wide.
print(...)
Returns: nothing
Write a line to the editor’s Output tab (and the MCP’s script_log), named with the entity and file that printed it. Arguments are joined with tabs, as Lua’s print joins them.
dt
Returns: number
The tick’s delta in seconds — the same number update receives. Available as a bare global (not time.dt).
self.entity
Returns: entity
The entity this script is attached to. Opaque — you cannot do arithmetic on it, only pass it to world.* functions. Available in every callback.
Declaring your own components
component(name, defaults, meta?)
Returns: nothing
Declare a component TYPE at MODULE SCOPE (top-level, not inside a function). Declaring is not adding: the entity this script is attached to does NOT get one, because a script often declares what other entities carry — so a script that reads its own world.get(self.entity, "Spinner") gets nil until a Spinner is added (the editor’s + Component lists the script’s declarations first; the MCP’s attach_script names the missing ones). defaults is a table of field defaults — the value +Component places in the editor and Stop rewinds to, and what fills any field a world.spawn, world.set or scene file leaves out. The defaults say which fields are vectors: vel = vec(0, 0) makes vel read back as a vector, path = { vec(0, 0) } a list of them; spot = {1, 2} stays a list of numbers. Putting a vector in a field the defaults did not declare as one is an error naming the line to add. Every script under scripts/, subfolders included, is compiled before the game starts, so a declaration in any of them (a shared scripts/lib/components.luau, say) exists from the first frame. meta (optional) maps field names to editor hints: { hidden = true } hides a field from the Inspector, { read_only = true } shows it but prevents edits, { range = {min, max} } shows a slider, { tip = "..." } shows a tooltip. E.g. component("Ship", {health = 100, cooldown = 0.0}, {cooldown = {hidden = true}}).
world — entities and components
world.get(entity, component_name)
Returns: table | nil
Read a component SNAPSHOT from any entity. Returns a COPY — changes to it do nothing; to change a component use world.edit. Nil if the entity doesn’t have the component. Works on ANY entity, not just self.entity. The copy is of EVERY field, made fresh on each call: to read one or two fields, world.edit(e, "Sprite").layer copies only those. A Tilemap comes back WHOLE, every row of every layer — to read or change cells use the tilemap table, which touches only the cells asked about.
world.edit(entity, component_name)
Returns: table | nil
The way to change a component. Returns a handle you change in place — local ship = world.edit(e, "Ship"); ship.hp -= 1; ship.vel += vec(0, 5) — saved automatically when your function returns (even if it errors afterwards). In the same function, world.get sees your changes and asking world.edit again returns the same handle. Do not keep a handle past the function that opened it: it is saved and closed when that function returns, and using it later is an error that says to call world.edit again. Nil if the entity doesn’t have the component. A handle copies only the fields you touch and saves only the ones you change — one that is only read saves nothing — so editing two fields of a hundred sprites is cheap. Iterate a handle with for k, v in handle do; that, or #handle, copies the whole component.
world.set(entity, component_name, value)
Returns: nothing
Write a component value directly — the whole of it, every field read from the table you pass. Prefer world.edit, which writes only the fields you change. Works on ANY entity.
world.modify(entity, component_name, fn)
Returns: boolean
Read a component, hand it to fn, write back the result — the older spelling of world.edit, kept working. Edit the table in place (function(t) t.hp -= 1 end) or return a new one; returning nothing keeps the edited table. Returns false if the entity has no such component. Works on ANY entity.
world.has(entity, component_name)
Returns: boolean
Whether an entity carries that component. Use before get/modify if absence is expected.
world.remove(entity, component_name)
Returns: nothing
Take a component off an entity. For Collider, this also removes the physics body.
world.spawn(components?)
Returns: entity
Create a new entity. Pass a table of {Component = value} to set components immediately, e.g. world.spawn({Transform = {position = vec(100, 200)}, Sprite = {width = 32, height = 32}}). Give it Name = "run" to find it again with world.find("run") — a Name is the one thing in the table that is not a component a file writes, and the way a spawned singleton is found. Fields you leave out of a component a script declared are filled from its component(...) default, as they are for world.set and a scene file — write only what differs. WHAT YOU SPAWN JOINS THE CURRENT SCENE, so a scene.replace takes it away with everything else — a wave of enemies does not follow you onto the game-over screen. This is Unity’s Instantiate rule. If you want something to SURVIVE a scene change — a score, a carried item — give it the Persistent component, which is DontDestroyOnLoad by another name.
world.set_active(entity, on)
Returns: nothing
Switch an entity off, or back on. Off means not drawn, not ticked, and not in the physics simulation — and its children go with it. Unlike despawn, the entity is still there: its components keep their values, its id stays valid, and switching it back on brings it back where it was. A script on a switched-off entity does not run, so something ELSE has to switch it back on.
world.is_active(entity)
Returns: boolean
Whether an entity is running — false if it or any of its parents was switched off. Answers the same question the engine’s own systems ask, so a game’s query and the renderer cannot disagree.
world.despawn(entity)
Returns: nothing
Remove an entity from the world. Always check world.alive(e) before accessing an entity that may have been despawned.
world.alive(entity)
Returns: boolean
Whether the entity still exists. Call this before accessing an entity that another script or collision may have despawned.
world.find(name_or_uid)
Returns: entity | nil
Find an entity by its uid (the eight-character id the editor’s tools give it) or by its name — the name a scene file gives it, or the Name = "..." it was spawned with; a name tie-breaks by lowest entity id. Use for singletons like world.find("director") or world.find("player"), and a uid for one of several that share a name.
world.find_all(name)
Returns: {entity}
All entities with this name (a scene file’s name, or Name = "..." given to world.spawn). Returns a Lua array — iterate with ipairs.
world.query(component_name, ...)
Returns: {entity}
All entities carrying EVERY named component — world.query("Foe"), or world.query("Foe", "Collider") for both. Returns a Lua array, a snapshot taken before you see it, so despawning while you walk it is safe — use # for count, ipairs to iterate. E.g. for _, e in ipairs(world.query("Foe")) do ... end.
world.spawn_prefab(path, overrides?)
Returns: entity
Spawn a prefab from a file. The optional second arg is a table of component overrides: world.spawn_prefab("props/bullet.ron", {Transform = {position = vec(x, y)}}). Overrides merge with the prefab’s defaults.
world.after(entity, delay, method_name, payload?)
Returns: nothing
Run a method of the script on entity after delay seconds. The method is NAMED, as a string, not passed as a function — a stored function would be the version from before the next hot reload. world.after(self.entity, 0.3, "do_spawn", {column = i}) calls M.do_spawn(self, dt, {column = i}) 0.3s later: the payload is the THIRD argument, after dt. A misspelt name is reported when the timer fires. Timers on a despawned entity are dropped. "expire" is only a common choice of name, not a callback the engine calls by itself.
world.set_velocity(entity, velocity)
Returns: boolean
Set rigid-body velocity directly: world.set_velocity(e, vec(0, -300)), or two numbers (e, 0, -300). Applied IMMEDIATELY (not queued), so you can read it back next line. Returns false if the entity has no physics body. On a 3D body (a Collider3d) it takes a 3-vector, in metres a second with +Y up: world.set_velocity(e, vector.create(0, 5, 0)).
world.apply_impulse(entity, impulse)
Returns: boolean
Apply an impulse: a vector, or two numbers. False if no body. On a 3D body, a 3-vector.
world.angular_velocity(entity)
Returns: number | vector | nil
How fast the body is turning, in radians per second, counter-clockwise as Transform.rotation is. nil for an entity with no body. On a 3D body, a vector: radians a second round each world axis.
world.set_angular_velocity(entity, radians_per_second)
Returns: boolean
Set how fast the body turns, immediately. False if no body. A Collider with lock_rotation = true does not turn at all. Damping is the Collider’s damping and angular_damping, which can be changed while the game runs: world.edit(e, "Collider").damping = 2. On a 3D body, a vector: radians a second round each world axis.
world.apply_angular_impulse(entity, amount)
Returns: boolean
Push the body round, once — the turning half of apply_impulse. How much it turns depends on its mass and size. False if no body. On a 3D body, a vector whose direction is the axis.
world.velocity(entity)
Returns: vector | nil
Read the entity’s current rigid-body velocity as a vector (.x, .y). Returns nil if the entity has no body (different from vec(0, 0)). On a 3D body, with .z too.
world.ease(curve_name, t)
Returns: number
Shape t (clamped to 0…1) with a named easing curve and return the shaped value — 0 at 0 and 1 at 1, with the curve’s character between; out_back and out_elastic overshoot past 1. The curves are linear, in_quad, out_quad, in_out_quad, in_cubic, out_cubic, in_out_cubic, in_back, out_back, in_out_back, out_elastic, out_bounce, smoothstep. E.g. local s = world.ease("out_back", self.t / 0.4).
world.set_parent(child, parent)
Returns: nothing
Hang child under parent. THE CHILD’S Transform THEN MEANS SOMETHING DIFFERENT: it becomes an OFFSET FROM THE PARENT rather than a place in the world. So a child at (0, 12) under a parent at (100, 200) draws at (100, 212), and world.get(child, "Transform") answers (0, 12) — the offset, not where it is on screen. Refuses a loop. A child is placed by its parent OR simulated by physics and never both: giving a child a rigid body means physics wins and the parent is ignored.
world.detach(entity)
Returns: nothing
Take an entity out of whatever it hangs from, making it a root again. Its Transform is left as it is, so it JUMPS to wherever that offset points in world space — read parent_of and add the positions first if you want it to stay put.
world.parent_of(entity)
Returns: entity | nil
What this hangs from, or nil if it is a root.
world.children(entity)
Returns: {entity}
Everything parented directly to this one — not grandchildren. Despawning a parent already takes its whole subtree, so this is for reaching them rather than for cleaning up.
world.random()
Returns: number
A random float in [0, 1) from THE WORLD’S generator. Use this rather than math.random: this one is seeded with the world, so a replay or a fixed seed gives the same game twice, and math.random would not.
world.random_range(lo, hi)
Returns: number
A random float between lo and hi, from the world’s generator. Same determinism argument as world.random.
events — scripts telling each other things
events.emit(name, payload?)
Returns: nothing
Tell every script that listens: each one defining M.on_<name>(self, payload) gets it, on every entity. events.emit("player_died", {score = 120}) reaches function M.on_player_died(self, p). Delivered this pass, after every update and before contacts, in the order emitted; one emitted while events are being delivered arrives next pass. A broadcast nobody hears is not an error. The payload is copied like world.after’s: no functions.
events.send(entity, name, payload?)
Returns: nothing
Tell one entity: each of ITS scripts defining M.on_<name>(self, payload) gets it, delivered like events.emit. A send nothing on that entity handles is an error at the line that sent it — a misspelt name, almost always. One to an entity that is switched off or gone is dropped quietly.
task — code that waits
task.spawn(fn, ...)
Returns: task id
Run fn(...) as a task: code that can WAIT. It runs at once up to its first task.wait, then carries on after every update once the wait is over: task.spawn(function() audio.play("warning"); task.wait(1.5); world.despawn(self.entity) end). The task belongs to the script on the entity that spawned it, and is cancelled when that entity is despawned or switched off, when the script is taken off it or hot-reloaded (it is running the old code), and on Stop. An error before its first wait is the spawning hook’s; one after is reported as task. Keep the id to task.cancel it.
task.wait(seconds?)
Returns: seconds slept
Inside a task only: sleep for seconds of GAME time (a pause pauses it), then carry on, returning how long it really slept. task.wait() or task.wait(0) is until the next pass, so while true do ...; task.wait() end runs once a frame. Called from a hook it is an error — a hook runs to its end every pass.
task.cancel(id)
Returns: nothing
Stop the task task.spawn returned id for, wherever it is: asleep, due later this pass, or the one running now (it stops at its next wait). A finished task, or nil, is nothing to cancel and not an error.
tween — a field moved over time
tween.to(entity, component, field, target, seconds, easing?)
Returns: tween id
Move one field of a component to target over seconds of game time: tween.to(e, "Sprite", "color", {1, 1, 1, 0}, 0.4) fades a sprite out, tween.to(e, "Transform", "position", vec(400, 300), 0.5, "out_back") slides it. What moves is a number, a vector or four numbers (a colour); field may be a path, like “light.intensity”. It starts from the field’s value now, moves from the next pass, and lands exactly on target. The easing is a world.ease curve name, out_quad if left out. A second tween on the same field replaces the first, from where it had got to; seconds of 0 sets it at once. Cancelled, where it is, when the entity it moves or the script that asked is despawned or switched off, when that script is hot-reloaded, and on Stop.
tween.wait(id)
Returns: seconds waited
Inside a task only: sleep until the tween tween.to returned id for is done — finished, replaced or cancelled. task.spawn(function() tween.wait(tween.to(e, "Sprite", "color", {1, 1, 1, 0}, 0.4)); world.despawn(e) end) fades, then removes.
tween.cancel(id)
Returns: nothing
Stop a tween where it is. A finished one, or nil, is nothing to cancel and not an error.
input — keys, axes, pointer, touches, on-screen controls
input.down(action_name)
Returns: boolean
Is the ACTION currently held? Actions, never keys. The name comes from the input table in project.ron — "left", "shoot" — and a key name is NOT one: input.down("Space") throws no action "Space" is bound at runtime. Bind a key to a new action with the editor’s bind_action tool, or the Project Settings panel, then ask for that name. input.actions() lists what this project binds.
input.pressed(action_name)
Returns: boolean
Was the action pressed THIS tick? True only on the frame the key went down — use for single-fire actions like shooting.
input.released(action_name)
Returns: boolean
Was the action released this tick?
input.pointer()
Returns: vector | nil
Where the mouse pointer is this tick, in WORLD units — the space Transform.position is in, through the camera — as a vector (.x, .y). Nil when the pointer is off the game’s frame (a letterbox bar, or another panel of the editor). For a click: bind “MouseLeft” to an action in project.ron, then if input.pressed("click") then local p = input.pointer() ... end.
input.pointer_screen()
Returns: vector | nil
The pointer in SCREEN units — the space a Text or a HUD is laid out in, unmoved by the camera — or nil off the frame. Same as input.pointer() while the camera sits at the origin with zoom 1.
input.axis(name)
Returns: number
-1 to 1. A project’s own axis — axes: { "steer": (minus: Some("left"), plus: Some("right"), stick: Some("left_x")) } in project.ron, made of ACTIONS so the keys stay in input — is the plus action minus the minus action, with the stick added, held to -1…1. A pad axis by its own word works too: “left_x”, “left_y”, “right_x”, “right_y”, “l2”, “r2”. An unknown name lists every axis there is.
input.touches()
Returns: { {id, pos, screen, phase} }
Every finger on the screen that is the game’s: pos in the world (through the camera) and screen in screen units, both vectors; phase is “began” on the frame it went down (once, however long it is held), “held”, then “ended” or “cancelled” on the frame it lifts. id stays the same for one finger from began to ended. A finger on an on-screen control (project.ron’s touch:) is the control’s, and is not here — nor is it the pointer, so a thumb on the stick never presses a Button drawn under it.
input.touching()
Returns: boolean
Whether the player is on the touch screen: true from a touch until a key or a pad button is pressed, and never while a pad is connected. What a prompt follows — “TAP JUMP” rather than “PRESS SPACE” — and what draws the on-screen controls.
input.show_touch(name, shown)
Returns: nothing
Show or hide an on-screen control from project.ron’s touch:, by the action it presses or “stick” — a control drawn and doing nothing is a fault, so a title with no menu hides MENU: input.show_touch("menu", false). A hidden control is not there: a finger landing on it is the game’s, and one already holding it lets go. From the next frame, and until it is changed — a scene change does not reset it. An unknown name lists the controls there are.
input.typed()
Returns: string
The text typed this frame, in the player’s own keyboard layout — for entering a name. Empty almost always. Backspace and Enter are keys: bind them as actions.
input.scroll()
Returns: vector
How far the wheel or trackpad scrolled this frame; y positive is away from the player (scrolling up a page).
input.look()
Returns: vector
How far to look round this tick, in degrees, x across and y down: the mouse’s motion (0.15° a point), the right stick (180° a second at full tilt) and, on a phone, a thumb dragged on the glass (0.3° a point, with look: true in project.ron’s touch:) together — camera3d.orbit(look.x, look.y) is mouse look. The mouse counts only while the game holds it (input.capture_mouse).
input.capture_mouse(on)
Returns: nothing
Ask for the mouse (true): the pointer is hidden and kept in the window, so moving the mouse turns the camera rather than leaving it. false gives it back — a pause menu wants it. In the editor the game gets it from a click in its view while playing, and Escape gives it back.
input.rumble(strength, seconds)
Returns: nothing
Shake the pad, strength 0 to 1, for seconds. Nothing where nothing can rumble.
input.actions()
Returns: {string}
Every action name this project binds, in order. What lets a script be written against a project it did not ship with — and what to check when input.down("name") says the action is unknown.
ui — buttons and what is under a point
ui.at(point)
Returns: {entity}
The buttons, then the sprites, under a point (a world vector, like input.pointer()), topmost first — by the same hit test that decides what a click presses.
time
time.dt
Returns: number
Seconds since the last frame — the same number update(self, dt) is handed. Here as well because a script that keeps its own accumulator wants it outside update too.
time.elapsed
Returns: number
Game time in seconds since the world loaded. NOT wall-clock: it pauses when the game pauses, and sums the dts processed. Two runs of the same replay give the same answer.
physics — gravity, rays, overlaps, joints
physics.set_gravity(g)
Returns: nothing
Set gravity for the whole simulation, in units per second squared: a vector, or two numbers. Screen space has +y DOWN, so a side-on game wants physics.set_gravity(vec(0, 900)). It starts at zero, because a top-down game is as likely as a side-on one. Gravity belongs to a level, so set it in the level’s own script’s start: it is not reset by a scene change.
physics.gravity()
Returns: vector
The gravity now in force.
physics.overlap_circle(centre, radius, options?)
Returns: {entity}
Every entity whose collider a circle here touches, in entity-id order — “who is in the blast”: for _, e in physics.overlap_circle(t.position, 80, { layers = {"enemy"}, ignore = self.entity }) do ... end. Answered at once, unlike a sensor. Sensors ARE included (a pickup in reach is an ordinary question); sensors = false leaves them out. layers counts only colliders that named one of those layers — one that names no layer is on none.
physics.overlap_box(centre, half, options?)
Returns: {entity}
overlap_circle with a box half wide and high each way: physics.overlap_box(vec(400, 300), vec(50, 20)). Options as overlap_circle’s, plus rotation in radians.
physics.joint(a, b, { kind, at?, length?, stiffness?, damping? })
Returns: joint id
Hold two bodies together. kind is “pin” (both turn about at, a world point — a’s centre if not given: a pendulum, a hinge), “weld” (held as they are now: one rigid thing), “spring” (pulled towards length apart, as far apart as they are now if not given; stiffness 100 and damping 10 by default, per unit of mass so a heavy and a light body bounce alike) or “rope” (never more than length apart). Both need a body: a Collider is built into one at the next physics step, so two things spawned this pass can be joined from the next. A joint lasts as long as BOTH BODIES — despawning or switching either off, or changing its Collider’s body or sensor, ends it; physics.joint_exists(id) says whether it still holds.
physics.remove_joint(id)
Returns: boolean
Let go. False for a joint already gone, which is not an error.
physics.joint_exists(id)
Returns: boolean
Does the joint physics.joint returned id for still hold — both bodies live and it not removed?
physics.cast(from, dir, max, options?)
Returns: { entity, point, normal, distance, cell? } | nil
Cast a ray into the physics world: physics.cast(t.position, vec(1, 0), 500). from and dir are vectors (or two numbers each), max is how far to look, and options is { layers = {"wall"}, ignore = self.entity }. Nil for no hit; otherwise a table with the hit entity, its point and surface normal (vectors) and distance — and when what was hit is a Tilemap, the cell of it (a vector of column and row).
physics3d — a 3D world: gravity, rays, overlaps, a walking character
physics3d.set_gravity(g)
Returns: nothing
Set the 3D world’s gravity, in metres per second squared: a vector or three numbers. +Y is UP in 3D, so weight is a negative y: physics3d.set_gravity(vector.create(0, -30, 0)) for a platformer’s snappy fall. It starts at Earth’s (0, -9.81, 0). Set it in the level’s own script’s start.
physics3d.gravity()
Returns: vector
The 3D world’s gravity now in force.
physics3d.cast(from, dir, max, options?)
Returns: { entity, point, normal, distance } | nil
Cast a ray into the 3D world: physics3d.cast(t.position, vector.create(0, -1, 0), 2, { ignore = self.entity }) — is there ground under me? from and dir are vectors (or three numbers each), max how far to look in metres, options { layers = {"wall"}, ignore = self.entity }. Sensors are never hit. Nil for no hit; otherwise the hit entity, its point and surface normal (vectors) and distance.
physics3d.overlap_sphere(centre, radius, options?)
Returns: {entity}
Every entity whose 3D collider a ball here touches, in entity-id order: for _, e in physics3d.overlap_sphere(t.position, 3, { layers = {"coin"} }) do ... end. Sensors ARE included unless sensors = false. layers counts only colliders that named one of those layers.
physics3d.overlap_box(centre, half, options?)
Returns: {entity}
overlap_sphere with a level box half (a vector) from its middle to each face. Options as overlap_sphere’s.
physics3d.move_character(entity, by, options?)
Returns: { moved, grounded, sliding }
Walk a character by (a vector, in metres, this tick): it slides along walls, steps up kerbs, walks slopes and stays on the ground over crests, and MOVES the entity’s Transform3d. It returns how far it actually went (moved), whether it is standing on something (grounded — gate a jump on it) and whether it is sliding down a slope too steep to climb. The entity needs a built Collider3d, best a kinematic capsule: (radius: 0.4, height: 1.6, body: "kinematic"). Gravity is the script’s: keep a fall speed and fold it into by. Dynamic bodies it walks into are pushed. options: { step = 0.35, slope = 45, snap = 0.2, push = 70 } — step height and snap in metres, the steepest slope in degrees, and the mass it pushes with (0 pushes nothing).
quat — turns in 3D
quat.euler(x, y, z)
Returns: {x, y, z, w}
A turn from three angles in degrees — round Y, then X, then Z, as the Inspector shows a rotation — as the four numbers a Transform3d’s rotation holds: world.edit(e, "Transform3d").rotation = quat.euler(-20, 45, 0).
quat.yaw(degrees)
Returns: {x, y, z, w}
A turn round +Y — which way a thing faces across the ground.
quat.facing(dir)
Returns: {x, y, z, w}
The turn that faces a model’s front (its +Z, as a model from Blender is made) along a direction, level: world.edit(self.entity, "Transform3d").rotation = quat.facing(step) — a hero facing where it runs. A direction with no level part is no turn.
quat.rotate(q, v)
Returns: vector
A vector turned by a turn: quat.rotate(quat.yaw(camera_yaw), vector.create(0, 0, -1)) is the way a camera at that yaw looks — for movement that goes where the camera points.
quat.mul(a, b)
Returns: {x, y, z, w}
One turn after another: b, then a.
audio — sounds, buses, placed sound
audio.play(clip_name, options?)
Returns: number
Play sounds/<clip_name>.ogg (or .wav, .mp3, .flac) and return its id, for audio.stop and audio.set_volume. options is a gain (audio.play("hit", 0.5), linear, 1 as recorded) or a table: { gain = 0.5, loop = true, pan = -0.3, bus = "music" } — loop plays until stopped (music), pan runs -1 left to 1 right, bus is the mixer bus it plays through (“sfx” if not given; see audio.set_bus_volume); any other key is an error. A sound in the world: { at = vec(x, y) } or { follow = entity }, with range (how far it carries, one screen’s width if not given) — heard from the camera each frame, quieter far and on the side it is on, so it takes no pan. A followed entity that goes leaves its sound where it was last. Queued, played at the end of the pass. Music keeps playing across scene.replace; the editor’s Stop silences everything.
audio.stop(id)
Returns: nothing
Stop the sound audio.play returned id for. An id that has finished, or was already stopped, is quietly nothing — ids are never reused, so it cannot stop someone else’s sound. E.g. self.music = audio.play("theme", { loop = true }) in start, audio.stop(self.music) on game over.
audio.set_volume(id, gain)
Returns: nothing
Change a playing sound’s volume — linear, 0 silent, 1 as recorded. For ducking music under a voice, or an engine hum that follows the throttle.
audio.stop_all()
Returns: nothing
Stop every sound the scripts started, music included.
audio.pause(id)
Returns: nothing
Hold a playing sound where it is, until audio.resume(id). A paused sound still counts as playing for audio.is_playing.
audio.resume(id)
Returns: nothing
Carry on a paused sound from where it was held.
audio.fade(id, gain, seconds)
Returns: nothing
Glide the sound’s volume to gain (linear, 1 as recorded) over seconds: audio.fade(music, 0.2, 1.5) ducks the music. Fading to 0 leaves it playing silently; stop it when the fade is done if it should end.
audio.set_rate(id, rate, seconds?)
Returns: nothing
Speed and pitch together: 1 as recorded, 2 an octave up and twice as fast. Glides over seconds if given. Rate-shifting a looped sample is the classic way to rev an engine.
audio.set_pan(id, pan)
Returns: nothing
Move a playing sound between the speakers: -1 left, 0 centre, 1 right.
audio.set_master(gain)
Returns: nothing
The whole mix’s volume, linear — a game’s own volume setting. Keep the player’s choice with store.set("volume", v) and set it again in start. The editor’s Stop puts it back to 1.
audio.set_bus_volume(bus, gain, seconds?)
Returns: nothing
One volume for a group of sounds — a game’s music and effects sliders. Every sound plays through a bus: "sfx" unless audio.play(clip, { bus = "music" }) says otherwise. Every game has “music” and “sfx”; a project adds its own with buses: ["voice"] in project.ron, and naming one that is not there is an error listing those that are. Glides over seconds if given. The editor’s Stop puts every bus back to 1.
audio.is_playing(id)
Returns: boolean
Has the sound play returned id for not finished — playing or paused? True from the line that started it, false from the line that stopped it, though the game carries both out after the pass. A one-shot is false once it has played to its end.
audio.position(id)
Returns: number | nil
How many seconds into itself the sound play returned id for has got — read from the audio thread’s own playhead, not counted in frames, so a rhythm game judges a tap against what is actually playing. It keeps moving between ticks (two reads in one pass differ by the time between them), holds still while paused, and follows set_rate. It is where the mixer is, which the player hears audio.output_latency() later, plus whatever a calibration screen measures. 0 on the pass that started it; nil once stopped or finished, or if it never started (no such sound, no audio device). While the editor is being STEPPED it counts ticks instead (see audio.clock), so the same steps always give the same answers.
audio.clock()
Returns: string
What audio.position is counted by: “audio” — the device’s playhead, the game playing in real time — or “ticks”: 1/60 s times the rate each tick from the tick after play, because the editor is being stepped (by a person or step) and the ticks are not arriving in real time. A test that steps to exact ticks can check it is on “ticks”. Like everything the game reports, it is what the tick before saw, so it changes one tick after stepping starts or stops.
audio.output_latency()
Returns: number
Seconds from the mixer to the speaker, as far as the device says: on iOS its output latency plus one buffer, 0 elsewhere. What is heard is audio.position(id) - audio.output_latency(), less whatever more a calibration screen finds (Bluetooth headphones add delay no device reports) — keep that in store, per device. Ask again rather than once: plugging in headphones changes it.
camera
camera.follow(entity)
Returns: nothing
Have the active camera track an entity from now on — pass the ENTITY, e.g. camera.follow(world.find("player")). The camera records it by name so the follow survives a save, so the entity MUST have a Name component; one without is an error. Queued, applied at the end of the pass.
camera.set(x, y)
Returns: nothing
Stop following and put the camera at an absolute world position — a cut, not a glide. Queued, applied at the end of the pass.
camera.snap()
Returns: nothing
Arrive at the followed entity NOW instead of gliding in — for a respawn or a level load. Takes no arguments; to put the camera at a point, use camera.set. Queued.
camera.zoom(factor)
Returns: nothing
Set the camera zoom: 1.0 is one texel to one pixel, 2.0 shows half as much world. Refuses zero, negative and NaN. Queued.
camera3d — a 3D camera that follows, and mouse look
camera3d.follow(entity)
Returns: nothing
Make the scene’s active Camera3d follow an entity — from behind and above, at its distance, height, yaw and pitch, eased by its damping and pulled in before walls. Written down as the entity’s name (or uid), so the entity needs one. nil stops following. Applied at once; an error if the scene has no active Camera3d.
camera3d.orbit(dx, dy)
Returns: nothing
Turn the following camera round what it follows, by degrees across and down (or a vector) — mouse right turns the view right, down looks further down, held between -30° and 80°: local look = input.look(); camera3d.orbit(look.x, look.y).
camera3d.yaw()
Returns: number
Which way the camera faces across the ground, in degrees — for movement that goes where the camera looks: quat.rotate(quat.yaw(camera3d.yaw()), vector.create(x, 0, -y)) turns a stick’s push into a direction in the world.
camera3d.pitch()
Returns: number
How far the following camera looks down, in degrees.
camera3d.set_distance(metres)
Returns: nothing
How far behind what it follows the camera stands — nearer in a corridor, further out over a gap.
particles3d — a burst of a 3D entity’s smoke or sparks
particles3d.burst(entity, count)
Returns: nothing
Throw count of an entity’s 3D particles at the next tick, on top of its stream, from wherever it is then and as its Particles3d says — a crash’s sparks, a splash. The stream itself is the component’s on and rate. An error if the entity has no Particles3d; for bursts alone give it one with on = false.
scene
scene.replace(path)
Returns: nothing
Replace the current scene with another. Queued — happens at end of pass, because replacing despawns entities while the script pass is walking them. It takes the current scene’s entities with it, INCLUDING what scripts spawned into it — you do not have to sweep your own enemies first. What survives is anything marked Persistent (Unity’s DontDestroyOnLoad, by another name), which is how a score or a carried item crosses a level change on purpose.
screen
screen.size()
Returns: {width, height}
How big the screen is this tick, in SCREEN units — the space a Text and a space: "screen" Sprite are laid out in. Under the project’s design: "height" the height is fixed and the width follows the window, so this is how a script centres a menu or spaces a row of icons across whatever screen it is on. For anything hung from an edge or a corner, a pin on the component is simpler and needs no script.
screen.safe()
Returns: {x, y, width, height}
The part of the screen that is safe to draw on, in screen units: past a phone’s notch and home indicator, and the whole screen on a desktop or in a browser. What a component’s pin is measured from.
screen.post(passes, {under = layer}?)
Returns: nothing
Passes over the whole picture — a wipe, a flash, scanlines — in place of the scene camera’s PostEffects. Each pass is a .wgsl that defines fn post(p: PostIn) -> vec4<f32>, given as its path or as {shader = "shaders/wipe.wgsl", params = {amount = 0}, textures = {…}}. under is the layer they stop below: that layer and up (a HUD) is drawn over them, sharp. Kept across scene.replace, so a wipe started in one scene covers the change; screen.post(nil) hands back to the scene’s own, and Stop ends it. docs/manual/shaders.md has what a pass can read.
screen.post_params(index, params)
Returns: nothing
Change one pass’s params — screen.post_params(1, {amount = t}) each tick to run a wipe — the rest of the chain as it is. index counts from 1. An error if no screen.post chain is set or there is no such pass.
save — a whole run
save.write(slot)
Returns: nothing
Capture the world and write it to a save slot (a string like "auto" or "best"). Queued — a save nobody took is a run that was lost.
save.read(slot)
Returns: boolean
Load a save slot, replacing the current world. Queued — happens at end of pass. True if there is a save in the slot to load, false if not, so if save.read("run") then ... else ... end is a resume.
save.exists(slot)
Returns: boolean
Whether a save slot has been written.
store — what this device keeps between runs
store.get(key, default?)
Returns: value
What this device keeps under key, or default (nil if not given) when nothing is. local best = store.get("best", 0). The store is for what outlives a RUN — a best score, a volume, “seen the tutorial” — and Stop, a new game, a rewind and a hot reload all leave it alone; a run itself is save. Works at module scope too. A table comes back as a copy: change it and store.set it to keep the change.
store.set(key, value)
Returns: nothing
Keep value under key on this device: a boolean, number, string, vector, or a table of those — a list {30, 20, 10} or a record {music = 0.5}, not both at once. nil deletes. Functions and entities are refused, since neither means anything on the next run. Written to store.ron in the game’s saves folder at the end of the pass.
store.delete(key)
Returns: nothing
Forget key. Forgetting one that is not there is not an error.
store.keys()
Returns: list of strings
Every key the store holds, sorted.
shop — in-app purchases
shop.products()
Returns: {string}
What this game sells: the identifiers in project.ron’s products: [...], spelled as App Store Connect and Play Console have them. The store is opened with them at launch, before any script runs, so a purchase a parent approves hours later still arrives. Empty for a game that sells nothing.
shop.price(product)
Returns: string | nil
The product’s price as the store formats it for this player — currency, symbol and all (“£1.99”, “1,99 €”) — or nil until the store has answered, a moment after launch. Show it as it comes; never build a price yourself. Off the phone the store is simulated and says £1.99. A product not in products: is an error.
shop.buy(product)
Returns: nothing
Put the platform’s own purchase sheet up. The answer comes through shop.events() — “owned”, “failed” or “unsold” — or nothing at all if the player cancels, which is them changing their mind, not an error to apologise for. A purchase waiting for a parent’s approval (Ask to Buy) comes back as “owned” whenever it is approved. Off the phone the store is simulated: the editor’s shop tool chooses how it answers.
shop.restore()
Returns: nothing
Ask the store for everything this player already owns: each comes back through shop.events() as “owned”, or one “nothing_to_restore” if there is none. App Review requires a Restore button. Owned products are also reported at every launch without it, so a reinstalled game unlocks by itself.
shop.events()
Returns: {table}
What happened in the store since the last pass, each once: { kind = "owned", product = id } (grant it and keep that in store — it is said again at every launch, which a game that saved it takes in its stride), { kind = "failed" }, { kind = "unsold" } (no such product on sale yet — the developer’s to fix, not the player’s to retry) or { kind = "nothing_to_restore" }. Every script on a pass sees the same list. Read it EVERY tick, on every screen, in the script that grants: an event no script read on its pass is gone.
shop.busy()
Returns: boolean
A purchase or a restore is under way — the sheet is up, or the store is thinking. A paywall shows that and does not offer a second.
shop.can_pay()
Returns: boolean
Whether this device may buy at all: false when purchases are switched off (Screen Time, a managed phone). Hide the Buy button rather than offer one that fails.
shop.real()
Returns: boolean
Whether purchases go to a real store: true on a phone, false in the editor and on a desktop, where the store is simulated.
feel — haptics on a phone
feel.play(kind, strength?)
Returns: nothing
A tap in the hand: the Taptic Engine on iOS, haptics on Android, nothing elsewhere (the editor’s phone tool lists what was played). kind is “light”, “rigid”, “soft”, “medium” (rigid at 0.7), “heavy”, “success”, “warning” or “error”; strength 0 to 1, default 1. iOS plays the impacts at that strength; success, warning and error are Apple’s own patterns, and Android has fixed patterns for all of them. The player’s own System Haptics setting is obeyed, so a game needs no switch of its own. Cheap enough for every hit.
review — the rate-this-app prompt
review.ask()
Returns: nothing
Ask for the platform’s “rate this app” prompt — after something went well. The platform decides whether it shows (iOS at most three times a year per player, Play by its own quota) and says nothing either way, so keep your own stricter rule: Warpline asks after a win, at most three times an install, ninety days apart. Does nothing off a phone (the editor’s phone tool counts the asks); no need to check available first.
review.available()
Returns: boolean
Whether this platform has a review prompt: true on iOS and Android.
games — Game Center and Play Games
games.start()
Returns: nothing
Sign in to Game Center or Play Games, once, at launch — a sign-in sheet over a results screen is the worst moment for one. Again is ignored. Silent where there is neither.
games.available()
Returns: boolean
Whether this platform has leaderboards at all: true on iOS and Android, signed in or not.
games.signed_in()
Returns: boolean
Somebody is signed in, so a score would post and the boards would open. Always false off a phone.
games.post(board, score)
Returns: nothing
One whole-number score on a board, by its key in project.ron’s games: (boards: { "best": (apple: "<Game Center id>", play: "leaderboard_best") }). Both stores keep the best they are sent. Silent when signed out or when it fails — a leaderboard is a garnish. A key project.ron does not name is an error listing those it does.
games.achieve(achievement, percent?)
Returns: nothing
An achievement, by its key in project.ron’s games: (achievements: { ... }), percent of the way there (0–100, default 100). Game Center shows progress and its own banner at 100; Play only hears 100. Silent when signed out. A key project.ron does not name is an error listing those it does.
games.show(what?)
Returns: nothing
The platform’s own screen over the game: “leaderboards” (the default), “achievements”, or one board by its key. On Android somebody signed out is asked to sign in instead.
share — the share sheet
share.text(text, url?)
Returns: nothing
The platform’s share sheet with text and an optional link — the player picks Messages, a social app, Copy. iOS and Android; off a phone the editor’s phone tool lists it. Nothing comes back: whether it was sent is the player’s business.
share.screenshot(text, url?, rect?)
Returns: nothing
The share sheet with text, a link, and a PICTURE of the screen — the next frame drawn, cut to rect = { x =, y =, w =, h = } in design pixels (the space the HUD is laid out in), or the whole frame without one: a results card with its stars is what people post. Sent the tick after the frame is drawn. Off a phone the picture is saved as shared.png beside the store and the editor’s phone tool names it. On Android the game’s manifest needs a file provider for the picture (forge’s android/README.md).
share.available()
Returns: boolean
Whether this platform has a share sheet: true on iOS and Android.
site — leaderboards and achievements on cinderfoxgames.com
site.submit(board, value)
Returns: boolean
Send a score to one of the game’s cinderfoxgames.com leaderboards (project.ron’s site: boards), by its key: a whole number from 0 to 2147483647, milliseconds for a time board. The site keeps each player’s best, so call it whenever a run ends. True if it went to the site; false, silently, anywhere there is no player to save it for — the desktop, the editor, a visitor not signed in.
site.unlock(key)
Returns: boolean
Award one of the game’s achievements (project.ron’s site: achievements), by its key, where the player earns it. Sent once a session; one already earned is harmless. False, silently, where there is no site. A new one comes back from site.earned.
site.earned()
Returns: list of strings
The keys of achievements the site has just recorded as NEW for this player, since the last call — for the game’s own “achievement unlocked” banner. Empty everywhere else.
site.available()
Returns: boolean
Whether the game is on cinderfoxgames.com with a signed-in player the site will save scores or achievements for. Never needed before submit or unlock, which are silent without one; for a title screen’s “signed in as”.
site.player()
Returns: string | nil
The signed-in player’s public display name on cinderfoxgames.com, or nil. Text, not markup; names are not unique.
debug_draw — show your working
debug_draw.line(x1, y1, x2, y2, color?)
Returns: nothing
Draw a line in WORLD space for one frame, over the game. color is {r, g, b, a} (alpha optional) and defaults to magenta, so a forgotten colour still shows. For seeing what a script thinks — a ray it just cast, the box it believes it is in — and it costs nothing when the call is not made.
debug_draw.rect(x, y, width, height, color?)
Returns: nothing
Draw a rectangle outline in world space for one frame, CENTRED on x, y and width by height across — the same numbers a Sprite of that size takes.
debug_draw.circle(x, y, radius, color?)
Returns: nothing
Draw a circle outline in world space for one frame.
debug_draw.cross(x, y, size, color?)
Returns: nothing
Draw a small X at a world point for one frame. For marking a single position — where a raycast hit, where a thing is about to spawn.
debug_draw.line3d(a, b, color?)
Returns: nothing
Draw a line in the 3D world for one frame, between two vectors — a ground ray, a line of sight. Hidden behind what is in front of it.
debug_draw.box3d(min, max, color?)
Returns: nothing
Draw a box’s edges in the 3D world for one frame, from its lowest corner to its highest — a trigger’s reach, an overlap’s box.
debug_draw.sphere3d(centre, radius, color?)
Returns: nothing
Draw a ball’s three rings in the 3D world for one frame — physics3d.overlap_sphere’s reach.
tilemap — a map’s cells by name
A map is one entity with a Tilemap, painted in the editor’s Tiles tab. Every call takes that entity first; a cell is vec(column, row) (row 0 at the top), a point is a world vector, and a tile is its tileset NAME. Asking a map is cheap; world.get(map, "Tilemap") copies the whole grid, so do not. Walking behind a tall tile: on a layer with y_sort, each tile’s depth is its foot’s world y, so a Sprite on that layer’s draw_layer whose z is its own feet’s y goes behind the tiles in front of it and in front of those behind.
tilemap.cell_at(map, point)
Returns: vector
The cell of the Tilemap on entity map a world point is in, as vec(column, row) — on a square or an isometric grid. Every tilemap call takes the map’s entity first and a cell as such a vector (or two numbers).
tilemap.centre_of(map, cell)
Returns: vector
The world point at the middle of a cell — where to put something that stands in it.
tilemap.foot_of(map, cell)
Returns: vector
Where a tile in a cell stands: the bottom middle of a square cell, the bottom point of an isometric one. A tile taller than its cell is drawn up from here (then moved by its offset), and in a y_sort layer its depth is this point’s y — so a Sprite on the layer’s draw_layer with z set to the y of its own foot goes behind the tiles in front of it: sprite.z = tilemap.foot_of(map, cell).y + 0.1 for something standing in cell.
tilemap.get(map, cell, layer?)
Returns: string | nil
The name of the tile in a cell ("lava"), or nil for an empty one. layer is a layer’s name; left out, the map’s first layer.
tilemap.tile(map, cell, layer?)
Returns: table | nil
Everything about the tile in a cell: { id, name, collision, flags, data, flip_x, flip_y, transpose }, where collision is “open”, “solid” or “one_way_top”, flags the tileset’s flag names it carries, and data its free table (tilemap.tile(map, c).data.key). Nil for an empty cell.
tilemap.set(map, cell, tile, layer?)
Returns: boolean
Paint a cell with the tile of that name, or erase it with nil: tilemap.set(map, cell, "floor"). A tile turned is { tile = "door", flip_x = true }. True if the cell changed. Colliders follow on the next tick. A coin collected is tilemap.set(map, contact.cell, nil, "things").
tilemap.fill(map, from, to, tile, layer?)
Returns: number
Paint every cell of the rectangle between two cells, corners included, with a tile (or nil to erase). How many cells changed.
tilemap.clear(map, layer?)
Returns: number
Erase every cell of a layer. How many there were.
tilemap.flags_at(map, point)
Returns: {string}
The names of every flag on the tiles at a world point, across all layers — {"hazard", "deep"}.
tilemap.has_flag(map, point, flag)
Returns: boolean
Is a tile at this world point carrying the named flag? if tilemap.has_flag(map, t.position, "hazard") then. A flag the tileset does not declare is an error, so a typo is not a silent false.
tilemap.box_has_flag(map, centre, half, flag)
Returns: boolean
Does any tile under a box — centre and half-size in world units — carry the flag? For a body wider than a point: is any of the player standing in acid.
tilemap.data_at(map, point, key)
Returns: value
One entry of the data of the tile at a world point, from the topmost layer whose tile has it — a door’s key, a conveyor’s speed. Nil if none does.
tilemap.move_box(map, centre, half, delta, options?)
Returns: { position, moved, hit_x, hit_y, cell_x?, cell_y? }
Move a box (centre and half-size, world units) by delta as far as the map lets it — x then y, stopping flush at the first blocking cell, never through one however fast. position is where its centre ends, hit_x/hit_y whether a leg was stopped and cell_x/cell_y by which cell. Solid tiles block, one-way tiles from above only; options adds { blocked_by = {"deep"}, empty_blocks = true, one_way = false }. Square grids only — an isometric map’s walls are its physics colliders.
tilemap.blocked(map, centre, half, options?)
Returns: vector | nil
The first cell under a box that would stop move_box, or nil — the same rule and the same options, asked of where a box already is: is this bullet in a wall (tilemap.blocked(map, pos, vec(0, 0)), a point is a box of half zero), would the player fit there. A one-way tile never blocks a box already in it, and a box flush against a wall is not in it, so where move_box leaves a box is never blocked. Square and isometric.
tilemap.find(map, { tile = name } or { flag = name }, layer?)
Returns: {vector}
Every cell holding that tile, or a tile with that flag, row by row from the top — every layer, or the one named. for _, c in tilemap.find(map, { flag = "gate" }) do ... end.
tilemap.bounds(map, layer?)
Returns: { min, max } | nil
The first and last cell of what is painted on a layer, both included, as vectors; nil for an empty layer.
tilemap.tiles(map)
Returns: {string}
Every tile name the map’s tileset has.
terrain — an isometric map’s ground: how high, and how to cross it
An isometric Tilemap with a terrain has height on each cell’s four corners, drawn as lifted ground with cliff faces where it drops. Every call takes the map’s entity first. A PLACE is vec(u, v) in cells, continuous (vec(3.5, 2.25) is a quarter of the way into cell 3, 2) — the space a walker or a ball moves in; terrain.project turns one into the world point it is drawn at, terrain.at a world point (a tap) into one. A direction is vec(1, 0), vec(0, 1), vec(-1, 0) or vec(0, -1). Something with an OnTerrain stands on the ground by itself.
terrain.height(map, place)
Returns: number, vector, string | nil
The ground at a place: its height in storeys, its upward normal as vec(c, r, up), and its material’s name — from the same two triangles a cell is drawn with, so what is seen is what a ball rolls on. Nil off the ground. Cheap enough to call every frame.
terrain.walk_height(map, place)
Returns: number | nil
The height a walker stands at: a deck’s (a bridge, a walkway) where an enabled one runs over the cell, the ground’s otherwise.
terrain.join(map, cell, direction)
Returns: string
How a walker crosses from cell one step toward direction: “step” (level, or a step within the project’s weld), “ramp”, “cliff”, “blocked” or “edge” (nothing there). Blocked is a cell terrain.set_blocked closed, a Solid tile on one of the map’s colliding layers, or something standing there with OnTerrain blocks on. A deck joins only along its length, and to the ground at its ends.
terrain.walkable(map, place)
Returns: boolean
Whether something can stand at a place: there is ground or an enabled deck, and nothing in the way — not a blocked cell, a Solid tile, or a thing with OnTerrain blocks on.
terrain.water(map, place)
Returns: number | nil
The level of the standing water over a place, in storeys, where a pool covers it — nil where none does. How deep it is there is this less terrain.height. Whether a walker may wade, swim or not go in at all is the game’s to say.
terrain.edge(map, cell, direction)
Returns: number, number, boolean | nil
The edge from cell to its neighbour toward direction: how far the ground falls at each end, in storeys — positive where cell stands higher, measured to 0 where nothing is in front — and whether a cliff face is drawn along it. Nil if cell has no ground.
terrain.at(map, point)
Returns: vector, number | nil
The ground under a world point — a tap, the cursor — as its place vec(u, v) and its height. A raised map hides ground behind ground, so this answers with the nearest surface the point lies on, as the eye would.
terrain.project(map, place, height?)
Returns: vector, number
Where a place is drawn, as a world point, at height storeys (the walking height if none), and the depth it sorts at among the things standing on the ground. For the ground to hide something where the ground is nearer — the terrace in front of it — give it OnTerrain, which places, sorts and hides it for you.
terrain.set_blocked(map, cell, blocked)
Returns: nothing
Close a cell to walking, or open it again — a gate, a rockfall, a pushed slab. terrain.join answers “blocked” across it. Kept while the game runs; not written to the scene.
terrain.set_deck(map, name, enabled)
Returns: nothing
Turn a named deck on or off — a bridge snapped, a bridge mended. Off, its cells are walked at the ground’s height and joined as the ground is.
Components you can put on an entity
As a scene file writes them, and as world.get and world.edit hand them over.
Transform3d
Where an entity is in 3D: its position in world units (metres), its turn and its scale. +Y is up. Under a parent it is an OFFSET from the parent.
| field | meaning |
|---|---|
position |
[x, y, z] in metres; +Y is up |
rotation |
a quaternion [x, y, z, w]; the Inspector shows it as angles in degrees |
scale |
[x, y, z] multipliers on the size |
MeshRenderer
What a 3D entity looks like: a primitive or a model’s file, at a size, in a colour.
| field | meaning |
|---|---|
mesh |
“cube”, “sphere”, “plane”, “capsule” (each fills a 1-unit box), or a model’s path — a .glb or .bbmodel |
size |
[x, y, z] the drawn size in metres; a primitive is stretched to it |
color |
[r, g, b, a] 0…1 in LINEAR light, multiplies the model’s own colours |
emissive |
[r, g, b] light it gives off itself; above 1 glows |
metallic |
0…1, how metal it is |
roughness |
0…1, how rough; 0 is a mirror shine. None keeps each of a model’s materials its own (a primitive is 0.6) |
texture |
a picture’s path wrapped over it, or None |
Collider3d
Makes a 3D entity solid: a box, a ball, a capsule or its model’s own shape, fixed, moved by physics, or moved by its script.
| field | meaning |
|---|---|
half |
a box’s half size [x, y, z] — from the middle to each face — or None |
radius |
a ball’s radius, or None; give half or radius, not both |
height |
with radius, a capsule this tall end to end, standing along Y — a character’s shape; or None |
mesh |
true: solid as its MeshRenderer’s model is drawn — ground made in Blender, a hill or a curved path; fixed or kinematic, never dynamic |
body |
“fixed” (never moves), “dynamic” (physics moves it) or “kinematic” (its script does) |
sensor |
true: things pass through it and are told so |
restitution |
0…1, how bouncy |
friction |
how much it grips; 0 is ice |
density |
how heavy it is for its size |
lock_rotation |
true: physics never turns it — a character that must stay upright |
layer |
a collision layer’s name, or None |
collides_with |
the layers it touches, or None for all |
Velocity3d
How fast a 3D entity moves and turns, applied every tick.
| field | meaning |
|---|---|
linear |
[x, y, z] metres a second |
angular |
[x, y, z] radians a second round each axis |
Camera3d
Where a 3D scene is seen from: the entity’s place and turn, looking down its own -Z. The lowest active one wins.
| field | meaning |
|---|---|
fov |
the vertical field of view in degrees |
near |
the nearest that is drawn, in metres; not 0 |
far |
the furthest that is drawn, in metres |
ortho |
above 0: orthographic, showing this many metres above and below the middle |
active |
whether the scene is looked through this camera |
follow |
an entity’s name (or uid) to follow from behind and above; empty stays put |
distance |
how far behind what it follows, in metres |
height |
how high above the followed entity’s feet it looks, in metres |
yaw |
which way round what it follows it stands, in degrees; 0 is behind, looking along -Z |
pitch |
how far it looks down, in degrees, between -30 and 80 |
damping |
how quickly it catches up; higher is tighter, 0 never moves |
avoid_walls |
true: pull in before a wall rather than look at the back of it |
Lighting3d
The light a 3D scene sits in, on its camera: the ambient, the sky, and how far the sun’s shadows reach.
| field | meaning |
|---|---|
ambient_sky |
[r, g, b] the light surfaces facing up catch |
ambient_ground |
[r, g, b] the light surfaces facing down catch |
sky |
true: a sky gradient behind everything |
sky_top |
[r, g, b] the sky straight up |
sky_horizon |
[r, g, b] the sky at the horizon |
sky_below |
[r, g, b] the sky below the horizon |
shadow_range |
metres round the view the sun’s shadows reach; smaller is sharper |
soft_shadows |
true: soft edges; false is cheaper, for phones |
fog_color |
[r, g, b] what the distance fades into; None is the sky’s horizon colour |
fog_near |
metres from the eye where the fog starts; None is half the camera’s far |
fog_far |
metres where it is whole and the world has faded out; None is the camera’s far |
Light3d
A sun, a lamp or a spotlight. A sun and a spotlight shine down the entity’s own -Z, so they are aimed by turning them.
| field | meaning |
|---|---|
kind |
“sun”, “point” or “spot”; one sun to a scene |
color |
[r, g, b] 0…1 in linear light |
intensity |
how bright; 1 is a plain lamp |
range |
how far a lamp or spotlight reaches, in metres |
cone |
a spotlight’s half-width in degrees |
shadows |
whether a sun casts shadows |
enabled |
off without being deleted |
Particles3d
Smoke, spray, sand or sparks from where a 3D entity is: a stream while on, and bursts a script throws with particles3d.burst(entity, count).
| field | meaning |
|---|---|
shape |
“puff” soft lit smoke, “spark” an added glow, “chunk” a wire cube of light, “block” a lit solid cube |
on |
throwing a stream, rate a second |
rate |
how many a second while on |
color |
[r, g, b, a] a puff’s or block’s surface (a spark’s glow; above 1 blooms); a is how thick a fresh puff is |
size |
[smallest, largest] half-widths in metres at birth; a puff grows as it goes |
life |
[shortest, longest] seconds each lives |
speed |
[slowest, fastest] metres a second outward |
lift |
metres a second thrown upward at birth, at most |
rise |
metres a second squared upward: smoke rises; spray and sand fall (negative; -26 falls like a stone) |
spread |
metres round the entity they are born in |
drag |
speed lost a second, as a fraction |
push |
[x, y, z] metres a second every piece is given on top: a car’s speed, or a wind |
floor |
a height they stop at and skid along; None falls for ever |
most |
how many can be alive at once; a burst past it overwrites the oldest |
Transform
Where an entity is in 2D: its position in world units (screen pixels when the camera is at the origin), rotation and scale. Under a parent it is an OFFSET from the parent.
| field | meaning |
|---|---|
position |
[x, y] in world units; y grows downward |
rotation |
radians, clockwise |
scale |
[x, y] multipliers on the drawn size |
origin |
the pivot in world units from the top-left; [0, 0] means the centre |
Sprite
A textured or coloured rectangle, centred on the Transform. Sprites and Text share layers: higher layers draw in front.
| field | meaning |
|---|---|
width |
drawn width in world units |
height |
drawn height in world units |
color |
[r, g, b, a] 0…1, multiplies the texture; alpha below 1 is translucent |
uv_rect |
[u0, v0, u1, v1], the part of the texture drawn; [0,0,1,1] is all of it |
slice |
nine-slice insets [left, top, right, bottom] in the picture’s own pixels (an SVG’s own units), inside uv_rect: the corners keep their pixel size and the edges and middle fill the rest of width x height, so a panel resizes without smearing its border. A size smaller than the corners shrinks them. [0, 0, 0, 0] (the default) is no slicing |
slice_fill |
how a sliced sprite fills between its corners: “stretch” (the default), “tile” (edges and middle repeat at their pixel size from the top-left, the last tile cut) or “tile_edges” (edges repeat, the middle stretches) |
slice_scale |
the picture’s pixels to a unit for a sliced sprite’s corners and tiles: 3 for art drawn at 3x detail, whose slice is then in its own pixels and draws the size the 1x art did, sharper. 1 is the default; an SVG’s slice is in its own units already |
layer |
draw order: lower first, so higher is in front |
z |
order within a layer, lower first. Tiles share it: a flat Tilemap layer is behind every sprite on its draw_layer; on a y_sort layer each tile’s z is the y of where it stands (tilemap.foot_of), so a sprite whose z is its own foot’s y goes behind the tiles in front of it |
flip_x |
mirror the picture left-to-right, for facing the other way |
flip_y |
mirror the picture top-to-bottom |
texture_name |
the picture, a project path: “art/ship.svg” or a .png. Some(“art/ship.svg”) always reads, and is what a save writes; a bare “art/ship.svg” is read too, as a hand would write it. Absent draws a plain coloured rectangle |
space |
“world” (moves and zooms with the camera) or “screen” (HUD art: the camera leaves it alone, and its position is in screen units) |
pin |
screen space only: “none”, or the point of the screen it hangs from and the corner of the sprite that sits there — “top_right” with position (10, 10) puts its top-right corner 10 in from the screen’s, on any screen width. The nine anchor words |
lit |
whether the dark falls on it: the camera’s Lighting2d ambient multiplies it. false for things that glow (a fire, a lit window). A screen sprite is never lit |
light_reach |
how much a Light2d adds to it, 0…1 (default 1). 0 for a far parallax strip a torch should not light; it still goes dark with the ambient |
blend |
how it lands on what is under it: “alpha” (default), “add” (light, fire), “screen” (a glow that rolls off), “multiply” (a tinted shadow) |
shader |
a .wgsl file it is drawn with, a project path (“shaders/shine.wgsl”), bare or as Some(…); None is the plain picture. The file defines fn fragment(in: Fragment) -> vec4<f32>; docs/manual/shaders.md has every name it can read. A shader that will not compile draws the plain picture and script_trouble says why |
shader_params |
the shader’s params by the names its struct Params gives them: { “phase”: 0.3, “tint”: [1.0, 0.9, 0.6, 1.0] }. Left out is the shader’s DEFAULTS |
shader_textures |
the shader’s extra textures by the names it declares them under (var noise: texture_2d<f32>;): { “noise”: “art/noise.png” } |
Button
Makes an entity pressable by the pointer or a finger, where its Sprite is drawn. Its scripts hear on_click, on_pointer_down/up and on_pointer_enter/exit.
| field | meaning |
|---|---|
size |
Some([w, h]): a pressable area other than the sprite’s; None is the sprite |
enabled |
false: drawn and not pressable |
TextField
A line the player types into. Pressed to focus, so it needs a Button; shown in its Text. Scripts hear on_change(self, text) and on_submit(self, text).
| field | meaning |
|---|---|
text |
what has been typed |
placeholder |
shown while empty and not focused |
max |
Some(n): the most characters it takes; None for no limit |
focused |
whether typing goes here; Enter, Escape or a press elsewhere lets go |
Text
Words drawn with the built-in font. Position is the Transform; it shares layers with sprites.
| field | meaning |
|---|---|
content |
what it says; a script sets it with t.content = "SCORE " … n |
size |
cap height: screen pixels in screen space, world units in world space |
color |
[r, g, b, a] 0…1 |
space |
“screen” (a HUD, unmoved by the camera) or “world” (moves and zooms with it) |
layer |
draws over sprites on this layer and below, under higher layers |
anchor |
which part of the line the position names: “top_left”, “top_center”, “top_right”, “middle_left”, “middle_center”, “middle_right”, “bottom_left”, “bottom_center”, “bottom_right” |
pin |
screen space only: “none”, or the point of the screen the label hangs from — “top_right” with position (20, 10) ends the line 20 in from the right edge and 10 down, on any screen width (design “height” makes the width follow the screen). When set it is the pivot too and anchor is not consulted. The nine anchor words |
lit |
whether the camera’s Lighting2d ambient darkens it (world space only; a 2D light does not reach words) |
Animator
Plays a clip from a clips/*.ron file (make_sheet writes one) on this entity’s Sprite. Needs a Sprite.
| field | meaning |
|---|---|
playing |
the clip’s name, e.g. “walk”; a script changes it to switch animation |
running |
false pauses on the current frame |
flip_x |
mirror the frames left-to-right, for facing the other way |
elapsed |
internal clock — leave it |
frame |
internal — the frame shown now |
Animator3d
Plays a 3D model’s own clips — the actions exported with it from Blender. Beside a MeshRenderer whose model has clips; a script switches them with world.edit(e, “Animator3d”).clip = “run”.
| field | meaning |
|---|---|
clip |
the clip’s name in the model’s file, e.g. “run”; empty is the model at rest |
speed |
1 is as made; 2 twice as fast |
looping |
false plays it once, holds the last pose and calls on_animation_finished |
fade |
seconds to blend into a new clip; 0 cuts straight to it |
time |
seconds into the clip; 0 with running true plays a one-shot again |
running |
false holds the pose where it is |
playing |
internal — the clip time belongs to |
from |
internal — the clip being blended out of |
from_time |
internal — how far into it |
fading |
internal — seconds into the blend |
ended |
internal — a one-shot ended and the scripts have not heard yet |
Tilemap
A grid of tiles from a tilesets/*.ron file, one entity for the whole map. Its Transform’s position is where cell (0, 0) is: its top-left corner on a square grid, its top point on an isometric one.
| field | meaning |
|---|---|
tileset |
the tileset file, e.g. “tilesets/station.ron” |
grid |
“square” or “isometric” |
cell |
[w, h] of one cell in world units: a square’s sides, or a diamond’s width and height |
collision |
(layer, collides_with, one_way_layer, bodies): the physics layers solid and one-way tiles are on, as Collider’s words; bodies: false makes no colliders |
key |
character -> (tile: id, flip_x, flip_y, transpose): what each character in the rows stands for; tile is the tileset’s id |
layers |
[(name, at: [col, row] of the first character, rows: [“####”, “#…#”], draw_layer, y_sort, tint, lit, light_reach, collision, visible)]; a space is an empty cell. lit: false keeps a layer out of the dark (Lighting2d) — lava, lit windows; light_reach (0…1) is how much a Light2d adds, as Sprite’s. A tile is drawn one cell wide and as tall as its picture’s shape makes it, standing on its cell’s foot — the bottom middle of a square, the bottom point of a diamond (tilemap.foot_of) — then moved by its offset. y_sort is OFF unless set: the layer is ground, every tile behind every sprite on its draw_layer, tall ones in their cells’ order. ON, each tile’s depth is its foot’s y (its offset does not change it), so walls and blocks a sprite goes behind belong in a y_sort layer; a tile its tileset marks lying (a bridge’s deck) sorts at its cell’s back instead, under whatever stands in its cell. set_tile_layer changes one layer’s settings; paint_tiles its cells |
stands_on |
the NAME of the terrain map a flat isometric map’s objects stand on (left out: none): its y_sort tiles are hidden where that ground is nearer than their feet — behind its cliffs — and not lifted, since their offsets already place them. For objects baked flat over real ground; a map with terrain of its own stands on that |
OnTerrain
Stands on the ground of a terrain map: each frame the Transform is put where at is drawn and the Sprite on the terrain’s layer at that place’s depth, so it goes behind the ground in front of it. It stands on its FEET: a Sprite drawn centred (no Transform origin) is raised half its height so its bottom edge is on the ground; with an origin (its feet, say) that point is put there instead. A script moves it by writing at.
| field | meaning |
|---|---|
map |
the NAME of the entity with the terrain Tilemap |
at |
[u, v]: where on the ground, in cells, continuous — [3.5, 2.25] is a quarter into cell (3, 2) |
lift |
storeys above the walking height (a deck’s, where one runs) |
blocks |
true: nothing walks into its cell — terrain.join answers “blocked” there (a boulder, a guard) |
lying |
true: it lies flat on the ground — a shadow, a rug — centred where it is and drawn under anything standing there |
Camera
The view. Put one on an entity: its Transform is the CENTRE of the view. With none, the view’s top-left is the world origin.
In scene files and the Inspector only, for now: a script cannot world.get or world.edit it.
| field | meaning |
|---|---|
zoom |
1.0 is one texel to one pixel; 2.0 shows half as much world |
follow |
the NAME of an entity to keep in view; empty looks at the camera’s own Transform |
deadzone |
[half_w, half_h] box the followed entity may move in without moving the camera |
damping |
how fast it catches up; higher is snappier, 0 never moves |
bounds |
Some([min_x, min_y, max_x, max_y]) the view must stay inside, or None |
active |
whether this is the camera the game looks through |
clear |
Some([r, g, b, a]): the colour behind everything while this camera is active; None leaves the default |
PostEffects
Passes over the whole picture — a vignette, scanlines, a colour grade. Put it on the Camera entity. Each pass is a .wgsl that defines fn post(p: PostIn) -> vec4<f32>, reading the picture so far with screen_at(p.uv); save_shader writes one. A script’s screen.post stands in for these (a wipe across a scene change).
| field | meaning |
|---|---|
passes |
in order, each (shader: “shaders/vignette.wgsl”, params: {“strength”: 0.6}, textures: {“noise”: “art/noise.png”}) — params and textures by the names the shader gives them, left out for its DEFAULTS |
under |
Some(layer): that layer and up (the HUD) is drawn over the passes, untouched; None runs them over everything |
Lighting2d
The dark the 2D world is seen in. Put it on the Camera entity: its ambient multiplies every lit world draw — sprites, map layers, particles, world labels — and leaves the HUD (screen space) and anything lit: false alone. Day into night is one write: world.edit(camera, “Lighting2d”).ambient = {0.25, 0.3, 0.55}.
| field | meaning |
|---|---|
ambient |
[r, g, b]: white is daylight (no change), a dark blue is night, near black is a cave. In linear light, so it looks softer than its numbers: (0.36, 0.45, 0.75) leaves about (0.6, 0.7, 0.87) of a pixel’s brightness as you see it |
resolution |
how fine the light map is against the view: 0.5 (the default) is half as many pixels each way; lower is cheaper, and light is smooth enough not to show it |
Light2d
A light: adds color x intensity to every lit draw within radius of this entity, fading to the edge. Lights are where they are on screen, so what one reaches is each draw’s light_reach (a far parallax strip is 0). Parented, it moves with its parent; it scales with it and does not turn.
| field | meaning |
|---|---|
color |
[r, g, b] |
intensity |
multiplies the colour; above 1 overpowers the ambient where it is strong |
radius |
[rx, ry] in world units: an ellipse — an isometric lamp is about twice as wide as tall |
softness |
how the edge fades: 1 from the very middle, near 0 a hard disc |
enabled |
off is a lamp that is out |
Collider
A physics shape. Contacts call on_contact_began/ended in scripts; world.set_velocity moves a dynamic one. Every field can be changed while the game runs; changing body or sensor rebuilds the body at rest.
| field | meaning |
|---|---|
half |
Some([half_w, half_h]) for a box |
radius |
Some® for a circle, instead of half |
body |
“fixed” (walls), “dynamic” (moved by physics) or “kinematic” (moved by you) |
sensor |
true: reports contacts and blocks nothing |
restitution |
bounciness, 0…1 |
friction |
0 is ice |
density |
mass per area, for dynamic bodies |
lock_rotation |
true keeps a dynamic body upright |
damping |
how fast it slows by itself, per second; 0 never does |
angular_damping |
the same for spin |
layer |
Some(“name”): this shape’s collision layer |
collides_with |
Some([“layer”, …]): the layers it meets; None meets all |
Velocity
A constant drift, in world units per second, for an entity physics does not move.
| field | meaning |
|---|---|
x |
units per second rightward |
y |
units per second downward |
ParticleEmitter
Sparks, smoke, debris: particles born at the Transform. A burst is emitting = true with mode “burst”.
| field | meaning |
|---|---|
mode |
“continuous” (rate per second) or “burst” (count at once) |
emitting |
on or off; a burst fires when this turns on |
rate |
particles per second, continuous |
count |
particles per burst |
lifetime |
seconds each lives |
lifetime_spread |
random ± seconds on each particle’s life, so a burst thins out instead of vanishing at once; 0 is every particle living exactly lifetime |
speed |
units per second at birth |
speed_spread |
random ± speed, in the same units per second as speed |
direction |
degrees the particles head: 0 is right, 90 down |
spread |
degrees either side of direction |
gravity |
units per second², downward |
drag |
how fast a particle slows by itself, per second: velocity × e^(-drag·dt) each tick, so a burst shoots out then billows (4 keeps ~2% of its speed after a second); 0 never slows |
size |
size at birth, in world units (the quad’s side) |
size_spread |
random ± on each particle’s size, in size’s units; end_size is scaled by the same factor so each particle keeps its proportions. 0 is all one size |
end_size |
size at death |
color |
[r, g, b, a] at birth; with a texture it multiplies the picture, as a Sprite’s does |
end_color |
[r, g, b, a] at death; alpha 0 fades out |
layer |
draw order, as Sprite’s |
lit |
whether the dark (Lighting2d) falls on the particles, as Sprite’s; false for sparks and embers |
light_reach |
how much a Light2d adds to the particles, 0…1, as Sprite’s |
texture_name |
the picture each particle is, a project path: “art/fx/puff.svg” or a .png, bare or as Some(…), as Sprite’s. None draws flat coloured squares |
frames |
the picture is a horizontal strip of this many equal frames; each particle picks one at random at birth and keeps it (variety, not animation). 1 is the whole picture. A frame is drawn square, size by size |
spin |
each particle turns at a random rate within ± this many degrees per second, from a random start angle; 0 never turns |
mirror |
true flips each particle at random left-right and/or top-bottom at birth — variety for pixel art, which rotation smears |
blend |
“alpha” (default), “add” for fire and sparks, “screen”, “multiply” — as Sprite’s |
shader |
a .wgsl file every particle is drawn with, as Sprite’s; in.local runs across one particle |
shader_params |
the shader’s params by name, as Sprite’s |
shader_textures |
the shader’s extra textures by name, as Sprite’s |