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

defineSave

defineSave<Each, Excluded>(config): EachSaveDeclaration<Each>

Declares a world’s save with each, at module scope: one record for each entity holding that trait, which keeps the trait’s own fields. defineGame’s worldSaves lists it. Takes no requires and no perWorld. Throws for a version that is no whole number from 1, a step missing, an exclude that names no field of the trait, and a field whose default no record can keep, naming the field.

Type Parameter Default type
Each extends Trait -
Excluded extends string never
Parameter Type
config EachSaveConfig<Each, Excluded> & RequireNumberWidths<Each, Excluded>

EachSaveDeclaration<Each>

export const blocks = defineSave({
scopes: ["world"],
each: BlockTrait,
version: 1,
});

defineSave<Schema, Scopes, Requires>(config): SaveDeclaration<Schema, Scopes, Requires>

Declares a save, at module scope: one of a plugin’s saves, by name, or a game’s own playerState, playerWorldState or worldState on defineGame. It is on once the plugin is listed, kept in the first of its scopes and in the record perWorld names unless the game’s override says another, and off where the override says false. Throws for no schema, a version that is no whole number from 1, a step missing between 2 and the version, no scopes, scopes that are not "player" and "entity" each at most once or "world" alone, and a perWorld that is not a boolean or is on a world’s save.

Type Parameter Default type
Schema extends SaveSchema -
Scopes extends SaveScopes -
Requires extends SaveRequires readonly []
Parameter Type
config SaveConfig<Schema, Scopes, Requires>

SaveDeclaration<Schema, Scopes, Requires>