use scanner for farm heading + scanning miner fixes

This commit is contained in:
kepler155c
2018-10-15 21:14:37 -04:00
parent 77aada762f
commit 611e4676a4
2 changed files with 24 additions and 22 deletions

View File

@@ -44,11 +44,8 @@ local function harvest(blocks)
end end
turtle.reset() turtle.reset()
local directions = { [5] = 2, [3] = 3, [4] = 0, [2] = 1, } local facing = scanner.getBlockMeta(0, 0, 0).state.facing
turtle.placeUp('minecraft:chest') or error('Missing chest') pt.heading = Point.facings[facing].heading
local _, bi = turtle.inspectUp()
turtle.digUp()
turtle.point.heading = directions[bi.metadata]
turtle.setPolicy('digOnly') turtle.setPolicy('digOnly')

View File

@@ -95,8 +95,8 @@ local page = UI.Page {
y = 2, ey = -2, y = 2, ey = -2,
sortColumn = 'name', sortColumn = 'name',
columns = { columns = {
{ heading = 'Resource', key = 'displayName' },
{ heading = 'Count', key = 'count', width = 5 }, { heading = 'Count', key = 'count', width = 5 },
{ heading = 'Resource', key = 'displayName' },
}, },
}, },
statusBar = UI.StatusBar { statusBar = UI.StatusBar {
@@ -228,7 +228,7 @@ local function safeGoto(x, z, y, h)
local oldStatus = turtle.getStatus() local oldStatus = turtle.getStatus()
while not turtle._goto({ x = x, z = z, y = y or turtle.point.y, heading = h }) do while not turtle._goto({ x = x, z = z, y = y or turtle.point.y, heading = h }) do
--status('stuck') status('stuck')
if turtle.isAborted() then if turtle.isAborted() then
return false return false
end end
@@ -434,30 +434,35 @@ local function scan()
end end
local function mineChunk() local function mineChunk()
local topDown = turtle.point.y > -mining.home.y / 2 local pts = { }
local y = topDown and -8 or -mining.home.y + 8
local inc = topDown and for i = 1, math.ceil(mining.home.y / 16) do
function() y = y - 16 end or pts[i] = { x = mining.x + 8, z = mining.z + 8, y = (i - 1) * 16 + 8 }
function() y = y + 16 end if pts[i].y > mining.home.y - 8 then
pts[i].y = mining.home.y - 8
end
pts[i].y = pts[i].y - mining.home.y -- abs to rel
debug(pts[i])
end
Point.eachClosest(turtle.point, pts, function(pt)
if turtle.isAborted() then
error('aborted')
end
status('scanning ' .. pt.y + mining.home.y - 8 .. ' - ' .. pt.y + mining.home.y + 8)
while true do
status('scanning')
turtle.select(1) turtle.select(1)
safeGoto(mining.x + 8, mining.z + 8, y) safeGoto(pt.x, pt.z, pt.y)
scan() scan()
if turtle.getFuelLevel() < LOW_FUEL then if turtle.getFuelLevel() < LOW_FUEL then
refuel() refuel()
local veryMinFuel = Point.turtleDistance(turtle.point, { x = 0, y = 0, z = 0}) + 512 local veryMinFuel = Point.turtleDistance(turtle.point, { x = 0, y = 0, z = 0 }) + 512
if turtle.getFuelLevel() < veryMinFuel then if turtle.getFuelLevel() < veryMinFuel then
error('Not enough fuel to continue') error('Not enough fuel to continue')
end end
end end
inc() end)
if y > 0 or y < -mining.home.y then
break
end
end
end end
local function addTrash() local function addTrash()