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

defineSave

defineSave<Schema, Scope>(config): [Schema] extends [never] ? IncludeSaveDeclaration : GameStateSaveDeclaration<Schema, Scope>

Declares a game’s own save, once, in src/save.ts: the engine saves it wants, and one schema, read and restore for its own state, or none of them where it keeps only what include names. Throws for some of the game’s own fields without the rest, for a version that is no whole number from 1, a step missing between 2 and the version, an include name the engine has no save for, and resources without stats. A game sets no interval: the platform writes the save on its own schedule.

Type Parameter Default type
Schema extends SaveSchema never
Scope extends "entity" | "world" | "player" "player"
Parameter Type
config SaveConfig<Schema, Scope>

[Schema] extends [never] ? IncludeSaveDeclaration : GameStateSaveDeclaration<Schema, Scope>