Skip to Content
DocsGodot Save Game Example
DocsGodot Save Game Example

Godot Save Game Example

Advanced Linux code-testing download. This is not a playable game: there is no main scene or Save button. It contains a JSON save/load helper and tests that run without a game window, covering numeric health and a 2D position. Loading updates a mutable, untyped Dictionary, not scene nodes.

If you want saves in your game, ask Ziva: “Add Save and Load buttons for my player’s health and position. Explain where the save goes and help me try loading it after restarting the game.”

Download: https://ziva.sh/assets/examples/godot-save-game.zip

For the complete helper and an explanation of its format, see https://ziva.sh/blogs/godot-save-game.

Safety limits: review the files before running them. The helper assumes a trusted private directory and a single writer. A controlled truncated-write check does not prove power-loss safety, concurrent-writer safety or general disk-full handling. Use the supplied runner to keep test saves separate from existing game saves.

Plan and privacy

The standalone download needs no AI account, Ziva installation or paid plan. Asking Ziva to adapt it uses your selected model’s normal usage. The supplied files contain no network or upload code. The runner writes synthetic save data and local diagnostic files, which can contain local paths; review them before sharing. Do not put secrets into save data or error reports. This does not describe networking in other projects or editor plugins.

Optional reference: Linux requirements, commands and failure help

Requirements

This download was checked with Godot 4.7.2 on Linux. The supplied runner requires Python 3 with its Linux resource module, Godot at /usr/bin/godot, and taskset and timeout on your command path. It uses a CPU available to the process. Other platforms and Godot versions were not tested.

Run the example

  1. Extract the ZIP into a new writable folder. It contains project.godot, save_load.gd, test_save_load.gd, run_tests.py and README.md.
  2. Review the files before running them. From the extracted folder, run:
python3 run_tests.py
  1. Read the result for each stage and the printed manifest location. A successful run exits with code zero, records all three stages as passed and sets the manifest’s final passed value to true.

The stages check saving and loading, reading a save after restarting Godot, and a failed write. The failed-write check limits file size only for its separate child process.

Each invocation creates a new directory under artifacts/ with private XDG data, configuration and cache directories. This keeps the test saves separate from your existing game saves. Launching the test script directly does not provide the runner’s isolation.

Understand the output

Some save/load rejection errors are intentional: the tests try invalid saves and a constrained write. Do not decide success by counting red messages or by the Godot exit code alone. Check that all three stages passed and that the manifest’s final passed value is true.

If a stage fails, inspect its captured standard output, standard error and manifest entry in the new attempt directory. Do not suppress a failed check just to get a passing result.

Troubleshooting

  • The editor asks for a main scene: this is a headless test project. Run the Python command above, not the editor’s Play button.
  • A required program or module is missing: check the Linux requirements and the exact /usr/bin/godot location. The runner does not install tools for you.
  • A timeout or a failed stage: inspect that stage’s output and manifest entry. Later stages may not have run; do not treat an incomplete run as a pass.
  • An effective-file-logging assertion fails: check the bundled project settings and Godot version. Do not suppress the assertion to get a passing result.
  • Loading returns ERR_INVALID_PARAMETER: use a mutable, untyped Dictionary as the destination. Read-only and typed dictionaries are rejected before file access or state mutation. This restriction does not apply to read-only input used for saving.
  • Your own save is rejected: compare it with the article’s exact keys, numeric version, whole-health rule and numeric magnitude limit, including coordinates. Validation is of parsed numeric values, not arbitrary decimal text.
  • A .tmp path already exists in your own project: stop and inspect it. The helper refuses it rather than deleting an unknown file. Determine its origin before deciding how to handle it.
Last updated on