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