saveKit.store: where saves live. Each player's saves sit in their own
`runtime_data.player(id)` store under `saveKit/<namespace>/...`, which survives
leaving and rejoining. Anyone can read any player's store; the engine refuses a write
to a store that isn't the writer's own, so no machine (modified or not) can change
another player's profile. Tests swap the live store for a stand-in with `use`.
use(fn: (() → void
Test hook: `fn()` returns the store to save to instead of the local player's data; `others(id)` returns another player's. `use(nil)` puts the live session back.
isOverridden( ) → boolean return override
localId( ) → string
The local player's identity, or nil (an anonymous guest, or identity not arrived yet).
mine( ) → any
The local player's own store (the one store this machine may write), or nil with no identity.
of(userId: string) → any
Any player's store, for reading. Writes to it fail unless it is the local player's.
| arg | type | description |
|---|
| userId | string | |
key(ns: string, name: string) → string
The path of a save inside the store: saveKit/<namespace>/<name>.
| arg | type | description |
|---|
| ns | string | |
| name | string | |
get(path: string) → any
Read a path from the local player's store (nil without an identity or a value). A write this machine made a moment ago is returned even before the engine's replica shows it.
| arg | type | description |
|---|
| path | string | |
remember(path: string, value: any, promise: any) → void
Writes to runtime_data are confirmed asynchronously: the local replica keeps the
old value until the engine answers. Until then reads see the value written here.
| arg | type | description |
|---|
| path | string | |
| value | any | |
| promise | any | |
set(path: string, value: any) → void
Write a path to the local player's store. Returns ok, error. Never raises.
| arg | type | description |
|---|
| path | string | |
| value | any | |
delete(path: string) → void
Delete a path from the local player's store. Returns ok, error.
| arg | type | description |
|---|
| path | string | |
read(userId: string, path: string) → any
Read a path from another player's store (or your own).
| arg | type | description |
|---|
| userId | string | |
| path | string | |
writeOther(userId: string, path: string, value: any) → void
Try to write another player's store. Returns ok, error; the engine refuses it for anyone but the owner, which is what this exists to show (tests and the showcase's tamper check).
| arg | type | description |
|---|
| userId | string | |
| path | string | |
| value | any | |
onChange(fn: (string, any) → void
Watch the local player's store. fn(path, value). Returns an unsubscribe function (a no-op without a store).
| arg | type | description |
|---|
| fn | (string, any | |
onAnyChange(fn: (string, string, any) → void
Watch every player's store: fn(userId, path, value). Returns an unsubscribe function.
| arg | type | description |
|---|
| fn | (string, string, any | |
users( ) → void
Everyone connected: { { id, name, isLocal } }, from world.connectedUsers.
localName( ) → string
The local player's display name, or "Player".