feat(turtle-utils): compactInventory now returnthe number of freed slots
This commit is contained in:
parent
8483ffc696
commit
f76877b0ab
@ -252,8 +252,9 @@ local function compactItem(itemName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Compact the internal turtle inventory
|
-- Compact the internal turtle inventory (return the number of freed slots)
|
||||||
turtleUtils.compactInventory = function()
|
turtleUtils.compactInventory = function()
|
||||||
|
local initialNbFreeSlots = turtle.countFreeSlots()
|
||||||
local initialSelectedSlot = turtle.getSelectedSlot()
|
local initialSelectedSlot = turtle.getSelectedSlot()
|
||||||
local itemsMap = getItemsMap()
|
local itemsMap = getItemsMap()
|
||||||
|
|
||||||
@ -266,6 +267,8 @@ turtleUtils.compactInventory = function()
|
|||||||
if initialSelectedSlot ~= turtle.getSelectedSlot() then
|
if initialSelectedSlot ~= turtle.getSelectedSlot() then
|
||||||
turtle.select(initialSelectedSlot)
|
turtle.select(initialSelectedSlot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return turtle.countFreeSlots() - initialNbFreeSlots
|
||||||
end
|
end
|
||||||
|
|
||||||
return turtleUtils
|
return turtleUtils
|
||||||
Loading…
Reference in New Issue
Block a user