The slot container is the list of saves on the Save Screen and the Load Screen. It finds the saves in the game’s storage, shows each as a Save Slot, adds and removes slots as saves are written and deleted, and decides what a click on a slot does: overwrite it on the save screen, load it on the load screen.

Two save slots side by side, each with a picture of the game in front of the palace, a name in the corner and a date
A slot container with two saves

Tag <slot-container>
Where it lives Created by the save screen and the load screen (one for saves, and one for autosaves when autosave is on)
Built on Component
Source src/components/slot-container/

What it does

  • Lists the saves whose storage key starts with its label and an underscore (Save_…), leaving out their pictures (keys ending in __screenshot) and anything that isn’t a save. It orders them by the number after the underscore, so manual saves, numbered by the time they were made, come oldest first.
  • Keeps up to date: a new save adds a slot, a save written over updates its slot, and a deleted save removes it, while the screen is open.
  • Handles clicks, according to its type:
    • load: loads the save and continues the game from it;
    • save: asks to overwrite it, with its name in an editable field. Overwrite saves the current game into that slot under the name in the field; an empty name does nothing.
  • Shows “No saved games” when the list is empty, also when the storage can’t be read (the engine’s own dialog says why the storage didn’t open; the console says The save and load screens could not read the saved games).

It draws itself again when the player changes the language, so the dates follow the new language.

Markup

<slot-container data-component="slot-container" class="animated" label="Save" type="load">
  <save-slot slot="Save_1795891820557" …></save-slot>
  <save-slot slot="Save_1795891828453" …></save-slot>
</slot-container>

With no saves:

<slot-container data-component="slot-container" class="animated" label="Save" type="load">
  <p data-string="NoSavedGames">No saved games</p>
</slot-container>
Hook What it is
[type="save"], [type="load"] Which screen’s list it is.
[label="…"] Which saves it lists: Save or AutoSave by default.
save-slot One save (Save Slot).

Properties and attributes

Name Type Default What it does
type 'save' or 'load' none What a click on a slot does.
label string none The start of the storage keys it lists: the value of the SaveLabel or AutoSaveLabel setting.
slots (state) string[] [] The storage keys of the saves shown.

The save and load screens write both attributes. If you change the SaveLabel setting after your game is out, old saves under the old label stop appearing.

Events

None of its own. It listens to the storage’s changes, and the didLocalize engine event.

Style it

The list is a centered row of slots that wraps onto more rows, with 2rem between slots and 1rem above and below the list. In your game’s style/main.css:

slot-container {
  gap: 1rem;
  justify-content: flex-start;
  padding: 0 2rem;
}

Replace or extend it

The save and load screens write <slot-container> in their markup, and the overwrite and delete listeners rely on its slots’ slot attribute. Change the slots’ look on the Save Slot instead; a subclass of the list itself must keep type, label and one <save-slot slot="…"> per save.