diff --git a/libs/turtle-utils.lua b/libs/turtle-utils.lua index e247b3a..2af9561 100644 --- a/libs/turtle-utils.lua +++ b/libs/turtle-utils.lua @@ -252,8 +252,9 @@ local function compactItem(itemName) end end --- Compact the internal turtle inventory +-- Compact the internal turtle inventory (return the number of freed slots) turtleUtils.compactInventory = function() + local initialNbFreeSlots = turtle.countFreeSlots() local initialSelectedSlot = turtle.getSelectedSlot() local itemsMap = getItemsMap() @@ -266,6 +267,8 @@ turtleUtils.compactInventory = function() if initialSelectedSlot ~= turtle.getSelectedSlot() then turtle.select(initialSelectedSlot) end + + return turtle.countFreeSlots() - initialNbFreeSlots end return turtleUtils \ No newline at end of file