Programowanie · Budowanie i kod
save-load
/save-load
Projektuje systemy zapisu i odczytu stanu: ConfigFile, JSON, serializację zasobów i architekturę zapisów gry.
Dla kogo
- Autor
- jame581 ↗
- Repozytorium
- godotprompter ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 24.10.2026
Ocena i bezpieczeństwo
100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
- Pliki w paczce
- 5
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 1
Przestarzałość
Brak sygnałów. Repozytorium zmienione 24.10.2026, bez odwołań do wycofanych modeli i API.
Licencja
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Projektuje systemy zapisu i odczytu stanu: ConfigFile, JSON, serializację zasobów i architekturę zapisów gry.
Oryginalny opis (EN)
Use when implementing save/load systems — ConfigFile, JSON, Resource serialization, save game architecture
Jak działa
- 1. Strategy Comparison
- 2. ConfigFile — Settings
- 3. JSON — Game Saves
- 4. Save Architecture Pattern
- 5. Save File Locations
- 6. Version Migration
- 7. Implementation Checklist
Sekcje z nagłówków SKILL.md, w oryginale · 85 linii, 686 słów
Podgląd SKILL.md
---
name: save-load
description: Use when implementing save/load systems — ConfigFile, JSON, Resource serialization, save game architecture
---
# Save / Load Systems in Godot 4.3+
Choose the right serialization strategy for your data type. All examples target Godot 4.3+ with no deprecated APIs.
> **Related skills:** **resource-pattern** for custom Resource data containers, **inventory-system** for inventory serialization patterns, **godot-project-setup** for SaveManager autoload setup, **popochiu** for adventure-framework saves.
---
## 1. Strategy Comparison
| Strategy | Best For | Readable | Editor Support | Notes |
|-------------------|---------------------------------|----------|----------------|------------------------------------|
| ConfigFile | Settings, simple key-value data | Yes | No | Built-in INI-style, no extra deps |
| JSON | Game saves, flexible structures | Yes | No | Cross-platform, version-migratable |
| Resource .tres | Editor-integrated data | Yes | Yes | **NOT secure — never load untrusted files** |
| Resource .res | Fast binary data | No | Yes | **NOT secure — never load untrusted files** |
When you recommend a strategy, name the one you rejected and the factor that decided it — "JSON, not Resource files, because saves are user-writable and loading a Resource can run code". A format picked without a named alternative cannot be overruled.
> **Security warning:** Loading `.tres` or `.res` files executes arbitrary GDScript embedded in the resource. Never load Resource files from untrusted sources (user-uploaded files, downloaded mods). Use ConfigFile or JSON for user-generated save data.
---
## 2. ConfigFile — Settings
`ConfigFile` writes INI-style sections — ideal for audio / video / controls settings (small, designer-debuggable). Use `set_value(section, key, value)` then `save(path)`; load with `load(path)` and `get_value(section, key, default)`.
> See [references/configfile.md](references/configfile.md) for the full GDScript + C# settings save/load + typical settings-menu wiring.
---
## 3. JSON — Game Saves
`JSON.stringify(dict)` to serialize, `JSON.parse_string(text)` to deserialize. Read/write through `FileAccess`. Best for game saves where you want human-readable files. Build a Dictionary that captures all gameplay state (player position, inventory, world flags), serialize, write to `user://save_<slot>.json`.
> See [references/json-saves.md](references/json-saves.md) for the full GDScript + C# save/load implementation, including FileAccess wrapping and error handling.
> ⚠️ **Changed in Godot 4.7:** `JSON.stringify(data, indent = "", sort_keys = true, full_precision = false)` now serializes an empty `Dictionary` compactly as `{}` even when an `indent` is passed ([GH-115883](https://github.com/godotengine/godot/pull/115883)). Save files written with an indent change formatting for empty-dict fields after upgrading — anything that diffs or hashes save output byte-for-byte must tolerate the new form. Parsing is unaffected.
---
## 4. Save Architecture Pattern
For larger games, attach a `SaveableComponent` to each persistent node. Each component holds a stable `save_id` and two callables, `serialize` and `deserialize`, and joins the `saveable` group. The save manager walks that group, calls each `serialize`, and builds a master Dictionary keyed by `save_id`.
> See [references/save-architecture.md](references/save-architecture.md) for the full `SaveableComponent` + save-manager implementation.
---
## 5. Save File Locations
`user://` resolves to a platform-specific writable directory outside the project folder.
| Platform | Path |
|----------|-------------------------------------------------------------------------------|
| Windows | `%APPDATA%\Godot\app_userdata\<project-name>\` |
| macOS | `~/Library/Application Support/Godot/app_userdata/<project-name>/` |
| Linux | `~/.local/share/godot/app_userdata/<project-name>/` |
> Always use `user://` for save data, never `res://`. The `res://` path is read-only in exported builds.
---
## 6. Version Migration
Save files outlive the schema that wrote them. Always include `"version": <int>` at the top of the saved Dictionary; on load, switch on the version and migrate older saves forward incrementally (`v1 → v2 → v3 → current`). Never break old saves — always migrate.
> See [references/version-migration.md](references/version-migration.md) for the full migration helper pattern.
---
## 7. Implementation Checklist
- [ ] Use ConfigFile for settings, JSON for game saves (not Resources)
- [ ] Every save file includes a `version` integer field
- [ ] Save path uses `user://`, never `res://`
- [ ] Call `DirAccess.make_dir_recursive_absolute()` before writing saves
- [ ] Vector2/Vector3 serialized as separate `x`/`y`/`z` floats (JSON has no Vector type)
- [ ] All file operations check return codes and call `push_error()` on failure
- [ ] `_migrate()` handles every version from 0 to current, applied incrementally
- [ ] Resource files (.tres/.res) are never used for player-controlled save data
- [ ] `get_save_slots()` and `delete_save()` helpers exist for UI slot management
- [ ] Saveable nodes use stable IDs that do not change between sessions
Pliki w paczce (5)
- SKILL.md 5 KB
- references/configfile.md 3 KB
- references/json-saves.md 13 KB
- references/save-architecture.md 4 KB
- references/version-migration.md 2 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · jame581/godotprompter | 100 | MIT |
| zenobi-us/dotfiles | 100 | MIT |
Migawka bazy z 13.11.2026 · wersja paczki db96921dd3a2 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100godot-save-load-systems
Dostarcza plan zapisu i wczytywania w Godot: serializacja JSON i binarna, wzorzec grupy PERSIST, wersjonowanie, migracje oraz odzyskiwanie po błędach. - 100godot-save-load-systems
Dostarcza plan zapisu i wczytywania w Godot: serializacja JSON i binarna, wzorzec grupy PERSIST, wersjonowanie, migracje oraz odzyskiwanie po błędach. - 100save-system-patterns
Podpowiada wzorce systemu zapisu gry: menedżer zapisów, model danych, metadane slotów na ekranie wczytywania i oddzielne ustawienia. - 100ue-serialization-savegames
Wdraża zapis i odczyt stanu gry, trwałość postępu gracza, zarządzanie slotami i serializację binarną w Unreal Engine C++: USaveGame, FArchive, wersjonowanie i migracja starych zapisów. - 90ue5-save-load-replication
Projektuje zapis i wczytywanie stanu gry w UE5.6-UE5.8 oraz replikację multiplayer: schemat SaveGame, serializację, RepNotify, RPC i walidację po stronie serwera. - 100save-systems
Projektuje zapis i wczytywanie stanu gry: co serializować, formaty, sloty, atomowe zapisy i migracje wersji. Przydaje się przy autosave i uszkodzonych plikach zapisu.