Wander builtins¶
Every function a Wander script can call lives in one registry: name, typed parameters, return type, category, documentation and an example. The compiler checks calls against it (arity, types, did-you-mean), and this page is generated from it. 177 builtins in 24 categories.
Agents get the same information from wander_reference (the guide) and wander_reference {topic} (structured entries for a category or a function). For the language itself, read the Wander manual.
Subsystem triggers¶
Besides the core triggers (on start, on tick, on event, on key, on click, on frame, and on enter / on exit inside states), subsystems register these:
| Trigger | Fires when |
|---|---|
on action |
An input action was pressed: on action "jump" (actions come from input.json). |
on collide |
Two bodies touched: on collide ("name or tag")? — other, contact_point, contact_normal, impact. |
on collide_end |
Two 2D bodies stopped touching: on collide_end — other. data: {} |
on dialogue |
on dialogue "start" \| "line" \| "choice" \| "end" \| "<command>": conversation events and <<command>>s of .dialogue scripts (event "dialogue:..."). |
on impact |
A 2D body hit this one faster than physics2d_world.impactSpeed: on impact — other, data. data: |
on loaded |
A save was loaded (load_game or the load_game tool): on loaded — data.slot, data.version, data.meta. Refresh what is derived from saved state (HUD, music). data: |
on pause |
The game was paused (pause_game): delivered to every behavior, also those the pause stops. |
on resume |
The game resumed (resume_game). |
on saved |
A save_game() finished: on saved — data.slot, data.meta. data: |
on scene_loaded |
A scene finished loading: on scene_loaded — data.id (alias or path, or a sub-scene's handle), data.path, data.additive. data: |
on scene_unloading |
A scene is about to go: on scene_unloading — data.id, data.to (the next scene), data.additive. Delivered the tick before the change, to the leaving scene too. data: |
on trigger_enter |
Something entered this trigger collider: on trigger_enter ("name or tag")? — other. |
on trigger_exit |
Something left this trigger collider: on trigger_exit ("name or tag")? — other. |
on ui |
on ui "Name": the button/toggle/slider/input named Name was used (event "ui:Name"). |
2d¶
play_anim¶
Plays a sprite_anim clip (keeps playing if it already is, unless restart). Frame events arrive as on anim "name"; a non-looping clip sends on anim "finished".
| Parameter | Type | |
|---|---|---|
entity |
entity | |
clip |
string | |
restart |
bool | optional |
Returns: none
set_tile¶
Sets the tile at a world position: an id (0 clears) or a terrain from tilemap.autotile (auto-tiled).
| Parameter | Type | |
|---|---|---|
map |
entity | |
position |
vector|entity | |
tile |
number|string | |
layer |
string | optional |
Returns: none
tile_at¶
Tile id of a tilemap at a world position (topmost non-empty layer, or the named layer); 0 = empty.
| Parameter | Type | |
|---|---|---|
map |
entity | |
position |
vector|entity | |
layer |
string | optional |
Returns: number
animation¶
anim_state¶
Name of the animator's current state.
| Parameter | Type | |
|---|---|---|
entity |
entity |
Returns: string
foot_ik¶
Turns automatic foot planting on or off (feet on stairs, slopes and rocks, pelvis lowered, feet locked while planted); the optional weight fades it (0..1). Adds the characterIk component if needed.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
on |
bool | |
weight |
number | optional |
Returns: none
hand_ik¶
Makes a character's hand reach an entity ("left" or "right"): a grip point on a staff held in the other hand, a ledge, a rail, a door handle. none (or weight 0) releases it. Adds the characterIk component if needed.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
side |
string | |
target |
none|entity | |
weight |
number | optional |
Returns: none
look_at¶
Turns a character's head and upper spine toward an entity (look-at IK, clamped by animator.lookAtLimit), or stops with none; the turn fades in and out smoothly.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
target |
none|entity | |
weight |
number | optional |
Returns: none
play_animation¶
Crossfades straight to a clip or state (seconds of fade, default 0.2).
| Parameter | Type | |
|---|---|---|
entity |
entity | |
clip |
string | |
fade |
number | optional |
loop |
bool | optional |
Returns: none
play_sequence¶
Plays the entity's sequencer (a cutscene) from start seconds.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
start |
number | optional |
Returns: none
set_param¶
Sets an animator controller parameter (blend spaces and transitions read them).
| Parameter | Type | |
|---|---|---|
entity |
entity | |
name |
string | |
value |
bool|number |
Returns: none
trigger¶
Fires an animator trigger (jump, attack, wave).
| Parameter | Type | |
|---|---|---|
entity |
entity | |
name |
string |
Returns: none
turn_in_place¶
Turns a standing character in place toward a world yaw (degrees, 0 = -Z) or to face a point / entity, at characterIk.turnSpeed; planted feet stay locked and re-plant in small steps. Controllers can read the float turn (degrees left) and bool turning parameters to play turn clips.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
toward |
number|vector|entity |
Returns: none
audio¶
music¶
Crossfades the music to a clip ("" fades out); fade in seconds.
| Parameter | Type | |
|---|---|---|
clip |
string | |
fade |
number | optional |
Returns: none
play¶
Starts the entity's audio component (its clip, volume, spatial settings).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: none
play_sound¶
Plays a one-shot sound at self (positional), e.g. a hit or a pickup.
| Parameter | Type | |
|---|---|---|
clip |
string | |
volume |
number | optional |
Returns: none
set_volume¶
Sets a mixer bus volume (master, music, sfx, ambience, voice, ui), 0..1.
| Parameter | Type | |
|---|---|---|
bus |
string | |
volume |
number |
Returns: none
stop_sound¶
Stops the entity's audio component.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: none
character¶
grounded¶
Whether a character stands on the ground.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: bool
jump¶
Makes a grounded character jump (default: its jumpSpeed); false when airborne.
| Parameter | Type | |
|---|---|---|
e |
entity | |
speed |
number | optional |
Returns: bool
walk¶
Moves a character this tick (|direction| 1 = its moveSpeed). Call every tick while walking.
| Parameter | Type | |
|---|---|---|
e |
entity | |
direction |
vector |
Returns: none
character2d¶
drop_through2d¶
Drops a character2d through the one-way platform it stands on; false when it stands on solid ground.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: bool
grounded2d¶
Whether a character2d stands on walkable ground (a slope up to maxSlope or a platform).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: bool
jump2d¶
Makes a character2d jump (default: its jumpSpeed). True when it jumps now (grounded or within coyote time); otherwise the press is buffered and the jump happens on landing within jumpBuffer seconds.
| Parameter | Type | |
|---|---|---|
e |
entity | |
speed |
number | optional |
Returns: bool
move2d¶
Runs a character2d this tick: -1 = full speed left, 1 = right (scaled by moveSpeed, with acceleration). Call every tick.
| Parameter | Type | |
|---|---|---|
e |
entity | |
x |
number |
Returns: none
color¶
color¶
Makes a color from 0..1 channels.
| Parameter | Type | |
|---|---|---|
r |
number | |
g |
number | |
b |
number | |
a |
number | optional |
Returns: color
hsv¶
Color from hue (0..1, wraps), saturation and value.
| Parameter | Type | |
|---|---|---|
h |
number | |
s |
number | |
v |
number |
Returns: color
dialogue¶
dialogue_advance¶
Shows the rest of the typing line, or moves to the next line.
Returns: none
dialogue_choose¶
Picks one of the current dialogue choices (0-based).
| Parameter | Type | |
|---|---|---|
index |
number |
Returns: none
dialogue_var¶
Reads (or with a value, sets) a dialogue variable ($trust = "trust") of the first dialogue component.
| Parameter | Type | |
|---|---|---|
name |
string | |
value |
any | optional |
Returns: any
start_dialogue¶
Starts a conversation at a node: start_dialogue("Intro") on the first dialogue component, or start_dialogue(entity, "Intro").
| Parameter | Type | |
|---|---|---|
entity_or_node |
entity|string | |
node |
string | optional |
Returns: none
effects¶
burst¶
Emits particles right now from self's particles (or particles2d) component: burst(n), or burst(entity, n) for another emitter. Explosions, muzzle flashes, impacts, dust puffs.
| Parameter | Type | |
|---|---|---|
entity_or_count |
number|entity | |
count |
number | optional |
Returns: none
camera_shake¶
Shakes the 2D camera: adds trauma (0..1; 0.2 a hit, 0.5 a heavy slam, 1 an explosion) to the camera2d (the active camera, or the given one). The offset grows with trauma squared (camera2d.shakeAmplitude world units at 1) and decays by shakeDecay per second. Runs through hit-stops; replays identically.
| Parameter | Type | |
|---|---|---|
trauma |
number | |
camera |
entity | optional |
Returns: none
flash¶
Flashes a sprite: it turns color (default white; its alpha is the strength) and fades back over seconds (default 0.12). Damage feedback, parries, pickups. For a constant tint set sprite.flash.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
seconds |
number | optional |
color |
color | optional |
Returns: none
hit_stop¶
Freeze frames on impact: the game clock stops (or runs at scale, 0..1) for seconds of real time, then resumes at the time scale. 0.04-0.12 s sells a hit; a longer, stronger stop extends the current one. UI, camera_shake and entities on the real clock keep moving. Per entity: set process.timeScale instead.
| Parameter | Type | |
|---|---|---|
seconds |
number | |
scale |
number | optional |
Returns: none
hit_stop_left¶
Real seconds of hit-stop left (0 when the game clock runs normally).
Returns: number
water_height¶
Height of the animated water surface at (x, z) or at a point — the same surface that is rendered (0 where there is no water). Boats, buoyancy, splashes.
| Parameter | Type | |
|---|---|---|
x_or_point |
number|vector|entity | |
z |
number | optional |
Returns: number
input¶
action¶
Whether an input action is held ("jump", "fire" from input.json).
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: bool
axis¶
Value of an axis action: a number (-1..1), or a vector (x, y, 0) for 2D axes (x right, y forward/up).
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: number|vector
cursor_lock¶
Hides and captures the mouse cursor (first-person look: read mouse movement with axis("look")) or gives it back. Honored by the standalone player; resets when the game stops.
| Parameter | Type | |
|---|---|---|
on |
bool |
Returns: none
key¶
Whether a key is held ("w", "space", "left", ...).
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: bool
key_pressed¶
Whether a key was pressed this tick (once per press).
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: bool
pressed¶
Whether an input action was pressed this tick.
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: bool
quit_game¶
Closes the game (a "Quit" menu button). The standalone player exits; the editor ignores it.
Returns: none
released¶
Whether an input action was released this tick.
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: bool
list¶
clear¶
Removes everything.
Returns: none
contains¶
Lists: has an equal item. Maps: has the key. Strings: has the substring. (Same as x in y.)
| Parameter | Type | |
|---|---|---|
item |
any |
Returns: bool
first¶
The first item (none if empty).
Returns: any
index_of¶
Position of the first equal item/substring, or -1.
| Parameter | Type | |
|---|---|---|
item |
any |
Returns: number
insert¶
Inserts an item before index (index = length appends).
| Parameter | Type | |
|---|---|---|
index |
number | |
item |
any |
Returns: none
is_empty¶
Whether it has no items / keys / characters.
Returns: bool
join¶
Text of all items joined by a separator.
| Parameter | Type | |
|---|---|---|
separator |
string | optional |
Returns: string
last¶
The last item (none if empty).
Returns: any
pop¶
Removes and returns the last item.
Returns: any
push¶
Appends an item.
| Parameter | Type | |
|---|---|---|
item |
any |
Returns: none
remove¶
Lists: removes the first item equal to the argument. Maps: removes a key. Returns whether something was removed.
| Parameter | Type | |
|---|---|---|
item_or_key |
any |
Returns: bool
remove_at¶
Removes and returns the item at index.
| Parameter | Type | |
|---|---|---|
index |
number |
Returns: any
reverse¶
Reverses the list in place.
Returns: none
slice¶
Items (or characters) from index from up to, not including, to. Negative indexes count from the end.
| Parameter | Type | |
|---|---|---|
from |
number | |
to |
number | optional |
Returns: string|list
sort¶
Sorts numbers or strings in place (ascending).
Returns: none
sorted¶
A sorted copy (numbers or strings).
Returns: list
sum¶
Sum of a list of numbers.
Returns: number
locale¶
locale¶
The current locale code ("en", "fr", "pt-BR").
Returns: string
locales¶
Locale codes the game has strings for (with the source language), sorted: for a language menu.
Returns: list
set_locale¶
Switches the game's language from the next frame (a language menu): "fr", "pt-BR". Texts written as "@key" and #line dialogue lines follow at once. Undone when play stops; save it with game_var to keep it.
| Parameter | Type | |
|---|---|---|
code |
string |
Returns: none
tr¶
The localized string for a key in the current locale (locale/.csv or .po), falling back pt-BR -> pt -> the source language. args fill {placeholders}, plurals ({n, plural, one {# coin} other {# coins}}) and selects; numbers are formatted for the locale. A missing key returns the key and is reported by locale_check.
| Parameter | Type | |
|---|---|---|
key |
string | |
args |
map | optional |
Returns: string
map¶
get¶
Value for a key, or the default (none) if missing.
| Parameter | Type | |
|---|---|---|
key |
string | |
default |
any | optional |
Returns: any
has¶
Whether the map has a key.
| Parameter | Type | |
|---|---|---|
key |
string |
Returns: bool
keys¶
The keys, in insertion order.
Returns: list
set¶
Sets a key (same as m[key] = value).
| Parameter | Type | |
|---|---|---|
key |
string | |
value |
any |
Returns: none
values¶
The values, in insertion order.
Returns: list
math¶
abs¶
Absolute value.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
acos¶
Arc cosine in radians (x is clamped to -1..1).
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
approach¶
Moves current toward target by at most max_step (never overshoots).
| Parameter | Type | |
|---|---|---|
current |
number | |
target |
number | |
max_step |
number |
Returns: number
asin¶
Arc sine in radians (x is clamped to -1..1).
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
atan¶
Arc tangent in radians.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
atan2¶
Angle of the point (x, y) in radians, -pi..pi.
| Parameter | Type | |
|---|---|---|
y |
number | |
x |
number |
Returns: number
ceil¶
Smallest whole number >= x.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
clamp¶
x limited to the range lo..hi.
| Parameter | Type | |
|---|---|---|
x |
number | |
lo |
number | |
hi |
number |
Returns: number
cos¶
Cosine of an angle in radians.
| Parameter | Type | |
|---|---|---|
radians |
number |
Returns: number
deg¶
Radians to degrees.
| Parameter | Type | |
|---|---|---|
radians |
number |
Returns: number
exp¶
e raised to x.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
floor¶
Largest whole number <= x.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
inverse_lerp¶
Where x lies between a (0) and b (1).
| Parameter | Type | |
|---|---|---|
a |
number | |
b |
number | |
x |
number |
Returns: number
lerp¶
Linear blend from a (t=0) to b (t=1); numbers, vectors or colors.
| Parameter | Type | |
|---|---|---|
a |
number|vector|color | |
b |
number|vector|color | |
t |
number |
Returns: number|vector|color
ln¶
Natural logarithm (x > 0).
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
max¶
Larger of numbers, or the largest number in a list.
| Parameter | Type | |
|---|---|---|
a |
number|list | |
b |
number | optional |
Returns: number
min¶
Smaller of numbers, or the smallest number in a list.
| Parameter | Type | |
|---|---|---|
a |
number|list | |
b |
number | optional |
Returns: number
noise¶
Smooth deterministic value noise in -1..1 (1D or 2D).
| Parameter | Type | |
|---|---|---|
x |
number | |
y |
number | optional |
Returns: number
pow¶
base raised to exponent.
| Parameter | Type | |
|---|---|---|
base |
number | |
exponent |
number |
Returns: number
rad¶
Degrees to radians.
| Parameter | Type | |
|---|---|---|
degrees |
number |
Returns: number
round¶
Rounds to the nearest whole number, or to digits decimals.
| Parameter | Type | |
|---|---|---|
x |
number | |
digits |
number | optional |
Returns: number
sign¶
-1, 0 or 1.
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
sin¶
Sine of an angle in radians.
| Parameter | Type | |
|---|---|---|
radians |
number |
Returns: number
smoothstep¶
Smooth 0..1 ramp between two edges.
| Parameter | Type | |
|---|---|---|
edge0 |
number | |
edge1 |
number | |
x |
number |
Returns: number
sqrt¶
Square root (0 for negative input).
| Parameter | Type | |
|---|---|---|
x |
number |
Returns: number
tan¶
Tangent of an angle in radians.
| Parameter | Type | |
|---|---|---|
radians |
number |
Returns: number
navigation¶
arrived¶
Whether a nav agent reached its destination.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: bool
navigate¶
Walks a nav agent to a point, or follows an entity as it moves. on event "arrived" fires on arrival.
| Parameter | Type | |
|---|---|---|
e |
entity | |
target |
vector|entity |
Returns: none
path_length¶
Walking distance along the navmesh; none if unreachable or there is no navmesh.
| Parameter | Type | |
|---|---|---|
from |
vector|entity | |
to |
vector|entity |
Returns: none|number
stop_navigation¶
Stops a nav agent.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: none
physics¶
impulse¶
An instant kick (N s) to a dynamic body.
| Parameter | Type | |
|---|---|---|
e |
entity | |
impulse |
vector |
Returns: none
overlap_sphere¶
Nearest entity (not self) whose collider overlaps the sphere, optionally with a tag; none if empty.
| Parameter | Type | |
|---|---|---|
center |
vector|entity | |
radius |
number | |
tag |
string | optional |
Returns: none|entity
push¶
Applies a continuous force (N) to a dynamic body this step.
| Parameter | Type | |
|---|---|---|
e |
entity | |
force |
vector |
Returns: none
raycast¶
First collider hit along a ray (self is ignored); sets hit_point, hit_normal and hit_distance.
| Parameter | Type | |
|---|---|---|
origin |
vector|entity | |
direction |
vector | |
max_distance |
number | optional |
Returns: none|entity
torque¶
Applies a torque (N m) to a dynamic body.
| Parameter | Type | |
|---|---|---|
e |
entity | |
torque |
vector |
Returns: none
velocity¶
Current linear velocity of a body or character (m/s).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
physics2d¶
impulse2d¶
An instant kick (N s, x/y) to a dynamic body2d.
| Parameter | Type | |
|---|---|---|
e |
entity | |
impulse |
vector |
Returns: none
overlap2d¶
Nearest entity (not self) whose 2D collider overlaps the circle, optionally with a tag; sensors are ignored; none if empty.
| Parameter | Type | |
|---|---|---|
center |
vector|entity | |
radius |
number | |
tag |
string | optional |
Returns: none|entity
point2d¶
Entity whose 2D collider contains the point (sensors included, self excluded), optionally with a tag; none if empty.
| Parameter | Type | |
|---|---|---|
point |
vector|entity | |
tag |
string | optional |
Returns: none|entity
push2d¶
Applies a continuous force (N, x/y) to a dynamic body2d this tick.
| Parameter | Type | |
|---|---|---|
e |
entity | |
force |
vector |
Returns: none
raycast2d¶
First 2D collider hit along a ray on the XY plane (self is ignored, sensors too); sets hit_point, hit_normal and hit_distance.
| Parameter | Type | |
|---|---|---|
origin |
vector|entity | |
direction |
vector | |
max_distance |
number | optional |
Returns: none|entity
set_velocity2d¶
Sets the velocity of a body2d (dynamic or kinematic) or character2d (knockback, launch pads).
| Parameter | Type | |
|---|---|---|
e |
entity | |
velocity |
vector |
Returns: none
torque2d¶
Applies a torque (N m, counter-clockwise) to a dynamic body2d.
| Parameter | Type | |
|---|---|---|
e |
entity | |
torque |
number |
Returns: none
velocity2d¶
Current velocity of a body2d or character2d (units/s, z = 0).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
random¶
chance¶
true with probability p (0..1).
| Parameter | Type | |
|---|---|---|
p |
number |
Returns: bool
pick¶
A random element of a list (none if empty).
| Parameter | Type | |
|---|---|---|
items |
list |
Returns: any
random¶
random() is 0..1; random(hi) is 0..hi; random(lo, hi) is lo..hi. Seeded by the scene: replays exactly.
| Parameter | Type | |
|---|---|---|
lo_or_hi |
number | optional |
hi |
number | optional |
Returns: number
random_int¶
A whole number from lo to hi (both included).
| Parameter | Type | |
|---|---|---|
lo |
number | |
hi |
number |
Returns: number
shuffle¶
A shuffled copy of a list.
| Parameter | Type | |
|---|---|---|
items |
list |
Returns: list
render¶
layer_mask¶
Render layer bitmask from layer names (game.json render.layers), layer numbers as strings ("3"), "all" / "none", or a list of names / layer numbers; several arguments are combined. Set it on mesh.layers, camera.cullMask or light.cullMask, e.g. hide the player's own body from the first-person camera.
| Parameter | Type | |
|---|---|---|
layers |
number|string|list |
Returns: number
probe_bake¶
Re-captures a reflection probe (or every probe without an argument) over the next rendered frames: after opening a door, switching the room's lights or rearranging furniture, so once probes reflect the new state. Rendering only; the simulation is unaffected.
| Parameter | Type | |
|---|---|---|
probe |
entity | optional |
Returns: none
save¶
delete_save¶
Deletes a slot. Returns whether there was a save to delete.
| Parameter | Type | |
|---|---|---|
slot |
string |
Returns: bool
game_var¶
Reads (or with a value, sets) a global game variable: state that belongs to the game, not to one entity (chapter, flags, unlocked levels, settings). Saved with every save; reset when play stops. Setting none removes it.
| Parameter | Type | |
|---|---|---|
name |
string | |
value |
any | optional |
Returns: any
has_save¶
Whether a slot holds a save (a "Continue" button shows only then).
| Parameter | Type | |
|---|---|---|
slot |
string |
Returns: bool
list_saves¶
Every save, sorted by slot: maps {slot, meta, play_time, saved_at, version, scene}; damaged files have an error instead. For load / save menus.
Returns: list
load_game¶
Loads a slot at the end of this tick: persisted entities, game vars, the exact behavior state and the scene return to the moment of the save. Returns false (and does nothing) when the slot is empty. on loaded follows next tick.
| Parameter | Type | |
|---|---|---|
slot |
string |
Returns: bool
save_game¶
Saves the game into a slot at the end of this tick: every entity with a persist component, game_var values, the scene and the play time. meta is shown in save menus (title, chapter, thumbnail). on saved follows next tick (on event "save_failed" on error). Slots: "slot1", "autosave", "quicksave"...
| Parameter | Type | |
|---|---|---|
slot |
string | |
meta |
map | optional |
Returns: none
scene¶
add_tag¶
Adds a tag to an entity.
| Parameter | Type | |
|---|---|---|
e |
entity | |
tag |
string |
Returns: none
change_scene¶
Moves the game to another scene (a game.json "scenes" alias or a .sky.json path) after this tick: the current scene hears on scene_unloading, entities with a carry component (and options.keep) carry over with their running behaviors, the rest is replaced. Options: transition ("fade" | "crossfade" | "none" or {kind, duration, color}), duration, keep: [names], spawn_at: "EntityName" (the player moves there), loading: a loading scene shown while assets preload. on scene_loaded follows. Stopping play returns the editor to the scene play started in.
| Parameter | Type | |
|---|---|---|
scene |
string | |
options |
map | optional |
Returns: none
children¶
Direct children of an entity, in order.
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: list
count¶
How many entities have a tag.
| Parameter | Type | |
|---|---|---|
tag |
string |
Returns: number
current_scene¶
The scene the game is in: its game.json alias, else its path.
Returns: string
exists¶
Whether a value is an entity that still exists.
| Parameter | Type | |
|---|---|---|
e |
any |
Returns: bool
find¶
Entity by name (or "#id"); none if missing. "%Name" finds the entity marked unique (entity_update unique=true) inside this prefab instance, else in the scene, so each copy of a prefab finds its own part.
| Parameter | Type | |
|---|---|---|
name |
string |
Returns: none|entity
find_all¶
Active entities with a tag, in scene order.
| Parameter | Type | |
|---|---|---|
tag |
string |
Returns: list
has¶
Whether the entity has a component ("light", "particles", ...).
| Parameter | Type | |
|---|---|---|
e |
entity | |
component |
string |
Returns: bool
load_additive¶
Adds a scene's entities to the running one at the end of this tick (a room, a streaming chunk, a UI overlay) and returns its handle for unload_scene. Options: id (handle), parent (entity to load under), offset (vector added to its root positions). It owns exactly the entities it created.
| Parameter | Type | |
|---|---|---|
scene |
string | |
options |
map | optional |
Returns: string
loading_progress¶
How far the next scene has preloaded, 0..1 (1 when nothing is loading): for a loading bar in a loading scene.
Returns: number
nearest¶
Closest other active entity with a tag (within max_distance); none if there is none.
| Parameter | Type | |
|---|---|---|
tag |
string | |
max_distance |
number | optional |
Returns: none|entity
remove_tag¶
Removes a tag from an entity.
| Parameter | Type | |
|---|---|---|
e |
entity | |
tag |
string |
Returns: none
set_parent¶
Moves an entity under a new parent, or to the scene root with none. By default it keeps its world position, rotation and scale (keep_world = false keeps its local transform instead, so it jumps to the same offset from the new parent). Parenting under itself or a descendant fails. Like every play-time change, it is undone when play stops.
| Parameter | Type | |
|---|---|---|
e |
entity | |
parent |
none|entity | |
keep_world |
bool | optional |
Returns: none
spawn¶
Creates an entity: a primitive mesh ("cube", "sphere"...), "asset:models/x.glb", or a whole prefab "prefab:prefabs/coin.prefab.json" (with its children and behaviors). Its behaviors start next tick. Limits: 256 spawns per tick, 20000 entities.
| Parameter | Type | |
|---|---|---|
mesh |
string | |
position |
vector|entity | optional |
name |
any | optional |
Returns: entity
tagged¶
Whether an entity has a tag (false for none).
| Parameter | Type | |
|---|---|---|
e |
any | |
tag |
string |
Returns: bool
unload_scene¶
Removes a sub-scene loaded with load_additive: its entities hear on scene_unloading next tick and are removed the tick after. Entities the game added under it are kept (moved to the root).
| Parameter | Type | |
|---|---|---|
handle |
string |
Returns: none
text¶
num¶
Number parsed from text (none if it is not a number).
| Parameter | Type | |
|---|---|---|
text |
any |
Returns: none|number
str¶
Text form of any value (entities give their name).
| Parameter | Type | |
|---|---|---|
value |
any |
Returns: string
type_of¶
The type name: number, bool, string, vector, color, entity, list, map, none.
| Parameter | Type | |
|---|---|---|
value |
any |
Returns: string
ends_with¶
Whether the text ends with a suffix.
| Parameter | Type | |
|---|---|---|
suffix |
string |
Returns: bool
lower¶
Lowercase copy.
Returns: string
replace¶
Copy with every occurrence of old replaced.
| Parameter | Type | |
|---|---|---|
old |
string | |
new |
string |
Returns: string
split¶
Parts of the text between separators (default: spaces).
| Parameter | Type | |
|---|---|---|
separator |
string | optional |
Returns: list
starts_with¶
Whether the text starts with a prefix.
| Parameter | Type | |
|---|---|---|
prefix |
string |
Returns: bool
trim¶
Copy without leading/trailing spaces.
Returns: string
upper¶
Uppercase copy.
Returns: string
time¶
is_paused¶
True while the game is paused (or will be from the next tick, after pause_game()).
Returns: bool
pause_game¶
Pauses the game (a pause menu) from the next tick: pausable entities (the default) stop — behaviors, physics, animation, particles, sounds — while UI canvases and entities with process mode always or when_paused keep running. Sends on pause to every behavior. pause_game(false) = resume_game().
| Parameter | Type | |
|---|---|---|
paused |
bool | optional |
Returns: none
resume_game¶
Resumes a paused game from the next tick and sends on resume.
Returns: none
teleport¶
Moves an entity instantly (when given a position) and tells render interpolation not to smear it across the screen: respawns, portals, checkpoints. Without a position it only resets the smoothing for this frame.
| Parameter | Type | |
|---|---|---|
entity |
entity | |
position |
vector|entity | optional |
Returns: none
time_scale¶
Slow motion / fast forward: time_scale(0.3) makes the game clock run at 30% from the next tick (dt, timers, waits, physics, animation, particles; 0..10). Entities on the real clock (UI, process clock real) ignore it. Returns the scale (the requested one).
| Parameter | Type | |
|---|---|---|
scale |
number | optional |
Returns: number
unscaled_dt¶
Real seconds per tick (1/60), whatever the time scale or pause: timers that must ignore slow motion.
Returns: number
unscaled_time¶
Real seconds since play started (keeps counting while the game is paused or slowed; time does not).
Returns: number
vector¶
cross¶
Cross product.
| Parameter | Type | |
|---|---|---|
a |
vector | |
b |
vector |
Returns: vector
direction¶
Unit vector pointing from one point to another.
| Parameter | Type | |
|---|---|---|
from |
vector|entity | |
to |
vector|entity |
Returns: vector
distance¶
Distance between two points; entities count as their world position.
| Parameter | Type | |
|---|---|---|
a |
vector|entity | |
b |
vector|entity |
Returns: number
dot¶
Dot product.
| Parameter | Type | |
|---|---|---|
a |
vector | |
b |
vector |
Returns: number
forward¶
World direction the entity faces (its -Z axis).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
length¶
Length (magnitude) of a vector.
| Parameter | Type | |
|---|---|---|
v |
vector |
Returns: number
normalize¶
Vector scaled to length 1 (zero stays zero).
| Parameter | Type | |
|---|---|---|
v |
vector |
Returns: vector
right¶
World direction of the entity's right side (+X).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
up¶
World direction of the entity's up axis (+Y).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
vec¶
Makes a vector (same as (x, y, z)).
| Parameter | Type | |
|---|---|---|
x |
number | |
y |
number | |
z |
number |
Returns: vector
world_position¶
World position (self.position is relative to the parent).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: vector
vehicle¶
vehicle_drive¶
Sets a vehicle's inputs for this tick: throttle 0..1, steer -1 (left)..1 (right), brake 0..1, handbrake 0..1. Overrides the player's drive actions this tick; with control "script" it is the only driver. Holding brake at a standstill reverses (autoReverse).
| Parameter | Type | |
|---|---|---|
e |
entity | |
throttle |
number | |
steer |
number | |
brake |
number | optional |
handbrake |
number | optional |
Returns: none
vehicle_shift¶
Manual gearbox: selects a gear (-1 reverse, 0 neutral, 1..). Automatic gearboxes shift by themselves.
| Parameter | Type | |
|---|---|---|
e |
entity | |
gear |
number |
Returns: none
vehicle_speed¶
Speed along the vehicle's heading in km/h (negative reversing).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: number
vehicle_state¶
Live vehicle state: speed (km/h), rpm, gear, wheels_on_ground, skid 0..1, drift_angle (degrees), lateral_g, longitudinal_g, load 0..1 and skidding (a list of contact points of sliding wheels, for smoke and marks).
| Parameter | Type | |
|---|---|---|
e |
entity |
Returns: map
vehicle_wheel¶
One wheel's live state by index (0-based) or name ("rear_left"): contact, point, normal, surface, load (N), slip_ratio, slip_angle (degrees), skid 0..1, compression 0..1, steer, rpm, driven. none before play. Tire smoke and skid marks: spawn at point while skid > 0.3.
| Parameter | Type | |
|---|---|---|
e |
entity | |
wheel |
number|string |
Returns: none|map
The guide agents read¶
wander_reference without a topic returns this text: a compact language guide followed by the builtin list.
wander_reference output
Wander 2 — Skywalker's behavior language (ECPS: Entity · Component · Prompt System)
A behavior = an `intent` (plain language, the human source of truth) + deterministic code.
Safe by construction: every handler run has a step budget (loops can't hang the engine),
randomness is seeded (runs replay exactly), and the compiler reports line/column/code/hint.
behavior Guard
intent "Patrol between two posts; chase the player when close; lose 1 hp per hit."
param speed = 3 in 0..10 "walk speed (m/s)" -- tunable: shown as a slider in the editor
var hp = 3 -- per-entity state (persisted, visible to tools)
var posts: list = []
on start
posts = [self.position, self.position + (6, 0, 0)]
end
state Patrol -- first state is the initial one
on tick
let goal = posts[floor(state_time / 4) % 2]
move self toward goal at speed
let p = nearest("player", 5)
if p then go to Chase end
end
end
state Chase
on enter
self.color = #ff4040
end
on tick
let p = nearest("player", 8)
if not p then go to Patrol end
move self toward p at speed * 1.5
end
end
on event "damage" with hit -- payload map; `other` is the sender
hp -= hit.get("amount", 1)
if hp <= 0 then
emit "guard_down" with {at: self.position}
destroy self
end
end
on event "alarm"
wait 0.5 -- coroutine: resumes 0.5 s later (per entity)
log "{self.name} heard the alarm"
end
test "loses hp when hit"
emit "damage" with {amount: 1} to self
wait frames 2
expect hp == 2
end
end
TRIGGERS on start | on tick | on event "name" (with x) | on key "space" | on click
inside a state: on enter | on exit | on tick | on event ... (plus subsystem triggers, see below)
DECLARE var x = 0 (per entity; `x` or `self.x`) | param x = 1 in 0..5 "doc" | const MAX = 10
fn name(a, b: number) -> number ... return a + b end (recursion ok) | use "scripts/combat" (then combat.fn())
STATEMENTS
let x = v | x = v | x += v (-= *= /=) | set x to v
if c then .. elif c then .. else .. end (`then` optional)
for x in list .. end | for i, x in list | for k, v in map | for i in 0..10 (end excluded; 0..=10 includes) step 2
while c .. end | repeat n times .. end | break | continue | return v | stop
every 2 seconds .. end | after 1 seconds .. end (timers that tick with the handler)
wait 1.5 | wait frames 3 | wait until hp <= 0 (handlers and tests only, not inside fn)
go to StateName
move e by vec | move e toward point at speed | rotate e by (0, 90 * dt, 0) | look e at point
emit "event" (with payload) (to entity) | destroy e | log value
VALUES 1.5 "text {interpolated}" true false none #ff8800 (x, y, z) [list] {key: value}
OPERATORS + - * / % < <= > >= == != and or not x in list/map/string "a" + 1 joins text
NAMES self other (sender / collision partner) dt time frame pi state state_time data (event payload)
PROPERTIES e.position e.rotation (degrees) e.scale e.color e.name e.id e.enabled e.tags e.parent e.state
e.<component>.<field> (self.light.intensity, self.particles.rate) e.<var>
v.x v.y v.z v.length c.r c.g c.b c.a list.length string.length map.key
LISTS/MAPS are values (copied on assignment); mutate in place with methods: self.items.push(x)
TESTS test "name" .. end — run by wander_test in a sandbox: expect cond ("why"), wait (advances the sim),
emit, press "space" / hold "w" / release "w" / click e, spawn(...). Tests start after the first tick.
IDIOMS
- Smooth motion: move self toward target at speed | self.position = lerp(self.position, goal, 1 - exp(-8 * dt))
- Frame-rate independent: always multiply per-tick changes by dt.
- Sequences: on event "open" .. wait 1 .. end — no manual timers.
- Find things: nearest("enemy", 10), find_all("coin"), find("Door"); check `if x then` before using a maybe-none.
- Cooldowns: var cooldown = 0 / cooldown -= dt / if cooldown <= 0 then ... cooldown = 1 end
- Share code across behaviors with modules: use "scripts/util" then util.clamp01(x).
- Prefer states over boolean flags for modes (Idle/Chase/Flee); `state` reads the current one.
RULES meters, +Y up, entities face -Z, rotations are Euler degrees (pitch X, yaw Y, roll Z).
A handler that errors 5 times disables its script. Events arrive next tick, in emission order.
FUNCTIONS (category: signature — what it does)
[2d]
play_anim(entity: entity, clip: string, restart: bool?) — Plays a sprite_anim clip (keeps playing if it already is, unless restart). Frame events arrive as `on anim "name"`; a non-looping clip sends `on anim "finished"`.
set_tile(map: entity, position: vector|entity, tile: number|string, layer: string?) — Sets the tile at a world position: an id (0 clears) or a terrain from tilemap.autotile (auto-tiled).
tile_at(map: entity, position: vector|entity, layer: string?) -> number — Tile id of a tilemap at a world position (topmost non-empty layer, or the named layer); 0 = empty.
[animation]
anim_state(entity: entity) -> string — Name of the animator's current state.
foot_ik(entity: entity, on: bool, weight: number?) — Turns automatic foot planting on or off (feet on stairs, slopes and rocks, pelvis lowered, feet locked while planted); the optional weight fades it (0..1). Adds the characterIk component if needed.
hand_ik(entity: entity, side: string, target: none|entity, weight: number?) — Makes a character's hand reach an entity ("left" or "right"): a grip point on a staff held in the other hand, a ledge, a rail, a door handle. `none` (or weight 0) releases it. Adds the characterIk component if needed.
look_at(entity: entity, target: none|entity, weight: number?) — Turns a character's head and upper spine toward an entity (look-at IK, clamped by animator.lookAtLimit), or stops with `none`; the turn fades in and out smoothly.
play_animation(entity: entity, clip: string, fade: number?, loop: bool?) — Crossfades straight to a clip or state (seconds of fade, default 0.2).
play_sequence(entity: entity, start: number?) — Plays the entity's sequencer (a cutscene) from `start` seconds.
set_param(entity: entity, name: string, value: bool|number) — Sets an animator controller parameter (blend spaces and transitions read them).
trigger(entity: entity, name: string) — Fires an animator trigger (jump, attack, wave).
turn_in_place(entity: entity, toward: number|vector|entity) — Turns a standing character in place toward a world yaw (degrees, 0 = -Z) or to face a point / entity, at characterIk.turnSpeed; planted feet stay locked and re-plant in small steps. Controllers can read the float `turn` (degrees left) and bool `turning` parameters to play turn clips.
[audio]
music(clip: string, fade: number?) — Crossfades the music to a clip ("" fades out); fade in seconds.
play(e: entity) — Starts the entity's audio component (its clip, volume, spatial settings).
play_sound(clip: string, volume: number?) — Plays a one-shot sound at self (positional), e.g. a hit or a pickup.
set_volume(bus: string, volume: number) — Sets a mixer bus volume (master, music, sfx, ambience, voice, ui), 0..1.
stop_sound(e: entity) — Stops the entity's audio component.
[character]
grounded(e: entity) -> bool — Whether a character stands on the ground.
jump(e: entity, speed: number?) -> bool — Makes a grounded character jump (default: its jumpSpeed); false when airborne.
walk(e: entity, direction: vector) — Moves a character this tick (|direction| 1 = its moveSpeed). Call every tick while walking.
[character2d]
drop_through2d(e: entity) -> bool — Drops a character2d through the one-way platform it stands on; false when it stands on solid ground.
grounded2d(e: entity) -> bool — Whether a character2d stands on walkable ground (a slope up to maxSlope or a platform).
jump2d(e: entity, speed: number?) -> bool — Makes a character2d jump (default: its jumpSpeed). True when it jumps now (grounded or within coyote time); otherwise the press is buffered and the jump happens on landing within jumpBuffer seconds.
move2d(e: entity, x: number) — Runs a character2d this tick: -1 = full speed left, 1 = right (scaled by moveSpeed, with acceleration). Call every tick.
[color]
color(r: number, g: number, b: number, a: number?) -> color — Makes a color from 0..1 channels.
hsv(h: number, s: number, v: number) -> color — Color from hue (0..1, wraps), saturation and value.
[dialogue]
dialogue_advance() — Shows the rest of the typing line, or moves to the next line.
dialogue_choose(index: number) — Picks one of the current dialogue choices (0-based).
dialogue_var(name: string, value?) -> any — Reads (or with a value, sets) a dialogue variable ($trust = "trust") of the first dialogue component.
start_dialogue(entity_or_node: entity|string, node: string?) — Starts a conversation at a node: start_dialogue("Intro") on the first dialogue component, or start_dialogue(entity, "Intro").
[effects]
burst(entity_or_count: number|entity, count: number?) — Emits particles right now from self's particles (or particles2d) component: burst(n), or burst(entity, n) for another emitter. Explosions, muzzle flashes, impacts, dust puffs.
camera_shake(trauma: number, camera: entity?) — Shakes the 2D camera: adds `trauma` (0..1; 0.2 a hit, 0.5 a heavy slam, 1 an explosion) to the camera2d (the active camera, or the given one). The offset grows with trauma squared (camera2d.shakeAmplitude world units at 1) and decays by shakeDecay per second. Runs through hit-stops; replays identically.
flash(entity: entity, seconds: number?, color: color?) — Flashes a sprite: it turns `color` (default white; its alpha is the strength) and fades back over `seconds` (default 0.12). Damage feedback, parries, pickups. For a constant tint set sprite.flash.
hit_stop(seconds: number, scale: number?) — Freeze frames on impact: the game clock stops (or runs at `scale`, 0..1) for `seconds` of real time, then resumes at the time scale. 0.04-0.12 s sells a hit; a longer, stronger stop extends the current one. UI, camera_shake and entities on the real clock keep moving. Per entity: set `process.timeScale` instead.
hit_stop_left() -> number — Real seconds of hit-stop left (0 when the game clock runs normally).
water_height(x_or_point: number|vector|entity, z: number?) -> number — Height of the animated water surface at (x, z) or at a point — the same surface that is rendered (0 where there is no water). Boats, buoyancy, splashes.
[input]
action(name: string) -> bool — Whether an input action is held ("jump", "fire" from input.json).
axis(name: string) -> number|vector — Value of an axis action: a number (-1..1), or a vector (x, y, 0) for 2D axes (x right, y forward/up).
cursor_lock(on: bool) — Hides and captures the mouse cursor (first-person look: read mouse movement with axis("look")) or gives it back. Honored by the standalone player; resets when the game stops.
key(name: string) -> bool — Whether a key is held ("w", "space", "left", ...).
key_pressed(name: string) -> bool — Whether a key was pressed this tick (once per press).
pressed(name: string) -> bool — Whether an input action was pressed this tick.
quit_game() — Closes the game (a "Quit" menu button). The standalone player exits; the editor ignores it.
released(name: string) -> bool — Whether an input action was released this tick.
[list]
list|map.clear() — Removes everything.
string|list|map.contains(item) -> bool — Lists: has an equal item. Maps: has the key. Strings: has the substring. (Same as `x in y`.)
list.first() -> any — The first item (none if empty).
string|list.index_of(item) -> number — Position of the first equal item/substring, or -1.
list.insert(index: number, item) — Inserts an item before index (index = length appends).
string|list|map.is_empty() -> bool — Whether it has no items / keys / characters.
list.join(separator: string?) -> string — Text of all items joined by a separator.
list.last() -> any — The last item (none if empty).
list.pop() -> any — Removes and returns the last item.
list.push(item) — Appends an item.
list|map.remove(item_or_key) -> bool — Lists: removes the first item equal to the argument. Maps: removes a key. Returns whether something was removed.
list.remove_at(index: number) -> any — Removes and returns the item at index.
list.reverse() — Reverses the list in place.
string|list.slice(from: number, to: number?) -> string|list — Items (or characters) from index `from` up to, not including, `to`. Negative indexes count from the end.
list.sort() — Sorts numbers or strings in place (ascending).
list.sorted() -> list — A sorted copy (numbers or strings).
list.sum() -> number — Sum of a list of numbers.
[locale]
locale() -> string — The current locale code ("en", "fr", "pt-BR").
locales() -> list — Locale codes the game has strings for (with the source language), sorted: for a language menu.
set_locale(code: string) — Switches the game's language from the next frame (a language menu): "fr", "pt-BR". Texts written as "@key" and #line dialogue lines follow at once. Undone when play stops; save it with game_var to keep it.
tr(key: string, args: map?) -> string — The localized string for a key in the current locale (locale/*.csv or *.po), falling back pt-BR -> pt -> the source language. `args` fill {placeholders}, plurals ({n, plural, one {# coin} other {# coins}}) and selects; numbers are formatted for the locale. A missing key returns the key and is reported by locale_check.
[map]
map.get(key: string, default?) -> any — Value for a key, or the default (none) if missing.
map.has(key: string) -> bool — Whether the map has a key.
map.keys() -> list — The keys, in insertion order.
map.set(key: string, value) — Sets a key (same as m[key] = value).
map.values() -> list — The values, in insertion order.
[math]
abs(x: number) -> number — Absolute value.
acos(x: number) -> number — Arc cosine in radians (x is clamped to -1..1).
approach(current: number, target: number, max_step: number) -> number — Moves current toward target by at most max_step (never overshoots).
asin(x: number) -> number — Arc sine in radians (x is clamped to -1..1).
atan(x: number) -> number — Arc tangent in radians.
atan2(y: number, x: number) -> number — Angle of the point (x, y) in radians, -pi..pi.
ceil(x: number) -> number — Smallest whole number >= x.
clamp(x: number, lo: number, hi: number) -> number — x limited to the range lo..hi.
cos(radians: number) -> number — Cosine of an angle in radians.
deg(radians: number) -> number — Radians to degrees.
exp(x: number) -> number — e raised to x.
floor(x: number) -> number — Largest whole number <= x.
inverse_lerp(a: number, b: number, x: number) -> number — Where x lies between a (0) and b (1).
lerp(a: number|vector|color, b: number|vector|color, t: number) -> number|vector|color — Linear blend from a (t=0) to b (t=1); numbers, vectors or colors.
ln(x: number) -> number — Natural logarithm (x > 0).
max(a: number|list, b: number?, ...) -> number — Larger of numbers, or the largest number in a list.
min(a: number|list, b: number?, ...) -> number — Smaller of numbers, or the smallest number in a list.
noise(x: number, y: number?) -> number — Smooth deterministic value noise in -1..1 (1D or 2D).
pow(base: number, exponent: number) -> number — base raised to exponent.
rad(degrees: number) -> number — Degrees to radians.
round(x: number, digits: number?) -> number — Rounds to the nearest whole number, or to `digits` decimals.
sign(x: number) -> number — -1, 0 or 1.
sin(radians: number) -> number — Sine of an angle in radians.
smoothstep(edge0: number, edge1: number, x: number) -> number — Smooth 0..1 ramp between two edges.
sqrt(x: number) -> number — Square root (0 for negative input).
tan(radians: number) -> number — Tangent of an angle in radians.
[navigation]
arrived(e: entity) -> bool — Whether a nav agent reached its destination.
navigate(e: entity, target: vector|entity) — Walks a nav agent to a point, or follows an entity as it moves. `on event "arrived"` fires on arrival.
path_length(from: vector|entity, to: vector|entity) -> none|number — Walking distance along the navmesh; none if unreachable or there is no navmesh.
stop_navigation(e: entity) — Stops a nav agent.
[physics]
impulse(e: entity, impulse: vector) — An instant kick (N s) to a dynamic body.
overlap_sphere(center: vector|entity, radius: number, tag: string?) -> none|entity — Nearest entity (not self) whose collider overlaps the sphere, optionally with a tag; none if empty.
push(e: entity, force: vector) — Applies a continuous force (N) to a dynamic body this step.
raycast(origin: vector|entity, direction: vector, max_distance: number?) -> none|entity — First collider hit along a ray (self is ignored); sets hit_point, hit_normal and hit_distance.
torque(e: entity, torque: vector) — Applies a torque (N m) to a dynamic body.
velocity(e: entity) -> vector — Current linear velocity of a body or character (m/s).
[physics2d]
impulse2d(e: entity, impulse: vector) — An instant kick (N s, x/y) to a dynamic body2d.
overlap2d(center: vector|entity, radius: number, tag: string?) -> none|entity — Nearest entity (not self) whose 2D collider overlaps the circle, optionally with a tag; sensors are ignored; none if empty.
point2d(point: vector|entity, tag: string?) -> none|entity — Entity whose 2D collider contains the point (sensors included, self excluded), optionally with a tag; none if empty.
push2d(e: entity, force: vector) — Applies a continuous force (N, x/y) to a dynamic body2d this tick.
raycast2d(origin: vector|entity, direction: vector, max_distance: number?) -> none|entity — First 2D collider hit along a ray on the XY plane (self is ignored, sensors too); sets hit_point, hit_normal and hit_distance.
set_velocity2d(e: entity, velocity: vector) — Sets the velocity of a body2d (dynamic or kinematic) or character2d (knockback, launch pads).
torque2d(e: entity, torque: number) — Applies a torque (N m, counter-clockwise) to a dynamic body2d.
velocity2d(e: entity) -> vector — Current velocity of a body2d or character2d (units/s, z = 0).
[random]
chance(p: number) -> bool — true with probability p (0..1).
pick(items: list) -> any — A random element of a list (none if empty).
random(lo_or_hi: number?, hi: number?) -> number — random() is 0..1; random(hi) is 0..hi; random(lo, hi) is lo..hi. Seeded by the scene: replays exactly.
random_int(lo: number, hi: number) -> number — A whole number from lo to hi (both included).
shuffle(items: list) -> list — A shuffled copy of a list.
[render]
layer_mask(layers: number|string|list, ...) -> number — Render layer bitmask from layer names (game.json render.layers), layer numbers as strings ("3"), "all" / "none", or a list of names / layer numbers; several arguments are combined. Set it on mesh.layers, camera.cullMask or light.cullMask, e.g. hide the player's own body from the first-person camera.
probe_bake(probe: entity?) — Re-captures a reflection probe (or every probe without an argument) over the next rendered frames: after opening a door, switching the room's lights or rearranging furniture, so `once` probes reflect the new state. Rendering only; the simulation is unaffected.
[save]
delete_save(slot: string) -> bool — Deletes a slot. Returns whether there was a save to delete.
game_var(name: string, value?) -> any — Reads (or with a value, sets) a global game variable: state that belongs to the game, not to one entity (chapter, flags, unlocked levels, settings). Saved with every save; reset when play stops. Setting none removes it.
has_save(slot: string) -> bool — Whether a slot holds a save (a "Continue" button shows only then).
list_saves() -> list — Every save, sorted by slot: maps {slot, meta, play_time, saved_at, version, scene}; damaged files have an `error` instead. For load / save menus.
load_game(slot: string) -> bool — Loads a slot at the end of this tick: persisted entities, game vars, the exact behavior state and the scene return to the moment of the save. Returns false (and does nothing) when the slot is empty. `on loaded` follows next tick.
save_game(slot: string, meta: map?) — Saves the game into a slot at the end of this tick: every entity with a `persist` component, game_var values, the scene and the play time. `meta` is shown in save menus (title, chapter, thumbnail). `on saved` follows next tick (`on event "save_failed"` on error). Slots: "slot1", "autosave", "quicksave"...
[scene]
add_tag(e: entity, tag: string) — Adds a tag to an entity.
change_scene(scene: string, options: map?) — Moves the game to another scene (a game.json "scenes" alias or a .sky.json path) after this tick: the current scene hears `on scene_unloading`, entities with a `carry` component (and options.keep) carry over with their running behaviors, the rest is replaced. Options: transition ("fade" | "crossfade" | "none" or {kind, duration, color}), duration, keep: [names], spawn_at: "EntityName" (the player moves there), loading: a loading scene shown while assets preload. `on scene_loaded` follows. Stopping play returns the editor to the scene play started in.
children(e: entity) -> list — Direct children of an entity, in order.
count(tag: string) -> number — How many entities have a tag.
current_scene() -> string — The scene the game is in: its game.json alias, else its path.
exists(e) -> bool — Whether a value is an entity that still exists.
find(name: string) -> none|entity — Entity by name (or "#id"); none if missing. "%Name" finds the entity marked unique (entity_update unique=true) inside this prefab instance, else in the scene, so each copy of a prefab finds its own part.
find_all(tag: string) -> list — Active entities with a tag, in scene order.
has(e: entity, component: string) -> bool — Whether the entity has a component ("light", "particles", ...).
load_additive(scene: string, options: map?) -> string — Adds a scene's entities to the running one at the end of this tick (a room, a streaming chunk, a UI overlay) and returns its handle for unload_scene. Options: id (handle), parent (entity to load under), offset (vector added to its root positions). It owns exactly the entities it created.
loading_progress() -> number — How far the next scene has preloaded, 0..1 (1 when nothing is loading): for a loading bar in a loading scene.
nearest(tag: string, max_distance: number?) -> none|entity — Closest other active entity with a tag (within max_distance); none if there is none.
remove_tag(e: entity, tag: string) — Removes a tag from an entity.
set_parent(e: entity, parent: none|entity, keep_world: bool?) — Moves an entity under a new parent, or to the scene root with none. By default it keeps its world position, rotation and scale (keep_world = false keeps its local transform instead, so it jumps to the same offset from the new parent). Parenting under itself or a descendant fails. Like every play-time change, it is undone when play stops.
spawn(mesh: string, position: vector|entity?, name?) -> entity — Creates an entity: a primitive mesh ("cube", "sphere"...), "asset:models/x.glb", or a whole prefab "prefab:prefabs/coin.prefab.json" (with its children and behaviors). Its behaviors start next tick. Limits: 256 spawns per tick, 20000 entities.
tagged(e, tag: string) -> bool — Whether an entity has a tag (false for none).
unload_scene(handle: string) — Removes a sub-scene loaded with load_additive: its entities hear `on scene_unloading` next tick and are removed the tick after. Entities the game added under it are kept (moved to the root).
[text]
num(text) -> none|number — Number parsed from text (none if it is not a number).
str(value) -> string — Text form of any value (entities give their name).
type_of(value) -> string — The type name: number, bool, string, vector, color, entity, list, map, none.
string.ends_with(suffix: string) -> bool — Whether the text ends with a suffix.
string.lower() -> string — Lowercase copy.
string.replace(old: string, new: string) -> string — Copy with every occurrence of old replaced.
string.split(separator: string?) -> list — Parts of the text between separators (default: spaces).
string.starts_with(prefix: string) -> bool — Whether the text starts with a prefix.
string.trim() -> string — Copy without leading/trailing spaces.
string.upper() -> string — Uppercase copy.
[time]
is_paused() -> bool — True while the game is paused (or will be from the next tick, after pause_game()).
pause_game(paused: bool?) — Pauses the game (a pause menu) from the next tick: `pausable` entities (the default) stop — behaviors, physics, animation, particles, sounds — while UI canvases and entities with process mode `always` or `when_paused` keep running. Sends `on pause` to every behavior. pause_game(false) = resume_game().
resume_game() — Resumes a paused game from the next tick and sends `on resume`.
teleport(entity: entity, position: vector|entity?) — Moves an entity instantly (when given a position) and tells render interpolation not to smear it across the screen: respawns, portals, checkpoints. Without a position it only resets the smoothing for this frame.
time_scale(scale: number?) -> number — Slow motion / fast forward: time_scale(0.3) makes the game clock run at 30% from the next tick (dt, timers, waits, physics, animation, particles; 0..10). Entities on the `real` clock (UI, process clock real) ignore it. Returns the scale (the requested one).
unscaled_dt() -> number — Real seconds per tick (1/60), whatever the time scale or pause: timers that must ignore slow motion.
unscaled_time() -> number — Real seconds since play started (keeps counting while the game is paused or slowed; `time` does not).
[vector]
cross(a: vector, b: vector) -> vector — Cross product.
direction(from: vector|entity, to: vector|entity) -> vector — Unit vector pointing from one point to another.
distance(a: vector|entity, b: vector|entity) -> number — Distance between two points; entities count as their world position.
dot(a: vector, b: vector) -> number — Dot product.
forward(e: entity) -> vector — World direction the entity faces (its -Z axis).
length(v: vector) -> number — Length (magnitude) of a vector.
normalize(v: vector) -> vector — Vector scaled to length 1 (zero stays zero).
right(e: entity) -> vector — World direction of the entity's right side (+X).
up(e: entity) -> vector — World direction of the entity's up axis (+Y).
vec(x: number, y: number, z: number) -> vector — Makes a vector (same as (x, y, z)).
world_position(e: entity) -> vector — World position (self.position is relative to the parent).
[vehicle]
vehicle_drive(e: entity, throttle: number, steer: number, brake: number?, handbrake: number?) — Sets a vehicle's inputs for this tick: throttle 0..1, steer -1 (left)..1 (right), brake 0..1, handbrake 0..1. Overrides the player's drive actions this tick; with control "script" it is the only driver. Holding brake at a standstill reverses (autoReverse).
vehicle_shift(e: entity, gear: number) — Manual gearbox: selects a gear (-1 reverse, 0 neutral, 1..). Automatic gearboxes shift by themselves.
vehicle_speed(e: entity) -> number — Speed along the vehicle's heading in km/h (negative reversing).
vehicle_state(e: entity) -> map — Live vehicle state: speed (km/h), rpm, gear, wheels_on_ground, skid 0..1, drift_angle (degrees), lateral_g, longitudinal_g, load 0..1 and skidding (a list of contact points of sliding wheels, for smoke and marks).
vehicle_wheel(e: entity, wheel: number|string) -> none|map — One wheel's live state by index (0-based) or name ("rear_left"): contact, point, normal, surface, load (N), slip_ratio, slip_angle (degrees), skid 0..1, compression 0..1, steer, rpm, driven. none before play. Tire smoke and skid marks: spawn at `point` while `skid` > 0.3.
SUBSYSTEM TRIGGERS
on action — An input action was pressed: on action "jump" (actions come from input.json).
on collide — Two bodies touched: on collide ("name or tag")? — other, contact_point, contact_normal, impact.
on collide_end — Two 2D bodies stopped touching: on collide_end — other. data: {}
on dialogue — `on dialogue "start" | "line" | "choice" | "end" | "<command>"`: conversation events and <<command>>s of .dialogue scripts (event "dialogue:...").
on impact — A 2D body hit this one faster than physics2d_world.impactSpeed: on impact — other, data. data: {point: vec, normal: vec, speed: number, impulse: number}
on loaded — A save was loaded (load_game or the load_game tool): on loaded — data.slot, data.version, data.meta. Refresh what is derived from saved state (HUD, music). data: {slot: string, version: number, meta: map}
on pause — The game was paused (pause_game): delivered to every behavior, also those the pause stops.
on resume — The game resumed (resume_game).
on saved — A save_game() finished: on saved — data.slot, data.meta. data: {slot: string, meta: map}
on scene_loaded — A scene finished loading: on scene_loaded — data.id (alias or path, or a sub-scene's handle), data.path, data.additive. data: {id: string, path: string, additive: bool}
on scene_unloading — A scene is about to go: on scene_unloading — data.id, data.to (the next scene), data.additive. Delivered the tick before the change, to the leaving scene too. data: {id: string, to: string, additive: bool}
on trigger_enter — Something entered this trigger collider: on trigger_enter ("name or tag")? — other.
on trigger_exit — Something left this trigger collider: on trigger_exit ("name or tag")? — other.
on ui — `on ui "Name"`: the button/toggle/slider/input named Name was used (event "ui:Name").
More: wander_reference topic="<category or function>" for details and examples.