Types
Players, scores, match state, discs, replays and the other shapes the SDK returns.
Each type notes where it can be imported from. Types that are not exported by name are still part of the public contract; reach them through the values that return them, for example ReturnType<NodeRoom['getState']>.
Players and scores
HostPlayer
Import fromball2dball2d/node
interface HostPlayernumberrequired0.stringrequiredstringrequired0 | 1 | 2required0 spectators, 1 red, 2 blue.booleanrequiredbooleanstring | nullnull.{ x: number; y: number; } | nullrequirednull in the lobby and for spectators.numberrequiredHostScores
Import fromball2dball2d/node
interface HostScoresnumberrequirednumberrequirednumberrequirednumberrequired0 for no limit.numberrequired0 for no limit.Match state
MatchState
Not exported by name; reach it through the values that return it.
interface MatchStateBallTouch | nullBallTouch | nullnumberrequirednumberrequirednumberrequirednumberrequired'lobby' | 'playing' | 'goal' | 'finished'requiredlobby, playing, goal (5.5 s after a goal) or finished (5 s after a win).booleanrequirednumberrequired0–119.numberrequiredgoal or finished phase.1 | 2required1 red or 2 blue.booleanrequiredtrue until the kickoff is taken.numberrequired0 for no limit.numberrequired0 for no limit.numberrequiredmin | rate << 8 | burst << 16.number[]requirednumber[]required-1 is transparent.BallTouch
Not exported by name; reach it through the values that return it.
interface BallTouchnumberrequired0. Not a player ID.1 | 2required1 red or 2 blue.Discs
DiscProperty
Not exported by name; reach it through the values that return it.
type DiscProperty = 'x' | 'y' | 'xspeed' | 'yspeed' | 'xgravity' | 'ygravity' | 'radius' | 'bCoeff' | 'invMass' | 'damping' | 'color' | 'cMask' | 'cGroup'Supported public disc properties; no internal solver offsets or validation tables.
Names of the disc properties you can read and change. See Physics for their ranges.
DiscProperties
Not exported by name; reach it through the values that return it.
type DiscProperties = Record<DiscProperty, number>HostDiscProperties
Import fromball2dball2d/node
type HostDiscProperties = DiscPropertiesDiscProperties.DiscPropertyPatch
Not exported by name; reach it through the values that return it.
type DiscPropertyPatch = Partial<Record<DiscProperty, number | null>>A partial update. Omitted and null fields keep their current value.
Chat
AnnouncementStyle
Not exported by name; reach it through the values that return it.
type AnnouncementStyle = 'normal' | 'bold' | 'italic' | 'small' | 'small-bold' | 'small-italic'sendAnnouncement().Teams
TeamColors
Not exported by name; reach it through the values that return it.
interface TeamColorsnumberrequirednumberrequirednumber[]requiredTeamStyles
Not exported by name; reach it through the values that return it.
type TeamStyles = [TeamColors | null, TeamColors | null]null for a team that uses the default kit.Replays
Replay
Import fromball2dball2d/node
interface Replay'B2DR'requiredB2DR.1requiredstringrequiredstringrequired{ tick: number; slot: number; name: string | null; avatar?: string | null; }[]required{ tick: number; teams: TeamStyles; }[]{ tick: number; slots: number[]; }[]numberrequiredstringrequiredReplayCommand
Not exported by name; reach it through the values that return it.
type ReplayCommand = { tick: number; kind: 'input' | 'team' | 'start' | 'stop' | 'pause' | 'scoreLimit' | 'timeLimit' | 'kickRate' | 'join' | 'disc'; properties?: DiscPropertyPatch; slot: number; value: number; }numberrequired'input' | 'team' | 'start' | 'stop' | 'pause' | 'scoreLimit' | 'timeLimit' | 'kickRate' | 'join' | 'disc'requiredDiscPropertyPatchdisc commands, the properties that changed.numberrequirednumberrequiredCheckpoint
Not exported by name; reach it through the values that return it.
interface Checkpointnumberrequiredstringrequired