defineRoom
defineRoom<
JoinHints>(settings?):RoomSettings&object
Declares a game’s room: how many players one room holds, 2 to 100, how often
its world steps, 30 or 60 ticks a second, and how often it sends them the
world, a rate that divides the tick rate. Also how long it holds a dropped
player’s seat for the player to come back to, up to 300 seconds, whether its
players talk, and, for a game with several kinds of room, which kinds hold
its worlds. voice: true turns voice on 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. Pass it to the
game, defineGame({ room }): the room reads it off the game as it starts,
and spawnite build writes it into the bundle’s manifest. The worlds its
rooms hold are the game’s, defineGame({ worlds }), declared in the same
place for a game played alone. Each setting left out takes the platform’s
default, 20 players, 30 ticks, in the room and in a run of the game alone, a
send each tick, a hold of 15 seconds after a closed page and 30 after a
broken connection, no 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.
interest: { radius } turns interest culling on: each page holds only what
stands within the radius of what it controls and looks through, and what
Relevance.Always marks, for every kind or one kind of room. Left out,
culling is off, and the engine never turns it on for a game. joinHints
lists the names a share link or a teleport may carry for readJoinHint;
register the room, as
declare module "@spawnite/engine" { interface Register { room: typeof room } },
and every hint is typed by the list.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
JoinHints extends readonly string[] |
readonly [] |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
settings |
RoomSettings & object |
Returns
Section titled “Returns”RoomSettings & object
Example
Section titled “Example”const room = defineRoom({ maxPlayers: 8, tickRate: 60 }); const room = defineRoom({ maxPlayers: 8, tickRate: 60, sendsPerSecond: 30 }); const room = defineRoom({ voice: true, textChat: false }); const room = defineRoom({ joinHints: ["gate", "house"] }); const room = defineRoom({ maxPlayers: 50, interest: { radius: 60 } }); const room = defineRoom({ kinds: { island: { world: true }, plaza: {} } }); export const game = defineGame({ name, start, room, plugins });