feat(tunnels-miner): use turtleUtils.compactInventory

This commit is contained in:
Guillaume ARM 2024-05-26 14:07:32 +02:00
parent 0b2e412ad9
commit cc817f53ea

View File

@ -6,7 +6,7 @@ local TIME_TO_START = 3
local IDLE_TIME_BETWEEN_TUNNELS = 1 local IDLE_TIME_BETWEEN_TUNNELS = 1
local SPACE_BETWEEN_TUNNELS = 3 local SPACE_BETWEEN_TUNNELS = 3
local VERSION = "2.1.1" local VERSION = "2.2.0"
local MOVES_BY_DIRECTION = { local MOVES_BY_DIRECTION = {
right = { right = {
@ -129,13 +129,20 @@ local function ensureEnoughSpaceInInventory(config)
return return
end end
-- 1. select an item that is not in whitelist item -- 1. try to compact inventory
turtleUtils.compactInventory()
if not turtleUtils.isInventoryFull() then
return
end
-- 2. otherwise select an item that is not in whitelist item
local selected = turtleUtils.selectItemBy(function(slot) local selected = turtleUtils.selectItemBy(function(slot)
return not isWhitelistedOre(config, turtle.getItemDetail(slot)) return not isWhitelistedOre(config, turtle.getItemDetail(slot))
end) end)
if selected then if selected then
-- 2. drop the selected item -- 3. and drop the selected item
turtle.drop() turtle.drop()
trySelectEmptySlot() trySelectEmptySlot()
else else