feat(inferium-harvester): better logs on refuel, harvest and remove seeds

This commit is contained in:
Guillaume ARM 2024-05-22 00:04:17 +02:00
parent b8fb2390f2
commit 0a9294310a

View File

@ -3,7 +3,7 @@ local utils = require('libs/utils')
local turtleUtils = require('libs/turtle-utils')
local config = require('config/harvesting')
local VERSION = "2.3.0"
local VERSION = "2.5.0"
local INFERIUM_SERVER = 'inferium.com'
local IDLE_TIME = 2
local WAIT_ITEM_IDLE_TIME = 5
@ -157,12 +157,20 @@ local function dropAllProcedure()
end
local function refuelProcedure()
print('> refuel')
local fuelLevel = turtle.getFuelLevel()
print('> fuel: ' .. tostring(fuelLevel))
if fuelLevel < MIN_FUEL_NEEDED then
print('> refuel needed (minimum is ' .. MIN_FUEL_NEEDED .. ')')
local refuelOk, refuelErr = turtleUtils.refuelWithBuffer('bottom', 'front', MIN_FUEL_NEEDED, IDLE_TIME)
if not refuelOk then
error('Cannot refuel the turtle: "' .. refuelErr .. '"')
end
print('> fuel: ' .. tostring(fuelLevel))
end
end
local function goToHarvestPoint()
@ -222,15 +230,23 @@ local function forward()
end
local function harvestProcedure()
print('> harvest')
term.write('> harvest on ' .. tostring(config.length) .. ' blocks')
local nbHarvested = 0
for i=1, config.length, 1 do
harvestDown(i)
if harvestDown(i) then
nbHarvested = nbHarvested + 1
term.write(' .')
else
term.write(' !')
end
if i ~= config.length then
forward()
end
end
term.write('\n')
print('> ' .. tostring(nbHarvested) .. ' harvested crops')
turtle.turnLeft()
turtle.turnLeft()
@ -302,7 +318,7 @@ end
local function removeSeeds(seeds)
goToHarvestPoint()
print('> remove old seeds')
print('> remove ' .. utils.sizeof(seeds) .. ' seed(s)')
local stateSeeds = seeds -- warning: do not mutate the data (only the ref)
for i=1, config.length, 1 do