peter-kish / gloot

A universal inventory system for the Godot game engine.
MIT License
658 stars 28 forks source link

Assertion failed: Items must be mergable! (2.4.9) #216

Closed snipercup closed 5 months ago

snipercup commented 5 months ago

Still using your awesome plugin and I'd like to upgrade to 2.4.9 but I get this error that I haven't seen before: Assertion failed: Items must be mergable!

This happens when I move an item from another inventory to the player inventory. In this case I am trying to add a screwdriver from a nearby container (ignore the machete highlighted): image

I get this stack trace: image

It's trying to merge the screwdriver: image

with a 9mm pistol: image

I don't understand where this error comes from and what I can do to fix it? I haven't seen this before.

This is my handle item drop function:


# When the player drops items into this list
func _handle_item_drop(dropped_data, _newpos) -> void:
    # Check if the dropped data is valid and contains inventory items
    if dropped_data is Array and dropped_data.size() > 0 and dropped_data[0] is InventoryItem:
        var first_item = dropped_data[0]

        # Get the inventory of the first item
        var item_inventory = first_item.get_inventory()

        # If the item's inventory is different from the current inventory, transfer the items
        if item_inventory != myInventory:
            # Get the items that fit inside the remaining volume
            var items_to_transfer = get_items_that_fit_by_volume(dropped_data)

            Helper.signal_broker.inventory_operation_started.emit()
            for item in items_to_transfer:
                # Transfer the item to the current inventory
                item_inventory.transfer_automerge(item, myInventory)
            Helper.signal_broker.inventory_operation_finished.emit()
peter-kish commented 5 months ago

I think I managed to reproduce and fix the issue (should be fixed in bff9b62a35285df274ff6945063347bb1cdc84b6).

Can you give it a try?

snipercup commented 5 months ago

I think I managed to reproduce and fix the issue (should be fixed in bff9b62).

Can you give it a try?

I tested your change and it worked! Thank you for the quick fix. Will you re-release 2.4.9 with this fix included?

peter-kish commented 5 months ago

I just created a new release: v2.4.10 It doesn't contain a lot of changes but i think it's better than "overwriting" a previous release.

snipercup commented 5 months ago

Thanks! No problems now