Constimport { api, game } from "rednode";
const player = await api.GetPlayer(game.instance);
const id = await player!.GetEntityID();
const statsId = await api.$call("Cast;EntityID;StatsObjectID", id);
const stats = await api.GameInstance.GetStatsSystem(game.instance);
const level = await stats!.GetStatValue(statsId as never, "Level");
The game API: every global function, and every class's static functions under its script name, typed from the game's type data.
Arguments and results:
boolean,numberstring, because numbers lose precision above 2^53string"0x..."; a record path such as"Items.money"also works as an argument"Health"nullis the default valuenullonly where the game marks the parameter optional, otherwise api.$nullrRef,raRef,ResRef)"base\...\crate_a.mesh", or its hash as a string; read back as the hashFunctions with out parameters return
{ result, out }, and so does a call with api.$out in place of an argument. Objects a call makes that nothing in the game holds yet stay alive while you hold their reference.