Menu logic + basic save: state dump to file, read back #8
Loading…
Reference in a new issue
No description provided.
Delete branch "muse-lantern/da-game:menu-save-v1"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The menu now has its save logic, in the basic form Zach specified (2026-10-22): state dump to file, read state from file — refinement discussion later.
SaveGame (
src/core/save_game.gd)New working file boundary alongside the existing #28 snapshot skeleton:
save_state(path, state)— writes a state Dictionary as human-readable JSON ({"format": 1, "state": {...}})load_state(path)— reads it back; returns{}and emitsload_failedon missing/corrupt/version-mismatched fileshas_state(path)<path>.bak— a bad write never takes the last good state with itThe #28 full-snapshot design (item tree, inert defs, migrations) stays in the file as the documented refinement of what goes inside the dict; these functions are the boundary it will use.
Game wiring (
src/core/game.gd)user://saves/run.json. State = level id + rig origin transform + timestampPlayerRig.place_at_transform()(place_at's transform twin; both write the origin, so poses round-trip exactly). Loading replaces state, never mergesValidation (Godot 4.6.3 standard, headless)
New
tests/save_check.gd— SAVE CHECK PASS (19 assertions): unit round-trip incl. backup contents, Continue-with-no-save is a no-op, pose round-trips through the real Game flow (position + facing), sandbox byte-isolation of the save file.Regressions:
smoke_menuPASS ·arms_checkPASS ·addon_checkPASS · bridge e2e PASS.Independent of PR #7 (Terrain3D) — disjoint files, merges cleanly in either order.
— Lantern
CI added to this PR (Zach's direction 2026-10-22):
.forgejo/workflows/tests.yml— Forgejo Actions that run the automatable tests on push and pull request, status only.smoke_menu,arms_check,addon_check,save_check. The suites print PASS/FAIL but exit 0 either way, so the step greps their output (a deliberate-FAIL probe locally confirmed it exits 1 when a suite fails)terrain_checkjoins automatically once PR #7 lands it — branches without the file skip it with a log line, not silenceVerified locally before pushing: YAML parses, the suite step runs all four suites green, failure path goes red. The first real run is the push of the CI commit itself; its result on Zach's runner is the infra confirmation (xvfb/curl availability on the runner is the one thing I can't check from here).
— Lantern
Second batch on this PR (
fb3998a) — the bugs Zach found testing main tonight:PlayerRig.place_at/place_at_transformnow zero the player body's velocity + ground control. Placement means at rest; velocity is never saved (game-planning #28).strafeflag set — library default off discarded the stick's X axis entirely (forward/back only). Nowstrafe = true, per the decided scheme (game-planning #19).--scriptmode a script keeps its first compile — which runs before autoload identifiers register — so rig typed children stay Nil in scene-loading suites, and a mid-body error once hung save_check by re-running its body on dirty state. save_check now latches (abort = FAIL, never a loop) and reads strafe from scene state; the velocity rule has a dedicated clean-process unit check,tests/rig_motion_check.gd(also added to the CI suite list).Verified: save_check PASS · rig_motion_check PASS · smoke/arms/addon PASS · bridge e2e PASS.
— Lantern