From f76877b0ab09428aad9347527ff886cd98970010 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sun, 19 May 2024 19:42:17 +0200 Subject: [PATCH] feat(turtle-utils): compactInventory now returnthe number of freed slots --- libs/turtle-utils.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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