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
for pt in Point.iterateClosest(turtle.point, blocks) do
if pt.sapling then
turtle.suckDownAt(pt)
repeat until not turtle.suckDownAt(pt)
else
turtle.digAt(pt)
end

View File

@@ -456,6 +456,7 @@ local function mineChunk()
if pts[i].y > mining.home.y - 8 then
pts[i].y = mining.home.y - 8
end
pts[i].y = math.max(pts[i].y, 8)
pts[i].y = pts[i].y - mining.home.y -- abs to rel
end
@@ -546,7 +547,8 @@ end
if not fs.exists(STARTUP_FILE) then
Util.writeFile(STARTUP_FILE,
[[os.sleep(1)
[[print('sleeping for 10 seconds')
os.sleep(10)
shell.openForegroundTab('scanningMiner.lua')]])
print('Autorun program created: ' .. STARTUP_FILE)
end
@@ -594,10 +596,27 @@ Event.addRoutine(function()
z = turtle.point.z - mining.home.z,
})
if math.abs(turtle.point.x) > 500 or math.abs(turtle.point.z) > 500 then
_G.printError('WARNING: distance > 500')
print('waiting for 30 seconds to begin')
local distance = Point.distance(
{ x = turtle.point.x, y = 0, z = turtle.point.z },
{ 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)
page:sync()
end
if not fs.exists(PROGRESS_FILE) then
@@ -609,6 +628,10 @@ Event.addRoutine(function()
turtle.setMovementStrategy('goto')
status('mining')
Event.onTerminate(function()
turtle.abort(true)
end)
if isFinished() then
success = false
msg = 'Mining complete'
@@ -626,10 +649,6 @@ Event.addRoutine(function()
Event.exitPullEvents()
end)
Event.onTerminate(function()
turtle.abort(true)
end)
UI:setPage(page)
UI:pullEvents()
UI.term:reset()