From 6a50fef10a252bb3b1d1b7f817621483ddd384d2 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Fri, 24 May 2024 18:29:01 +0200 Subject: [PATCH] feat(coal-creafter): dropAll at start --- coal-crafter.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/coal-crafter.lua b/coal-crafter.lua index 64f8040..ca9efc5 100644 --- a/coal-crafter.lua +++ b/coal-crafter.lua @@ -14,6 +14,20 @@ local STORAGE_INVENTORY_SIDE = 'front' local dropInStorageFn = turtle.drop local suckFromBufferFn = turtle.suckDown +local function dropAll(side, dropFn) + for i=1, 16, 1 do + local count = turtle.getItemCount(i) + + if count > 0 then + turtleUtils.waitForInventory(side, IDLE_TIME) + + if not turtleUtils.dropSlot(i, dropFn) then + error('please empty the turtle inventory', 0) + end + end + end +end + local function countCoalItems(inventory) local total = 0 @@ -112,6 +126,9 @@ local function main() print('> Waiting for the front inventory (buffer chest)') local bufferInventory = turtleUtils.waitForInventory(STORAGE_BUFFER_SIDE, WAIT_INVENTORY_TIME) + print('> drop all') + dropAll(STORAGE_INVENTORY_SIDE, dropInStorageFn) + print('> coal-crafter process started') while true do