peter-kish / gloot

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

Support stacks filling #209

Closed Nordsoft91 closed 4 months ago

Nordsoft91 commented 5 months ago

There is prototype

{
  "id": "my_item",
  "max_stack_size": 5
},

There are 2 items of same id "my_item" in one InventoryStacked

$InventoryItem1
{
  "id": "my_item",
  "max_stack_size": 5,
  "stack_size": 4
},

$InventoryItem2
{
  "id": "my_item",
  "max_stack_size": 5,
  "stack_size": 2
},

I want to have a method to do auto split-merge (InventoryItem2 -> InventoryItem1):

$InventoryItem1
{
  "id": "my_item",
  "max_stack_size": 5,
  "stack_size": 5
},

$InventoryItem2
{
  "id": "my_item",
  "max_stack_size": 5,
  "stack_size": 1
},
peter-kish commented 4 months ago

pack(item) has been added to InventoryStacked and InventoryGridStacked in v2.4.9. It can be used to merge the given item stack with all compatible items in the same inventory.