Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

defineRoom

defineRoom(settings): RoomSettings

Declares a game’s room: how many players one room holds, 2 to 50, how often it sends them the world, 30 or 60 times a second, how long it holds a dropped player’s seat for her to come back to, up to 300 seconds, and whether its players talk: voice: false turns voice off for the game, and setVoice turns it off for a phase, and textChat: false turns text chat off. Only a game whose package.json names spawnite.room has a room; a game for one player is played alone, with no room and no defineRoom. Export it from src/game.ts as room and re-export it from the room’s scene file beside the plugins, as export { plugins, room } from "../game": the room reads it as it starts, and spawnite build writes it into the bundle’s manifest. Each setting left out takes the platform’s default, 20 players, 60 sends, a hold of 15 seconds after a closed page and 30 after a broken connection, and voice and text chat on. A turn-based card game holds a seat for minutes. The types refuse a number the platform does not run.

Parameter Type
settings RoomSettings

RoomSettings

export const room = defineRoom({ maxPlayers: 8, sendRate: 30 });
export const room = defineRoom({ maxPlayers: 4, rejoinHoldSeconds: 300 });
export const room = defineRoom({ voice: false, textChat: false });