본문으로 건너뛰기
cccskills
무료GitHub에 공개

save-load

Use when implementing save/load systems — ConfigFile, JSON, Resource serialization, save game architecture

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md5.4 KB
  • references/configfile.md3.4 KB
  • references/json-saves.md12.5 KB
  • references/save-architecture.md4.1 KB
  • references/version-migration.md2.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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

StrategyBest ForReadableEditor SupportNotes
ConfigFileSettings, simple key-value dataYesNoBuilt-in INI-style, no extra deps
JSONGame saves, flexible structuresYesNoCross-platform, version-migratable
Resource .tresEditor-integrated dataYesYesNOT secure — never load untrusted files
Resource .resFast binary dataNoYesNOT 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 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 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). 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 declares save_callable and load_callable. The save manager iterates components by ID, calls each one's save callable, builds a master Dictionary.

See 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.

PlatformPath
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 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

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when working with 2D-specific systems — TileMaps, parallax scrolling, 2D lights and shadows, canvas layers, particles 2D, custom drawing, and 2D meshes in Godot 4.3+

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

Use when working with 3D-specific systems — materials, lighting, shadows, environment, global illumination, fog, LOD, occlusion culling, and decals in Godot 4.3+

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

Use when building character abilities — Resource-based abilities with cost/cooldown/cast, buffs/debuffs, stat modifiers, gameplay tags, and HUD binding

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

Use when creating Godot editor plugins — EditorPlugin, @tool scripts, custom inspectors, and dock panels

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

Use when implementing AI movement — NavigationAgent2D/3D, steering behaviors, behavior trees, and patrol patterns

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

Use when implementing animations — AnimationPlayer, AnimationTree, blend trees, state machines, sprite animation, and code-driven animation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8522026년 10월 15일 업데이트

jame581의 스킬 모두 보기

이 스킬의 문제 신고