PluginSave
A save as the session reads it, in the one scope the game keeps it in: what each owner of a record holds, the engine’s own saves included.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Schema extends SaveSchema |
SaveSchema |
Scope extends SaveScopeName |
SaveScopeName |
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
migrations? |
Readonly<Record<number, (saved) => unknown>> |
One step per version: step 2 turns a version 1 state into version 2. A pure function from old JSON to new JSON. |
schema |
Schema |
Checks every state loaded, after its steps, and types restore’s. |
scope |
Scope |
Where the state is read from and restored onto: the player entity, each saved entity by the name it is saved as, or the world. |
version |
number |
Counts the shape of the state. Any change to the shape raises it, an added optional field included, and adds a step. |
with? |
readonly SaveTrait[] |
The traits a saved entity holds for the save to keep its state on it, as defineSave’s with says. |
Methods
Section titled “Methods”read()
Section titled “read()”read(
context):input<Schema>
What to keep, as plain JSON: synchronous, and changing nothing. A value its schema or JSON would refuse refuses the whole read.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
SaveContext<Scope> |
Returns
Section titled “Returns”input<Schema>
restore()
Section titled “restore()”restore(
context,saved):void
Puts a loaded state back: a player’s after every onPlayerJoin and
before any onPlayerReady, a saved entity’s as setSavedEntity
registers it, over what its spawn set up, or after the player’s
where a join hook registered it. The world’s state restores as the
record loads. A throw refuses the load.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
context |
RestoreContext<Scope> |
saved |
output<Schema> |
Returns
Section titled “Returns”void