game global
Lifecycle, players, permissions, events, chat and asset imports, generated from the shipped declarations.
Generated from the declarations in @disko-game/build/types, which editors
use for type checking. Types live in the Disko namespace, for example
Disko.Player. See Players, teams & actions
for a guide.
The game global
Lifecycle, players, permissions, events and chat.
Common types
Disko.JsonValue
A JSON value, as carried by game.emit payloads.
Disko.Vector
A point or vector in world units.
Disko.PackageAsset
An imported asset: import puck from "./puck.png". Its name is the asset's package path. Every import of one path yields the same frozen object.
Disko.Subscription
Returned by game.on; remove() unsubscribes from the next turn.
Players and actions
Disko.Player
A connected player. The same object is returned for the same player.
| Member | Description |
|---|---|
id | Room-local identity, stable for the connection. |
name | Display name under the room's name policy. |
controlledObject | The disc this player controls, or null. |
play() | Asks the engine to make this player a participant (player-enter). |
spectate() | Moves this player to spectators (player-exit). |
control() | Gives this player native movement control of a disc. |
release() | Releases the controlled disc. |
setRadius() | Sets the controlled disc's radius. |
setAvatar() | Sets the controlled disc's avatar: text, an image asset, or null. |
setAcceleration() | Movement acceleration per tick. |
setDamping() | Movement damping per tick. |
useActionSchema() | Selects the action schema this player's inputs use. |
isHolding() | Whether the player currently holds an action of their schema. |
Disko.ActionBehavior
Native behavior of an action, for example a kick.
Disko.Action
One declared action.
Disko.ActionSchema
A set of actions a player can use; created during top-level evaluation.
Permissions
Disko.PermissionDefault
Who holds a permission when the room decides nothing: "everyone" (a normal player ability), "restricted" (no normal player; only the room grants it, such as to its admins), or "owner" (the connected player signed in with the room owner's account, never a guest).
Disko.PermissionOptions
Options of game.permission.
| Member | Description |
|---|---|
default | The declared default. |
label | Shown to the room; defaults to the permission's name. |
Disko.Permission
A declared permission, created by game.permission during top-level evaluation. Only handles returned by game.permission are accepted where a permission is expected.
| Member | Description |
|---|---|
name | 1-64 lowercase ASCII letters, digits, -, _, . or :, starting with a letter. |
setDefault() | Sets the game-managed default for one player, applied after this turn commits: game.can observes it from the next turn, together with a permission-change event. Unavailable at top level. |
Chat
Disko.MessageSpan
One span of a structured chat message.
Disko.Message
A structured chat message.
Events
Disko.UiRequestEvent
A ui-request event: a player used a control with ui.request.
| Member | Description |
|---|---|
respond() | Replies to the requesting control once: content placed at the request's target with its swap method, or explicit swaps. |
Disko.TickEvent
The tick and post-tick turns, with the turn's events.
| Member | Description |
|---|---|
events | The payloads of this turn's events, in delivery order. |
Disko.GameEventMap
Events with a known payload.
| Member | Description |
|---|---|
"permission-change" | A game.can value changed. Delivered after the change commits: immediately while ready or paused, at the next boundary while running. |
Disko.GameEvent
The payload of an event: typed for the events in GameEventMap, any for events the room sends with room.emit.
Disko.Game
The game global: lifecycle, players, permissions, events and chat.
| Member | Description |
|---|---|
ui | The same object as the ui global. |
players | Connected players, spectators included. |
on() | Subscribes to an event, including those the room sends with room.emit; changes apply from the next turn. |
createActionSchema() | Creates an action schema; only during top-level evaluation. |
permission() | Declares a permission; only during top-level evaluation, at most 64 per game, each name once. |
can() | Whether a player holds a permission in this turn. Every read in one turn observes the same decisions; a pending room decision reads as denied. |
send() | Sends a chat message to the room. |
start() | Asks the room to start a match. |
stop() | Asks the room to stop the match. |
pause() | Asks the room to pause the match. |
resume() | Asks the room to resume the match. |
finish() | Ends the match as finished. |
playSound() | Plays an audio asset, optionally positioned at a disc. |
emit() | Sends an event to the room host (room.on("game:<name>")). |
Errors
StaleHandleError
Thrown when a handle is used outside its lifetime: a physical object or HUD node after its match stopped, or a Menu node of a replaced game.
Asset modules
Asset imports. The only form is a default import, import puck from "./puck.png", whose value is the frozen { kind: "package-asset", name: "<package path>" } reference.
| Module | Default export |
|---|---|
*.png | Disko.PackageAsset |
*.jpg | Disko.PackageAsset |
*.jpeg | Disko.PackageAsset |
*.webp | Disko.PackageAsset |
*.mp3 | Disko.PackageAsset |
*.ogg | Disko.PackageAsset |
*.wav | Disko.PackageAsset |