ReadonlyaudioThe game's audio.
ReadonlyinstanceThe game instance, for the many game functions whose first argument is a
GameInstance.
ReadonlyplayerThe player character.
Calls a bridge method by name. The typed calls such as Player.position are built on it.
The result type.
For example "player.position".
Optionalparams: Record<string, unknown>
The method's parameters, if any.
The interface language the player chose in the game: its own name ("fr-fr") and the
standard tag ("fr-FR") for Intl. game.on("language", …) hears a change, with the new
name in the event's language.
Subscribes to a game event.
Events are named by the game class and method that raise them, such as
"PlayerPuppet.OnGameAttached", at the main menu and on every save load. REDnode's own
events have short names: "combat" (CombatEvent: V's combat state changed) and
"npcDowned" (NpcDownedEvent: a person defeated or killed, with their
affiliation and whether V did it), sent by the game as they happen, never polled.
The event payload.
Event name, for example "PlayerPuppet.OnGameAttached".
Called for every occurrence. The game does not wait for it.
A function that stops the subscription.
Calls a handler whenever the game state changes, and once at the start with the current state.
game.onState((s) => console.log(s.menu ? "menu open" : "menu closed"));
// Read the world only while V is in it.
let reading: ReturnType<typeof setInterval> | undefined;
game.onState((s) => {
if (s.world && !reading) reading = setInterval(readWeather, 1000);
if (!s.world && reading) {
clearInterval(reading);
reading = undefined;
}
});
Reads what the game is showing: menus, photo mode, scenes, the main menu.
Entry point for Tier 2 mods and overlay apps. Use the game instance.