save-systems
Fungsinya
Skill ini mencakup penyimpanan dan pemuatan kemajuan game, termasuk apa yang disimpan, penulisan file yang aman, dan versi. Skill ini ditujukan untuk pengembang game yang memerlukan penyimpanan yang tetap utuh setelah pembaruan.
Kapan dipakai
- βSaat Anda perlu menyimpan kemajuan pemain, inventaris, dan flag dunia di antara sesi.
- βSaat penyimpanan rusak setelah crash atau saat game terhenti ketika sedang menyimpan.
- βSaat file simpan lama berhenti berfungsi setelah Anda memperbarui game.
Link skill
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/save-systems/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βPemain saya kehilangan file simpan ketika game crash saat menyimpan, dan simpanan lama rusak setelah pembaruan. Bisakah Anda memperbaiki sistem penyimpanannya?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent memutuskan data mana yang menjadi sumber kebenaran dan menyimpan data itu, bukan objek engine. Agent menambahkan nomor versi pada setiap simpanan, menulis file dengan cara yang tidak dapat dirusak oleh crash, dan menambahkan kode migrasi untuk versi yang lebih lama.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Save systems
A save file is a serialized snapshot of game state that survives restarts. The hard parts aren't writing bytes β they're choosing what to save, writing it so a crash mid-save can't corrupt it, and reading old saves after you ship a patch. Get those three right and the rest is plumbing.
When to use
- Use to persist progress: player stats, inventory, world flags, settings, positions β across sessions and game updates.
- Use to design save slots, quicksave/autosave, and crash-safe writes.
- Use when old save files break after a content/code change (versioning & migration).
When not to use: for Roblox cloud persistence specifics, use
roblox-datastores. For the data model the save serializes (resources/SOs), use
godot-resources / unity-scriptableobjects. For Godot's FileAccess/
ResourceSaver and user:// paths, defer to the Godot engine skill while
applying the patterns here.
Core workflow
- Decide what state is authoritative. Save the data (hp, position, seed, unlocked flags), not engine objects or scene nodes. You will reconstruct objects from data on load β never serialize live node references.
- Define a versioned schema. Every save embeds a
versioninteger. This is the single most important field for a game you intend to patch. - Pick a format. JSON/text for readability and debuggability; a binary format for size/speed or mild tamper-resistance. Start with JSON.
- Write atomically. Serialize to a temp file, flush, then rename over the real file. A crash leaves either the old save or the new one β never a half-written one.
- Load defensively. Read version β migrate up to current β validate β instantiate. Keep a backup of the last good save and fall back on parse error.
- Autosave on safe boundaries (level change, checkpoint), throttled, and to a separate slot so it can't clobber a manual save.
- Verify: save, fully quit, relaunch, load β and confirm by inspection that state matches. Test loading a save from the previous version.
Patterns
1. Serialize state as plain data (not engine objects)
# Build a dictionary of pure data. Each savable object reports its own state.
func capture_state() -> Dictionary:
return {
"version": SAVE_VERSION, # ALWAYS stamp the schema version
"player": { "hp": player.hp, "pos": [player.position.x, player.position.y] },
"inventory": player.inventory.to_array(), # ids + counts, not Item nodes
"flags": world.flags, # e.g. {"met_guard": true}
"seed": world.seed, # regenerate procedural content
}
# On load, RECONSTRUCT objects from the data β do not expect live references back.
func apply_state(data: Dictionary) -> void:
player.hp = data["player"]["hp"]
player.position = Vector2(data["player"]["pos"][0], data["player"]["pos"][1])
player.inventory.from_array(data["inventory"])
world.flags = data["flags"]
2. Atomic, crash-safe write (temp + rename)
# Godot 4.7. Write a temp file, keep the previous save as .bak, then rename.
func save_atomic(path: String, data: Dictionary) -> Error:
var tmp := path + ".tmp"
var f := FileAccess.open(tmp, FileAccess.WRITE)
if f == null:
return FileAccess.get_open_error() # disk full, read-only, no permission...
if not f.store_string(JSON.stringify(data)):
return ERR_FILE_CANT_WRITE
f.close() # flushes Godot's buffer to the OS
if FileAccess.file_exists(path):
DirAccess.rename_absolute(path, path + ".bak") # keep the last good save
return DirAccess.rename_absolute(tmp, path)
func load_save(path: String) -> Dictionary: # empty = nothing loadable
for p in [path, path + ".bak"]: # .bak covers a crash between renames
if FileAccess.file_exists(p):
var data = JSON.parse_string(FileAccess.get_file_as_string(p))
if data is Dictionary and data.has("version"):
data["version"] = int(data["version"]) # JSON numbers load as float
return data
return {}
# WRONG: opening `path` directly and writing in place β a crash mid-write leaves a
# truncated, unloadable save and destroys the player's progress.
A crash now leaves the old save, the new one, or (between the two renames) only
the .bak β which the loader tries
Pertanyaan umum
Mengapa menambahkan nomor versi pada setiap simpanan?
Skill menyebutnya field paling penting, karena memungkinkan pembaruan di masa depan mengonversi simpanan lama.
Haruskah saya menyimpan objek scene?
Tidak. Skill menyebutkan untuk menyimpan data dan membangun ulang objek dari data itu saat dimuat.
Apakah mencakup penyimpanan Roblox?
Tidak. Data store Roblox dicakup oleh skill Roblox yang terpisah.
Detail
Deskripsi asli dari pembuat
Design save/load for game state β choosing what to serialize, file formats, save slots, atomic crash-safe writes, schema versioning and migration, and autosave. Engine-neutral. Use when the user mentions save system, save/load, game state persistence, save slots, autosave, save file corruption, or migrating old saves to a new version.
Popularitas
- Bintang GitHub
- 6.6k
- Peringkat
- #13804
- Lisensi
- Apache-2.0
- Diperbarui
- 28/10/2026
Komentar
- β¦
Skill lain dari repositori ini
router
6.6kMembantu agent Anda memilih skill pengembangan game yang tepat untuk setiap permintaan dengan mendeteksi engine Anda dan jenis tugas yang Anda perlukan.
ai-behavior-trees-utility-ai
6.6kMembantu agent Anda membangun behavior tree dan sistem utility AI untuk musuh dan karakter game yang memilih aksi berdasarkan prioritas dan skor.
audio-design
6.6kMengajari agent Anda cara mixing audio game: bus, volume dalam desibel, ducking di bawah dialog, musik adaptif, dan variasi efek suara.
camera-systems
6.6kMembantu agent Anda membangun kamera game yang mengikuti dengan halus, tetap berada di dalam level, dan dapat mengorbit atau melihat sekeliling dalam 3D.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.