feat(turtle-utils): compactInventory now returnthe number of freed slots

This commit is contained in:
Guillaume ARM 2024-05-19 19:42:17 +02:00
parent 8483ffc696
commit f76877b0ab

View File

@ -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