Skip to content

Objectives beta ​

Class of @v12-engine/engine

ts
export declare class Objectives

The objectives of the players of a world. What changes in them is the engine's objectiveChanged event, which the player is shown, and which a game's listeners and sequences can wait for

Members ​

constructor ​

ts
constructor(world: World);

Constructs a new instance of the Objectives class

add ​

ts
add(player: PlayerId, def: ObjectiveDef, options?: {
        params?: Message['params'];
        progress?: {
            value: number;
            max: number;
        };
    }): ObjectiveState;

Gives a player an objective, open. Its words' params and its progress can be given with it

complete ​

ts
complete(player: PlayerId, id: string): void;

Done. Only an open one can be

fail ​

ts
fail(player: PlayerId, id: string, reason?: MessageRef): void;

Failed, and why when that is worth saying. Only an open one can be

get ​

ts
get(player: PlayerId, id: string): ObjectiveState;

The player's objective of this id; throws when the player has none

has ​

ts
has(player: PlayerId, id: string): boolean;

Whether a player has the objective, open or not

of ​

ts
of(player: PlayerId): readonly ObjectiveState[];

A player's objectives, in the order they were given

progress ​

ts
progress(player: PlayerId, id: string, value: number, options?: {
        max?: number;
        params?: Message['params'];
    }): void;

How far along an open one is. Its words' params can change with it: "wave 3 of 10"