Variable: Plot

Plot: Plot

The shared Plot SDK used throughout a game.

Create views and register lifecycle and ordinary change listeners first, then call Plot.ready(). Connected lifecycle callbacks can safely read every current state getter during both startup and recovery.

Example

import Plot from '@plot.game/sdk'

const gameState = Plot.gameState.as<{ phase?: string }>()
const render = () => renderPhase(gameState.get().phase ?? 'lobby')
Plot.onLifecycleChange((status) => {
  if (status === 'connected') render()
})
gameState.onChanged(render)

await Plot.ready()
console.log(Plot.party.get().host.displayName)