Skip to content

Timers beta ​

Class of @v12-engine/engine

ts
export declare class Timers

The timers of a world. Time is counted in ticks, which every machine counts the same, never with the clock: a timer goes off at the start of the tick it is due, after the players' commands and before anything else, in the order they are due and then the order they were set

Members ​

constructor ​

ts
constructor(world: World, defs: readonly TimerDef[]);

Constructs a new instance of the Timers class

after ​

ts
after<T>(seconds: number, timer: TimerDef<T>, ...data: T extends undefined ? [] : [T]): number;

Goes off once, seconds from now. Returns its id, for cancel and left

cancel ​

ts
cancel(id: number): boolean;

Stops a timer from going off again. Whether it was still waiting

every ​

ts
every<T>(seconds: number, timer: TimerDef<T>, options: EveryOptions<T>): number;

Goes off every seconds: the first time seconds from now, or after first seconds; times times, or until cancelled. Returns its id

has ​

ts
has(id: number): boolean;

Whether the timer is still waiting

hide ​

ts
hide(player: PlayerId, id: number): void;

Shows a player a timer no more

left ​

ts
left(id: number): number | undefined;

Seconds until the timer next goes off, or undefined when it is not waiting any more

list ​

ts
list(): WaitingTimer[];

What is waiting, in the order it was set: a copy, for the debug tools

show ​

ts
show(player: PlayerId, id: number, options: {
        label: MessageRef;
    }): void;

Shows a player a timer (campaign plan CP5): its words and when it goes off, counted down on their screen (the HUD's timers) for as long as it waits. A timer that repeats is shown to each time it next goes off

shownTo ​

ts
shownTo(player: PlayerId): ShownTimer[];

The timers a player is shown that still wait, with the tick each goes off at next

update ​

ts
update(): void;

Sets off what is due. The timers system calls it at the start of every tick