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

    Interface Player

    The player character, V.

    interface Player {
        addItem(id: string, count?: number): Promise<void>;
        body(): Promise<"wa" | "ma">;
        getHealth(): Promise<number>;
        position(): Promise<Vector3>;
        removeItem(id: string, count?: number): Promise<boolean>;
        setHealth(value: number): Promise<void>;
        teleport(
            to:
                | { x: number; y: number; yaw?: number; z: number }
                | { nodeRef: string },
        ): Promise<void>;
    }
    Index
    • Puts items in V's inventory by their TweakDB id, as Cyber Engine Tweaks' Game.AddToInventory does. Built on the transaction system's GiveItemByTDBID. Rejects when there is no such record, so a typo is not given as an empty item.

      Parameters

      • id: string

        The item's record, such as "Items.Pants_01_basic_01".

      • Optionalcount: number

        How many, 1 by default.

      Returns Promise<void>

      await game.player.addItem("Items.Pants_01_basic_01");
      await game.player.addItem("Items.money", 5000); // eddies
    • V's body, as chosen in character creation: "wa" (the feminine body) or "ma" (the masculine one), the two letters the game's own file names use, such as a workspot or a garment made for one body. Read from the game's GetResolvedGenderName (#47).

      Returns Promise<"wa" | "ma">

      const body = await game.player.body();
      const workspot = `my_mod\\workspots\\wave_${body}.workspot`;
    • Reads V's health, in health points. Built on api: the stat pools system's Health pool.

      Returns Promise<number>

      const hp = await game.player.getHealth();
      
    • Reads V's position in the world.

      Rejects at the main menu and while a save loads, when there is no player.

      Returns Promise<Vector3>

      const { x, y, z } = await game.player.position();
      console.log(`V is at ${x.toFixed(1)}, ${y.toFixed(1)}, ${z.toFixed(1)}`);
    • Takes items out of V's inventory by their TweakDB id. Resolves with whether the game took any. Built on the transaction system's RemoveItemByTDBID.

      Parameters

      • id: string

        The item's record, such as "Items.Pants_01_basic_01".

      • Optionalcount: number

        How many, 1 by default.

      Returns Promise<boolean>

      await game.player.removeItem("Items.money", 100);
      
    • Sets V's health, in health points. Applied by the game on its next update.

      Parameters

      • value: number

        New health points. The game caps it at V's maximum.

      Returns Promise<void>

      await game.player.setHealth(1); // one hit from death
      
    • Moves V: to a position (yaw in degrees, 0 by default), or to a world node by its reference ("$/…", or its hash as a string; unverified which forms the game takes).

      Parameters

      • to: { x: number; y: number; yaw?: number; z: number } | { nodeRef: string }

      Returns Promise<void>

      const here = await game.player.position();
      await game.player.teleport({ ...here, z: here.z + 20 }); // a drop from 20 m