fix(inferium-harvester): replant only when needed
This commit is contained in:
parent
cc1d083aa7
commit
cdad0204ba
@ -2,7 +2,7 @@ local utils = require('libs/utils')
|
||||
local turtleUtils = require('libs/turtle-utils')
|
||||
local config = require('config/harvesting')
|
||||
|
||||
local VERSION = "1.0.0"
|
||||
local VERSION = "1.0.1"
|
||||
local IDLE_TIME = 2
|
||||
local WAIT_ITEM_IDLE_TIME = 5
|
||||
local MIN_FUEL_NEEDED = (100 + config.firstCropZ + config.length) * 2
|
||||
@ -337,6 +337,7 @@ local function removeSeeds(seeds)
|
||||
end
|
||||
|
||||
local function retrieveSeeds(seeds)
|
||||
local seedRetrieved = false
|
||||
local seedsCount = getIndexedCount(seeds)
|
||||
|
||||
local storageInventory = turtleUtils.waitForInventory('bottom', WAIT_ITEM_IDLE_TIME)
|
||||
@ -345,7 +346,7 @@ local function retrieveSeeds(seeds)
|
||||
for seedName, count in pairs(seedsCount) do
|
||||
local slot = getItemSlot(storageInventory, seedName)
|
||||
|
||||
if slot then
|
||||
if slot and count > 0 then
|
||||
local inventoryCount = getCountItem(storageInventory, seedName)
|
||||
local realCount = math.min(count, inventoryCount)
|
||||
local pushOk = storageInventory.pushItems(peripheral.getName(bufferInventory), slot, realCount)
|
||||
@ -359,8 +360,12 @@ local function retrieveSeeds(seeds)
|
||||
if not suckOk then
|
||||
error('retrieveSeeds error: cannot suck items from buffer')
|
||||
end
|
||||
|
||||
seedRetrieved = true
|
||||
end
|
||||
end
|
||||
|
||||
return seedRetrieved
|
||||
end
|
||||
|
||||
local function replantSeeds()
|
||||
@ -418,8 +423,9 @@ local function replantProcedure()
|
||||
end
|
||||
|
||||
if utils.sizeof(seedsToPlant) > 0 then
|
||||
retrieveSeeds(seedsToPlant)
|
||||
replantSeeds()
|
||||
if retrieveSeeds(seedsToPlant) then
|
||||
replantSeeds()
|
||||
end
|
||||
end
|
||||
|
||||
-- reset the local plan (it will be re-updated during the harvest procedure)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user