Skip to content

Kiln API / kiln / SaveSlots

Class: SaveSlots ​

Save slots: res.mut(Saves).save('slot1') writes now; .load('slot1') applies at the start of the next frame and emits Loaded. Also has, delete, slots(). What is saved comes from savePlugin({ resources, traits }).

Constructors ​

Constructor ​

ts
new SaveSlots(app, opts): SaveSlots;

Parameters ​

ParameterType
appApp
opts{ resources: Resource<any>[]; traits: Trait[]; key: string; storage: SaveStorage; }
opts.resourcesResource<any>[]
opts.traitsTrait[]
opts.keystring
opts.storageSaveStorage

Returns ​

SaveSlots

Properties ​

pendingLoad ​

ts
pendingLoad: string | null = null;

A load requested this frame, applied at the next frame start.

Methods ​

save() ​

ts
save(slot?): string;

Writes the slot now and emits Saved. Returns the JSON written.

Parameters ​

ParameterTypeDefault value
slotstring'auto'

Returns ​

string


load() ​

ts
load(slot?): boolean;

Loads the slot at the start of the next frame. Returns false (and does nothing) if it doesn't exist.

Parameters ​

ParameterTypeDefault value
slotstring'auto'

Returns ​

boolean


has() ​

ts
has(slot?): boolean;

Parameters ​

ParameterTypeDefault value
slotstring'auto'

Returns ​

boolean


delete() ​

ts
delete(slot?): void;

Parameters ​

ParameterTypeDefault value
slotstring'auto'

Returns ​

void


slots() ​

ts
slots(): string[];

Slot names that exist, sorted.

Returns ​

string[]


toJSON() ​

ts
toJSON(): object;

Returns ​

object

slots ​
ts
slots: string[];
pendingLoad ​
ts
pendingLoad: string | null;