app tweaks

This commit is contained in:
kepler155c@gmail.com
2018-12-23 02:17:59 -05:00
parent e69d68c7b4
commit 29af471374
2 changed files with 28 additions and 9 deletions

View File

@@ -548,7 +548,7 @@ local function fellTrees(blocks)
end end
for pt in Point.iterateClosest(turtle.point, blocks) do for pt in Point.iterateClosest(turtle.point, blocks) do
if pt.sapling then if pt.sapling then
turtle.suckDownAt(pt) repeat until not turtle.suckDownAt(pt)
else else
turtle.digAt(pt) turtle.digAt(pt)
end end

View File

@@ -456,6 +456,7 @@ local function mineChunk()
if pts[i].y > mining.home.y - 8 then if pts[i].y > mining.home.y - 8 then
pts[i].y = mining.home.y - 8 pts[i].y = mining.home.y - 8
end end
pts[i].y = math.max(pts[i].y, 8)
pts[i].y = pts[i].y - mining.home.y -- abs to rel pts[i].y = pts[i].y - mining.home.y -- abs to rel
end end
@@ -546,7 +547,8 @@ end
if not fs.exists(STARTUP_FILE) then if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE, Util.writeFile(STARTUP_FILE,
[[os.sleep(1) [[print('sleeping for 10 seconds')
os.sleep(10)
shell.openForegroundTab('scanningMiner.lua')]]) shell.openForegroundTab('scanningMiner.lua')]])
print('Autorun program created: ' .. STARTUP_FILE) print('Autorun program created: ' .. STARTUP_FILE)
end end
@@ -594,10 +596,27 @@ Event.addRoutine(function()
z = turtle.point.z - mining.home.z, z = turtle.point.z - mining.home.z,
}) })
if math.abs(turtle.point.x) > 500 or math.abs(turtle.point.z) > 500 then local distance = Point.distance(
_G.printError('WARNING: distance > 500') { x = turtle.point.x, y = 0, z = turtle.point.z },
print('waiting for 30 seconds to begin') { x = mining.x, y = 0, z = mining.z }
)
local maxDistance = Point.distance(
{ x = 0, y = 0, z = 0 },
{ x = mining.x + 16, y = 0, z = mining.z + 16 }
)
_G._debug({ distance = distance, maxDistance = maxDistance })
if distance > maxDistance then
term.clear()
term.setCursorPos(1, 1)
_G.printError('WARNING\n\nTurtle is outside the mining area\n')
print('Max distance: ' .. math.floor(maxDistance))
print('Distance to home: ' .. math.floor(distance))
print('\nIf in a new location, delete usr/config/scanning_miner.progress')
print('\nWaiting for 30 seconds to begin')
os.sleep(30) os.sleep(30)
page:sync()
end end
if not fs.exists(PROGRESS_FILE) then if not fs.exists(PROGRESS_FILE) then
@@ -609,6 +628,10 @@ Event.addRoutine(function()
turtle.setMovementStrategy('goto') turtle.setMovementStrategy('goto')
status('mining') status('mining')
Event.onTerminate(function()
turtle.abort(true)
end)
if isFinished() then if isFinished() then
success = false success = false
msg = 'Mining complete' msg = 'Mining complete'
@@ -626,10 +649,6 @@ Event.addRoutine(function()
Event.exitPullEvents() Event.exitPullEvents()
end) end)
Event.onTerminate(function()
turtle.abort(true)
end)
UI:setPage(page) UI:setPage(page)
UI:pullEvents() UI:pullEvents()
UI.term:reset() UI.term:reset()