Skip to content

Kiln API / kiln / Timer

Variable: Timer ​

ts
const Timer: Trait<{
  duration: number;
  repeat: boolean;
  paused: boolean;
  ticks: number;
  elapsed: number;
  remaining: number;
  finished: boolean;
  justFinished: boolean;
  count: number;
}>;

A countdown on an entity, ticked every fixed step: Timer({ duration: 2 }), or Timer({ duration: 0.5, repeat: true }) for a repeating one. Read justFinished in Fixed (true for exactly one step each time it completes), finished (stays true, one-shot only), remaining and elapsed (seconds), count (completions). Set paused to hold it; restartTimer(row) resets it. Each completion also emits TimerFinished, which Update systems should read instead.