Spielerando

Lesson 13 of 14Keep it whole7 minFree

What a Save Game Must Hold: Facts, Not Where You Stand

A pixel art beekeeper pours honey from a barrel in her workshop, and the number at the top left goes up. When she stops for a moment, a bee carries that number over to the chest in the corner, which is the save. When the chest is locked, the bee bounces off and an amber bar counts down before the next try.

The save starts after 3 seconds without a change, never while a wasp is in the room, and at once when she walks out of the door. A failed save waits 5 seconds before the next try, then 10, then 15, up to 30.

Try it: Pour again while the bee is still flying: the chest gets the old number, and a second save follows, because your new honey was not in the first. Lock the chest and watch each failed try wait longer. Keep pouring without a pause: after 60 seconds it saves anyway.

Keys: Space pour honey X walk out (quit) ↓ lock or unlock the chest

This little game runs this blueprint's tested code in your browser. Nothing you press is sent anywhere. Its code on GitHub.

The game above is the playable demo of our blueprint Autosave. It runs that blueprint's tested code in your browser.

A save has to hold what the player did, not only where they stand. This lesson finds what a load must give back on the game above, where a chest keeps a beekeeper's work. Then your AI tests a save taken in the middle of a quest, and an old save loaded after the story changed.

Also in this lesson 5 things to read up on 3 questions to check yourself

The idea

A save is a promise: close the game now, and the story will be where you left it. So the list of what a save holds is not a new list. It is the facts, quest states and character numbers you already wrote down in this course, and the place where the player stands is one more line at the bottom.

What a save leaves out matters just as much. The scene on the screen, a line half said, a cutscene that is running: the game draws them again from the facts. A save that keeps the scene keeps the part that is easiest to rebuild, and forgets the part that cannot be rebuilt at all.

Play the game above for a minute first. The beekeeper pours honey in her workshop, and the chest in the corner is the save.

How it works

Read the two numbers. The number at the top left is what she has done: every spoon of honey poured. The number over the chest is what the last good save holds. If the game crashed now, a load would give back the chest's number and nothing else. Pour a few spoons and stop. After 3 seconds without a change, and with no wasp in the room, a bee carries the number to the chest, and the two numbers agree again.

Look at what is not in the chest. The full jars on the shelf and the honey in the jar under the tap are not saved. The game works them out from the one number, so a load that gives back the number gives back the shelf as well. Where she stands is not in the chest, and neither is the wasp. That is the line between a fact and the scene: a fact is what the game cannot work out again, and the scene is drawn from the facts.

Pour again while the bee is flying. The chest gets the old number, and a second save follows a few seconds later. The bee carries a copy taken at the moment it set off, so a save is all the facts of one moment. A game that writes its quests at one moment and its items at another can load a mix of two moments. The autosave blueprint behind this game warns of exactly that: a door already open while its key is still in the pocket.

Wait for the wasp. Now and then a wasp flies in at the window, and while it is in the room no save starts. The wasp stands for the moments in your game that a load cannot start from: a fight, a cutscene, a line half said. Now pour, and walk out of the door while the wasp is in the room. The save starts at once, because leaving may be the last chance.

So a save can still land in the middle of something, and that is why it holds facts and not the scene. When such a save is loaded, the game does not try to rebuild the half-said line. It starts the scene again from its beginning, with the facts as they were. A scene that hands something over asks a fact first, such as "the sword is given", so that it never hands it over twice.

Write the list for your own game. Next to every line of your story's facts, write where today's save holds it. A line with nothing next to it is something a player loses on the next load.

What goes wrong

Ask an AI to "add saving", and it saves what it can see in the code at that moment, such as where the player stands, their health and what they carry. Or it saves the scene, and on load plays that scene again. Both look right when you try them once: you stand in the right room, or in the right scene.

But the scene by the river asks whether the player spared the thief two scenes before, and the save does not know. The game answers with what a new game starts with: the thief was never spared. He is an enemy again, and nothing on the screen says why. That is the shortcut of this lesson: a save that keeps where the player stands and forgets what they did.

The gap opens again as the story grows. A new fact goes into the facts file and into the scenes, but not into the save, and nothing breaks on the day it is added. And a save from last week has no line for a fact you added today. If nobody decided what an old save gets, the code picks something by accident, or the load fails.

You notice all of these by comparing two lists, not by playing: the facts your story has, from its file, and the facts your save holds. A test that compares them, and names every fact missing from the save, fails on the day the gap is made, not on the day a player finds it.

Tell your AI

I want my game's save to keep the story, not only where the player stands. My story's facts are in [the file with your facts, for example story-facts.md].

Before you change any code, list everything a load must give back: every fact in that file, every quest with its state and step, every number a character keeps about the player, every item a later scene needs, and the place last. Next to each, write where the game sets it and where today's save holds it, or "not saved". Then list what stays out because the game can work it out from the facts, such as the scene on screen. Show me both lists and wait for my yes.

Then make the save one copy of all of it, taken at one moment, with a version number. A save loaded in the middle of a scene starts that scene from its beginning, and a scene that hands something over checks a fact first.

Write these tests, run them and show me their output:
- For each line of that first list: set it, save, load into a fresh game, check it came back.
- Save in the middle of [a quest of mine] at its second step, load, and finish the quest.
- Save in the middle of a scene that hands something over, load, and check the player has it once.
- Compare the facts file with the save, and fail with the fact's name when the save lacks one.
- Keep one save from today in a folder of old saves. After every change, load each and print what it gives back. When a fact is new, ask me what an old save gets for it.

Do not tell me saving works. Show me the output.

Try it

Read up

Where to go deeper: the pages of ours this lesson builds on, and what others have written about its point.

Check yourself: three questions

Each answer is checked and explained at once. The questions are part of the quiz, so they count for your Game Coder IQ like any other.

Question 1 of 3Easy

In the workshop game of this lesson, the number over the chest is lower than the number at the top left, and no bee is flying. The game crashes now. What does a load give back?

All questions of this course · The quiz and the Game Coder IQ

Next lesson When Your AI Forgets the Story: Keep the Facts in a File

How useful was this page?

Nobody has rated this page yet.

One click, no account. It tells us which pages to make better next.

Last updated: 2026-11-27