rednode API - v0.50.0
    Preparing search index...

    Interface GameRef

    A game object, such as the player, a system or an item. It stands in for the object in the game: call its methods as if it were local, with await.

    A reference points at the object weakly. When the game deletes the object, or a save loads, calls on it fail with "that game object no longer exists".

    const player = await api.GetPlayer(game.instance);
    const pos = await player?.GetWorldPosition();
    interface GameRef {
        $ref: number;
        $type: string;
        $call(fn: string, ...args: unknown[]): Promise<unknown>;
        $get(prop: string): Promise<unknown>;
        $set(prop: string, value: unknown): Promise<void>;
    }
    Index
    $ref: number

    The reference's id.

    $type: string

    The object's class, its native name, for example "PlayerPuppet".

    • Calls a method by its full name, for overloads that share a name.

      Parameters

      • fn: string
      • ...args: unknown[]

      Returns Promise<unknown>

      await obj.$call("SetHealth;Float", 100);
      
    • Reads one of the object's properties.

      Parameters

      • prop: string

      Returns Promise<unknown>

      const slots = await player.$get("quickSlotsManager");
      
    • Writes one of the object's properties, with the same type checks as arguments. A resource reference takes a depot path or its hash.

      Parameters

      • prop: string
      • value: unknown

      Returns Promise<void>

      await mesh.$set("meshAppearance", "default");
      await mesh.$set("visualScale", { X: 2, Y: 2, Z: 2 });