defineKeyedSave
defineKeyedSave<
Schema,Parent>(options):KeyedSaveDeclaration<Schema,Parent>
Declares a record the game names, at module scope: a plot in each
world, a bank for each account, a guild’s vault in the game. A room
opens one through the handle for gives, such as
plots.for(worldId, "ada"), holds it under its lease, commits it with
the players in the room, and closes it. Throws for a name that is not
kebab-case, a parent that is none of game, world and account, a
version that is no whole number from 1, a step missing, no schema, an
idle time that is no positive number of seconds, and an unanswered ask
that is neither close nor refuse.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Schema extends SaveSchema |
Parent extends "game" | "world" | "account" |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
KeyedSaveOptions<Schema, Parent> |
Returns
Section titled “Returns”KeyedSaveDeclaration<Schema, Parent>
Example
Section titled “Example”export const plots = defineKeyedSave({ name: "plot", parent: "world", version: 1, schema: PlotSchema, read: ({ entities }) => serializePlot(entities), restore: ({ writer, entity }, saved) => placePlot(writer, entity, saved), }); plots.for(worldId, "ada"); // Ada's plot in that world