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

GameOptions

What defineGame takes: what every consumer of the game must agree on and can read headless as the module loads. Room and Worlds are its room and its worlds as written, which decide whether a world’s records are the game’s to declare. SavesOff is false where saves is the literal false, which keeps none of the game’s own state.

Type Parameter Default type
Room extends RoomSettings | undefined RoomSettings | undefined
Worlds extends true | WorldsOptions | undefined true | WorldsOptions | undefined
SavesOff extends false | undefined false | undefined
Property Type Default value Description
deposits? GameDeposits none: deliver refuses a deposit to a record with no hook for its kind The hooks of each of the game’s records for the deposits it takes and the returns of those it sent: player, the player’s game-wide record, playerWorld, the player’s in a world, and world, the world’s. A keyed record’s hooks are on its defineKeyedSave.
levels? Readonly<Record<string, string>> none: the game has no levels The game’s levels in order, as defineLevels lists them.
name string undefined The game’s identity.
omit? readonly ReplaceableHandle[] none Systems of the listed plugins left out of every world, by handle: [behaviours.systems.reapDead] for a game that keeps its dead. A system another listed plugin requires or anchors to cannot be left out, and the game refuses here naming both. As Bevy’s DefaultPlugins.build().disable::<X>() leaves one out by type, and Unity’s [DisableAutoCreation] one system.
physics? PhysicsSettings every default definePhysics gives The game’s physics scene, as definePhysics made it. A page whose settings differ from its room’s is refused at the welcome.
playerState? KeptStateOption<SavesOff, PlayerStateDeclaration> none The game’s own state in the player’s game-wide record, made with defineSave in the player’s or each saved entity’s scope, kept under game. A type error beside saves: false, which keeps nothing.
playerWorldState? WorldRecordOption<Room, Worlds, KeptStateOption<SavesOff, PlayerWorldStateDeclaration>> none The game’s own state in the player’s record in each world, made with defineSave in the player’s or each saved entity’s scope, kept under game: what the player keeps in one world alone, such as the plot the player claimed there. A page keeps it in the player’s one record; a room that holds a world loads it beside the player’s game-wide record as the player joins. A type error in a game with rooms that declares no worlds. Not worldState, the world’s own.
plugins? readonly Plugin<Readonly<Record<string, SystemHandle<"input" | "rules" | "motion" | "physics", boolean, RunContext>>>, Readonly<Record<string, ButtonInputDeclaration | AxisInputDeclaration | VectorInputDeclaration | AngleInputDeclaration>>, Readonly<Record<string, PageActionDeclaration>>, string, Readonly<Record<string, CommandDeclaration<Readonly<Record<string, CommandField>>, string, Readonly<Record<string, ReturnField>> | undefined, boolean, boolean, boolean, boolean>>>, Readonly<Record<string, InputContextDeclaration>>, Readonly<Record<string, SaveHandle<"player" | "world" | "entity">>>>[] none: the core alone The game’s plugins, each as definePlugin or an engine plugin’s call made it, in list order. A kit that bundles several is a spread, and a conditional plugin is one too, ...(hardMode ? [rules()] : []).
room? Room none: the game is played alone The game’s room, as defineRoom makes it: a game whose package.json names spawnite.room plays in rooms and passes it, and a game played alone passes none.
saves? SavesOff | CoreSavesOption<GameHoldsWorld<Room, Worlds>> every core save on, in its own scope: the character's position and health in the player's record in each world, the player's stats and wallet game-wide, and levels and random in the world's The core’s saves, each on by default: false keeps nothing at all, the plugins’ saves included, and is a type error beside any of the game’s own states, which it would keep nowhere. Or an override per save by name: { stats: false }, { wallet: { scope: "entity" } } among that save’s scopes. Or { stats: { perWorld: true } } to keep it in the player’s record in each world, { position: { perWorld: false } } to keep it game-wide. A plugin’s saves are overridden on its call, inventory({ saves }).
start string undefined The scene that opens.
textureSeed? number a hash of the game's name The seed every pixel texture paints from, so every page of a room paints the same pixels and a kit’s painters draw a village of the game’s own: a whole number, changed to paint the game anew.
tickRate? AloneTickRateOption<Room> 60, defaultAloneTickRate: a game played alone steps only on the player’s page The ticks a second a game played alone steps at, 30 or 60. A game with a room sets its rate on its room, defineRoom({ tickRate }), which also steps a run of it alone, and names none here.
worlds? Worlds none The worlds the game keeps, each with records that outlive a session, declared here whether the game plays in rooms or alone: true for the defaults, or their settings. A game with rooms holds them in its one kind of room, or in each kind kinds marks world: true, and takes what Play does with them and who makes them. A game played alone keeps them as the player’s save slots, up to ten, which the player makes, renames and deletes on the same screens a room game’s worlds use, as Minecraft lists its worlds; it takes settings alone. Left out, a game with rooms keeps no world’s records, and a game played alone keeps one world in the player’s record, with no slots. Example worlds: { play: "own", playerWorlds: "private" }
worldSaves? WorldRecordOption<Room, Worlds, KeptStateOption<SavesOff, Readonly<Record<string, EachSaveDeclaration>>>> none The world’s per-entity saves, by name: each a defineSave with each, keeping one record for every entity of the world holding its trait, such as { blocks, chests }. A checkpoint reads again only the records whose entity changed. A type error in a game with rooms that declares no worlds.
worldState? WorldRecordOption<Room, Worlds, KeptStateOption<SavesOff, WorldStateDeclaration>> none The world’s own state in the world’s record, made with defineSave and scopes: ["world"], kept under game: its buildings and its plots, what no one player owns. Its read sees the world without the entities a player’s record or a key keeps. A page keeps it in the player’s one record; a room that holds a world keeps it in the world’s. A type error in a game with rooms that declares no worlds. Not playerWorldState, the player’s in each world.