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

KeyedSaveOptions

What defineKeyedSave takes.

Type Parameter Default type
Schema extends SaveSchema SaveSchema
Parent extends `${KeyedSaveParent}` `${KeyedSaveParent}`
Property Type Default value Description
deleteAfterIdleSeconds? number undefined How long a record no room holds is kept: one no room opens for this many seconds after its last close is deleted. Off by default, so no record is deleted unasked.
migrations? Readonly<Record<number, (saved) => unknown>> undefined One step per version, as a save’s.
name string undefined The declaration’s name, part of every head’s identity: kebab-case, such as plot or guild-bank, and one per game.
onDepositReceive? DepositReceiveHooks<KeyDepositContext> undefined The deposits the record takes, one hook per kind by its name, as a save’s onDepositReceive: a guild’s bank takes donations. Its hooks receive the key’s entity and key.
onDepositReturn? DepositReturnHooks<KeyDepositContext> undefined The deposits this record sends, one hook per kind by its name, as a save’s onDepositReturn.
parent Parent undefined What each record belongs to and goes with.
schema Schema undefined Checks every record loaded, after its steps.
version number undefined Counts the shape of the record, as a save’s version does.
whenUnanswered? "refuse" | "close" "close" What the room does with an ask for a key its game leaves unanswered for 45 seconds.

read(context): input<Schema>

What to keep of the key’s entities, as plain JSON.

Parameter Type
context KeyedSaveContext

input<Schema>


restore(context, saved): void

Puts a stored record back onto the key’s entity and what it spawns; a key with no record yet opens with no restore.

Parameter Type
context KeyedRestoreContext
saved output<Schema>

void