fix(inferium-harvester): get seedName from cropName

This commit is contained in:
Guillaume ARM 2024-05-19 17:10:21 +02:00
parent 88d8fae296
commit 1438db9973

View File

@ -5,7 +5,7 @@ local config = {
local MIN_FUEL_NEEDED = (10 + config.firstCropZ + config.length) * 2
local VERSION = "0.1.1"
local VERSION = "0.1.2"
local IDLE_TIME = 2
local turtleUtils = require('libs/turtle-utils')
@ -35,6 +35,10 @@ local function retrieveChestFuelOrientation()
end
end
local function getSeedNameFromCropName(cropName)
return string.gsub(cropName, 'crop', 'seeds')
end
-- Implementations
local function retrieveHomePositionProcedure()
if turtleUtils.getInventory('bottom') then
@ -115,12 +119,13 @@ end
local function harvestDown()
local cropName = turtleUtils.waitForMatureCrop(turtle.inspectDown, IDLE_TIME)
local seedName = getSeedNameFromCropName(cropName)
if not turtle.digDown() then
error('turtle cannot harvest crop')
end
if not turtleUtils.selectItemByName(cropName) then
if not turtleUtils.selectItemByName(seedName) then
error('turtle cannot find any crop to place')
end