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

    Interface ApiExtras

    Extra calls on api for names the typed API cannot express.

    interface ApiExtras {
        $null: never;
        $out: never;
        $call(fn: string, ...args: unknown[]): Promise<unknown>;
        $new(
            className: string,
            props?: Record<string, unknown>,
        ): Promise<Record<string, unknown> | GameRef>;
        $static(
            className: string,
            fn: string,
            ...args: unknown[],
        ): Promise<unknown>;
    }
    Index
    $null: never

    Put in place of an object argument to pass none on purpose. A plain null is refused for an object parameter the game does not mark optional, since many game functions use one without checking it and an empty one can crash the game. Pass real data where you can: the game's own scripts usually do.

    // The game's scripts pass the item's data here; this passes none.
    const name = await api.$static("UIItemsHelper", "GetItemName;TweakDBIDgameItemData", "Items.Vest_24_rich_01", api.$null);
    $out: never

    Put in place of an argument to get that parameter's value back after the call, in out. Some native functions write their answer into a parameter the game does not mark as out; the call then returns { result, out }.

    const camera = await api.GameInstance.GetCameraSystem(game.instance);
    const r = (await camera!.GetActiveCameraWorldTransform(api.$out)) as unknown as {
    result: boolean;
    out: { transform: { position: { X: number; Y: number; Z: number } } };
    };
    • Calls a global function by name or full name, for example an operator such as "Cast;EntityID;StatsObjectID".

      Parameters

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

      Returns Promise<unknown>

    • Builds a game object by its class name (native or script name) and sets properties on it first. Resolves with a GameRef for an object, which keeps the object alive until the reference is released (or a save loads), since nothing in the game holds it yet; or with the value, for a struct.

      Parameters

      • className: string
      • Optionalprops: Record<string, unknown>

      Returns Promise<Record<string, unknown> | GameRef>

      const mesh = await api.$new("entMeshComponent", {
      name: "crate",
      mesh: "base\environment\props\crate_a.mesh", // a depot path or its hash
      meshAppearance: "default",
      visualScale: { X: 1, Y: 1, Z: 1 },
      });
    • Calls a class's static function by name or full name.

      Parameters

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

      Returns Promise<unknown>