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

    Interface Game

    Entry point for Tier 2 mods and overlay apps. Use the game instance.

    interface Game {
        audio: Audio;
        player: Player;
        call<T = unknown>(
            method: string,
            params?: Record<string, unknown>,
        ): Promise<T>;
        on<T = GameEvent>(name: string, handler: EventHandler<T>): Unsubscribe;
        onState(handler: EventHandler<GameState>): Unsubscribe;
        state(): Promise<GameState>;
    }
    Index
    audio: Audio

    The game's audio.

    player: Player

    The player character.

    • Calls a bridge method by name. The typed calls such as Player.position are built on it.

      Type Parameters

      • T = unknown

        The result type.

      Parameters

      • method: string

        For example "player.position".

      • Optionalparams: Record<string, unknown>

        The method's parameters, if any.

      Returns Promise<T>

      const info = await game.call<{ frame: number }>("game.info");
      
    • Subscribes to a game event.

      Events are named by the game class and method that raise them. Today the plugin sends "PlayerPuppet.OnGameAttached", at the main menu and on every save load. Events from any hooked game function arrive with phase P2.

      Type Parameters

      Parameters

      • name: string

        Event name, for example "PlayerPuppet.OnGameAttached".

      • handler: EventHandler<T>

        Called for every occurrence. The game does not wait for it.

      Returns Unsubscribe

      A function that stops the subscription.

      const stop = game.on("PlayerPuppet.OnGameAttached", async () => {
      console.log("A save was loaded");
      });
    • Reads what the game is showing: menus, photo mode, scenes, the main menu.

      Returns Promise<GameState>

      const s = await game.state();
      if (s.connected && !s.mainMenu) console.log("In a loaded save");