player
player.get(): Player
Section titled “player.get(): Player”Synchronous. Throws before init() resolves; after it, always answers.
const player = sdk.player.get();// { id: string, nickname: string, guest: boolean, host: HostName }drawName(player.guest ? 'Guest' : player.nickname);import type { Player } from '@filudi/game-sdk';
const player: Player = sdk.player.get();drawName(player.guest ? 'Guest' : player.nickname);id is stable per host. On filudi.com it is the player id of the API: the same for a guest and for the
account that guest later creates. On portals it is the portal’s user id when the portal exposes one, else
a random id kept in localStorage. nickname is the hub’s or the portal’s display name; a guest on
filudi.com gets a generated one like Guest-Fox. Do not key saves on id: the SDK does that for you.
player.on('change', listener): Off
Section titled “player.on('change', listener): Off”Fires when the nickname changes or the player links an account while the game runs. The listener gets the
new Player. Returns a function that removes the listener.
const off = sdk.player.on('change', (player) => drawName(player.nickname));// off() when the scene goes awayimport type { Off, Player } from '@filudi/game-sdk';
const off: Off = sdk.player.on('change', (player: Player) => drawName(player.nickname));Unavailable cases
Section titled “Unavailable cases”None: every host has a player. On Poki and on the standalone mock the player is always a guest. features.account
from init() says whether the host lets a guest become an account; the hub owns that flow, the game only
reads the result through change.