feat(inferium-harvester): do not block harvest procedure when no crop

This commit is contained in:
Guillaume ARM 2024-05-21 18:02:08 +02:00
parent 4af7ae8cfe
commit d4cbe6e808
2 changed files with 11 additions and 1 deletions

View File

@ -2,7 +2,7 @@ local utils = require('libs/utils')
local turtleUtils = require('libs/turtle-utils') local turtleUtils = require('libs/turtle-utils')
local config = require('config/harvesting') local config = require('config/harvesting')
local VERSION = "0.6.0" local VERSION = "1.0.0"
local IDLE_TIME = 2 local IDLE_TIME = 2
local WAIT_ITEM_IDLE_TIME = 5 local WAIT_ITEM_IDLE_TIME = 5
local MIN_FUEL_NEEDED = (100 + config.firstCropZ + config.length) * 2 local MIN_FUEL_NEEDED = (100 + config.firstCropZ + config.length) * 2
@ -189,6 +189,10 @@ local function harvestDown(index)
localPlan[index] = seedName localPlan[index] = seedName
if not seedName then
return false
end
if not turtle.digDown() then if not turtle.digDown() then
error('turtle cannot harvest crop') error('turtle cannot harvest crop')
end end
@ -202,6 +206,8 @@ local function harvestDown(index)
end end
compactIfNeeded() compactIfNeeded()
return true
end end

View File

@ -57,6 +57,10 @@ end
turtleUtils.waitForMatureCrop = function(inspectFn, sleepTime) turtleUtils.waitForMatureCrop = function(inspectFn, sleepTime)
inspectFn = inspectFn or turtle.inspect inspectFn = inspectFn or turtle.inspect
if not inspectFn() then
return nil
end
return waitFor(function() return waitFor(function()
return turtleUtils.getMatureCrop(inspectFn) return turtleUtils.getMatureCrop(inspectFn)
end, sleepTime) end, sleepTime)