tweaks for superTreefarm
This commit is contained in:
@@ -451,7 +451,6 @@ end
|
|||||||
local function findDroppedSaplings()
|
local function findDroppedSaplings()
|
||||||
equip('left', 'plethora:sensor', SENSOR)
|
equip('left', 'plethora:sensor', SENSOR)
|
||||||
local raw = peripheral.call('left', 'sense')
|
local raw = peripheral.call('left', 'sense')
|
||||||
equip('left', PICKAXE)
|
|
||||||
|
|
||||||
local sensed = Util.reduce(raw, function(acc, b)
|
local sensed = Util.reduce(raw, function(acc, b)
|
||||||
Point.rotate(b, state.home.heading)
|
Point.rotate(b, state.home.heading)
|
||||||
@@ -472,7 +471,6 @@ local function scan(pt, filter)
|
|||||||
|
|
||||||
equip('left', 'plethora:scanner', SCANNER)
|
equip('left', 'plethora:scanner', SCANNER)
|
||||||
local raw = peripheral.call('left', 'scan')
|
local raw = peripheral.call('left', 'scan')
|
||||||
equip('left', PICKAXE)
|
|
||||||
|
|
||||||
local blocks = Util.reduce(raw, function(acc, b)
|
local blocks = Util.reduce(raw, function(acc, b)
|
||||||
Point.rotate(b, state.home.heading)
|
Point.rotate(b, state.home.heading)
|
||||||
@@ -487,7 +485,7 @@ local function scan(pt, filter)
|
|||||||
return blocks
|
return blocks
|
||||||
end
|
end
|
||||||
|
|
||||||
local function plantTrees(blocks)
|
local function getPlantLocations(blocks)
|
||||||
Util.each(state.trees, function(sapling)
|
Util.each(state.trees, function(sapling)
|
||||||
local key = makeKey(sapling)
|
local key = makeKey(sapling)
|
||||||
local b = blocks[key]
|
local b = blocks[key]
|
||||||
@@ -551,8 +549,7 @@ local function fell()
|
|||||||
return b.y >= 0 and (b.name == LOG or b.name == LOG2 or b.name == SAPLING)
|
return b.y >= 0 and (b.name == LOG or b.name == LOG2 or b.name == SAPLING)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- low scan
|
local fuel = turtle.getFuelLevel()
|
||||||
local blocks = scan(HOME_PT, filter)
|
|
||||||
local sensed = { }
|
local sensed = { }
|
||||||
|
|
||||||
-- determine if we need saplings
|
-- determine if we need saplings
|
||||||
@@ -563,6 +560,8 @@ local function fell()
|
|||||||
sensed = findDroppedSaplings()
|
sensed = findDroppedSaplings()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- low scan
|
||||||
|
local blocks = scan(HOME_PT, filter)
|
||||||
if not Util.every(blocks, function(b) return b.y < 6 end) then
|
if not Util.every(blocks, function(b) return b.y < 6 end) then
|
||||||
-- tree might be above low scan range, do a scan higher up
|
-- tree might be above low scan range, do a scan higher up
|
||||||
blocks = scan(HIGH_PT, filter)
|
blocks = scan(HIGH_PT, filter)
|
||||||
@@ -571,13 +570,12 @@ local function fell()
|
|||||||
Util.merge(blocks, sensed)
|
Util.merge(blocks, sensed)
|
||||||
|
|
||||||
-- add any locations that need saplings
|
-- add any locations that need saplings
|
||||||
plantTrees(blocks)
|
getPlantLocations(blocks)
|
||||||
|
|
||||||
|
equip('left', PICKAXE)
|
||||||
if not Util.empty(blocks) then
|
if not Util.empty(blocks) then
|
||||||
print('Chopping')
|
print('Chopping')
|
||||||
|
|
||||||
local fuel = turtle.getFuelLevel()
|
|
||||||
|
|
||||||
fellTrees(blocks)
|
fellTrees(blocks)
|
||||||
|
|
||||||
print('Used ' .. (fuel - turtle.getFuelLevel()) .. ' fuel')
|
print('Used ' .. (fuel - turtle.getFuelLevel()) .. ' fuel')
|
||||||
|
|||||||
Reference in New Issue
Block a user