Spielstand: Werte über den Lauf hinaus speichern (Savegame) #166

Closed
opened 2026-09-19 11:41:52 +02:00 by meleki · 2 comments
Owner

Aus #91 (Entscheidung C: Lebensdauer „pro Lauf“; „jede Form von Persistenz über den Lauf hinaus wäre der Anfang eines Savegames und gehört in ein eigenes Issue“).

Befund

  • Alle Laufzeitwerte entstehen beim Play-Start frisch aus den Defaults und verschwinden beim Stop. Highscore, freigeschaltete Level oder Einstellungen des Spielers lassen sich nicht speichern.

Zu bauen (Vorschlag)

  • Nodes Save value / Load value (Schlüssel, Wert, Vorgabe) und Delete saved, gespeichert im Browser (localStorage) pro Projekt.
  • Werte aller Variablen-Arten, auch Listen und Structs.
  • Im Editor ein Knopf „Clear saved data“ für das Projekt, sonst testet man nie den ersten Start.
  • Tests: Wert überlebt Stop und Play; getrennt pro Projekt; Löschen.

Offen (mit Vorschlag)

  1. Einzelwerte oder ganzer Spielstand (alle globalen Variablen auf einmal)? Vorschlag: zuerst Einzelwerte, ein „Save all globals“ später.
  2. Im Editor-Run speichern? Vorschlag: ja, in einen getrennten Bereich, damit Tests im Editor den Spielstand nicht anfassen.
Aus #91 (Entscheidung **C**: Lebensdauer „pro Lauf“; „jede Form von Persistenz über den Lauf hinaus wäre der Anfang eines Savegames und gehört in ein eigenes Issue“). ## Befund - Alle Laufzeitwerte entstehen beim Play-Start frisch aus den Defaults und verschwinden beim Stop. Highscore, freigeschaltete Level oder Einstellungen des Spielers lassen sich nicht speichern. ## Zu bauen (Vorschlag) - Nodes **Save value** / **Load value** (Schlüssel, Wert, Vorgabe) und **Delete saved**, gespeichert im Browser (`localStorage`) pro Projekt. - Werte aller Variablen-Arten, auch Listen und Structs. - Im Editor ein Knopf „Clear saved data“ für das Projekt, sonst testet man nie den ersten Start. - Tests: Wert überlebt Stop und Play; getrennt pro Projekt; Löschen. ## Offen (mit Vorschlag) 1. **Einzelwerte oder ganzer Spielstand (alle globalen Variablen auf einmal)?** Vorschlag: zuerst Einzelwerte, ein „Save all globals“ später. 2. **Im Editor-Run speichern?** Vorschlag: ja, in einen getrennten Bereich, damit Tests im Editor den Spielstand nicht anfassen.
meleki added the new label 2026-09-19 11:41:52 +02:00
  1. ich würde sagen, save/load value node komplett weglassen. einfach nur bei variable asset mit einem toggle "persistent" versehen - sprich diese werden gespeichert und geladen.
  2. vorschlag passt
1. ich würde sagen, save/load value node komplett weglassen. einfach nur bei variable asset mit einem toggle "persistent" versehen - sprich diese werden gespeichert und geladen. 2. vorschlag passt
admin added low-priority and removed new labels 2026-09-19 12:09:21 +02:00
admin added this to the Development project 2026-09-19 12:09:24 +02:00
admin moved this to Next in Development on 2026-09-22 09:26:02 +02:00
Author
Owner

Done in 41772e5, as agreed above: no save or load nodes, a switch on the Variables asset instead.

How it works

  • "Persistent" checkbox in the inspector of a Variables asset. When on, the next run starts from what the last one left. The existing Variables nodes read and write as before. Toggling is one undo step.
  • Saved after every frame that changed a value, so a closed tab loses nothing.
  • Play and "Run in editor" save apart (point 2): trying a behavior in the editor leaves the Play save alone.
  • Clearing: "Clear saved values" under the checkbox clears this asset in both areas. Main menu → "Clear saved data" clears everything for the project. Clearing takes effect from the next run on.

Decisions

  • The switch covers the whole asset, not single variables. To mix both, use two assets.
  • Values live in the browser (localStorage) per project, not in the project file. Another browser or person starts fresh.
  • Saved values are read through the current declaration: a removed variable drops out, a new one starts from its default, a changed kind is converted.
  • A changed default in the inspector shows only after the save is cleared.

Tests

./check.sh              → 140 files, 2070 tests, exit 0   (before 138 / 2055)
GM_STEPS=32,46 (fresh)  → ALL PASSED, 24 checks
  • 15 new unit tests (tests/core/saved-values.test.ts, tests/editor/saves.test.ts).
  • 6 new e2e checks in module 32, all through the UI: checkbox, two runs in a row (2, then 4), project default stays 0, editor run saves apart, both ways to clear. Module 46 knows the new menu entry.
  • Counter-checks fail as expected: loading switched off → 2 unit tests and 2 e2e checks fail; editor run writing into the Play area → 1 e2e check fails.
  • Check total 1278 is computed (1272 measured by CI at bbbf341, plus 6). The CI run for 41772e5 was not awaited.

Wiki: Behaviors, Concepts, Architecture and Development updated (a1c77c7).

Done in 41772e5, as agreed above: no save or load nodes, a switch on the Variables asset instead. **How it works** - **"Persistent" checkbox** in the inspector of a Variables asset. When on, the next run starts from what the last one left. The existing `Variables` nodes read and write as before. Toggling is one undo step. - **Saved after every frame that changed a value**, so a closed tab loses nothing. - **Play and "Run in editor" save apart** (point 2): trying a behavior in the editor leaves the Play save alone. - **Clearing:** "Clear saved values" under the checkbox clears this asset in both areas. **Main menu → "Clear saved data"** clears everything for the project. Clearing takes effect from the next run on. **Decisions** - The switch covers the whole asset, not single variables. To mix both, use two assets. - Values live in the browser (`localStorage`) per project, not in the project file. Another browser or person starts fresh. - Saved values are read through the current declaration: a removed variable drops out, a new one starts from its default, a changed kind is converted. - A changed default in the inspector shows only after the save is cleared. **Tests** ``` ./check.sh → 140 files, 2070 tests, exit 0 (before 138 / 2055) GM_STEPS=32,46 (fresh) → ALL PASSED, 24 checks ``` - 15 new unit tests (`tests/core/saved-values.test.ts`, `tests/editor/saves.test.ts`). - 6 new e2e checks in module 32, all through the UI: checkbox, two runs in a row (2, then 4), project default stays 0, editor run saves apart, both ways to clear. Module 46 knows the new menu entry. - Counter-checks fail as expected: loading switched off → 2 unit tests and 2 e2e checks fail; editor run writing into the Play area → 1 e2e check fails. - Check total 1278 is computed (1272 measured by CI at bbbf341, plus 6). The CI run for 41772e5 was not awaited. Wiki: Behaviors, Concepts, Architecture and Development updated (a1c77c7).
admin moved this to Done in Development on 2026-09-22 10:24:34 +02:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: meleki/feuerwerk#166