Skip to content

Commit bacbc8c

Browse files
manuqclaude
andcommitted
When resuming a game, the inventory persisted is not loaded. Fix it.
- Updated `_update_trinkets_state()` to save all trinket fields (`id`, `name`, `description`, `icon` resource path, `full_text`) as dictionaries instead of just IDs. - Updated `restore()` to reconstruct full `Trinket` objects from saved data, including loading the icon texture from its resource path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 28fc6d8 commit bacbc8c

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

scenes/globals/game_state/game_state.gd

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,16 @@ func _update_trinkets_state() -> void:
312312
_state.set_value(
313313
TRINKETS_SECTION,
314314
TRINKETS_IDS_KEY,
315-
trinkets.map(func(t: Trinket) -> StringName: return t.id)
315+
trinkets.map(
316+
func(t: Trinket) -> Dictionary:
317+
return {
318+
"id": t.id,
319+
"name": t.name,
320+
"description": t.description,
321+
"icon": t.icon.resource_path if t.icon else "",
322+
"full_text": t.full_text,
323+
}
324+
)
316325
)
317326

318327

@@ -404,11 +413,17 @@ func restore() -> Dictionary:
404413
)
405414
completed_quests = _state.get_value(GLOBAL_SECTION, COMPLETED_QUESTS_KEY, [] as Array[String])
406415

407-
# Restore trinkets from saved IDs
416+
# Restore trinkets from saved data
408417
trinkets.clear()
409-
for trinket_id: StringName in _state.get_value(TRINKETS_SECTION, TRINKETS_IDS_KEY, []):
418+
for trinket_data: Dictionary in _state.get_value(TRINKETS_SECTION, TRINKETS_IDS_KEY, []):
410419
var trinket := Trinket.new()
411-
trinket.id = trinket_id
420+
trinket.id = trinket_data.get("id", &"")
421+
trinket.name = trinket_data.get("name", "")
422+
trinket.description = trinket_data.get("description", "")
423+
var icon_path: String = trinket_data.get("icon", "")
424+
if not icon_path.is_empty():
425+
trinket.icon = load(icon_path)
426+
trinket.full_text = trinket_data.get("full_text", "")
412427
trinkets.append(trinket)
413428

414429
# Restore lives from saved state, default to MAX_LIVES if not found

0 commit comments

Comments
 (0)