Script API reference

Gameplay scripts are JavaScript files in your project's Scripts/ folder. This page is generated from the public JavaScript prelude and native bridge in Sources/TTRGameplay/ScriptRuntime.swift; the QuickJS host itself is in Sources/TTRScript/ScriptVM.swift. Internal names beginning with __ are implementation glue, not a supported customer API. Standard JavaScript built-ins are separate from this engine reference.

Entity.method(...) below means call the method on self or an entity returned by the world—not a static call on the constructor. Check nullable results. Three-dimensional points/displacements are [x,y,z], in meters; Y is up. Rotations are degrees. The 2D velocity and tile APIs are explicitly marked.

Limits and execution

LimitDefault and meaning
Normal script call50 ms of JavaScript CPU time for a top-level call, including nested script calls. Native Swift work is excluded. This is not a wall-clock frame budget.
Loading and onStartA longer 1-second budget by default. A nested call cannot escape an already active budget.
Memory256 MiB (268,435,456 bytes), shared by all scripts in the VM—not 256 MiB per object.
Native stack640 KiB on Windows; 4 MiB elsewhere. Excessive recursion is reported as a script error.
Repeated timeoutsAfter 3 attributed timeouts, that file/entity script instance is disabled for the rest of Play. Timer callbacks are not attributed to an instance in the same way.
JavaScript-to-Swift conversionAt most 100,000 copied values and 32 levels deep when reading JavaScript data into Swift. Excess data can be truncated or converted to null/nil; this is not lossless serialization for arbitrarily large objects. These copy guards do not apply to Swift-to-JavaScript conversion.
Path searches3 script searches per simulation tick across the play session; further pathTo calls return false until a later tick.

The clock uses thread CPU time where supported, with a system-uptime fallback if the platform clock cannot be read. QuickJS checks its interrupt periodically, so 50 ms is a guard, not an exact scheduling promise. A host can change these limits; scripts do not get setters for them. Due timers are run together in one guarded timer pass. Keep callbacks short and spread large jobs over ticks.

Callbacks you define

Each attached file gets its own closure for each entity. Define only the callbacks you need. Use closure variables for transient per-instance state; self wrappers are recreated for calls. Put persistent plain data in self.save.

onStart(self)

Called when this script instance starts, including scripts attached to newly spawned objects.

onTick(self, dt)

Called each simulation tick. dt is seconds (normally 1/120), not a frame count.

onEnter(self, other)

Called when another eligible object enters this entity’s trigger volume.

onExit(self, other)

Called when another eligible object leaves the trigger volume.

onMessage(self, name, data)

Called for entity.send and engine messages. Check name before interpreting data.

onAnimEvent(self, name, info)

Called when this object's animation crosses a clip event: footstep.L/R, sound:<name>, a window edge (hit, hit.end, combo, cancel...) or any name a clip carries. info is { clip, time, layer } (layer "base" or "upper").

Functions and properties

Entity | Entity.act | Entity.aimAt | Entity.alert | Entity.anim | Entity.animate | Entity.animation | Entity.appear | Entity.attack | Entity.awareness | Entity.balance | Entity.block | Entity.board | Entity.boardState | Entity.body | Entity.breakable | Entity.burst | Entity.calm | Entity.carrying | Entity.character | Entity.clearEffects | Entity.clipWindows | Entity.color | Entity.combat | Entity.cooldown | Entity.crumple | Entity.dent | Entity.destroy | Entity.dismount | Entity.dissolve | Entity.distanceTo | Entity.dodge | Entity.drive | Entity.effect | Entity.emission | Entity.equip | Entity.equipped | Entity.exists | Entity.exposure | Entity.express | Entity.face | Entity.faceCue | Entity.field | Entity.flash | Entity.flashHit | Entity.flip | Entity.forward | Entity.frame | Entity.freeze | Entity.fx | Entity.gaze | Entity.give | Entity.giveWeapon | Entity.glass | Entity.glow | Entity.hangFrom | Entity.has | Entity.hasItem | Entity.heal | Entity.health | Entity.health2d | Entity.heat | Entity.hit | Entity.hitscan | Entity.hoist | Entity.holdFire | Entity.hurt | Entity.impulse | Entity.interaction | Entity.inventory | Entity.isLit | Entity.items | Entity.keep | Entity.keyDown | Entity.launch | Entity.layer | Entity.leaveBody | Entity.light | Entity.lightColor | Entity.litBy | Entity.litTargets | Entity.look | Entity.lookAt | Entity.magnet | Entity.magnetize | Entity.maxHealth | Entity.missile | Entity.motion | Entity.mount | Entity.move | Entity.name | Entity.opacity | Entity.openCreator | Entity.params | Entity.pathTo | Entity.pattern | Entity.perceive | Entity.physics | Entity.pickUp | Entity.play | Entity.playSound | Entity.playerName | Entity.pose | Entity.position | Entity.presses | Entity.projectile | Entity.push | Entity.pushAside | Entity.putDown | Entity.reload | Entity.ride | Entity.rig | Entity.rise | Entity.roomEnabled | Entity.rotation | Entity.save | Entity.say | Entity.scale | Entity.send | Entity.set | Entity.setField | Entity.setTile | Entity.shatter | Entity.shoot | Entity.sleep | Entity.sortOffset | Entity.sortWith | Entity.sprite | Entity.squash | Entity.stats | Entity.stopPatterns | Entity.strike | Entity.strikeGlass | Entity.stun | Entity.tag | Entity.tags | Entity.take | Entity.telegraph | Entity.throw | Entity.tile | Entity.toString | Entity.trail | Entity.unequip | Entity.unset | Entity.untag | Entity.velocity | Entity.walk | Entity.weapon | Entity.weaponTrail | Entity.wear | Entity.ySort | after | game.act | game.aim | game.ambience | game.apparition | game.apparitions | game.blackout | game.broadcast | game.burst | game.camera | game.cameraRoom | game.caption | game.cinematic25d | game.cinematic25dPlaying | game.clearSave | game.continueGame | game.controlSets | game.controls | game.crafting.check | game.crafting.craft | game.crafting.knows | game.crafting.learn | game.crafting.recipes | game.crtOff | game.cutscene | game.defineWeapon | game.deleteSlot | game.dialogue.active | game.dialogue.backlog | game.dialogue.choose | game.dialogue.next | game.dialogue.resume | game.dialogue.stop | game.driverReact | game.duck | game.earthquake | game.effectRecipe | game.equipWeapon | game.explode | game.exposure | game.fade | game.fail | game.feel | game.flash | game.flow.state | game.fx | game.glitch | game.hasSave | game.hitFeel | game.hud | game.hudWidget | game.impact | game.inventory | game.items.get | game.items.issues | game.items.list | game.items.reload | game.items.tagged | game.labTrial | game.language | game.languages | game.lighting2d | game.line | game.liveScreen | game.load | game.loadScene | game.loadSlot | game.look | game.loot.give | game.loot.roll | game.marker | game.mix | game.music | game.musicTime | game.newGame | game.nightVision | game.noise | game.objective | game.offhand | game.online | game.playCutscene | game.playSequence | game.player | game.players | game.profile.all | game.profile.get | game.profile.set | game.quests.advance | game.quests.complete | game.quests.fail | game.quests.journal | game.quests.list | game.quests.start | game.quests.state | game.quests.track | game.quests.tracked | game.rail | game.raiseWeapon | game.recoil | game.reloadWeapon | game.rightToLeft | game.roof | game.rumble | game.save | game.saveSlot | game.saves.autosave | game.saves.continueGame | game.saves.info | game.saves.list | game.saves.load | game.saves.remove | game.saves.restoreBackup | game.saves.save | game.saves.schema | game.saves.version | game.say | game.sayClear | game.scores.add | game.scores.best | game.scores.clear | game.scores.enterName | game.scores.qualifies | game.scores.show | game.scores.tables | game.scores.top | game.sequence | game.setLanguage | game.shake | game.shockwave | game.shoot | game.shooting | game.shops.buy | game.shops.info | game.shops.newDay | game.shops.open | game.shops.sell | game.show | game.signalLost | game.skipCutscene | game.slots | game.slowMotion | game.snapshot | game.sound | game.spawnPoint | game.state.add | game.state.all | game.state.flag | game.state.get | game.state.has | game.state.remove | game.state.set | game.stopCutscene | game.stopSequence | game.stopWorld | game.sun | game.t | game.talk | game.teleport | game.threat | game.time | game.timeOfDay | game.titleCard | game.tvStatic | game.ui | game.unshow | game.vhs | game.viewAssist | game.vn | game.voice | game.watch | game.watching | game.weapon | game.weaponData | game.weaponMagazine | game.weaponSupport | game.weaponView | game.win | input.action | input.actions | input.axis | input.device | input.family | input.glyph | input.isDown | input.mouseDown | input.pad | input.pointer | input.pointerRay | input.pressed | input.prompt | input.released | input.toScreen | input.value | input.wheel | log | random | world.all | world.copy | world.decal | world.equip | world.find | world.groundHeight | world.landSupport | world.lineOfSight | world.overlap2d | world.ray2d | world.raycast | world.spawn | world.spawnPrefab | world.sweep2d | world.unequip

<a id="script-entity"></a>

Entity(id)

Low-level constructor. id is an existing numeric entity ID, not a name. It wraps an ID; it does not create an object. Prefer world.find, world.all, or world.spawn.

Exact binding and defaults
Entity(id) { this.id = id; }

<a id="script-entity-act"></a>

Entity.act(action, target)

action is an action name such as open, close, lock, unlock, pick_up, use, enter, or exit. With a target entity (or numeric target ID), this entity is the actor. Without a target, this entity acts on itself with no actor. Returns {ok, reason}; inspect both rather than assuming the action succeeded.

Exact binding and defaults
Entity.act(action, target) {
        return target ? __act(target.id !== undefined ? target.id : target, String(action), this.id) : __act(this.id, String(action), -1);
      }

<a id="script-entity-aimat"></a>

Entity.aimAt(t, turn)

From the engine's script reference: .aimAt(target or [x, y], turn) aims (degrees a second, 0 at once) .shoot({ burst, telegraph, now }) fires; false while busy .holdFire(true or false)

Exact binding and defaults
Entity.aimAt(t, turn) { var o = at(t); if (o) { o.turn = turn || 0; __shoot2d(this.id, 'aim', o); } };

<a id="script-entity-alert"></a>

Entity.alert(at, amount)

at is an entity or [x,y,z] world point; amount is an optional suspicion amount, default 0. Alerts the entity's awareness system. A missing point does nothing. Returns nothing.

Exact binding and defaults
Entity.alert(at, amount) { var p = at && at.position ? at.position : at; if (p) __alert(this.id, p, amount === undefined ? 0 : amount); }

<a id="script-entity-anim"></a>

Entity.anim

Access: read.

From the engine's script reference: .anim the 2D animator's state (null without one); .anim.fire(trigger), .anim.set(param, value)

Exact binding and defaults
get Entity.anim() {
        var id = this.id, s = __anim(id);
        if (s === undefined || s === null) return null;
        s.fire = function (t) { __animCmd(id, 'fire', String(t), null); };
        s.set = function (k, v) { __animCmd(id, 'set', String(k), v); };
        s.play = function (state) { __animCmd(id, 'play', String(state), null); };   // forces a state (3D animator states)
        return s;
      }

<a id="script-entity-animate"></a>

Entity.animate(clip, loop)

clip is an animation name; an omitted or empty name uses auto. loop is a boolean, default false. Changes an existing animator; auto returns to automatic movement animation. A one-shot holds its last frame. Returns nothing.

Exact binding and defaults
Entity.animate(clip, loop) { __animate(this.id, String(clip || 'auto'), !!loop); }

<a id="script-entity-animation"></a>

Entity.animation

Access: read.

From the engine's script reference: .animation the playing 3D clip's state, or null .motion the motion brain's state; .motion.play(move), .motion.emotion(e, seconds)

Exact binding and defaults
get Entity.animation() { var a = __animation(this.id); return a === undefined ? null : a; }

<a id="script-entity-appear"></a>

Entity.appear(seconds, color)

From the engine's script reference: .flash(color, seconds, strength) a hit flash .dissolve(seconds, color) burns away and stays gone .appear(seconds, color) burns in

Exact binding and defaults
Entity.appear(seconds, color) { __fx2d(this.id, 'appear', color || [0.5, 0.8, 1], seconds === undefined ? 0.6 : seconds, 1); };

<a id="script-entity-attack"></a>

Entity.attack(move)

From the engine's script reference: .attack("move") / .block(true or false) / .dodge() a combatant's moves (true if it started) .combat its fight state, or null

Exact binding and defaults
Entity.attack(move) { var r = __combat(this.id, 'attack', JSON.stringify({move:String(move)})); return !!(r && r.ok); }

<a id="script-entity-awareness"></a>

Entity.awareness

Access: read.

Read-only awareness snapshot or null. Contains state, suspicion, seeing, point, target, lastSeen, lastHeard, since, arrived and why. target is converted to an Entity or null.

Exact binding and defaults
get Entity.awareness() {
        var a = __awareness(this.id);
        if (!a) return null;
        a.target = a.target >= 0 ? new Entity(a.target) : null;
        return a;
      }

<a id="script-entity-balance"></a>

Entity.balance

Access: read.

Read-only balance snapshot or null: sway, swaySpeed, recoverySteps, bumps, pushed, and pushing.

Exact binding and defaults
get Entity.balance() { var b = __balance(this.id); return b === undefined ? null : b; }

<a id="script-entity-block"></a>

Entity.block(on)

From the engine's script reference: .attack("move") / .block(true or false) / .dodge() a combatant's moves (true if it started) .combat its fight state, or null

Exact binding and defaults
Entity.block(on) { var r = __combat(this.id, 'block', JSON.stringify({enabled:!!on})); return !!(r && r.ok); }

<a id="script-entity-board"></a>

Entity.board(o)

From the engine's script reference: .board({kind: "skate" | "snow" | "surf" | "bmx" | "hover", ...settings}) makes it a board to ride; '' when ready

Exact binding and defaults
Entity.board(o) { var r = __board(this.id, 'make', JSON.stringify(o || {})); return (r && r.error) || ''; }

<a id="script-entity-boardstate"></a>

Entity.boardState()

From the engine's script reference: .boardState() {kind, phase "rolling" | "air" | "grinding" | "down", speed, lean, grind, down, rider} or null; events board_jumped, board_landed, board_grind, board_grind_end, board_down

Exact binding and defaults
Entity.boardState() { var r = __board(this.id, 'state', '{}'); return (r && r.state) || null; }

<a id="script-entity-body"></a>

Entity.body

Access: read.

Read-only 2D-body state or null. Includes movement/contact fields such as vx, vy, grounded, wall, ceiling, onLadder, climbing, ledge, and facing.

Exact binding and defaults
get Entity.body() { var v = __body2d(this.id); return v === undefined ? null : v; }

<a id="script-entity-breakable"></a>

Entity.breakable(material, anchored)

From the engine's script reference: .breakable(material, anchored) makes it breakable from its pre-cut chunks (f.fracture): material "concrete", "stone", "plaster", "ceramic", "glass", "wood", "plastic" or "metal"; '' when ready, else why not. Hits then break it where they land: lone chunks fly, what still holds together stays one piece (breakable again), what stands on the base stays put. A "broken" message goes to every script ({name, pieces, chunks, impulse, x, y, z}).

Exact binding and defaults
Entity.breakable(material, anchored) { return __breakable(this.id, material || 'concrete', anchored === undefined ? [] : [anchored ? 1 : 0]); }

<a id="script-entity-burst"></a>

Entity.burst(kind, dir)

From the engine's script reference: .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach })

Exact binding and defaults
Entity.burst(kind, dir) { __feel('burst', this.id, { kind: String(kind || 'spark'), dir: dir || 1 }); }

<a id="script-entity-calm"></a>

Entity.calm()

Returns an awareness-controlled entity to its calm/patrol behavior. Returns nothing; it is not a movement command.

Exact binding and defaults
Entity.calm() { __calm(this.id); }

<a id="script-entity-carrying"></a>

Entity.carrying

Access: read.

From the engine's script reference: .carrying what it holds (null) .weapon its 2D weapon's state (null) .inventory its bag (items: add, remove, count, info)

Exact binding and defaults
get Entity.carrying() def('carrying', function () { var b = __body2d(this.id); return b && b.carrying >= 0 ? new Entity(b.carrying) : null; });

<a id="script-entity-character"></a>

Entity.character

Access: read.

Read-only player snapshot or null: speed, sprint_speed, view, crouching, gait, grounded, can_sprint, moving (horizontal meters per second).

Exact binding and defaults
get Entity.character() { var c = __character(this.id); return c === undefined ? null : c; }

<a id="script-entity-cleareffects"></a>

Entity.clearEffects()

From the engine's script reference: .heat(amount, seconds) a heat-shimmer pulse (world units) .clearEffects() ends them all

Exact binding and defaults
Entity.clearEffects() { __fx2d(this.id, 'clear', [0, 0, 0], 0, 0); };

<a id="script-entity-clipwindows"></a>

Entity.clipWindows

Access: read.

From the engine's script reference: carries (clip_events adds them). .clipWindows → the windows open now, e.g. ["combo", "hit:hand.R"]

Exact binding and defaults
get Entity.clipWindows() { return __clipWindows(this.id); }

<a id="script-entity-color"></a>

Entity.color

Access: read, write.

From the engine's script reference: .color / .emission / .lightColor read or assign [r, g, b] (0...1) on its model, glow or light

Exact binding and defaults
get Entity.color() { return __meshColor(this.id); }
set Entity.color(v) { __setMeshColor(this.id, v); }

<a id="script-entity-combat"></a>

Entity.combat

Access: read.

From the engine's script reference: .attack("move") / .block(true or false) / .dodge() a combatant's moves (true if it started) .combat its fight state, or null

Exact binding and defaults
get Entity.combat() { var c = __combat(this.id, 'state', '{}'); return c === undefined ? null : c; }

<a id="script-entity-cooldown"></a>

Entity.cooldown(name, seconds)

name is a cooldown key and seconds its duration, default 0. Returns true when ready and starts the cooldown again; false while cooling down (also false without editable stats). Requires a stats component for a useful cooldown.

Exact binding and defaults
Entity.cooldown(name, seconds) { return !!__cooldown(this.id, String(name), seconds || 0); }

<a id="script-entity-crumple"></a>

Entity.crumple(o)

From the engine's script reference: .crumple({energy, cell, collider}) makes it crumple (a junk car, a drum): hits dent it, a press crushes it; '' when ready

Exact binding and defaults
Entity.crumple(o) { o = o || {};
        return __crumple(this.id, [o.energy || 0, o.cell || 0, o.collider === false ? 0 : 1]); }

<a id="script-entity-dent"></a>

Entity.dent(at, impulse, o)

From the engine's script reference: .dent([x, y, z], [ix, iy, iz], {mass, size}) a blow that dents it; how deep (m), -1 when it doesn't crumple

Exact binding and defaults
Entity.dent(at, impulse, o) { o = o || {}; return __dent(this.id, at, impulse, [o.mass || 8, o.size || 0.06]); }

<a id="script-entity-destroy"></a>

Entity.destroy()

Removes this object from the play world. Returns nothing. Its script handlers are dropped at the next safe tick; already scheduled timers can still run.

Exact binding and defaults
Entity.destroy() { __destroy(this.id); }

<a id="script-entity-dismount"></a>

Entity.dismount()

From the engine's script reference: .mount(character) puts a rider on it .dismount() .ride({steer, push, brake, jump, spin}) a script's or bot's controls

Exact binding and defaults
Entity.dismount() { __board(this.id, 'dismount', '{}'); }

<a id="script-entity-dissolve"></a>

Entity.dissolve(seconds, color)

From the engine's script reference: .flash(color, seconds, strength) a hit flash .dissolve(seconds, color) burns away and stays gone .appear(seconds, color) burns in

Exact binding and defaults
Entity.dissolve(seconds, color) { __fx2d(this.id, 'dissolve', color || [1, 0.55, 0.18], seconds === undefined ? 0.8 : seconds, 1); };

<a id="script-entity-distanceto"></a>

Entity.distanceTo(o)

o is another entity. Returns the distance between their positions in meters. Neither entity is automatically checked for existence.

Exact binding and defaults
Entity.distanceTo(o) { var a = this.position, b = o.position; return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]); }

<a id="script-entity-dodge"></a>

Entity.dodge()

From the engine's script reference: .attack("move") / .block(true or false) / .dodge() a combatant's moves (true if it started) .combat its fight state, or null

Exact binding and defaults
Entity.dodge() { var r = __combat(this.id, 'dodge', '{}'); return !!(r && r.ok); }

<a id="script-entity-drive"></a>

Entity.drive(o)

From the engine's script reference: .drive({throttle, steer, brake, handbrake}) drives a car from a script this tick (call it every tick: a sumo bot, a chase car; throttle -1...1, below 0 brakes then reverses; steer -1 left ... 1 right) → '' or why not (a player or an ai_driver in it)

Exact binding and defaults
Entity.drive(o) { o = o || {}; return __drive(this.id, [o.throttle || 0, o.steer || 0, o.brake || 0, o.handbrake ? 1 : 0]); }

<a id="script-entity-effect"></a>

Entity.effect(kind, seconds, amount)

kind names a stats effect; seconds defaults to 0 and amount to 0. For example, stun freezes control and slow/haste scale speed by amount. Requires appropriate stats; returns nothing. See Stats.swift for effect handling.

Exact binding and defaults
Entity.effect(kind, seconds, amount) { __effect(this.id, String(kind), seconds || 0, amount === undefined ? 0 : amount); }

<a id="script-entity-emission"></a>

Entity.emission

Access: read, write.

From the engine's script reference: .color / .emission / .lightColor read or assign [r, g, b] (0...1) on its model, glow or light

Exact binding and defaults
get Entity.emission() { return __emission(this.id); }
set Entity.emission(v) { __setEmission(this.id, v); }

<a id="script-entity-equip"></a>

Entity.equip(a, b)

From the engine's script reference: .equip("slot", "item") or .equip("item") wears or holds an item (the reply says what, or why not) .unequip("slot") .equipped() what it wears

Exact binding and defaults
Entity.equip(a, b) { return JSON.parse(b === undefined ? __equip(this.id, String(a), '') : __equip(this.id, String(b), String(a))); }

<a id="script-entity-equipped"></a>

Entity.equipped()

From the engine's script reference: .equip("slot", "item") or .equip("item") wears or holds an item (the reply says what, or why not) .unequip("slot") .equipped() what it wears

Exact binding and defaults
Entity.equipped() { return JSON.parse(__equipped(this.id)); }

<a id="script-entity-exists"></a>

Entity.exists

Access: read.

Read-only boolean indicating whether the entity still exists in the play world.

Exact binding and defaults
get Entity.exists() { return __exists(this.id); }

<a id="script-entity-exposure"></a>

Entity.exposure

Access: read.

Read-only light exposure from 0 (black) to 1 (bright).

Exact binding and defaults
get Entity.exposure() { return __exposureOf(this.id); }

<a id="script-entity-express"></a>

Entity.express(name, intensity)

From the engine's script reference: .express("scared", 0.8) face: happy, angry, sad, scared, surprised, pain, effort, disgusted, worried, determined, thinking, tired, smirk, contempt, laugh, shout... or a blend "happy:0.6, surprised:0.4"; eased in and out by the face

Exact binding and defaults
Entity.express(name, intensity) { __express(this.id, String(name || 'neutral'), intensity === undefined ? 1 : intensity); }

<a id="script-entity-face"></a>

Entity.face(target)

target is an entity or world [x,y,z]. Changes heading, including a player's view. A missing/null target does nothing. Returns nothing. Prefer this for turning a player.

Exact binding and defaults
Entity.face(target) { var t = target && target.position ? target.position : target; if (t) __face(this.id, t); }

<a id="script-entity-facecue"></a>

Entity.faceCue(name, intensity, seconds)

From the engine's script reference: .faceCue("effort", 1, 0.4) a short face event: "effort" while firing/reloading (held seconds), "pain" a flinch (hits flinch on their own), or any emotion as a quick flash. Eyes, blinks, breathing and glances are automatic.

Exact binding and defaults
Entity.faceCue(name, intensity, seconds) { __faceCue(this.id, String(name), intensity === undefined ? 1 : intensity, seconds || 0); }

<a id="script-entity-field"></a>

Entity.field(path)

From the engine's script reference: .field("light_2d.color") / .setField("light_2d.intensity", 0) read or set any 2D component field (light_2d, material_2d, occluder_2d, sprite, backdrop_2d, particles_2d)

Exact binding and defaults
Entity.field(path) { var v = __field2d(this.id, String(path)); return v === undefined ? null : v; };

<a id="script-entity-flash"></a>

Entity.flash(color, seconds, strength)

From the engine's script reference: .flash(color, seconds, strength) a hit flash .dissolve(seconds, color) burns away and stays gone .appear(seconds, color) burns in

Exact binding and defaults
Entity.flash(color, seconds, strength) { __fx2d(this.id, 'flash', color || [1, 1, 1], seconds === undefined ? 0.12 : seconds, strength === undefined ? 1 : strength); };

<a id="script-entity-flashhit"></a>

Entity.flashHit(seconds, color)

From the engine's script reference: Feel: .flashHit(seconds, color) white hit flash .freeze(seconds) hit-stop .squash(amount, seconds) .trail(seconds, every) after-images .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach }) 3D blades: a blade_trail component on the sword (base, tip, color, life, min_speed) leaves a trail of light along a cut; .set("blade_trail.intensity", 2) for a heavy blow

Exact binding and defaults
Entity.flashHit(seconds, color) { __feel('flash', this.id, { seconds: seconds === undefined ? 0.08 : seconds, color: color || [1, 1, 1] }); }

<a id="script-entity-flip"></a>

Entity.flip

Access: write.

Write-only sprite horizontal-flip flag. Assign a boolean.

Exact binding and defaults
set Entity.flip(v) { __setSprite2d(this.id, 'flip', v ? 1 : 0); }

<a id="script-entity-forward"></a>

Entity.forward

Access: read.

Read-only direction derived from yaw: [-sin(yaw),0,-cos(yaw)]. It does not include pitch.

Exact binding and defaults
get Entity.forward() { var y = this.rotation[1] * Math.PI / 180; return [-Math.sin(y), 0, -Math.cos(y)]; }

<a id="script-entity-frame"></a>

Entity.frame

Access: write.

Write-only sprite frame. Assigning it clamps below at 0 and clears the current animation clip.

Exact binding and defaults
set Entity.frame(v) { __setSprite2d(this.id, 'frame', v); }

<a id="script-entity-freeze"></a>

Entity.freeze(seconds)

From the engine's script reference: Feel: .flashHit(seconds, color) white hit flash .freeze(seconds) hit-stop .squash(amount, seconds) .trail(seconds, every) after-images .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach }) 3D blades: a blade_trail component on the sword (base, tip, color, life, min_speed) leaves a trail of light along a cut; .set("blade_trail.intensity", 2) for a heavy blow

Exact binding and defaults
Entity.freeze(seconds) { __feel('freeze', this.id, { seconds: seconds === undefined ? 0.05 : seconds }); }

<a id="script-entity-fx"></a>

Entity.fx(name, options)

From the engine's script reference: .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach })

Exact binding and defaults
Entity.fx(name, options) { var o = options || {}; return __feel('fx', this.id, { name: String(name), at: o.at, dir: o.dir, strength: o.strength === undefined ? 1 : o.strength, attach: o.attach !== false }); }

<a id="script-entity-gaze"></a>

Entity.gaze(target)

From the engine's script reference: .lookAt(entity or [x, y, z]) turns to face it, eyes and head following; .gaze(entity or [x, y, z]) eyes and head only; null (either) looks ahead again

Exact binding and defaults
Entity.gaze(target) { __lookAt(this.id, target === undefined || target === null ? null : (target.id !== undefined ? target.id : target)); }

<a id="script-entity-give"></a>

Entity.give(item, n)

item is an inventory key; n is the quantity, default 1. Adds items through the inventory system. Returns nothing.

Exact binding and defaults
Entity.give(item, n) { __give(this.id, String(item), n === undefined ? 1 : n); }

<a id="script-entity-giveweapon"></a>

Entity.giveWeapon(name, ammo, equip)

From the engine's script reference: .reload() .giveWeapon(name, ammo, equip) .telegraph(seconds, color) a laser sight and glint, nothing fired

Exact binding and defaults
Entity.giveWeapon(name, ammo, equip) { return !!__shoot2d(this.id, 'give', { name: String(name), ammo: ammo || 0, equip: equip !== false }); };

<a id="script-entity-glass"></a>

Entity.glass(o)

From the engine's script reference: .glass({strength}) its panes break into shards where struck .strikeGlass([x, y, z], [ix, iy, iz], {mass}) a blow on its glass

Exact binding and defaults
Entity.glass(o) { o = o || {}; return __glass(this.id, [o.strength || 0]); }

<a id="script-entity-glow"></a>

Entity.glow

Access: read, write.

Read or assign the mesh's self-glow through the play bridge.

Exact binding and defaults
get Entity.glow() { return __glow(this.id); }
set Entity.glow(v) { __setGlow(this.id, v); }

<a id="script-entity-hangfrom"></a>

Entity.hangFrom(owner, at, o)

From the engine's script reference: .hangFrom(owner, [x, y, z], {length, top, cable, cable_length}) hangs it on a line from a point on owner (a name; '' a world point): a wrecking ball from a crane's boom tip .hoist(length) its line's new length (m)

Exact binding and defaults
Entity.hangFrom(owner, at, o) { o = o || {}; var t = o.top || [0, 0, 0];
        return __hangFrom(this.id, owner || '', at, [o.length || 0, t[0], t[1], t[2], o.cable_length || 1], o.cable || ''); }

<a id="script-entity-has"></a>

Entity.has(tag)

tag is a string matched against the entity's tags. Returns a boolean.

Exact binding and defaults
Entity.has(tag) { return this.tags.indexOf(tag) >= 0; }

<a id="script-entity-hasitem"></a>

Entity.hasItem(item, n)

item is an inventory key and n the required quantity, default 1. Returns whether the inventory holds at least that many.

Exact binding and defaults
Entity.hasItem(item, n) { return (__inventory(this.id)[item] || 0) >= (n === undefined ? 1 : n); }

<a id="script-entity-heal"></a>

Entity.heal(n)

n is the health amount, default 0. Returns the health after the change, or null without stats. Health is bounded by the stats system; use non-negative amounts for healing.

Exact binding and defaults
Entity.heal(n) { var h = __health(this.id, n || 0); return h === undefined ? null : h; }

<a id="script-entity-health"></a>

Entity.health

Access: read.

From the engine's script reference: .health → the health alone, or null (one number: cheaper than .stats.health in a loop over many objects)

Exact binding and defaults
get Entity.health() { var h = __feel('health', this.id, {}); return h === undefined ? null : h; }

<a id="script-entity-health2d"></a>

Entity.health2d

Access: read.

From the engine's script reference: .health / .maxHealth (.health2d the same) its health, or null without one

Exact binding and defaults
get Entity.health2d() { var h = __feel('health', this.id, {}); return h === undefined ? null : h; }

<a id="script-entity-heat"></a>

Entity.heat(amount, seconds)

From the engine's script reference: .heat(amount, seconds) a heat-shimmer pulse (world units) .clearEffects() ends them all

Exact binding and defaults
Entity.heat(amount, seconds) { __fx2d(this.id, 'heat', [0, 0, 0], seconds === undefined ? 1.5 : seconds, amount === undefined ? 6 : amount); };

<a id="script-entity-hit"></a>

Entity.hit(target, options)

From the engine's script reference: .hit(target, { damage, knockback }) a 2D hit on another entity

Exact binding and defaults
Entity.hit(target, options) { __hit2d(this.id, target && target.id !== undefined ? target.id : target, options || {}); }

<a id="script-entity-hitscan"></a>

Entity.hitscan(options)

From the engine's script reference: .hitscan({ range, damage, spread }) / .projectile({ speed, damage, model }) / .missile({ target, speed, turn }) fire from it

Exact binding and defaults
Entity.hitscan(options) { return __combat(this.id, 'hitscan', JSON.stringify(options || {})); }

<a id="script-entity-hoist"></a>

Entity.hoist(length)

From the engine's script reference: point): a wrecking ball from a crane's boom tip .hoist(length) its line's new length (m)

Exact binding and defaults
Entity.hoist(length) { __hoist(this.id, [length]); }

<a id="script-entity-holdfire"></a>

Entity.holdFire(on)

From the engine's script reference: .aimAt(target or [x, y], turn) aims (degrees a second, 0 at once) .shoot({ burst, telegraph, now }) fires; false while busy .holdFire(true or false)

Exact binding and defaults
Entity.holdFire(on) { __shoot2d(this.id, 'hold', { on: on !== false }); };

<a id="script-entity-hurt"></a>

Entity.hurt(n)

n is the damage amount, default 0. Returns the remaining health, or null without stats. Use non-negative amounts for damage.

Exact binding and defaults
Entity.hurt(n) { var h = __health(this.id, -(n || 0)); return h === undefined ? null : h; }

<a id="script-entity-impulse"></a>

Entity.impulse(v, at)

v is [x,y,z] impulse in newton-seconds. Optional at is a world-space application point; omitted means no explicit point. Returns nothing. Requires an object the physics bridge can affect.

Exact binding and defaults
Entity.impulse(v, at) { __impulse(this.id, v, at || []); }

<a id="script-entity-interaction"></a>

Entity.interaction

Access: read.

Read-only interactable state or null: kind, open, locked, angle, and busy.

Exact binding and defaults
get Entity.interaction() { var s = __interaction(this.id); return s === undefined ? null : s; }

<a id="script-entity-inventory"></a>

Entity.inventory

Access: read.

From the engine's script reference: .carrying what it holds (null) .weapon its 2D weapon's state (null) .inventory its bag (items: add, remove, count, info)

Exact binding and defaults
get Entity.inventory() Object.defineProperty(Entity.prototype, 'inventory', { get: function () { return new Bag(this.id); }, configurable: true });

<a id="script-entity-islit"></a>

Entity.isLit(threshold)

threshold defaults to 0.08. Returns whether the entity's measured exposure is at least that number.

Exact binding and defaults
Entity.isLit(threshold) { return __exposureOf(this.id) >= (threshold === undefined ? 0.08 : threshold); }

<a id="script-entity-items"></a>

Entity.items

Access: read.

Read-only inventory snapshot mapping item keys to counts. Use give/take to change the inventory.

Exact binding and defaults
get Entity.items() { return __inventory(this.id); }

<a id="script-entity-keep"></a>

Entity.keep(a, b)

From the engine's script reference: .keep: self.keep(K, ['day', 'hour']) in onStart: those fields of an object are saved and put back with no more code;

Exact binding and defaults
Entity.keep(a, b) {
        var get = typeof a === 'function' ? a : function () { var o = {}; b.forEach(function (k) { o[k] = a[k]; }); return o; };
        var set = typeof a === 'function' ? (b || function () {}) : function (s) { b.forEach(function (k) { if (s[k] !== undefined) a[k] = s[k]; }); };
        var n = 0; __keeps.forEach(function (k) { if (k.id === this.id) n += 1; }, this);
        __keeps.push({ id: this.id, n: n, get: get, set: set });
      }

<a id="script-entity-keydown"></a>

Entity.keyDown(key)

From the engine's script reference: Online: .playerName the joined player's name ("" for a non-player) .keyDown("E") that player's key (each joined player has their own keys)

Exact binding and defaults
Entity.keyDown(key) { return __keyOf(this.id, String(key)); }

<a id="script-entity-launch"></a>

Entity.launch(v)

v is [x,up,z] velocity in meters per second. Throws a player through its movement system, for example from a bounce pad. Returns nothing.

Exact binding and defaults
Entity.launch(v) { __launch(this.id, v); }

<a id="script-entity-layer"></a>

Entity.layer

Access: read.

From the engine's script reference: .layer / .ySort / .sortOffset / .sortWith a sprite's draw order (read or assign) .roomEnabled = false turns its 2D room off

Exact binding and defaults
get Entity.layer() def('layer', function () { var v = __sort2d(this.id); return v ? v.layer : null; }, function (v) { __setSort2d(this.id, 'layer', v); });

<a id="script-entity-leavebody"></a>

Entity.leaveBody(clip, seconds)

clip is a death animation or ragdoll; omitted/empty keeps the current animation choice. seconds defaults to 12; 0 keeps the body. Replaces an animated character with a body and destroys the original. Returns a numeric body ID, or -1 on failure—not an Entity wrapper.

Exact binding and defaults
Entity.leaveBody(clip, seconds) { return __leaveBody(this.id, String(clip || ''), seconds === undefined ? 12 : seconds); }

<a id="script-entity-light"></a>

Entity.light

Access: read, write.

Read or assign point-light intensity. The bridge reports -1 when the entity has no point light. Setting it does not create a light component.

Exact binding and defaults
get Entity.light() { return __light(this.id); }
set Entity.light(v) { __setLight(this.id, v); }

<a id="script-entity-lightcolor"></a>

Entity.lightColor

Access: read, write.

From the engine's script reference: .color / .emission / .lightColor read or assign [r, g, b] (0...1) on its model, glow or light

Exact binding and defaults
get Entity.lightColor() { return __lightColor(this.id); }
set Entity.lightColor(v) { __setLightColor(this.id, v); }

<a id="script-entity-litby"></a>

Entity.litBy(tag)

From the engine's script reference: .litBy(tag) how strongly lights tagged tag fall on it (0 none ... 1 full)

Exact binding and defaults
Entity.litBy(tag) { return __litBy(this.id, String(tag || '')); }

<a id="script-entity-littargets"></a>

Entity.litTargets(tag)

From the engine's script reference: Light: .litTargets(tag) what its light (spot or flashlight) falls on: [{ entity, distance, strength, point }], tag to filter .litBy(tag) how strongly lights tagged tag fall on it (0 none ... 1 full)

Exact binding and defaults
Entity.litTargets(tag) { var s = __litTargets(this.id, String(tag || '')); return (s ? JSON.parse(s) : []).map(function (h) { return { entity: new Entity(h.id), distance: h.distance, strength: h.strength, point: h.point }; }); }

<a id="script-entity-look"></a>

Entity.look

Access: read, write.

From the engine's script reference: .look the character-creator look it wears ({ body: { height: 0.7, ... }, face: { jaw: 0.4, ... }, skin_tone, hair, hair_color, eye_color }; null: a model file); set it, or .wear(look) (true, or why not), to dress anyone in one

Exact binding and defaults
get Entity.look() { var s = __look(this.id); return s ? JSON.parse(s) : null; }
set Entity.look(v) { __wearLook(this.id, typeof v === 'string' ? v : JSON.stringify(v)); }

<a id="script-entity-lookat"></a>

Entity.lookAt(target)

target must be an entity or [x,y,z]. In this revision the last lookAt declaration wins: it changes transform yaw while keeping the other rotation axes. It does not use the earlier head/eye-tracking binding. Passing null throws; there is no null reset here. Returns nothing. Use face when the player's view should turn too.

Exact binding and defaults
Entity.lookAt(target) {
        if (target === undefined || target === null) { __lookAt(this.id, null); return; }
        var t = target.position ? target.position : target, p = this.position, r = this.rotation;
        if (!t || !p) return;
        this.rotation = [r[0], Math.atan2(-(t[0] - p[0]), -(t[2] - p[2])) * 180 / Math.PI, r[2]];
        __lookAt(this.id, target.id !== undefined ? target.id : t);
      }

<a id="script-entity-magnet"></a>

Entity.magnet(o)

From the engine's script reference: .magnet({strength, reach, grip, radius, most, face, normal}) a lifting electromagnet; '' when ready

Exact binding and defaults
Entity.magnet(o) { o = o || {};
        return __magnet(this.id, [o.strength || 0, o.reach || 0, o.grip || 0, o.radius || 0, o.most || 0], o.face || [], o.normal || []); }

<a id="script-entity-magnetize"></a>

Entity.magnetize(on)

From the engine's script reference: .magnetize(on) on pulls and holds the metal near its face, off drops it; how many it holds

Exact binding and defaults
Entity.magnetize(on) { return __magnetize(this.id, [on === false ? 0 : 1]); }

<a id="script-entity-maxhealth"></a>

Entity.maxHealth

Access: read.

From the engine's script reference: .health / .maxHealth (.health2d the same) its health, or null without one

Exact binding and defaults
get Entity.maxHealth() { var h = __feel('maxHealth', this.id, {}); return h === undefined ? null : h; }

<a id="script-entity-missile"></a>

Entity.missile(options)

From the engine's script reference: .hitscan({ range, damage, spread }) / .projectile({ speed, damage, model }) / .missile({ target, speed, turn }) fire from it

Exact binding and defaults
Entity.missile(options) { return __missile(this.id, JSON.stringify(options || {})); }

<a id="script-entity-motion"></a>

Entity.motion

Access: read.

From the engine's script reference: .animation the playing 3D clip's state, or null .motion the motion brain's state; .motion.play(move), .motion.emotion(e, seconds)

Exact binding and defaults
get Entity.motion() {
        var id = this.id, s = __motion(id, 'state', '', null);
        if (s === undefined || s === null) return null;
        s.play = function (m) { return !!__motion(id, 'play', String(m), null); };
        s.emotion = function (e, seconds) { __motion(id, 'emotion', e ? String(e) : '', seconds === undefined ? null : seconds); };
        s.say = function (text, seconds) { __motion(id, 'say', String(text === undefined ? '' : text), seconds === undefined ? null : seconds); };
        s.talk = function (on) { __motion(id, on === false ? 'quiet' : 'say', '', null); };
        s.aim = function (deg) { __motion(id, 'aim', '', deg === undefined || deg === null ? null : deg); };
        s.lookAt = function (p) { __rig(id, 'look', '', p && p.position ? p.position : (p || null)); };
        s.die = function (dir) { __motion(id, 'die', '', dir === undefined ? -1 : dir); };
        s.hurt = function (dir) { __motion(id, 'hurt', '', dir === undefined ? -1 : dir); };
        return s;
      }

<a id="script-entity-mount"></a>

Entity.mount(who)

From the engine's script reference: .mount(character) puts a rider on it .dismount() .ride({steer, push, brake, jump, spin}) a script's or bot's controls

Exact binding and defaults
Entity.mount(who) { var r = __board(this.id, 'mount', JSON.stringify({ rider: who && who.id !== undefined ? who.id : who })); return (r && r.error) || ''; }

<a id="script-entity-move"></a>

Entity.move(d)

d is [dx,dy,dz] in meters. Adds it directly to position and returns nothing. This does not perform the collision-aware movement of walk.

Exact binding and defaults
Entity.move(d) { var p = this.position; this.position = [p[0] + d[0], p[1] + d[1], p[2] + d[2]]; }

<a id="script-entity-name"></a>

Entity.name

Access: read.

Read-only name string.

Exact binding and defaults
get Entity.name() { return __name(this.id); }

<a id="script-entity-opacity"></a>

Entity.opacity

Access: write.

Write-only sprite opacity. The native setter clamps it to 0 through 1.

Exact binding and defaults
set Entity.opacity(v) { __setSprite2d(this.id, 'opacity', v); }

<a id="script-entity-opencreator"></a>

Entity.openCreator(options)

From the engine's script reference: .openCreator({ title, cancel }) a player: the character creator screen (Body, Face, Skin, Hair, Eyes, Presets); 'creator_done' { look } when they finish (they wear it; the run keeps it in every scene and save), 'creator_cancel'

Exact binding and defaults
Entity.openCreator(options) { return __openCreator(this.id, JSON.stringify(options || {})); }

<a id="script-entity-params"></a>

Entity.params

Access: read.

Mutable, cached object parsed from script.params entries such as speed=2. Numeric-looking values become numbers; other values remain strings. The parsed object is shared by the scripts on this entity.

Exact binding and defaults
get Entity.params() {                                     // parsed once per object, so scripts can change them (upgrades)
        if (!__paramCache[this.id]) __paramCache[this.id] = __parseParams(__params[this.id]);
        return __paramCache[this.id];
      }

<a id="script-entity-pathto"></a>

Entity.pathTo(target, radius)

target is an entity or world point. radius is a clearance radius in meters, default 0.4 (zero also selects that default). Returns a list of world points, null when no route is available, or false when this tick's search quota is exhausted. Retry false on a later tick, not in a tight loop. PlaySession allows three script path searches per tick across the session.

Exact binding and defaults
Entity.pathTo(target, radius) { var t = target.position ? target.position : target; return __path(this.id, t, radius || 0.4); }

<a id="script-entity-pattern"></a>

Entity.pattern(kind, o)

From the engine's script reference: .pattern("spiral", { count, speed, interval, duration, turn, arc, bursts, weapon }) a bullet pattern .stopPatterns()

Exact binding and defaults
Entity.pattern(kind, o) { var r = __shoot2d(this.id, 'pattern', Object.assign({ kind: String(kind) }, o || {})); return r === undefined ? null : r; };

<a id="script-entity-perceive"></a>

Entity.perceive()

Returns the perception verdict: hunt, hold, flee, or idle. It is a decision, not a movement command; the script must act on it.

Exact binding and defaults
Entity.perceive() { return __perceive(this.id); }

<a id="script-entity-physics"></a>

Entity.physics(o)

From the engine's script reference: .physics({velocity, spin, drag, lift, rolling, surface, fast}) sports physics (a pitched ball): sets what's given, returns {velocity, spin, speed, rpm, drag, lift, rolling, fast, friction, restitution}; null without a body

Exact binding and defaults
Entity.physics(o) { var r = __physics(this.id, JSON.stringify(o || {})); return r === undefined ? null : r; }

<a id="script-entity-pickup"></a>

Entity.pickUp(item)

From the engine's script reference: .pickUp(item) / .putDown() / .throw(speed) carry a 2D object (true if it worked)

Exact binding and defaults
Entity.pickUp(item) { return !!__pickUp2d(this.id, item ? item.id : -1); };

<a id="script-entity-play"></a>

Entity.play(clip, restart)

clip is a sprite-animation name and restart a boolean, default false. Applies to a sprite; requesting its current clip does not restart it unless restart is true. Returns nothing. Use animate for skeletal animation instead.

Exact binding and defaults
Entity.play(clip, restart) { __play(this.id, String(clip), !!restart); }

<a id="script-entity-playsound"></a>

Entity.playSound(name, volume, pitch)

name is a sound key, volume defaults to 1, and pitch to 1 (zero also selects 1). Plays at this entity's position. Returns nothing; unlike game.sound, this wrapper discards the native success boolean.

Exact binding and defaults
Entity.playSound(name, volume, pitch) { __sound(String(name), this.position, volume === undefined ? 1 : volume, pitch || 1); }

<a id="script-entity-playername"></a>

Entity.playerName

Access: read.

From the engine's script reference: Online: .playerName the joined player's name ("" for a non-player) .keyDown("E") that player's key (each joined player has their own keys)

Exact binding and defaults
get Entity.playerName() { return __playerName(this.id); }

<a id="script-entity-pose"></a>

Entity.pose(move, turn, pivot)

From the engine's script reference: .rig the 2D rig's state; .rig.play(clip), .rig.attach(bone, picture) .pose(move, turn, pivot) offsets the drawn pose (metres, degrees)

Exact binding and defaults
Entity.pose(move, turn, pivot) { __pose(this.id, move || [0, 0, 0], turn || [0, 0, 0], pivot || [0, 0, 0]); }

<a id="script-entity-position"></a>

Entity.position

Access: read, write.

Read or assign [x,y,z] in world meters. Assigning position is direct placement, not collision-aware walking.

Exact binding and defaults
get Entity.position() { return __getPosition(this.id); }
set Entity.position(v) { __setPosition(this.id, v); }

<a id="script-entity-presses"></a>

Entity.presses(on)

From the engine's script reference: .presses(on) a kinematic body (a crusher's plate) crushes what crumples where it moves; presses(false) stops

Exact binding and defaults
Entity.presses(on) { return __presses(this.id, [on === false ? 0 : 1]); }

<a id="script-entity-projectile"></a>

Entity.projectile(options)

From the engine's script reference: .hitscan({ range, damage, spread }) / .projectile({ speed, damage, model }) / .missile({ target, speed, turn }) fire from it

Exact binding and defaults
Entity.projectile(options) { return __combat(this.id, 'projectile', JSON.stringify(options || {})); }

<a id="script-entity-push"></a>

Entity.push(v)

v is a character-body shove [x,y,z] in meters per second, handled by the balance system. Returns nothing. This is separate from a rigid-body impulse.

Exact binding and defaults
Entity.push(v) { __push(this.id, v); }

<a id="script-entity-pushaside"></a>

Entity.pushAside(other, strength)

other is another entity or its numeric ID; strength defaults to 1. Uses the balance/pushing interaction. Returns nothing.

Exact binding and defaults
Entity.pushAside(other, strength) { __pushAside(this.id, other.id !== undefined ? other.id : other, strength === undefined ? 1 : strength); }

<a id="script-entity-putdown"></a>

Entity.putDown()

From the engine's script reference: .pickUp(item) / .putDown() / .throw(speed) carry a 2D object (true if it worked)

Exact binding and defaults
Entity.putDown() { return !!__putDown2d(this.id); };

<a id="script-entity-reload"></a>

Entity.reload()

From the engine's script reference: .reload() .giveWeapon(name, ammo, equip) .telegraph(seconds, color) a laser sight and glint, nothing fired

Exact binding and defaults
Entity.reload() { __shoot2d(this.id, 'reload', {}); };

<a id="script-entity-ride"></a>

Entity.ride(c)

From the engine's script reference: .mount(character) puts a rider on it .dismount() .ride({steer, push, brake, jump, spin}) a script's or bot's controls

Exact binding and defaults
Entity.ride(c) { __board(this.id, 'steer', JSON.stringify(c || {})); }

<a id="script-entity-rig"></a>

Entity.rig

Access: read.

From the engine's script reference: .rig the 2D rig's state; .rig.play(clip), .rig.attach(bone, picture) .pose(move, turn, pivot) offsets the drawn pose (metres, degrees)

Exact binding and defaults
get Entity.rig() {
        var id = this.id, s = __rig(id, 'state', '', null);
        if (s === undefined || s === null) return null;
        s.play = function (c) { __rig(id, 'play', String(c), null); };
        s.attach = function (bone, pic) { __rig(id, 'attach', String(bone), pic === undefined || pic === null ? null : String(pic)); };
        s.target = function (chain, p) { __rig(id, 'target', String(chain), p && p.position ? p.position : (p || null)); };
        s.lookAt = function (p) { __rig(id, 'look', '', p && p.position ? p.position : (p || null)); };
        s.bone = function (name) { var v = __rig(id, 'bone', String(name), null); return v === undefined ? null : v; };
        s.tip = function (name) { var v = __rig(id, 'tip', String(name), null); return v === undefined ? null : v; };
        return s;
      }

<a id="script-entity-rise"></a>

Entity.rise(seconds)

From the engine's script reference: .rise(seconds) a downed body gets up (0: at once) .set("component.field", value) / .unset("component") change any component live

Exact binding and defaults
Entity.rise(seconds) { return __rise(this.id, seconds === undefined ? 0 : seconds); }

<a id="script-entity-roomenabled"></a>

Entity.roomEnabled

Access: read.

From the engine's script reference: .layer / .ySort / .sortOffset / .sortWith a sprite's draw order (read or assign) .roomEnabled = false turns its 2D room off

Exact binding and defaults
get Entity.roomEnabled() def('roomEnabled', undefined, function (v) { __setRoom2d(this.id, !!v); });

<a id="script-entity-rotation"></a>

Entity.rotation

Access: read, write.

Read or assign [x,y,z] rotation in degrees.

Exact binding and defaults
get Entity.rotation() { return __getRotation(this.id); }
set Entity.rotation(v) { __setRotation(this.id, v); }

<a id="script-entity-save"></a>

Entity.save

Access: read.

Mutable plain-data object to include in saved games. Keep numbers, strings, booleans, lists and plain objects here, not functions or Entity wrappers. Restored data is delivered through the loaded message.

Exact binding and defaults
get Entity.save() { return __saves[this.id] || (__saves[this.id] = {}); }

<a id="script-entity-say"></a>

Entity.say(text, subtitle, audio)

text is converted to a string. subtitle is enabled unless explicitly false. Requests a spoken/lip-synced line from the character bridge; returns nothing.

Exact binding and defaults
Entity.say(text, subtitle, audio) { __say(this.id, String(text), subtitle !== false, audio ? String(audio) : ''); }

<a id="script-entity-scale"></a>

Entity.scale

Access: read, write.

Read or assign [x,y,z] visual scale. It does not resize the existing collision shape.

Exact binding and defaults
get Entity.scale() { return __getScale(this.id); }
set Entity.scale(v) { __setScale(this.id, v); }

<a id="script-entity-send"></a>

Entity.send(name, data)

name is the message name and data its payload; omitted data becomes null. Calls this entity's script onMessage handlers. Returns nothing. Synchronous nested script calls share the caller's time budget.

Exact binding and defaults
Entity.send(name, data) { __send(this.id, name, data === undefined ? null : data); }

<a id="script-entity-set"></a>

Entity.set(property, value)

From the engine's script reference: in each state's cancel window), .set("armed", 1) a param, .play("hurt") forces a state; onMessage 'state'

Exact binding and defaults
Entity.set(property, value) { return !!__setField(this.id, String(property), value); }

<a id="script-entity-setfield"></a>

Entity.setField(path, value)

From the engine's script reference: .field("light_2d.color") / .setField("light_2d.intensity", 0) read or set any 2D component field (light_2d, material_2d, occluder_2d, sprite, backdrop_2d, particles_2d)

Exact binding and defaults
Entity.setField(path, value) { return !!__setField2d(this.id, String(path), value); };

<a id="script-entity-settile"></a>

Entity.setTile(col, row, ch)

col and row are tile coordinates; ch is converted to text and only its first character is used. Coordinates must be non-negative and below 100,000; empty text or invalid coordinates do nothing. Returns nothing. Requires a tilemap.

Exact binding and defaults
Entity.setTile(col, row, ch) { __setTile(this.id, col, row, String(ch)); }

<a id="script-entity-shatter"></a>

Entity.shatter(count, push)

From the engine's script reference: .shatter(count, [x, y, z]) breaks it into count shards (default 14) under physics, pushed by the optional velocity (glass, a plate, a bottle)

Exact binding and defaults
Entity.shatter(count, push) { __shatter(this.id, [count || 14], push || []); }

<a id="script-entity-shoot"></a>

Entity.shoot(o)

From the engine's script reference: .aimAt(target or [x, y], turn) aims (degrees a second, 0 at once) .shoot({ burst, telegraph, now }) fires; false while busy .holdFire(true or false)

Exact binding and defaults
Entity.shoot(o) { return !!__shoot2d(this.id, 'fire', o && typeof o === 'object' ? o : {}); };

<a id="script-entity-sleep"></a>

Entity.sleep(wake)

wake is the noise wake distance in meters, default 7. Puts an awareness-controlled entity to sleep. Returns nothing.

Exact binding and defaults
Entity.sleep(wake) { __sleep(this.id, wake === undefined ? 7 : wake); }

<a id="script-entity-sortoffset"></a>

Entity.sortOffset

Access: read.

From the engine's script reference: .layer / .ySort / .sortOffset / .sortWith a sprite's draw order (read or assign) .roomEnabled = false turns its 2D room off

Exact binding and defaults
get Entity.sortOffset() def('sortOffset', function () { var v = __sort2d(this.id); return v ? v.sortOffset : 0; }, function (v) { __setSort2d(this.id, 'sort_offset', v); });

<a id="script-entity-sortwith"></a>

Entity.sortWith

Access: read.

From the engine's script reference: .layer / .ySort / .sortOffset / .sortWith a sprite's draw order (read or assign) .roomEnabled = false turns its 2D room off

Exact binding and defaults
get Entity.sortWith() def('sortWith', function () { var v = __sort2d(this.id); return v && v.sortWith ? world.find(v.sortWith) : null; },

<a id="script-entity-sprite"></a>

Entity.sprite

Access: read.

Read-only sprite snapshot or null: clip, frame, flip, opacity, and done.

Exact binding and defaults
get Entity.sprite() { var v = __sprite2d(this.id); return v === undefined ? null : v; }

<a id="script-entity-squash"></a>

Entity.squash(amount, seconds)

From the engine's script reference: Feel: .flashHit(seconds, color) white hit flash .freeze(seconds) hit-stop .squash(amount, seconds) .trail(seconds, every) after-images .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach }) 3D blades: a blade_trail component on the sword (base, tip, color, life, min_speed) leaves a trail of light along a cut; .set("blade_trail.intensity", 2) for a heavy blow

Exact binding and defaults
Entity.squash(amount, seconds) { __feel('squash', this.id, { amount: amount === undefined ? 0.15 : amount, seconds: seconds || 0.14 }); }

<a id="script-entity-stats"></a>

Entity.stats

Access: read.

Read-only stats snapshot or null without stats: health, max_health, stamina, exhausted, can_sprint, speed_scale, frozen, effects, cooldowns. Effect and cooldown maps contain remaining seconds.

Exact binding and defaults
get Entity.stats() { var s = __stats(this.id); return s === undefined ? null : s; }

<a id="script-entity-stoppatterns"></a>

Entity.stopPatterns()

From the engine's script reference: .pattern("spiral", { count, speed, interval, duration, turn, arc, bursts, weapon }) a bullet pattern .stopPatterns()

Exact binding and defaults
Entity.stopPatterns() { __shoot2d(this.id, 'stop_patterns', {}); };

<a id="script-entity-strike"></a>

Entity.strike(at, impulse)

From the engine's script reference: .strike([x, y, z], [ix, iy, iz]) a blow at a world point (impulse in newton-seconds: a sledgehammer swing is about 80, a 1 t wrecking ball at 5 m/s about 6500); returns how many pieces it broke into

Exact binding and defaults
Entity.strike(at, impulse) { return __strike(this.id, at, impulse); }

<a id="script-entity-strikeglass"></a>

Entity.strikeGlass(at, impulse, o)

From the engine's script reference: .glass({strength}) its panes break into shards where struck .strikeGlass([x, y, z], [ix, iy, iz], {mass}) a blow on its glass

Exact binding and defaults
Entity.strikeGlass(at, impulse, o) { o = o || {}; return __strikeGlass(this.id, at, impulse, [o.mass || 8]); }

<a id="script-entity-stun"></a>

Entity.stun(seconds)

seconds defaults to 1. Temporarily stuns the awareness system. Returns nothing; use the stats effect API for stats/control effects.

Exact binding and defaults
Entity.stun(seconds) { __stun(this.id, seconds === undefined ? 1 : seconds); }

<a id="script-entity-tag"></a>

Entity.tag(name)

From the engine's script reference: .tag(name) / .untag(name) add or remove a tag at runtime; repeated adds keep one copy.

Exact binding and defaults
Entity.tag(name) { return !!__tag(this.id, String(name), true); }

<a id="script-entity-tags"></a>

Entity.tags

Access: read.

Read-only list of tags from the entity's about component.

Exact binding and defaults
get Entity.tags() { return __tags(this.id); }

<a id="script-entity-take"></a>

Entity.take(item, n)

item is an inventory key and n the quantity to remove, default 1. Returns nothing.

Exact binding and defaults
Entity.take(item, n) { __give(this.id, String(item), -(n === undefined ? 1 : n)); }

<a id="script-entity-telegraph"></a>

Entity.telegraph(seconds, color)

From the engine's script reference: .reload() .giveWeapon(name, ammo, equip) .telegraph(seconds, color) a laser sight and glint, nothing fired

Exact binding and defaults
Entity.telegraph(seconds, color) { __shoot2d(this.id, 'telegraph', { seconds: seconds === undefined ? 0.4 : seconds, color: color || null }); };

<a id="script-entity-throw"></a>

Entity.throw(speed)

From the engine's script reference: .pickUp(item) / .putDown() / .throw(speed) carry a 2D object (true if it worked)

Exact binding and defaults
Entity.throw(speed) { return !!__throw2d(this.id, speed === undefined ? 600 : speed); };

<a id="script-entity-tile"></a>

Entity.tile(col, row)

col and row are tile coordinates. Returns the tile character, or null when the bridge has no tile result.

Exact binding and defaults
Entity.tile(col, row) { var t = __tile(this.id, col, row); return t === undefined ? null : t; }

<a id="script-entity-tostring"></a>

Entity.toString()

Returns the entity's name; also supplies its ordinary string conversion.

Exact binding and defaults
Entity.toString() { return this.name; }

<a id="script-entity-trail"></a>

Entity.trail(seconds, every)

From the engine's script reference: Feel: .flashHit(seconds, color) white hit flash .freeze(seconds) hit-stop .squash(amount, seconds) .trail(seconds, every) after-images .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach }) 3D blades: a blade_trail component on the sword (base, tip, color, life, min_speed) leaves a trail of light along a cut; .set("blade_trail.intensity", 2) for a heavy blow

Exact binding and defaults
Entity.trail(seconds, every) { __feel('trail', this.id, { seconds: seconds === undefined ? 0.25 : seconds, every: every || 0.035 }); }

<a id="script-entity-unequip"></a>

Entity.unequip(slot)

From the engine's script reference: .equip("slot", "item") or .equip("item") wears or holds an item (the reply says what, or why not) .unequip("slot") .equipped() what it wears

Exact binding and defaults
Entity.unequip(slot) { return JSON.parse(__unequip(this.id, String(slot))); }

<a id="script-entity-unset"></a>

Entity.unset(component)

From the engine's script reference: .rise(seconds) a downed body gets up (0: at once) .set("component.field", value) / .unset("component") change any component live

Exact binding and defaults
Entity.unset(component) { return !!__unsetComponent(this.id, String(component)); }

<a id="script-entity-untag"></a>

Entity.untag(name)

From the engine's script reference: .tag(name) / .untag(name) add or remove a tag at runtime; repeated adds keep one copy.

Exact binding and defaults
Entity.untag(name) { return !!__tag(this.id, String(name), false); }

<a id="script-entity-velocity"></a>

Entity.velocity

Access: read, write.

Read or assign 2D velocity [vx,vy]; reading without a 2D body gives [0,0]. A setter needs at least two finite numbers. This is not a 3D velocity property.

Exact binding and defaults
get Entity.velocity() { var v = __body2d(this.id); return v ? [v.vx, v.vy] : [0, 0]; }
set Entity.velocity(v) { __setVelocity2d(this.id, v); }

<a id="script-entity-walk"></a>

Entity.walk(d)

d is desired [dx,dy,dz] displacement in meters, not velocity. Uses collision-aware movement and returns the displacement actually made. Multiply a desired speed by dt before calling it.

Exact binding and defaults
Entity.walk(d) { return __walk(this.id, d); }

<a id="script-entity-weapon"></a>

Entity.weapon

Access: read.

From the engine's script reference: .carrying what it holds (null) .weapon its 2D weapon's state (null) .inventory its bag (items: add, remove, count, info)

Exact binding and defaults
get Entity.weapon() Object.defineProperty(Entity.prototype, 'weapon', { get: function () { var v = __shoot2d(this.id, 'info', {}); return v === undefined ? null : v; }, configurable: true });

<a id="script-entity-weapontrail"></a>

Entity.weaponTrail(socket, seconds, width, style)

From the engine's script reference: .weaponTrail(socket, seconds, width, style) a swing's ribbon .burst(kind, dir) sparks/dust from it .fx(name, { at, dir, strength, attach })

Exact binding and defaults
Entity.weaponTrail(socket, seconds, width, style) { __feel('weapon_trail', this.id, { socket: socket || 'tip', seconds: seconds === undefined ? 0.3 : seconds, width: width === undefined ? 14 : width, style: style && typeof style === 'object' ? style : {} }); }

<a id="script-entity-wear"></a>

Entity.wear(look)

From the engine's script reference: hair_color, eye_color }; null: a model file); set it, or .wear(look) (true, or why not), to dress anyone in one

Exact binding and defaults
Entity.wear(look) { var e = __wearLook(this.id, typeof look === 'string' ? look : JSON.stringify(look)); return e === '' ? true : e; }

<a id="script-entity-ysort"></a>

Entity.ySort

Access: read.

From the engine's script reference: .layer / .ySort / .sortOffset / .sortWith a sprite's draw order (read or assign) .roomEnabled = false turns its 2D room off

Exact binding and defaults
get Entity.ySort() def('ySort', function () { var v = __sort2d(this.id); return v ? v.ySort : false; }, function (v) { __setSort2d(this.id, 'y_sort', !!v); });

<a id="script-after"></a>

after(seconds, fn)

seconds is a delay in simulation seconds; fn is a function with no supplied arguments. Returns nothing. Runs on a later timer pass once game time reaches the due time. Timers survive the destruction of the entity that scheduled them. There is no cancellation handle; check entity.exists inside delayed work.

Exact binding and defaults
after(seconds, fn) {
      if (__timers.length >= 10000) throw new Error('after(): 10000 timers already waiting; check for a timer that re-arms itself many times');
      var running = __timerOwner();
      __timers.push({ at: __time + seconds, fn: fn, owner: running >= 0 ? running : __timerRunOwner });
    }

<a id="script-game-act"></a>

game.act(entity, action, actor)

entity is the target Entity; action is the action name; optional actor is the Entity doing it. Returns {ok, reason}. Reach, keys and other action rules can prevent success.

Exact binding and defaults
game.act(entity, action, actor) { return __act(entity.id, String(action), actor ? actor.id : -1); }

<a id="script-game-aim"></a>

game.aim()

Returns {origin:[x,y,z], direction:[x,y,z]} for the current script's player/aim context.

Exact binding and defaults
game.aim() { var a = __aim(); return { origin: [a[0], a[1], a[2]], direction: [a[3], a[4], a[5]] }; }

<a id="script-game-ambience"></a>

game.ambience(name, volume)

name is a sound key; volume defaults to 0.5. Requests looping background audio and returns nothing. Volume 0 silences it.

Exact binding and defaults
game.ambience(name, volume) { __ambience(String(name), volume === undefined ? 0.5 : volume); }

<a id="script-game-apparition"></a>

game.apparition(image, options)

From the engine's script reference: game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.apparition(image, options) { __apparition(String(image), options || {}); }

<a id="script-game-apparitions"></a>

game.apparitions(images, chance)

From the engine's script reference: game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.apparitions(images, chance) { __apparitions(images || [], chance === undefined ? 0.35 : Number(chance)); }

<a id="script-game-blackout"></a>

game.blackout(on)

With boolean on, changes blackout state; with no argument, reads it. Returns the current boolean. Blackout suppresses point lights except lights tagged battery.

Exact binding and defaults
game.blackout(on) { return __blackout(on === undefined ? null : !!on); }

<a id="script-game-broadcast"></a>

game.broadcast(name, data)

From the engine's script reference: game.broadcast(name, data) every scripted object (on the host) hears onMessage(name, data): a clock's hour, a round starting

Exact binding and defaults
game.broadcast(name, data) { __broadcast(String(name), data === undefined ? null : data); }

<a id="script-game-burst"></a>

game.burst(kind, at, dir)

From the engine's script reference: Feel: game.slowMotion(scale, seconds) game.stopWorld(seconds) hit-stop for everything game.burst(kind, at, dir) game.fx(name, at, dir, strength) game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings game.hitFeel(target, { at, direction, strength 0..2, material, source, kill, skip }) everything a 3D hit gets in one call: hit-stop on both, the camera shake, what flies off what was hit (blood off a body, sparks off metal or a robot,

Exact binding and defaults
game.burst(kind, at, dir) { __feel('burst', -1, { kind: String(kind || 'spark'), at: at, dir: dir || 1 }); }

<a id="script-game-camera"></a>

game.camera

Access: read.

Read-only local player camera snapshot or null. Contains position, direction and view. When a camera-rig readout exists it also contains shoulder (-1 left to 1 right) and arm (meters behind the pivot; 0 in first person).

Exact binding and defaults
get game.camera() { var c = __camera(); return c === undefined ? null : c; }

<a id="script-game-cameraroom"></a>

game.cameraRoom

Access: read.

From the engine's script reference: game.cameraRoom the 2D room the camera is in (null)

Exact binding and defaults
get game.cameraRoom() Object.defineProperty(game, 'cameraRoom', { get: function () { var id = __cameraRoom(); return id >= 0 ? new Entity(id) : null; }, configurable: true });

<a id="script-game-caption"></a>

game.caption(text, seconds)

From the engine's script reference: Captions for sounds (shown with the subtitles, in the player's language): game.caption("[Door creaks]", seconds); game.sound(name, pos, volume, pitch, { caption: "[Thunder]" }); or Assets/Strings/captions.json { "thunder": "[Thunder]" } captions that sound every time it plays (the same caption at most every 1.5 s). game.ui("loading", { progress: 0.65 }) updates loading progress; showing it does not perform loading.

Exact binding and defaults
game.caption(text, seconds) {

<a id="script-game-cinematic25d"></a>

game.cinematic25d(shot)

From the engine's script reference: game.cinematic25d({ target: "Boss", move: "boss_intro", duration: 4 }) 2D games: the flat view turns 3D for a big moment (layers become depth planes, sprites cards; push in / orbit / dolly / tilt / reveal / boss_intro / hold, depth of field (dof 0...1), light ("dramatic", "warm", "cold", "dark", "none"), letterbox) and lands back on the 2D view; holds the controls (hold: false lets play run). Returns { ok, reason }; onMessage 'cinematic25d_finished' when it

Exact binding and defaults
game.cinematic25d(shot) { return __cine25d(shot || {}); }

<a id="script-game-cinematic25dplaying"></a>

game.cinematic25dPlaying

Access: read.

From the engine's script reference: ends; game.cinematic25dPlaying. In a sequence: "cinematic25d": [ { "t": 1, "target": "Boss", "move": "orbit" } ].

Exact binding and defaults
get game.cinematic25dPlaying() { return !!__cine25dPlaying(); }

<a id="script-game-clearsave"></a>

game.clearSave(slot)

slot defaults to save. Returns true when the slot is empty afterward, including an already empty slot. Invalid names or a failed removal return false.

Exact binding and defaults
game.clearSave(slot) { return !!__clearSave(String(slot || 'save')); }

<a id="script-game-continuegame"></a>

game.continueGame()

From the engine's script reference: game.newGame() / game.continueGame() (the newest slot) / game.loadSlot(n) / game.deleteSlot(n) / game.slots() [{ slot, status, label, scene, savedAt, playSeconds }]

Exact binding and defaults
game.continueGame() { return __slot('continue', 0, ''); };   // loads the newest slot

<a id="script-game-controlsets"></a>

game.controlSets()

From the engine's script reference: game.controls("default") (or "on_foot" when not declared) goes back; game.controlSets() lists them.

Exact binding and defaults
game.controlSets() { return __speak('control_sets', {}) || ['default']; };

<a id="script-game-controls"></a>

game.controls(name)

From the engine's script reference: game.controls("vehicle:jet") switches (false for an unknown set); game.controls() is the set in use;

Exact binding and defaults
game.controls(name) {

<a id="script-game-crafting-check"></a>

game.crafting.check()

From the engine's script reference: game.crafting.recipes({ for: player, station: stove | 'kitchen' }) .check('jam', { for, station }) .craft(player, 'jam', { station, times }) .learn(player, 'jam') .knows(player, 'jam') .open(stove | 'kitchen', 'The bakery oven') (the crafting screen)

Exact binding and defaults
game.crafting.check() game.crafting = {

<a id="script-game-crafting-craft"></a>

game.crafting.craft()

From the engine's script reference: game.crafting.recipes({ for: player, station: stove | 'kitchen' }) .check('jam', { for, station }) .craft(player, 'jam', { station, times }) .learn(player, 'jam') .knows(player, 'jam') .open(stove | 'kitchen', 'The bakery oven') (the crafting screen)

Exact binding and defaults
game.crafting.craft() game.crafting = {

<a id="script-game-crafting-knows"></a>

game.crafting.knows()

From the engine's script reference: game.crafting.recipes({ for: player, station: stove | 'kitchen' }) .check('jam', { for, station }) .craft(player, 'jam', { station, times }) .learn(player, 'jam') .knows(player, 'jam') .open(stove | 'kitchen', 'The bakery oven') (the crafting screen)

Exact binding and defaults
game.crafting.knows() game.crafting = {

<a id="script-game-crafting-learn"></a>

game.crafting.learn()

From the engine's script reference: game.crafting.recipes({ for: player, station: stove | 'kitchen' }) .check('jam', { for, station }) .craft(player, 'jam', { station, times }) .learn(player, 'jam') .knows(player, 'jam') .open(stove | 'kitchen', 'The bakery oven') (the crafting screen)

Exact binding and defaults
game.crafting.learn() game.crafting = {

<a id="script-game-crafting-recipes"></a>

game.crafting.recipes()

From the engine's script reference: game.crafting.recipes({ for: player, station: stove | 'kitchen' }) .check('jam', { for, station }) .craft(player, 'jam', { station, times }) .learn(player, 'jam') .knows(player, 'jam') .open(stove | 'kitchen', 'The bakery oven') (the crafting screen)

Exact binding and defaults
game.crafting.recipes() game.crafting = {

<a id="script-game-crtoff"></a>

game.crtOff(seconds, hold)

From the engine's script reference: Screen: game.glitch(amount, seconds) game.tvStatic(amount, seconds) game.vhs(amount) (none: off) game.crtOff(seconds, hold) game.signalLost(seconds) game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.crtOff(seconds, hold) { __signal('crt', 1, seconds === undefined ? 0.6 : Number(seconds), hold === undefined ? 0.6 : Number(hold)); }

<a id="script-game-cutscene"></a>

game.cutscene

Access: read.

Read-only active cutscene name or null.

Exact binding and defaults
get game.cutscene() { var n = __cutscene(); return n === undefined ? null : n; }

<a id="script-game-defineweapon"></a>

game.defineWeapon(o)

From the engine's script reference: game.defineWeapon({ name, base, ... }) a new 2D weapon game.shooting() the 2D shooting report

Exact binding and defaults
game.defineWeapon(o) { return !!__shoot2d(-1, 'define', o || {}); };

<a id="script-game-deleteslot"></a>

game.deleteSlot(n)

From the engine's script reference: game.newGame() / game.continueGame() (the newest slot) / game.loadSlot(n) / game.deleteSlot(n) / game.slots() [{ slot, status, label, scene, savedAt, playSeconds }]

Exact binding and defaults
game.deleteSlot(n) { return __slot('delete', n, ''); };

<a id="script-game-dialogue-active"></a>

game.dialogue.active

Access: read.

From the engine's script reference: game.dialogue.active → { dialogue, node, speaker, text, choices } or null; game.dialogue.stop() / choose(card)

Exact binding and defaults
get game.dialogue.active() { var r = __dialogue('active', {}); return r === undefined ? null : r; }

<a id="script-game-dialogue-backlog"></a>

game.dialogue.backlog()

From the engine's script reference: game.dialogue.next() / game.dialogue.choose(index) advance or pick in the open conversation game.dialogue.backlog() the lines so far

Exact binding and defaults
game.dialogue.backlog() { var r = __dialogue('backlog', {}); return r === undefined || r === null ? [] : r; }

<a id="script-game-dialogue-choose"></a>

game.dialogue.choose(card)

From the engine's script reference: game.dialogue.next() / game.dialogue.choose(index) advance or pick in the open conversation game.dialogue.backlog() the lines so far

Exact binding and defaults
game.dialogue.choose(card) { return __dialogue('choose', { index: Number(card) || 0 }); }

<a id="script-game-dialogue-next"></a>

game.dialogue.next()

From the engine's script reference: game.dialogue.next() / game.dialogue.choose(index) advance or pick in the open conversation game.dialogue.backlog() the lines so far

Exact binding and defaults
game.dialogue.next() { return __dialogue('next', {}); }

<a id="script-game-dialogue-resume"></a>

game.dialogue.resume()

From the engine's script reference: stage: game.load(slot) then game.dialogue.resume(). ui_preset visual_novel has a Backlog screen (list

Exact binding and defaults
game.dialogue.resume() { return __dialogue('resume', {}); }

<a id="script-game-dialogue-stop"></a>

game.dialogue.stop()

From the engine's script reference: game.dialogue.active → { dialogue, node, speaker, text, choices } or null; game.dialogue.stop() / choose(card)

Exact binding and defaults
game.dialogue.stop() { return __dialogue('stop', {}); }

<a id="script-game-driverreact"></a>

game.driverReact(name, reaction)

From the engine's script reference: bouncing, looking into the corner, and reacting to a boost or a knock. game.driverReact(name, reaction) poses

Exact binding and defaults
game.driverReact(name, reaction) { return __driverReact(String(name), String(reaction)); }

<a id="script-game-duck"></a>

game.duck(db, seconds)

From the engine's script reference: Sound: game.voice(name, gain) plays a voice line (true if found) game.duck(db, seconds) lowers the music under speech game.mix() the mix report

Exact binding and defaults
game.duck(db, seconds) { __audio('duck', { db: db === undefined ? -8 : db, seconds: seconds === undefined ? 1 : seconds }); };

<a id="script-game-earthquake"></a>

game.earthquake(seconds, strength)

From the engine's script reference: kick away from it. game.earthquake(seconds, strength) a slow heavy rolling with aftershocks (0.2 a tremor, 1 big).

Exact binding and defaults
game.earthquake(seconds, strength) { __cameraShake('earthquake', { seconds: seconds === undefined ? 8 : seconds, strength: strength === undefined ? 1 : strength }); }

<a id="script-game-effectrecipe"></a>

game.effectRecipe(recipe)

From the engine's script reference: game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings

Exact binding and defaults
game.effectRecipe(recipe) { return __feel('recipe', -1, recipe || {}); }

<a id="script-game-equipweapon"></a>

game.equipWeapon(o)

From the engine's script reference: game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.equipWeapon(o) { return __equipWeapon(JSON.stringify(o || {})); }

<a id="script-game-explode"></a>

game.explode(at, power, damage)

From the engine's script reference: settles. game.explode shakes by itself; hard landings jolt the view by themselves.

Exact binding and defaults
game.explode(at, power, damage) { var r = __explode(at, power === undefined ? 1 : power, damage === undefined ? -1 : damage); return r === undefined ? null : r; }

<a id="script-game-exposure"></a>

game.exposure(point)

point is a world [x,y,z]; returns measured light exposure from 0 to 1.

Exact binding and defaults
game.exposure(point) { return __exposure(point); }

<a id="script-game-fade"></a>

game.fade(color, to, seconds)

From the engine's script reference: game.fade("black", 1, 2) fades the whole picture to black (or "white", a hex colour) over 2 s; game.fade("black", 0, 1.5) back to the game. Cutscenes and sequences: { do: "fade", name: "black", intensity: 1, seconds: 2 } and { do: "title", text: "HOLLOWREACH", name: "rune", sub: "...", hold: 3 } (a title card; styles slam, creep, type, glitch, neon, bleed, drift, wasted, rune).

Exact binding and defaults
game.fade(color, to, seconds) {
        return __gameUI('fade', { color: String(color === undefined ? 'black' : color), to: to === undefined ? 1 : Number(to),
                                  seconds: seconds === undefined ? 1 : Number(seconds) });
      }

<a id="script-game-fail"></a>

game.fail(text)

text defaults to Mission failed. Records a failed outcome; returns nothing. The play session keeps the first recorded outcome.

Exact binding and defaults
game.fail(text) { __fail(String(text || 'Mission failed')); }

<a id="script-game-feel"></a>

game.feel(settings)

From the engine's script reference: game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings

Exact binding and defaults
game.feel(settings) { return __feel(settings ? 'settings' : 'report', -1, settings || {}); }

<a id="script-game-flash"></a>

game.flash(color, seconds)

color defaults to [1,0,0]; seconds defaults to 0.25 (zero also selects that default). Flashes the HUD and returns nothing.

Exact binding and defaults
game.flash(color, seconds) { __flash(color || [1, 0, 0], seconds || 0.25); }

<a id="script-game-flow-state"></a>

game.flow.state

Access: read.

From the engine's script reference: game_ui_lifecycle): game.flow.state; game.flow.win(text) / lose(text) end the run (the win / game over screens

Exact binding and defaults
get game.flow.state() game.flow = {

<a id="script-game-fx"></a>

game.fx(name, at, dir, strength)

From the engine's script reference: Feel: game.slowMotion(scale, seconds) game.stopWorld(seconds) hit-stop for everything game.burst(kind, at, dir) game.fx(name, at, dir, strength) game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings game.hitFeel(target, { at, direction, strength 0..2, material, source, kill, skip }) everything a 3D hit gets in one call: hit-stop on both, the camera shake, what flies off what was hit (blood off a body, sparks off metal or a robot,

Exact binding and defaults
game.fx(name, at, dir, strength) {
        if (at && at.length === 3) return __fx(String(name), at, dir || [0, 1, 0], JSON.stringify(strength || {}));
        return __feel('fx', -1, { name: String(name), at: at, dir: dir === undefined ? 1 : dir, strength: strength === undefined ? 1 : strength });
      }

<a id="script-game-glitch"></a>

game.glitch(amount, seconds)

From the engine's script reference: Screen: game.glitch(amount, seconds) game.tvStatic(amount, seconds) game.vhs(amount) (none: off) game.crtOff(seconds, hold) game.signalLost(seconds) game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.glitch(amount, seconds) { __signal('glitch', amount === undefined ? 1 : Number(amount), seconds === undefined ? 0.4 : Number(seconds), 0); }

<a id="script-game-hassave"></a>

game.hasSave(slot)

slot defaults to save. Returns whether this session has a compatible save it could load, not merely whether a filename exists.

Exact binding and defaults
game.hasSave(slot) { return !!__hasSave(String(slot || 'save')); }

<a id="script-game-hitfeel"></a>

game.hitFeel(target, options)

From the engine's script reference: game.hitFeel(target, { at, direction, strength 0..2, material, source, kill, skip }) everything a 3D hit gets in one call: hit-stop on both, the camera shake, what flies off what was hit (blood off a body, sparks off metal or a robot, chips off stone, splinters off wood), the material's hit sound with a thud under a heavy one, a flash, a kill's slow motion, the pad's rumble → { played, strength, material }. Melee hits get it by themselves.

Exact binding and defaults
game.hitFeel(target, options) { var id = target && target.id !== undefined ? target.id : target; return __feel('hit', id, options || {}); }

<a id="script-game-hud"></a>

game.hud(key, value)

key is a readout name; value is its value, converted by the bridge to text. Omitted, null or undefined values clear the field. Returns nothing.

Exact binding and defaults
game.hud(key, value) { __hud(String(key), value === undefined ? null : value); }

<a id="script-game-hudwidget"></a>

game.hudWidget(id, widget)

From the engine's script reference: game.hudWidget("spell", {kind:"ability", rect:{x:0.05,y:0.75,width:0.08,height:0.12}, icon:"UI/spell.png", action:"hook:cast_spell", color:"36BCCC", value:0.7, maximum:1});

Exact binding and defaults
game.hudWidget(id, widget) { return !!__gameUI(widget === null ? 'hud_remove' : 'hud_widget', widget === null ? {id:String(id)} : {id:String(id), json:JSON.stringify(Object.assign({}, widget, {id:String(id)}))}); }

<a id="script-game-impact"></a>

game.impact(strength)

From the engine's script reference: game.rumble(amount, seconds) a fine trembling (an engine). game.impact(strength) a blow: the view dips and

Exact binding and defaults
game.impact(strength) { __cameraShake('impact', { strength: strength === undefined ? 0.5 : strength }); }

<a id="script-game-inventory"></a>

game.inventory(entity)

Optional entity selects an inventory; otherwise uses game.player. Returns an item-count object, or an empty object when there is no player.

Exact binding and defaults
game.inventory(entity) { var e = entity || game.player; return e ? __inventory(e.id) : {}; }

<a id="script-game-items-get"></a>

game.items.get()

From the engine's script reference: game.items.get('jam') / .tagged('seed') / .list() / .issues() / .reload()

Exact binding and defaults
game.items.get() 

<a id="script-game-items-issues"></a>

game.items.issues()

From the engine's script reference: game.items.get('jam') / .tagged('seed') / .list() / .issues() / .reload()

Exact binding and defaults
game.items.issues() 

<a id="script-game-items-list"></a>

game.items.list()

From the engine's script reference: game.items.get('jam') / .tagged('seed') / .list() / .issues() / .reload()

Exact binding and defaults
game.items.list() 

<a id="script-game-items-reload"></a>

game.items.reload()

From the engine's script reference: game.items.get('jam') / .tagged('seed') / .list() / .issues() / .reload()

Exact binding and defaults
game.items.reload() 

<a id="script-game-items-tagged"></a>

game.items.tagged()

From the engine's script reference: game.items.get('jam') / .tagged('seed') / .list() / .issues() / .reload()

Exact binding and defaults
game.items.tagged() 

<a id="script-game-labtrial"></a>

game.labTrial(o)

o is a JSON-serializable trial record (default empty object). Reports it to the Motion Lab harness. Returns nothing. This reports measurements; it does not itself run or verify a trial.

Exact binding and defaults
game.labTrial(o) { __labTrial(JSON.stringify(o || {})); }

<a id="script-game-language"></a>

game.language()

From the engine's script reference: game.language() → "es"; game.languages() → [{ code, name, native, rightToLeft }]; game.setLanguage("ja" or

Exact binding and defaults
game.language() { return __lang('get', {}) || 'en'; };

<a id="script-game-languages"></a>

game.languages()

From the engine's script reference: game.language() → "es"; game.languages() → [{ code, name, native, rightToLeft }]; game.setLanguage("ja" or

Exact binding and defaults
game.languages() { return __lang('list', {}) || [{ code: 'en', name: 'English', native: 'English', rightToLeft: false }]; };

<a id="script-game-lighting2d"></a>

game.lighting2d(fields)

From the engine's script reference: game.lighting2d({ time_of_day, ambient }) the scene's 2D lighting (made if missing) game.roof(group) a roof's reveal (0 shown ... 1 revealed)

Exact binding and defaults
game.lighting2d(fields) { __lighting2d(fields || {}); };

<a id="script-game-line"></a>

game.line()

From the engine's script reference: voice: a clip (Assets/Sounds name or a built-in voice) played as the line starts. game.line() is the line on

Exact binding and defaults
game.line() { var l = __speak('line', {}); return l === undefined ? null : l; };

<a id="script-game-livescreen"></a>

game.liveScreen(name, options)

From the engine's script reference: game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera

Exact binding and defaults
game.liveScreen(name, options) { var r = __liveScreen(String(name), JSON.stringify(options || {})); return r === undefined ? null : r; }

<a id="script-game-load"></a>

game.load(slot)

slot defaults to save. Returns true when a compatible load is accepted, false otherwise. During a script callback the load is applied at a safe boundary, not in the middle of that call. Scripts receive onMessage(self, 'loaded', {slot, data}) with their saved data.

Exact binding and defaults
game.load(slot) { return !!__loadGame(String(slot || 'save')); }

<a id="script-game-loadscene"></a>

game.loadScene(name)

name is another project scene's name. Requests a switch between frames and returns nothing. The current implementation does nothing in hidden/headless sessions; it does not even record the request there.

Exact binding and defaults
game.loadScene(name) { __loadScene(String(name)); }

<a id="script-game-loadslot"></a>

game.loadSlot(n)

From the engine's script reference: game.newGame() / game.continueGame() (the newest slot) / game.loadSlot(n) / game.deleteSlot(n) / game.slots() [{ slot, status, label, scene, savedAt, playSeconds }]

Exact binding and defaults
game.loadSlot(n) { return __slot('load', n, ''); };

<a id="script-game-look"></a>

game.look

Access: read.

From the engine's script reference: game.look the look the menus wear now: { backdrop: { mode, camera, cameraSpeed, scene }, accent } (a title camera script follows it)

Exact binding and defaults
get game.look() { var r = __uiLook(); return r === undefined || r === null ? {} : r; }

<a id="script-game-loot-give"></a>

game.loot.give()

From the engine's script reference: game.loot.roll('fishing_spot', { seed }) → what it rolled game.loot.give('chest_common', player, { seed })

Exact binding and defaults
game.loot.give() game.loot = {

<a id="script-game-loot-roll"></a>

game.loot.roll()

From the engine's script reference: game.loot.roll('fishing_spot', { seed }) → what it rolled game.loot.give('chest_common', player, { seed })

Exact binding and defaults
game.loot.roll() game.loot = {

<a id="script-game-marker"></a>

game.marker(entity)

entity is an Entity to mark as the next destination. Null clears the marker. Returns nothing.

Exact binding and defaults
game.marker(entity) { __marker(entity ? entity.id : -1); }

<a id="script-game-mix"></a>

game.mix()

From the engine's script reference: Sound: game.voice(name, gain) plays a voice line (true if found) game.duck(db, seconds) lowers the music under speech game.mix() the mix report

Exact binding and defaults
game.mix() { return __audio('report', {}); };

<a id="script-game-music"></a>

game.music(track, crossfade)

From the engine's script reference: game.music("title_theme", 2) a track (Assets/Sounds/Music) crossfaded in; game.music() back to the scene's

Exact binding and defaults
game.music(track, crossfade) {

<a id="script-game-musictime"></a>

game.musicTime()

From the engine's script reference: game.musicTime() the playing track's playhead { track, seconds } (wrapping as it loops; null while none plays or it loads): a beat clock that follows the music as mixed (kits/beats.js). Music tracks run up to 180 s.

Exact binding and defaults
game.musicTime() { var r = __audio('music_time', {}); return r === undefined ? null : r; };

<a id="script-game-newgame"></a>

game.newGame()

From the engine's script reference: game.newGame() / game.continueGame() (the newest slot) / game.loadSlot(n) / game.deleteSlot(n) / game.slots() [{ slot, status, label, scene, savedAt, playSeconds }]

Exact binding and defaults
game.newGame() { __state('new', ''); };

<a id="script-game-nightvision"></a>

game.nightVision(mode, options)

From the engine's script reference: game.nightVision("green" / "white" / "camcorder" / false, { gain: 1, tube: "none" / "monocular" / "binocular" }) night vision through the player's camera (an image intensifier: dark amplified with its noise, lights bloom, red and infrared read bright); lights tagged "infrared" (IR illuminators, lasers, strobes) shine only while it's on; game.nightVision() tells the mode ("off" when off). kits/night_vision.js: a key, a battery, an IR illuminator.

Exact binding and defaults
game.nightVision(mode, options) {   // night vision on ("green", "white", "camcorder", true = green) or off (false, "off")
        return __nightVision(mode === undefined ? null : mode === false ? 'off' : mode === true ? 'green' : String(mode), options || {});
      }

<a id="script-game-noise"></a>

game.noise(position, loudness)

position is a world point; loudness defaults to 30 meters of carrying distance. Notifies hearing/perception systems and returns the native listener count. This is a gameplay noise event, separate from playing audible sound.

Exact binding and defaults
game.noise(position, loudness) { return __noise(position, loudness === undefined ? 30 : loudness); }

<a id="script-game-objective"></a>

game.objective(text)

text is the objective string. Replaces the HUD objective and returns nothing.

Exact binding and defaults
game.objective(text) { __objective(String(text)); }

<a id="script-game-offhand"></a>

game.offhand(o)

From the engine's script reference: game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.offhand(o) { __offhand(o ? JSON.stringify(o) : 'null'); }

<a id="script-game-online"></a>

game.online

Access: read.

From the engine's script reference: game.players every player character (online: one per joined player) game.online { hosting, joined, players, max } or null offline

Exact binding and defaults
get game.online() { return __online(); }

<a id="script-game-playcutscene"></a>

game.playCutscene(name, onFinished)

name identifies a project cutscene; optional onFinished is a callback receiving {name, how, skipped}. how is finished, skipped, or stopped. Returns whether the native start succeeded. Every scripted entity also receives cutscene_finished. The callback is registered before the start attempt, so do not assume a failed start removed it.

Exact binding and defaults
game.playCutscene(name, onFinished) {
        if (typeof onFinished === 'function') __cutsceneDone.push({ name: String(name).split('.cutscene.json').join(''), fn: onFinished });
        return __playCutscene(String(name));
      }

<a id="script-game-playsequence"></a>

game.playSequence(name)

From the engine's script reference: game.playSequence("bottle") plays the cinematic Sequences/bottle.sequence.json (slow motion included); every scripted object gets onMessage 'sequence_finished' { name, how } when it ends. game.stopSequence() game.sequence (or null)

Exact binding and defaults
game.playSequence(name) { return __playSequence(String(name)); }

<a id="script-game-player"></a>

game.player

Access: read.

Read-only Entity for the relevant player or null when none exists. In a multi-player session, the owning script affects player resolution; do not assume one global player for every script.

Exact binding and defaults
get game.player() { var id = __player(); return id < 0 ? null : new Entity(id); }

<a id="script-game-players"></a>

game.players

Access: read.

From the engine's script reference: HUD, so a score, a role or a personal objective per player); player is the entity (game.players) or its id.

Exact binding and defaults
get game.players() { return __players().map(function (id) { return new Entity(id); }); }

<a id="script-game-profile-all"></a>

game.profile.all()

From the engine's script reference: game.profile.get('best_time', 0) .set('beat_game', true) .all()

Exact binding and defaults
game.profile.all() game.profile = {

<a id="script-game-profile-get"></a>

game.profile.get()

From the engine's script reference: game.profile.get('best_time', 0) .set('beat_game', true) .all()

Exact binding and defaults
game.profile.get() game.profile = {

<a id="script-game-profile-set"></a>

game.profile.set()

From the engine's script reference: game.profile.get('best_time', 0) .set('beat_game', true) .all()

Exact binding and defaults
game.profile.set() game.profile = {

<a id="script-game-quests-advance"></a>

game.quests.advance(id, objective, count)

From the engine's script reference: game.quests.advance). optional: true doesn't hold the quest back. game.quests.start(id, force) / advance(id,

Exact binding and defaults
game.quests.advance(id, objective, count) { return __quest('advance', { id: String(id), objective: String(objective), count: count === undefined ? 1 : Number(count) }); }

<a id="script-game-quests-complete"></a>

game.quests.complete(id)

From the engine's script reference: game.quests.list() / game.quests.state(id) / game.quests.journal(id) read quests game.quests.complete(id) / game.quests.fail(id) end one game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.complete(id) { return __quest('complete', { id: String(id) }); }

<a id="script-game-quests-fail"></a>

game.quests.fail(id)

From the engine's script reference: game.quests.list() / game.quests.state(id) / game.quests.journal(id) read quests game.quests.complete(id) / game.quests.fail(id) end one game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.fail(id) { return __quest('fail', { id: String(id) }); }

<a id="script-game-quests-journal"></a>

game.quests.journal(id)

From the engine's script reference: game.quests.list() / game.quests.state(id) / game.quests.journal(id) read quests game.quests.complete(id) / game.quests.fail(id) end one game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.journal(id) { var r = __quest('journal', { id: String(id) }); return r === undefined || r === null ? [] : r; }

<a id="script-game-quests-list"></a>

game.quests.list()

From the engine's script reference: game.quests.list() / game.quests.state(id) / game.quests.journal(id) read quests game.quests.complete(id) / game.quests.fail(id) end one game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.list() { var r = __quest('list', {}); return r === undefined || r === null ? [] : r; }

<a id="script-game-quests-start"></a>

game.quests.start(id, force)

From the engine's script reference: game.quests.advance). optional: true doesn't hold the quest back. game.quests.start(id, force) / advance(id,

Exact binding and defaults
game.quests.start(id, force) { return __quest('start', { id: String(id), force: !!force }); }

<a id="script-game-quests-state"></a>

game.quests.state(id)

From the engine's script reference: game.quests.list() / game.quests.state(id) / game.quests.journal(id) read quests game.quests.complete(id) / game.quests.fail(id) end one game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.state(id) { var r = __quest('state', { id: String(id) }); return r === undefined ? null : r; }

<a id="script-game-quests-track"></a>

game.quests.track(id)

From the engine's script reference: game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
game.quests.track(id) { return __quest('track', { id: id ? String(id) : '' }); }

<a id="script-game-quests-tracked"></a>

game.quests.tracked

Access: read.

From the engine's script reference: game.quests.track(id) shows one on the HUD ("" none) game.quests.tracked the shown quest's id, or null

Exact binding and defaults
get game.quests.tracked() { var r = __quest('tracked', {}); return r === undefined ? null : r; }

<a id="script-game-rail"></a>

game.rail(points)

From the engine's script reference: game.rail([[x, y, z], ...]) a rail that boards grind along (world points); '' when made

Exact binding and defaults
game.rail(points) { var r = __board(0, 'rail', JSON.stringify({ points: points || [] })); return (r && r.error) || ''; }

<a id="script-game-raiseweapon"></a>

game.raiseWeapon(seconds)

From the engine's script reference: game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... })

Exact binding and defaults
game.raiseWeapon(seconds) { __raiseWeapon(seconds === undefined ? 0.6 : seconds); }

<a id="script-game-recoil"></a>

game.recoil(degrees)

degrees defaults to 1; zero also selects 1. Applies player recoil and returns nothing.

Exact binding and defaults
game.recoil(degrees) { __recoil(degrees || 1); }

<a id="script-game-reloadweapon"></a>

game.reloadWeapon(seconds)

From the engine's script reference: game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... })

Exact binding and defaults
game.reloadWeapon(seconds) { return __reloadWeapon(seconds || 2); }

<a id="script-game-righttoleft"></a>

game.rightToLeft()

From the engine's script reference: "auto") → true (saved with the player's settings; false for a language the game lacks); game.rightToLeft().

Exact binding and defaults
game.rightToLeft() { return !!__lang('rtl', {}); };

<a id="script-game-roof"></a>

game.roof(group)

From the engine's script reference: game.lighting2d({ time_of_day, ambient }) the scene's 2D lighting (made if missing) game.roof(group) a roof's reveal (0 shown ... 1 revealed)

Exact binding and defaults
game.roof(group) { var r = __roof2d(String(group)); return r === undefined || r === null ? null : r; };   // 0 shown ... 1 revealed

<a id="script-game-rumble"></a>

game.rumble(amount, seconds)

From the engine's script reference: game.rumble(amount, seconds) a fine trembling (an engine). game.impact(strength) a blow: the view dips and

Exact binding and defaults
game.rumble(amount, seconds) { __cameraShake('rumble', { amount: amount === undefined ? 0.5 : amount, seconds: seconds === undefined ? 1 : seconds }); }

<a id="script-game-save"></a>

game.save(slot)

slot defaults to save. Returns true when the save was written. It saves supported play state and each entity's self.save data, not arbitrary closure variables. Use a slot of 1–40 letters, digits, underscores or hyphens.

Exact binding and defaults
game.save(slot) { return !!__saveGame(String(slot || 'save')); }

<a id="script-game-saveslot"></a>

game.saveSlot(n, label)

From the engine's script reference: same before any script runs. game.saveSlot / loadSlot / slots / continueGame still work.

Exact binding and defaults
game.saveSlot(n, label) { return __slot('save', n, label || ''); };

<a id="script-game-saves-autosave"></a>

game.saves.autosave()

From the engine's script reference: autosave() · restoreBackup(n) · game.saves.schema(2, [{ from: 1, rename: { gold: "coins" }, defaults: { lives: 3 },

Exact binding and defaults
game.saves.autosave() game.saves = {

<a id="script-game-saves-continuegame"></a>

game.saves.continueGame()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.continueGame() game.saves = {

<a id="script-game-saves-info"></a>

game.saves.info()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.info() game.saves = {

<a id="script-game-saves-list"></a>

game.saves.list()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.list() game.saves = {

<a id="script-game-saves-load"></a>

game.saves.load()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.load() game.saves = {

<a id="script-game-saves-remove"></a>

game.saves.remove()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.remove() game.saves = {

<a id="script-game-saves-restorebackup"></a>

game.saves.restoreBackup()

From the engine's script reference: autosave() · restoreBackup(n) · game.saves.schema(2, [{ from: 1, rename: { gold: "coins" }, defaults: { lives: 3 },

Exact binding and defaults
game.saves.restoreBackup() game.saves = {

<a id="script-game-saves-save"></a>

game.saves.save()

From the engine's script reference: game.saves.save(1, "Before the boss") · load(1) · continueGame() (newest) · list() · info(n) · remove(n) ·

Exact binding and defaults
game.saves.save() game.saves = {

<a id="script-game-saves-schema"></a>

game.saves.schema()

From the engine's script reference: autosave() · restoreBackup(n) · game.saves.schema(2, [{ from: 1, rename: { gold: "coins" }, defaults: { lives: 3 },

Exact binding and defaults
game.saves.schema() game.saves = {

<a id="script-game-saves-version"></a>

game.saves.version

Access: read.

From the engine's script reference: remove: ["debug"] }]) upgrades older saves (onMessage 'save_migrated' { from, to }); game.saves.version the game state's version now; UI/save_schema.json does the

Exact binding and defaults
get game.saves.version() game.saves = {

<a id="script-game-say"></a>

game.say(speaker, text, o)

From the engine's script reference: game.say("AWACS", "Bandits north, 20 miles", { voice: "awacs_bandits", seconds: 4, priority: 2 }) shows

Exact binding and defaults
game.say(speaker, text, o) {

<a id="script-game-sayclear"></a>

game.sayClear()

From the engine's script reference: screen { id, speaker, text, priority, waiting } or null; game.sayClear() empties the queue. Scripts get

Exact binding and defaults
game.sayClear() { __speak('clear', {}); };

<a id="script-game-scores-add"></a>

game.scores.add()

From the engine's script reference: game.scores.add('arcade', 'Ana', 12340) points, most first; game.scores.add('Kart Rush', 'Ana', { time: 83.4 }) times, shortest first (a table keeps the kind it started with) → { ok, rank (1 = best, 0 = not kept), best, previous_best, text }

Exact binding and defaults
game.scores.add() game.scores = {

<a id="script-game-scores-best"></a>

game.scores.best()

From the engine's script reference: game.scores.top(table, 10) → [{ rank, name, score | time, text ("1:23.40", "12,340"), date, latest }] .best(table) .qualifies(table, value, 10) (would it make the top 10: ask for a name only then) .clear(table) .tables()

Exact binding and defaults
game.scores.best() game.scores = {

<a id="script-game-scores-clear"></a>

game.scores.clear()

From the engine's script reference: game.scores.top(table, 10) → [{ rank, name, score | time, text ("1:23.40", "12,340"), date, latest }] .best(table) .qualifies(table, value, 10) (would it make the top 10: ask for a name only then) .clear(table) .tables()

Exact binding and defaults
game.scores.clear() game.scores = {

<a id="script-game-scores-entername"></a>

game.scores.enterName()

From the engine's script reference: game.scores.enterName(table, value, { title, placeholder, max }) asks the name (the typing overlay), adds it and opens the scores screen; onMessage 'score_added' { table, rank, best, name, text } (Esc: 'text_cancelled', nothing added). game.scores.show(table, { title }) opens the scores screen (add_ui_screen template "scores"; desktop and Mac/Windows games).

Exact binding and defaults
game.scores.enterName() game.scores = {

<a id="script-game-scores-qualifies"></a>

game.scores.qualifies()

From the engine's script reference: game.scores.top(table, 10) → [{ rank, name, score | time, text ("1:23.40", "12,340"), date, latest }] .best(table) .qualifies(table, value, 10) (would it make the top 10: ask for a name only then) .clear(table) .tables()

Exact binding and defaults
game.scores.qualifies() game.scores = {

<a id="script-game-scores-show"></a>

game.scores.show()

From the engine's script reference: game.scores.show(table, { title }) opens the scores screen (add_ui_screen template "scores"; desktop and Mac/Windows games).

Exact binding and defaults
game.scores.show() game.scores = {

<a id="script-game-scores-tables"></a>

game.scores.tables()

From the engine's script reference: game.scores.top(table, 10) → [{ rank, name, score | time, text ("1:23.40", "12,340"), date, latest }] .best(table) .qualifies(table, value, 10) (would it make the top 10: ask for a name only then) .clear(table) .tables()

Exact binding and defaults
game.scores.tables() game.scores = {

<a id="script-game-scores-top"></a>

game.scores.top()

From the engine's script reference: game.scores.top(table, 10) → [{ rank, name, score | time, text ("1:23.40", "12,340"), date, latest }] .best(table) .qualifies(table, value, 10) (would it make the top 10: ask for a name only then) .clear(table) .tables()

Exact binding and defaults
game.scores.top() game.scores = {

<a id="script-game-sequence"></a>

game.sequence

Access: read.

From the engine's script reference: object gets onMessage 'sequence_finished' { name, how } when it ends. game.stopSequence() game.sequence (or null)

Exact binding and defaults
get game.sequence() { var n = __sequence(); return n === undefined ? null : n; }

<a id="script-game-setlanguage"></a>

game.setLanguage(code)

From the engine's script reference: game.language() → "es"; game.languages() → [{ code, name, native, rightToLeft }]; game.setLanguage("ja" or

Exact binding and defaults
game.setLanguage(code) { return !!__lang('set', { code: code === undefined ? 'auto' : String(code) }); };

<a id="script-game-shake"></a>

game.shake(strength, seconds, options)

strength is degrees, default 2; seconds defaults to 0.5. Applies a fading camera shake and returns nothing. Explicit zero is preserved.

Exact binding and defaults
game.shake(strength, seconds, options) {   // degrees, fading out (2D: screen pixels); options.at [x, y, z]: a blast's shake from there
        if (options && options.at) __cameraShake('blast', { at: options.at, power: options.power === undefined ? strength / 3 : options.power, reach: options.reach === undefined ? 40 : options.reach });
        else __shake(strength === undefined ? 2 : strength, seconds === undefined ? 0.5 : seconds);
      }

<a id="script-game-shockwave"></a>

game.shockwave(at, o)

From the engine's script reference: game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings

Exact binding and defaults
game.shockwave(at, o) { __shockwave(at, o || {}); }

<a id="script-game-shoot"></a>

game.shoot(options)

From the engine's script reference: game.shoot({ ... }) fires the held weapon as the player (null: no shot, as with the gun raised against a wall) game.weapon() its state (ammo, reloading) game.weaponData(name) a weapon set's numbers game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... }) game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.shoot(options) { var r = __shoot(JSON.stringify(options || {})); return r === undefined ? null : r; }

<a id="script-game-shooting"></a>

game.shooting()

From the engine's script reference: game.defineWeapon({ name, base, ... }) a new 2D weapon game.shooting() the 2D shooting report

Exact binding and defaults
game.shooting() { return __shoot2d(-1, 'report', {}); };

<a id="script-game-shops-buy"></a>

game.shops.buy()

From the engine's script reference: game.shops.info('market_stall', player) .buy('market_stall', player, 'turnip_seeds', 5) .sell('market_stall', player, 'turnip', 3) .newDay() (restock) .open('market_stall') (the shop screen)

Exact binding and defaults
game.shops.buy() game.shops = {

<a id="script-game-shops-info"></a>

game.shops.info()

From the engine's script reference: game.shops.info('market_stall', player) .buy('market_stall', player, 'turnip_seeds', 5) .sell('market_stall', player, 'turnip', 3) .newDay() (restock) .open('market_stall') (the shop screen)

Exact binding and defaults
game.shops.info() game.shops = {

<a id="script-game-shops-newday"></a>

game.shops.newDay()

From the engine's script reference: game.shops.info('market_stall', player) .buy('market_stall', player, 'turnip_seeds', 5) .sell('market_stall', player, 'turnip', 3) .newDay() (restock) .open('market_stall') (the shop screen)

Exact binding and defaults
game.shops.newDay() game.shops = {

<a id="script-game-shops-open"></a>

game.shops.open()

From the engine's script reference: game.shops.info('market_stall', player) .buy('market_stall', player, 'turnip_seeds', 5) .sell('market_stall', player, 'turnip', 3) .newDay() (restock) .open('market_stall') (the shop screen)

Exact binding and defaults
game.shops.open() game.shops = {

<a id="script-game-shops-sell"></a>

game.shops.sell()

From the engine's script reference: game.shops.info('market_stall', player) .buy('market_stall', player, 'turnip_seeds', 5) .sell('market_stall', player, 'turnip', 3) .newDay() (restock) .open('market_stall') (the shop screen)

Exact binding and defaults
game.shops.sell() game.shops = {

<a id="script-game-show"></a>

game.show(text, seconds, player)

text is displayed as a message; seconds defaults to 3, and zero also selects 3. Returns nothing.

Exact binding and defaults
game.show(text, seconds, player) {
        if (player && player.id !== undefined) __showTo(String(text), seconds || 3, player.id); else __show(String(text), seconds || 3);
      }

<a id="script-game-signallost"></a>

game.signalLost(seconds)

From the engine's script reference: Screen: game.glitch(amount, seconds) game.tvStatic(amount, seconds) game.vhs(amount) (none: off) game.crtOff(seconds, hold) game.signalLost(seconds) game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.signalLost(seconds) { var s = seconds === undefined ? 1.2 : Number(seconds); __signal('glitch', 1, 0.3, 0); __signal('static', 0.92, s, 0); }

<a id="script-game-skipcutscene"></a>

game.skipCutscene()

Requests a skip of the active cutscene. Returns nothing. Skipping follows the cutscene system's event/hand-off rules; it is not identical to stopping.

Exact binding and defaults
game.skipCutscene() { __skipCutscene(); }

<a id="script-game-slots"></a>

game.slots()

From the engine's script reference: game.newGame() / game.continueGame() (the newest slot) / game.loadSlot(n) / game.deleteSlot(n) / game.slots() [{ slot, status, label, scene, savedAt, playSeconds }]

Exact binding and defaults
game.slots() { return __slot('list', 0, ''); };      // [{ slot, status, label, scene, savedAt, playSeconds }]

<a id="script-game-slowmotion"></a>

game.slowMotion(scale, seconds)

From the engine's script reference: Feel: game.slowMotion(scale, seconds) game.stopWorld(seconds) hit-stop for everything game.burst(kind, at, dir) game.fx(name, at, dir, strength) game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings game.hitFeel(target, { at, direction, strength 0..2, material, source, kill, skip }) everything a 3D hit gets in one call: hit-stop on both, the camera shake, what flies off what was hit (blood off a body, sparks off metal or a robot,

Exact binding and defaults
game.slowMotion(scale, seconds) { __feel('slow', -1, { scale: scale === undefined ? 0.2 : scale, seconds: seconds === undefined ? 0.65 : seconds }); }

<a id="script-game-snapshot"></a>

game.snapshot(which, seconds)

From the engine's script reference: game.snapshot("underwater", 0.5) blends the whole mix to a snapshot (underwater, muffled, stunned, pause, focus, quiet, or your own { music, ambience, sfx, voice, ui, lowpass }); game.snapshot() blends back to the scene's mix

Exact binding and defaults
game.snapshot(which, seconds) {

<a id="script-game-sound"></a>

game.sound(name, position, volume, pitch)

name is a sound key; optional position is [x,y,z] (otherwise the camera). volume defaults to 1; pitch defaults to 1 and zero also selects 1. Returns the native success boolean. Headless play does not play audio; its return only recognizes built-in sound names, so it is not an audible-playback test.

Exact binding and defaults
game.sound(name, position, volume, pitch) { return __sound(String(name), position || null, volume === undefined ? 1 : volume, pitch || 1); }

<a id="script-game-spawnpoint"></a>

game.spawnPoint(o)

From the engine's script reference: game.spawnPoint({ near, min, max, hidden }) a free spot on the ground min...max m away (hidden: out of the player's sight) game.watching true while the player looks at self

Exact binding and defaults
game.spawnPoint(o) { o = o || {}; var p = o.near || (game.player ? game.player.position : [0, 0, 0]);
        if (p && p.position) p = p.position;
        return __spawnPoint(p, o.min === undefined ? 20 : o.min, o.max === undefined ? 40 : o.max, o.hidden !== false, o.seed || 0); }

<a id="script-game-state-add"></a>

game.state.add()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.add() game.state = {

<a id="script-game-state-all"></a>

game.state.all()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.all() game.state = {

<a id="script-game-state-flag"></a>

game.state.flag()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.flag() game.state = {

<a id="script-game-state-get"></a>

game.state.get()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.get() game.state = {

<a id="script-game-state-has"></a>

game.state.has()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.has() game.state = {

<a id="script-game-state-remove"></a>

game.state.remove()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.remove() game.state = {

<a id="script-game-state-set"></a>

game.state.set()

From the engine's script reference: game.state.get('coins', 0) .set('door_open', true) .add('coins', 5) .has(key) .remove(key) .all() .flag(key)

Exact binding and defaults
game.state.set() game.state = {

<a id="script-game-stopcutscene"></a>

game.stopCutscene()

Stops the active cutscene. Returns nothing.

Exact binding and defaults
game.stopCutscene() { __stopCutscene(); }

<a id="script-game-stopsequence"></a>

game.stopSequence()

From the engine's script reference: object gets onMessage 'sequence_finished' { name, how } when it ends. game.stopSequence() game.sequence (or null)

Exact binding and defaults
game.stopSequence() { __stopSequence(); }

<a id="script-game-stopworld"></a>

game.stopWorld(seconds)

From the engine's script reference: Feel: game.slowMotion(scale, seconds) game.stopWorld(seconds) hit-stop for everything game.burst(kind, at, dir) game.fx(name, at, dir, strength) game.shockwave(at, { radius, strength }) game.effectRecipe({ ... }) a whole effect from a recipe game.feel(settings) sets (or with none, reports) the feel settings game.hitFeel(target, { at, direction, strength 0..2, material, source, kill, skip }) everything a 3D hit gets in one call: hit-stop on both, the camera shake, what flies off what was hit (blood off a body, sparks off metal or a robot,

Exact binding and defaults
game.stopWorld(seconds) { __feel('stop', -1, { seconds: seconds === undefined ? 0.06 : seconds }); }

<a id="script-game-sun"></a>

game.sun(v)

v is an optional object with numeric azimuth, elevation, and/or intensity. Missing keys keep their values. Returns those three values; with no directional light the returned fields are undefined. Native elevation is clamped to -90…90 degrees and intensity to 0…100.

Exact binding and defaults
game.sun(v) { var r = __sun(v || {}); return { azimuth: r[0], elevation: r[1], intensity: r[2] }; }

<a id="script-game-t"></a>

game.t(key, values)

From the engine's script reference: game.t("quest.oil", { place: "the mill" }) → a key's (or a sentence's) text in the player's language,

Exact binding and defaults
game.t(key, values) {

<a id="script-game-talk"></a>

game.talk(id, options)

From the engine's script reference: side, voice, next, choices [{ text, if, do, goto }], if, else, do, end } } }): game.talk("rowan", { start: "ask",

Exact binding and defaults
game.talk(id, options) {
        var o = options || {}, w = o.with, wid = w && w.id !== undefined ? w.id : (typeof w === 'number' ? w : -1);
        return __dialogue('talk', { id: String(id), start: o.start === undefined || o.start === null ? '' : String(o.start), with: wid });
      }

<a id="script-game-teleport"></a>

game.teleport(at, look, player, snap)

From the engine's script reference: game.teleport([x, y, z], look, player, snap) moves a player at once (a teleporter, a respawn): feet put on the floor under the point (snap false: exactly there), walking and falling stopped, the view turned to look [x, y, z] if given → what they landed on ("on <name>", "on the land"), or "" if it couldn't.

Exact binding and defaults
game.teleport(at, look, player, snap) { return __teleport(JSON.stringify({ at: at, look: look || null, snap: snap === undefined ? true : !!snap }), player && player.id !== undefined ? player.id : -1); }

<a id="script-game-threat"></a>

game.threat(level, seconds)

From the engine's script reference: game.threat("chase", 3) the adaptive score (audio_music) hears a threat for 3 s: "calm", "tension" or "chase" (a creature with its own script, no awareness component, still drives the music; call it each tick it hunts)

Exact binding and defaults
game.threat(level, seconds) {

<a id="script-game-time"></a>

game.time

Access: read.

Read-only simulation time in seconds, not a wall clock.

Exact binding and defaults
get game.time() { return __time; }

<a id="script-game-timeofday"></a>

game.timeOfDay(v)

From the engine's script reference: game.timeOfDay() the scene's clock (time_of_day component) → { hour, day, day_minutes, sun_elevation, night }, null without one. game.timeOfDay({ hour: 21.5 }) jumps to 9:30 PM; { day_minutes: 0 } stops the clock, -1 back to the scene's speed. The sun and the day's colour follow the hour; shops, traffic and people can keep to it. Built-in sounds: shot, shot_heavy, hit, hurt, pickup, explosion, alarm, footstep, click, wind, hum (fluorescent lights).

Exact binding and defaults
game.timeOfDay(v) { var r = __timeOfDay(v || {}); return r.length ? { hour: r[0], day: r[1], day_minutes: r[2], sun_elevation: r[3], night: r[4] > 0.5 } : null; }

<a id="script-game-titlecard"></a>

game.titleCard(text, o)

From the engine's script reference: game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera

Exact binding and defaults
game.titleCard(text, o) {
        o = o || {};
        var d = { text: String(text) };
        ['sub', 'style', 'font', 'fill', 'position'].forEach(function (k) { if (o[k] !== undefined) d[k] = String(o[k]); });
        if (o.size !== undefined) d.size = Number(o.size);
        if (o.hold !== undefined) d.hold = Number(o.hold);
        if (o.style === 'glitch') __signal('glitch', 0.45, 0.35, 0);
        return __gameUI('title_card', d);
      }

<a id="script-game-tvstatic"></a>

game.tvStatic(amount, seconds)

From the engine's script reference: Screen: game.glitch(amount, seconds) game.tvStatic(amount, seconds) game.vhs(amount) (none: off) game.crtOff(seconds, hold) game.signalLost(seconds) game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.tvStatic(amount, seconds) { __signal('static', amount === undefined ? 1 : Number(amount), seconds === undefined ? 1 : Number(seconds), 0); }

<a id="script-game-ui"></a>

game.ui(command, data)

From the engine's script reference: game.ui('hand', {json: JSON.stringify({cards:[{name:"Snuff", cost:1, text:"Deal 3", playable:true}], pick:0, played:{name:"Snuff", cost:1, text:"Deal 3"}})}): a card game's hand as framed cards along the bottom (the UI pack's plate art; the picked one raised; played rises over the table a moment); clicks, Left / Right / D-pad and A send onMessage "ui_hand" {action:"pick"|"play", index} (1-9 and Enter stay the script's); keys:false leaves the arrows to the game;

Exact binding and defaults
game.ui(command, data) {
        // cloud/game-ui: a list's rows (objects) travel as one JSON text.
        if (String(command) === 'list' && data && data.rows !== undefined) data = {key: String(data.key), json: JSON.stringify(data.rows || [])};
        // One player's own HUD value (online, each machine shows its own player's): { key, value, player } with the player
        // as an entity or its id.
        if (data && data.player && data.player.id !== undefined) { var d = {}; for (var k in data) d[k] = data[k]; d.player = data.player.id; data = d; }
        return !!__gameUI(String(command), data || {}); }

<a id="script-game-unshow"></a>

game.unshow(text)

From the engine's script reference: game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera

Exact binding and defaults
game.unshow(text) { __unshow(String(text)); }

<a id="script-game-vhs"></a>

game.vhs(amount)

From the engine's script reference: Screen: game.glitch(amount, seconds) game.tvStatic(amount, seconds) game.vhs(amount) (none: off) game.crtOff(seconds, hold) game.signalLost(seconds) game.titleCard(text, { sub, style, font, fill, position, size, hold }) game.unshow(text) removes a game.show line game.liveScreen(name, { ... }) a screen showing a camera game.apparition(picture, { ... }) / game.apparitions([pictures], chance) a figure glimpsed at the edge of view

Exact binding and defaults
game.vhs(amount) { return __signal('vhs', amount === undefined ? -1 : Number(amount), 0, 0); }

<a id="script-game-viewassist"></a>

game.viewAssist(o, player)

From the engine's script reference: game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.viewAssist(o, player) { __viewAssist(o ? JSON.stringify(o) : 'null', player && player.id !== undefined ? player.id : -1); }

<a id="script-game-vn"></a>

game.vn(options)

From the engine's script reference: game.vn({ auto, skip, delay }): auto moves lines on by themselves; skip passes lines seen in any playthrough

Exact binding and defaults
game.vn(options) { return __dialogue('vn', options || {}); }

<a id="script-game-voice"></a>

game.voice(name, gain)

From the engine's script reference: Sound: game.voice(name, gain) plays a voice line (true if found) game.duck(db, seconds) lowers the music under speech game.mix() the mix report

Exact binding and defaults
game.voice(name, gain) { return !!__audio('voice', { name: String(name), gain: gain === undefined ? 1 : gain }); };

<a id="script-game-watch"></a>

game.watch(from, at, fov, lens)

from and at are world [x,y,z] camera/target points; fov defaults to 40 degrees. Passing null for from releases the watching camera. Returns nothing. Intended for showcases/labs without a player.

Exact binding and defaults
game.watch(from, at, fov, lens) { if (!from) __watch([], [], 0, {}); else __watch(from, at, fov || 40, lens || {}); }

<a id="script-game-watching"></a>

game.watching

Access: read.

From the engine's script reference: game.spawnPoint({ near, min, max, hidden }) a free spot on the ground min...max m away (hidden: out of the player's sight) game.watching true while the player looks at self

Exact binding and defaults
get game.watching() { return !!__watching(); }

<a id="script-game-weapon"></a>

game.weapon()

From the engine's script reference: game.shoot({ ... }) fires the held weapon as the player (null: no shot, as with the gun raised against a wall) game.weapon() its state (ammo, reloading) game.weaponData(name) a weapon set's numbers game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... }) game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.weapon() { return __weaponState(); }

<a id="script-game-weapondata"></a>

game.weaponData(name)

From the engine's script reference: game.shoot({ ... }) fires the held weapon as the player (null: no shot, as with the gun raised against a wall) game.weapon() its state (ammo, reloading) game.weaponData(name) a weapon set's numbers game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... }) game.equipWeapon({ set, model }) / game.offhand({ ... }) or null game.viewAssist({ ... }, player) aim assist, null off

Exact binding and defaults
game.weaponData(name) { var s = __weaponData(String(name || '')); return s ? JSON.parse(s) : null; }

<a id="script-game-weaponmagazine"></a>

game.weaponMagazine(present)

From the engine's script reference: game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... })

Exact binding and defaults
game.weaponMagazine(present) { __weaponMagazine(!!present); }

<a id="script-game-weaponsupport"></a>

game.weaponSupport(offset)

From the engine's script reference: game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... })

Exact binding and defaults
game.weaponSupport(offset) { __weaponSupport(offset || [0, 0, 0]); }

<a id="script-game-weaponview"></a>

game.weaponView(options)

From the engine's script reference: game.raiseWeapon(seconds) / game.reloadWeapon(seconds) / game.weaponMagazine(present) / game.weaponSupport([x, y, z]) / game.weaponView({ ... })

Exact binding and defaults
game.weaponView(options) { return __weaponView(JSON.stringify(options || {})); }

<a id="script-game-win"></a>

game.win(text)

text defaults to Mission complete. Records a won outcome and returns nothing. The play session keeps the first recorded outcome.

Exact binding and defaults
game.win(text) { __win(String(text || 'Mission complete')); }

<a id="script-input-action"></a>

input.action(id)

From the engine's script reference: input.action("jump") held · input.pressed("attack") this tick · input.released("jump") · input.value("move_right")

Exact binding and defaults
input.action(id) { return !!__action('down', String(id)); };

<a id="script-input-actions"></a>

input.actions()

From the engine's script reference: input.actions() the game's declared actions (the controls a player can rebind)

Exact binding and defaults
input.actions() { return __action('list', '') || []; };

<a id="script-input-axis"></a>

input.axis(negative, positive)

From the engine's script reference: (0...1, a stick's share) · input.axis("move_left", "move_right") (-1...1). Standard actions: move_left/right/up/down,

Exact binding and defaults
input.axis(negative, positive) { return __action('axis', String(negative), String(positive)) || 0; };

<a id="script-input-device"></a>

input.device

Access: read.

From the engine's script reference: input.prompt("interact", "Talk") → "[E] Talk" or "(X) Talk" for the device in use; input.device ("keyboard" /

Exact binding and defaults
get input.device() Object.defineProperty(input, 'device', { get: function () { return __action('device', '') || 'keyboard'; }, configurable: true });

<a id="script-input-family"></a>

input.family

Access: read.

From the engine's script reference: "gamepad"); input.family ("xbox" / "playstation" / "nintendo"); input.pad { connected, buttons, left, right, lt, rt }.

Exact binding and defaults
get input.family() Object.defineProperty(input, 'family', { get: function () { return __action('family', '') || 'xbox'; }, configurable: true });

<a id="script-input-glyph"></a>

input.glyph(id)

From the engine's script reference: ({ id: "attack", logicalKey: "J", pad: ["x"], label: "Attack" }). input.glyph("interact") → "E" / "X" / "Square";

Exact binding and defaults
input.glyph(id) { return __action('glyph', String(id)) || ''; };

<a id="script-input-isdown"></a>

input.isDown(key)

key is a key name converted to text, such as W, Space, or Shift. Returns a boolean for the relevant player/input context.

Exact binding and defaults
input.isDown(key) { return __key(String(key)); }

<a id="script-input-mousedown"></a>

input.mouseDown(button)

button selects right only when it is the exact string right; every other value, including omitted, selects left. Returns a boolean. Use left or right, not numeric button IDs.

Exact binding and defaults
input.mouseDown(button) { return __mouse(button === 'right' ? 1 : 0); }

<a id="script-input-pad"></a>

input.pad

Access: read.

From the engine's script reference: "gamepad"); input.family ("xbox" / "playstation" / "nintendo"); input.pad { connected, buttons, left, right, lt, rt }.

Exact binding and defaults
get input.pad() Object.defineProperty(input, 'pad', { get: function () { return __action('pad', ''); }, configurable: true });

<a id="script-input-pointer"></a>

input.pointer()

From the engine's script reference: Mouse (builders, strategy and point-and-click games): input.mouseDown("left" / "right"), input.pointer() → { x, y } (-1...1 from the middle, y up; null off the view), input.wheel() scroll since the last tick (positive toward the view), input.pointerRay() → { origin, direction } from the game's camera through the pointer (null without one): world.raycast(r.origin, r.direction, 500) is what's under the mouse. kits/builder.js and kits/strategy_camera.js

Exact binding and defaults
input.pointer() { var p = __pointer(); return p ? { x: p[0] * 2 - 1, y: p[1] * 2 - 1 } : null; }

<a id="script-input-pointerray"></a>

input.pointerRay()

From the engine's script reference: view), input.pointerRay() → { origin, direction } from the game's camera through the pointer (null without one):

Exact binding and defaults
input.pointerRay() { var r = __pointerRay(); return r ? { origin: r[0], direction: r[1] } : null; }

<a id="script-input-pressed"></a>

input.pressed(id)

From the engine's script reference: input.action("jump") held · input.pressed("attack") this tick · input.released("jump") · input.value("move_right")

Exact binding and defaults
input.pressed(id) { return !!__action('pressed', String(id)); };

<a id="script-input-prompt"></a>

input.prompt(id, text)

From the engine's script reference: input.prompt("interact", "Talk") → "[E] Talk" or "(X) Talk" for the device in use; input.device ("keyboard" /

Exact binding and defaults
input.prompt(id, text) { return __action('prompt', String(id), text === undefined ? null : String(text)) || ''; };

<a id="script-input-released"></a>

input.released(id)

From the engine's script reference: input.action("jump") held · input.pressed("attack") this tick · input.released("jump") · input.value("move_right")

Exact binding and defaults
input.released(id) { return !!__action('released', String(id)); };

<a id="script-input-toscreen"></a>

input.toScreen(point)

From the engine's script reference: input.toScreen([x, y, z]) where a world point shows on screen: { x, y } in pixels, or null behind the camera

Exact binding and defaults
input.toScreen(point) { var s = __toScreen(point); return s ? { x: s[0], y: s[1] } : null; }

<a id="script-input-value"></a>

input.value(id)

From the engine's script reference: input.action("jump") held · input.pressed("attack") this tick · input.released("jump") · input.value("move_right")

Exact binding and defaults
input.value(id) { return __action('value', String(id)) || 0; };

<a id="script-input-wheel"></a>

input.wheel()

From the engine's script reference: (-1...1 from the middle, y up; null off the view), input.wheel() scroll since the last tick (positive toward the

Exact binding and defaults
input.wheel() { return __wheel(); }

<a id="script-log"></a>

log()

Accepts any number of values even though the declaration has no named parameters. Objects are JSON-stringified, other values converted to text, then joined with spaces in the script log. Returns nothing. Circular objects cannot be JSON-stringified.

Exact binding and defaults
log() { __log(Array.prototype.slice.call(arguments).map(function (a) { return typeof a === 'object' ? JSON.stringify(a) : String(a); }).join(' ')); }

<a id="script-random"></a>

random()

Returns a number at least 0 and less than 1 from the runtime's seeded sequence. Repeating the same seed and calls repeats the sequence. This is the engine helper, not a promise about Math.random().

Exact binding and defaults
random() { __seed = (__seed * 1103515245 + 12345) % 2147483648; return __seed / 2147483648; }

<a id="script-world-all"></a>

world.all(tag)

tag is a tag string. Returns an array of matching Entity wrappers, possibly empty.

Exact binding and defaults
world.all(tag) { return __all(tag).map(function (id) { return new Entity(id); }); }

<a id="script-world-copy"></a>

world.copy(entity, name, position)

From the engine's script reference: world.copy(entity, "name", [x, y, z]) a copy of an object, placed (null if it can't) world.equip(who, ...) / world.unequip(who, slot) the same as entity.equip by name

Exact binding and defaults
world.copy(entity, name, position) {
        if (!entity || typeof name !== 'string' || !position) throw new TypeError('copy needs an entity, a name and a position');
        var id = __copyEntity(entity.id, name, position); return id < 0 ? null : new Entity(id);
      }

<a id="script-world-decal"></a>

world.decal(point, normal, kind, size, options)

Presses a decal onto whatever surface lies at point (a world [x,y,z]), facing normal (e.g. a world.raycast hit's normal). kind is a built-in mark (bullet_hole, crack, rust_streak, water_stain, drips, scorch, chipped_paint, oil, glass_crack, grime) or image with options.image a PNG path inside Assets. size is meters: a number or [wide, tall, deep]. Options: color (sRGB tint), opacity, roughness (-1 keeps the surface's), depth (bump), seed, spin (degrees; random by default), name. Returns the decal's Entity or null; destroy it to remove the mark.

Exact binding and defaults
world.decal(point, normal, kind, size, options) {
        var o = options || {}, n = normal || [0, 1, 0], l = Math.hypot(n[0], n[1], n[2]) || 1;
        var rx = -Math.asin(Math.max(-1, Math.min(1, n[1] / l))) * 180 / Math.PI, ry = Math.atan2(n[0], n[2]) * 180 / Math.PI;
        var s = typeof size === 'number' ? [size, size, Math.max(size, 0.2)] : (size || [0.12, 0.12, 0.3]);
        var c = o.color || [1, 1, 1], spin = o.spin === undefined ? random() * 360 : o.spin;
        return world.spawn(o.name || 'Decal', 'transform { position (' + point[0] + ', ' + point[1] + ', ' + point[2] + ')  rotation (' + rx + ', ' + ry + ', ' + spin + ') } ' +
          'decal { kind "' + String(kind || 'bullet_hole') + '"  image "' + String(o.image || '') + '"  size (' + s[0] + ', ' + s[1] + ', ' + s[2] + ')  color (' + c[0] + ', ' + c[1] + ', ' + c[2] + ')' +
          '  opacity ' + (o.opacity === undefined ? 1 : o.opacity) + '  roughness ' + (o.roughness === undefined ? -1 : o.roughness) +
          '  depth ' + (o.depth === undefined ? 0.5 : o.depth) + '  seed ' + (o.seed === undefined ? Math.floor(random() * 99999) : o.seed) + ' }');
      }

<a id="script-world-equip"></a>

world.equip(who, a, b)

From the engine's script reference: world.copy(entity, "name", [x, y, z]) a copy of an object, placed (null if it can't) world.equip(who, ...) / world.unequip(who, slot) the same as entity.equip by name

Exact binding and defaults
world.equip(who, a, b) { var e = typeof who === 'string' ? this.find(who) : who; return e ? e.equip(a, b) : { ok: false, reason: 'no ' + who }; }

<a id="script-world-find"></a>

world.find(name)

name is an entity name. Returns an Entity or null when not found. Check the result before accessing its fields.

Exact binding and defaults
world.find(name) { var id = __find(name); return id < 0 ? null : new Entity(id); }

<a id="script-world-groundheight"></a>

world.groundHeight(x, z)

x and z are world coordinates in meters. Returns terrain height or null when no terrain is found there. This is not a general downward raycast onto every prop.

Exact binding and defaults
world.groundHeight(x, z) { return __ground(x, z); }

<a id="script-world-landsupport"></a>

world.landSupport(x, z)

From the engine's script reference: world.landSupport(x, z) the ground under a point: { height, normal, surface } or null

Exact binding and defaults
world.landSupport(x, z) { var s = __support(x, z); return s === undefined ? null : s; }

<a id="script-world-lineofsight"></a>

world.lineOfSight(a, b)

From the engine's script reference: world.overlap2d(center, size) the entities in a box world.lineOfSight(a, b) true when no wall or solid is between (entities or points)

Exact binding and defaults
world.lineOfSight(a, b) {

<a id="script-world-overlap2d"></a>

world.overlap2d(center, size)

From the engine's script reference: world.overlap2d(center, size) the entities in a box world.lineOfSight(a, b) true when no wall or solid is between (entities or points)

Exact binding and defaults
world.overlap2d(center, size) { return __overlap2d(center, size).map(function (id) { return new Entity(id); }); };

<a id="script-world-ray2d"></a>

world.ray2d(from, to, ignore)

From the engine's script reference: world.ray2d(from, to, ignore) the first hit: { entity, point, normal, distance } or null world.sweep2d(entity, [dx, dy]) where a moving body first touches: { t, point, normal, entity } or null

Exact binding and defaults
world.ray2d(from, to, ignore) {

<a id="script-world-raycast"></a>

world.raycast(origin, direction, maxDistance, ignore)

origin and direction are three-number vectors; maxDistance defaults to 1000 meters (zero also selects 1000). Optional ignore is an Entity. Returns null or {entity, point, normal, distance}; a terrain hit may have null entity. The play bridge ignores players. The public wrapper does not return the native hit's limb field in this revision.

Exact binding and defaults
world.raycast(origin, direction, maxDistance, ignore) {
        var h = __raycast(origin, direction, maxDistance || 1000, ignore ? ignore.id : -1);
        if (!h) return null;
        return { entity: h.entity >= 0 ? new Entity(h.entity) : null, point: h.point, normal: h.normal, distance: h.distance };
      }

<a id="script-world-spawn"></a>

world.spawn(name, components)

name is the new name; components is scene-component text, not a JavaScript object, default empty. Returns an Entity or null on failure. Attached scripts start immediately. Supply the components needed for the desired rendering, physics and behavior.

Exact binding and defaults
world.spawn(name, components) {
        if (typeof name !== 'string' || (components != null && typeof components !== 'string'))
          throw new TypeError('spawn name and components must be strings');
        var id = __spawn(name, components || ''); return id < 0 ? null : new Entity(id);
      }

<a id="script-world-spawnprefab"></a>

world.spawnPrefab(prefab, position, rotation, name)

From the engine's script reference: world.spawnPrefab("Crate", [x, y, z], [rx, ry, rz]?, "Name"?) → a copy of Assets/Prefabs/Crate.ttrprefab with its parts (null if no such prefab) (components as scene text; walls and lamps added this way collide, light and path like the scene's own)

Exact binding and defaults
world.spawnPrefab(prefab, position, rotation, name) {
        var parts = __prefabParts(String(prefab));
        if (!parts || !parts.length) return null;
        var p = position || [0, 0, 0], r = rotation || [0, 0, 0], s = parts[0].scale || [1, 1, 1];
        var root = this.spawn(name || parts[0].name, 'transform { position (' + p[0] + ', ' + p[1] + ', ' + p[2] + ')  rotation (' + r[0] + ', ' + r[1] + ', ' + r[2] + ')  scale (' + s[0] + ', ' + s[1] + ', ' + s[2] + ') }  ' + parts[0].body);
        if (!root) return null;
        for (var i = 1; i < parts.length; i++)
          this.spawn(root.name + '_' + parts[i].name, parts[i].body.split('"' + parts[0].name + '"').join('"' + root.name + '"'));
        return root;
      }

<a id="script-world-sweep2d"></a>

world.sweep2d(e, delta)

From the engine's script reference: world.ray2d(from, to, ignore) the first hit: { entity, point, normal, distance } or null world.sweep2d(entity, [dx, dy]) where a moving body first touches: { t, point, normal, entity } or null

Exact binding and defaults
world.sweep2d(e, delta) {

<a id="script-world-unequip"></a>

world.unequip(who, slot)

From the engine's script reference: world.copy(entity, "name", [x, y, z]) a copy of an object, placed (null if it can't) world.equip(who, ...) / world.unequip(who, slot) the same as entity.equip by name

Exact binding and defaults
world.unequip(who, slot) { var e = typeof who === 'string' ? this.find(who) : who; return e ? e.unequip(slot) : { ok: false, reason: 'no ' + who }; }
Arcwright Beta 2 (0.4.0) · generated from the engine source (25e375c86)Something wrong or missing? Tell us
Download Arcwright free