Releases: Rubonnek/inventory-manager
Releases · Rubonnek/inventory-manager
v2.0.0
New features
- InventoryManager is now able to track item instance data per slot.
See demo 6 for an usage example with more details.
Data Migration Notes
This release updates the serialized data format for InventoryManager and ItemRegistry.
- InventoryManager: the
SIZEkey moved from1→2, and a newINSTANCE_DATA_TRACKERkey was added at1. - ItemRegistry: per-item
METADATAkey moved from5→7due to new instance data fields.
If you load data gathered with get_data() from an older version, you will need to run a small migration step to migrate the data keys above before calling set_data().
Here's a small GDScript snippet you can use to migrate your InventoryManager and ItemRegistry data. Make sure to run this migration only once against your data:
# Call these before ItemRegistry.set_data(...) and InventoryManager.set_data(...)
# when loading data saved with get_data() from the old version.
func migrate_inventory_manager_data(p_data: Dictionary) -> Dictionary:
# Old format:
# 0 = ITEM_ENTRIES (item slots)
# 1 = SIZE
#
# New format:
# 0 = ITEM_SLOTS
# 1 = INSTANCE_DATA_TRACKER
# 2 = SIZE
if p_data.has(1) and not p_data.has(2) and typeof(p_data[1]) == TYPE_INT:
p_data[2] = p_data[1] # move SIZE
p_data[1] = {} # add empty INSTANCE_DATA_TRACKER
return p_data
func migrate_item_registry_data(p_registry_data: Dictionary) -> Dictionary:
# Old item entry key 5 = METADATA
# New item entry key 7 = METADATA
var entries: Dictionary = p_registry_data.get(0, {}) # _registry_key.ITEM_ENTRIES = 0
for item_id in entries:
var entry: Dictionary = entries[item_id]
if entry.has(5) and not entry.has(7):
entry[7] = entry[5] # move METADATA
entry.erase(5)
return p_registry_data
# Example usage:
func load_and_migrate(saved_inventory_data: Dictionary, saved_registry_data: Dictionary, inv: InventoryManager, registry: ItemRegistry) -> void:
var migrated_registry := migrate_item_registry_data(saved_registry_data)
registry.set_data(migrated_registry)
var migrated_inventory := migrate_inventory_manager_data(saved_inventory_data)
inv.set_data(migrated_inventory)What's Changed
- aea8f9a - Bump plugin version
- d35b145 - Update InventoryManager documentation
- 6d2fffe - Add item instance data demo
- 4c81ac0 - Disable unnecessary warning in InventoryManager
- e52b165 - Update get_item_total documentation
- 4f9993a - Fix erroneous has_item* documentation and logic
- 8fd98fb - Backport changes to 4.2.1
- b3fe1e3 - Implement slot-specific item instance data tracking
- acdb01c - Update FUNDING
- deff71c - Format gdscript code with gdscript-formatter
v1.3.0
v1.2.2
v1.2.1
v1.2.0
v1.1.0
v1.0.1
- e2cc015 - Update documentation
- 44adf2f - Update formatting and documentation
- 685ed25 - Update formatting
- f2c9e1c - Simplify excess item amount check
- 9a8305e - Update documentation
- b5e7017 - Clarify is_slot_valid documentation
- 4aefce9 - Simplify InventoryManager.has_item_amount
- ea68b2c - Optimize InventoryManager.has_item performance.
- 25c9442 - Fix duplicated scene UIDs