Skip to content
Docs
Reference

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.

ts

Common types

Disko.JsonValue

A JSON value, as carried by game.emit payloads.

ts

Disko.Vector

A point or vector in world units.

ts

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.

ts

Disko.Subscription

Returned by game.on; remove() unsubscribes from the next turn.

ts

Players and actions

Disko.Player

A connected player. The same object is returned for the same player.

ts
MemberDescription
idRoom-local identity, stable for the connection.
nameDisplay name under the room's name policy.
controlledObjectThe 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.

ts

Disko.Action

One declared action.

ts

Disko.ActionSchema

A set of actions a player can use; created during top-level evaluation.

ts

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).

ts

Disko.PermissionOptions

Options of game.permission.

ts
MemberDescription
defaultThe declared default.
labelShown 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.

ts
MemberDescription
name1-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.

ts

Disko.Message

A structured chat message.

ts

Events

Disko.UiRequestEvent

A ui-request event: a player used a control with ui.request.

ts
MemberDescription
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.

ts
MemberDescription
eventsThe payloads of this turn's events, in delivery order.

Disko.GameEventMap

Events with a known payload.

ts
MemberDescription
"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.

ts

Disko.Game

The game global: lifecycle, players, permissions, events and chat.

ts
MemberDescription
uiThe same object as the ui global.
playersConnected 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.

ts

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.

ModuleDefault export
*.pngDisko.PackageAsset
*.jpgDisko.PackageAsset
*.jpegDisko.PackageAsset
*.webpDisko.PackageAsset
*.mp3Disko.PackageAsset
*.oggDisko.PackageAsset
*.wavDisko.PackageAsset