feat(inferium-harvester): better logs on refuel, harvest and remove seeds
This commit is contained in:
parent
b8fb2390f2
commit
0a9294310a
@ -3,7 +3,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 = "2.3.0"
|
local VERSION = "2.5.0"
|
||||||
local INFERIUM_SERVER = 'inferium.com'
|
local INFERIUM_SERVER = 'inferium.com'
|
||||||
local IDLE_TIME = 2
|
local IDLE_TIME = 2
|
||||||
local WAIT_ITEM_IDLE_TIME = 5
|
local WAIT_ITEM_IDLE_TIME = 5
|
||||||
@ -157,11 +157,19 @@ local function dropAllProcedure()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function refuelProcedure()
|
local function refuelProcedure()
|
||||||
print('> refuel')
|
local fuelLevel = turtle.getFuelLevel()
|
||||||
local refuelOk, refuelErr = turtleUtils.refuelWithBuffer('bottom', 'front', MIN_FUEL_NEEDED, IDLE_TIME)
|
print('> fuel: ' .. tostring(fuelLevel))
|
||||||
|
|
||||||
if not refuelOk then
|
if fuelLevel < MIN_FUEL_NEEDED then
|
||||||
error('Cannot refuel the turtle: "' .. refuelErr .. '"')
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -222,15 +230,23 @@ local function forward()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function harvestProcedure()
|
local function harvestProcedure()
|
||||||
print('> harvest')
|
term.write('> harvest on ' .. tostring(config.length) .. ' blocks')
|
||||||
|
local nbHarvested = 0
|
||||||
for i=1, config.length, 1 do
|
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
|
if i ~= config.length then
|
||||||
forward()
|
forward()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
term.write('\n')
|
||||||
|
|
||||||
|
print('> ' .. tostring(nbHarvested) .. ' harvested crops')
|
||||||
|
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
@ -302,7 +318,7 @@ end
|
|||||||
local function removeSeeds(seeds)
|
local function removeSeeds(seeds)
|
||||||
goToHarvestPoint()
|
goToHarvestPoint()
|
||||||
|
|
||||||
print('> remove old seeds')
|
print('> remove ' .. utils.sizeof(seeds) .. ' seed(s)')
|
||||||
local stateSeeds = seeds -- warning: do not mutate the data (only the ref)
|
local stateSeeds = seeds -- warning: do not mutate the data (only the ref)
|
||||||
|
|
||||||
for i=1, config.length, 1 do
|
for i=1, config.length, 1 do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user