HasSaveSlots
Binds the save slot system to a live Player.
The slot model itself -- the roster, per-slot stores, selection, create/delete/reset, export/import, ephemeral slots and playtime -- lives in HasSaveSlotsDataStore, built here over the player's datastore. What stays behind is everything that only means something for a player in this server: replicating the slot container under them, the client remotes, teleport data, and summary providers (which are handed the Player).
Every slot method below is a straight delegation. Reach for HasSaveSlotsDataStore directly only when there is no player to bind -- admin tooling acting on someone who is not in this server.
Functions
GetSlotsDataStore
Returns the underlying player-independent slot system, a HasSaveSlotsDataStore. Prefer the delegating methods on this class; this is for code that needs to hand the slot system to something that does not know about players.
Typed any deliberately: naming HasSaveSlotsDataStore.HasSaveSlotsDataStore anywhere in this
file -- even once -- pushes the old solver over its complexity budget ("Code is too complex"). The
delegating methods below still carry their own precise return types, which is what callers read;
require the module directly for a typed handle.
ObserveActiveSlotStoreBrio
HasSaveSlots.ObserveActiveSlotStoreBrio(self: HasSaveSlots) → Observable.Observable<Brio.Brio<DataStoreStage.DataStoreStage>>Observes the DataStoreStage for the active slot as a Brio
PromiseActiveSlotStore
HasSaveSlots.PromiseActiveSlotStore(self: HasSaveSlots) → Promise.Promise<DataStoreStage.DataStoreStage?>Returns the DataStoreStage for the active slot
PromiseSlotsLoaded
Promises that all slots have loaded
PromiseHasSlot
HasSaveSlots.PromiseHasSlot(slotId: SaveSlotData.SlotId?) → Promise.Promise<boolean>Returns whether the slot with the given ID exists
PromiseSelectSlot
HasSaveSlots.PromiseSelectSlot(slotId: SaveSlotData.SlotId) → Promise.Promise<any>Selects the slot with the given ID
PromiseDeselectSlot
Clears the active slot selection, returning the player to a no-slot state -- the counterpart to HasSaveSlots.PromiseSelectSlot, backing a "back to menu" affordance. See HasSaveSlotsDataStore.PromiseDeselectSlot.
PromiseCreateSlot
HasSaveSlots.PromiseCreateSlot() → Promise.Promise<SaveSlotData.SlotId>Creates a slot at the given index
PromiseExportSlot
Exports a slot's saved data into a plain, serializable SaveSlotExportUtils.SaveSlotExport. Refuses
the main slot unless allowMainSlot is set -- see HasSaveSlotsDataStore.PromiseExportSlot.
PromiseImportSlot
HasSaveSlots.PromiseImportSlot(export: SaveSlotExportUtils.SaveSlotExport,targetSlotIndex: number?--
defaults to the lowest free non-main index
) → Promise<SlotId>Imports an exported slot into a fresh slot, at the lowest free non-main index by default. See HasSaveSlotsDataStore.PromiseImportSlot.
PromiseSaveSlotToSharedDataStore
Exports a non-main slot and writes it to the shared save slot store under the given key. See HasSaveSlotsDataStore.PromiseSaveSlotToSharedDataStore.
PromiseImportSlotFromSharedDataStore
Reads an export from the shared save slot store and imports it into a fresh non-main slot. See HasSaveSlotsDataStore.PromiseImportSlotFromSharedDataStore.
PromiseSelectTransferableEphemeralSlot
Resumes a transfer from the given shared-store key into a fresh ephemeral slot and selects it. Only entries written as transfers are accepted; a share code is redeemed through HasSaveSlots.PromiseImportEphemeralSaveSlotFromCode. See HasSaveSlotsDataStore.PromiseSelectTransferableEphemeralSlot.
PromiseBuildEphemeralTransferSlice
Builds this player's teleport slice for a transferable ephemeral slot. See HasSaveSlotsDataStore.PromiseBuildEphemeralTransferSlice.
PromiseLoadTransferableEphemeralSlotFromTeleport
HasSaveSlots.PromiseLoadTransferableEphemeralSlotFromTeleport(self: HasSaveSlots) → Promise<SlotId?>Selects the transferable ephemeral slot the player teleported in with, from the shared-store key in their arrived data. Reads the unified band (not trusted-only) so a client-initiated teleport -- the common case, e.g. a menu resume hop -- carries it too; a server-initiated teleport still works via the trusted band. Resolves to the slot id, or nil when none arrived.
Because the client band is honored, a client can present any key it knows -- which is why the entry
behind it must have been written as a transfer (see SaveSlotExportUtils.Kind). A share code, the one
key players deliberately pass around, is refused here, so redeeming one stays a decision the server
makes in HasSaveSlots.PromiseImportEphemeralSaveSlotFromCode rather than something a teleport can do.
A transfer key is itself replicated (see ActiveTransferableEphemeralKey) and only ever seeds a
throwaway, never-persisted slot, so what it exposes is read-only visibility of that snapshot.
SetCodeGenerator
Overrides the share-code generator for this player's exports (see SaveSlotCodeUtils.CodeGenerator). Games inject a custom format; the default is SaveSlotCodeUtils.generateDefaultCode. Usually set game-wide via SaveSlotService.SetCodeGenerator rather than per player.
PromiseExportSaveSlotToCode
HasSaveSlots.PromiseExportSaveSlotToCode(slotId: SlotId?,--
defaults to the active slot
allowMainSlot: boolean?--
defaults to false
) → Promise<string>Exports a slot to the shared store under a fresh generated code and resolves to that code. See HasSaveSlotsDataStore.PromiseExportSaveSlotToCode.
PromiseImportEphemeralSaveSlotFromCode
Redeems a share code into a fresh transferable ephemeral slot and selects it. The slot transfers onward under a freshly minted key, never the code itself. See HasSaveSlotsDataStore.PromiseImportEphemeralSaveSlotFromCode.
PromiseExportSaveSlotToJson
HasSaveSlots.PromiseExportSaveSlotToJson(slotId: SlotId?,--
defaults to the active slot
allowMainSlot: boolean?--
defaults to false
) → Promise<string>Exports a slot as a raw JSON string (no shared store). See HasSaveSlotsDataStore.PromiseExportSaveSlotToJson.
PromiseDuplicateSlot
HasSaveSlots.PromiseDuplicateSlot(slotId: SaveSlotData.SlotId) → Promise.Promise<SaveSlotData.SlotId>Duplicates the slot with the given ID into a new slot at the lowest free index, copying its saved data and accrued playtime. See HasSaveSlotsDataStore.PromiseDuplicateSlot.
PromisePersistEphemeralSlot
HasSaveSlots.PromisePersistEphemeralSlot(slotId: SlotId?--
defaults to the active slot
) → Promise<SlotId>Turns an ephemeral slot into a real save and selects it. See HasSaveSlotsDataStore.PromisePersistEphemeralSlot.
PromiseDeleteSlot
HasSaveSlots.PromiseDeleteSlot(slotId: SaveSlotData.SlotId) → Promise.Promise<any>Deletes the slot with the given ID. See HasSaveSlotsDataStore.PromiseDeleteSlot.
PromiseDeleteAllSlots
Deletes every slot for the player and clears the active/last-active selection, resetting the player to a fresh state. Resolves once all slots are gone.
PromiseResetSlot
HasSaveSlots.PromiseResetSlot(slotId: SaveSlotData.SlotId) → Promise.Promise<SaveSlotData.SlotId>Resets the slot with the given id to a fresh empty one. See HasSaveSlotsDataStore.PromiseResetSlot.
PromiseResetActiveSlot
Resets the active slot to a fresh empty one -- see HasSaveSlots.PromiseResetSlot. Resolves to the new slot id, or nil when no slot is active.
PromiseSetSlotMetadata
HasSaveSlots.PromiseSetSlotMetadata() → Promise.Promise<any>Sets the metadata for the slot with the given ID
PromiseGetSlotMetadata
HasSaveSlots.PromiseGetSlotMetadata(slotId: SaveSlotData.SlotId) → Promise.Promise<SaveSlotData.SaveSlotMetadata?>Gets the metadata for the slot with the given ID
PromiseSlotIdFromIndex
HasSaveSlots.PromiseSlotIdFromIndex(slotIndex: number) → Promise.Promise<SaveSlotData.SlotId?>Returns the slot ID from the given index
PromiseLastActiveSlotId
Gets the last active slot ID
PromiseSelectLastSaveSlot
Selects the player's last active slot if one still exists, resolving to the selected slot id -- or nil when there is no slot to continue on. Backs a "Continue" affordance that every save-slot consumer tends to need.
PromiseSelectNewSaveSlot
Creates a new slot at the lowest free index and selects it, resolving to the new slot id -- or nil when every slot is already in use. Backs a "New Game" affordance.
PromiseSelectEphemeralSlot
HasSaveSlots.PromiseSelectEphemeralSlot(metadata: SaveSlotCreateMetadata?--
optional SlotName/Summary for the in-memory slot
) → Promise<SlotId>Creates a fresh ephemeral slot and selects it, resolving to its id. See HasSaveSlotsDataStore.PromiseSelectEphemeralSlot.
RegisterSummaryProvider
HasSaveSlots.RegisterSummaryProvider() → () → ()
Registers a named summary provider. Every registered provider's current value is aggregated into
the active slot's Summary, keyed by name (see HasSaveSlots.PromiseGetSlotMetadata). Registering
the same name again replaces the previous provider. Returns a function that unregisters the provider
(also give it to a [Maid]).