gloot icon indicating copy to clipboard operation
gloot copied to clipboard

Slot clear() doesn't auto-merge item

Open Nordsoft91 opened this issue 1 year ago • 3 comments

Steps:

  1. Create InventorySlot, remember_source_inventory = true
  2. Create InventoryStacked
  3. Call InventorySlot.equip with any item
  4. Make sure you have one more item with same prototype_id in inventory
  5. Call InventorySlot.clear()

Expected:

  • Item returned to inventory and will be merged with another

Actual

  • Item added but wasn't merged

Nordsoft91 avatar May 12 '24 01:05 Nordsoft91

Honestly, I don't think the remember_source_inventory property is very useful and I'm planning to remove it completely as it causing more issues than it solves. In most cases clearing the slot and adding the item to an inventory manually is much simpler to understand and causes no side-effects.

peter-kish avatar May 12 '24 16:05 peter-kish

Actually, "slot" can derived "Inventory" as well, because it's inventory which can handle only one object. Then, no equip and clear are needed and everything could be done with regular transfer_item/add_item/... methods.

Nordsoft91 avatar May 12 '24 22:05 Nordsoft91

Yup, that's exactly what I'm planning to do for v3.0 🙂

peter-kish avatar May 13 '24 07:05 peter-kish

Version 3.0.0 has been released and the remember_source_inventory has been removed from ItemSlot.

peter-kish avatar Jan 28 '25 19:01 peter-kish