Skip to content

CommandDef beta ​

Interface of @v12-engine/engine

ts
export interface CommandDef<F extends Fields = Fields>

Commands are everything a player can ask for: plain data, and the only way input reaches the simulation, which keeps the door open for replays, the AI and multiplayer.

A command type is a CommandDef: the fields it carries, and what it does. What arrives is checked against the fields before anything happens, because on a server it is whatever anyone sends. The engine's own commands are defined the same way as a game module's (Rules.commands).

Members ​

execute ​

ts
execute(world: World, player: PlayerId, command: Checked<F>): void;

Carries it out, for player. Whether the player owns or can see what it names is for this to check

fields ​

ts
fields: F;

What it carries, besides its type and the player who sent it. See fields.ts for the checkers

outsideTick ​

ts
outsideTick?: boolean;

Carried out at once when given between two ticks, a paused game's too, not at the start of the next (World.issue): talk, a line of chat or a ping, which a game that waits is still to hear. Counted by the talk's own rate, not the commands a tick may have; a replay keeps it where it was given (RV14)

type ​

ts
type: string;

The command's name, which a sent command carries as its type