don-tnowe / godot-wyvernbox-inventory

Action RPG-focused inventory system for Godot 3 and 4
MIT License
97 stars 4 forks source link

load_from_array used with load_from_state nulls input array #7

Open Mazianni opened 1 year ago

Mazianni commented 1 year ago

I'm not sure how/why this is happening.

When using load_state, the array passed to load_from_array will remove all items from the passed array, meaning nothing is loaded.

It was driving me mad until I commented out these lines: for x in items.duplicate(): remove_item(x)

... and then it worked.

don-tnowe commented 1 year ago

Bizarre: for me, the passed array doesn't seem to change at all.

remove_item() must be called on each already-present item to trigger all on-remove behaviour and clear the items array.

From your solutuon I got the impression that the fact some items from before the load were present in the load data, but for me it all saves/loads just fine.