Skip to content

Entities, timers, and signals

RiftScript 1.1 can safely connect behavior across objects. It uses an opaque entity type: a string literal is not an entity handle, and creator code cannot invent a trusted target ID.

Find and read objects

Add the Tags component to an object in Workshop and give it up to eight labels. Tags are identifiers such as enemy, exit_door, or moving-platform.

text
riftscript 2;

event player_touched {
  let target: entity = entity.find("exit_door");
  let x: number = transform.x(target);
  let y: number = transform.y(target);
  transform.set(target, x, y - 40);
}

entity.find examines active tagged objects in stable object-ID order and returns one opaque handle. It is deliberately not an unbounded array query. If no object matches, the handler fails closed at that source line. entity.self() returns the current object. entity.exists safely returns false for a missing or disabled handle; component reads require the handle and component to exist.

Change authoritative state

The server validates every handle again when applying a command:

  • entity.destroy disables an object;
  • entity.set_active enables or disables it;
  • transform.set accepts only finite positions inside the world;
  • velocity.set requires a Rigidbody and each axis must remain within -2000…2000.

Value queries observe state at their point in the handler. Ordinary write commands are validated and applied after that handler finishes, so a read immediately following a queued write still sees the earlier state. This avoids partially applied commands when a later instruction fails.

Spawn an approved prefab

text
let orb: entity = world.spawn("reward_orb", 320, 180);

Only a prefab already validated inside the project can spawn. Runtime-spawnable prefabs contain at most 16 objects and cannot contain Player, Portal, HUD, or Persistent save components. A world permits at most 8 spawn calls in one tick and 256 dynamically spawned objects for the session. The returned handle identifies the prefab's first object. Spawn state and source metadata participate in authoritative snapshots and deterministic restoration.

Timers and signals

Timers use fixed simulation ticks, not wall-clock browser time:

text
event player_touched {
  timer.after(60, "ready");
}

event signal_ready {
  effects.play("ready");
}

timer.after accepts 1 through 3600 ticks. signal.emit("ready") queues the same signal_ready event for the next tick. A world holds at most 32 pending timers/signals and dispatches at most 16 in a tick in deterministic order. Pending timers are included in authoritative snapshots and state hashes.

Costs and failure behavior

Every API call consumes shared per-tick operation budget. A tag search costs more than a direct component read; spawning costs more than either. The generated capability reference lists each cost, return type, event restriction, example, and failure mode.

Value-returning calls compile to verified call_value instructions. Their results come from the loaded authoritative world, never from a browser request. Commands, queries, timers, spawns, and signal handlers still share the same instruction, operation, stack, and memory limits.

PixelRifts creator documentation · generated reference · protocol 21