defineSave
Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Each extends Trait |
- |
Excluded extends string |
never |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config |
EachSaveConfig<Each, Excluded> & RequireNumberWidths<Each, Excluded> |
Returns
Section titled “Returns”EachSaveDeclaration<Each>
Example
Section titled “Example”export const blocks = defineSave({ scopes: ["world"], each: BlockTrait, version: 1, });Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Schema extends SaveSchema |
- |
Scopes extends SaveScopes |
- |
Requires extends SaveRequires |
readonly [] |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
config |
SaveConfig<Schema, Scopes, Requires> |
Returns
Section titled “Returns”SaveDeclaration<Schema, Scopes, Requires>