relative-gps coord system

This commit is contained in:
kepler155c@gmail.com
2017-05-24 19:48:48 -04:00
parent 64146f8625
commit e6ee432997
11 changed files with 62 additions and 57 deletions

View File

@@ -12,21 +12,16 @@ if turtle and device.wireless_modem then
}
Config.load('gps', config)
local GPS = require('gps')
local pt
for i = 1, 3 do
pt = GPS.getPointAndHeading(2)
if pt then
break
end
local s = turtle.enableGPS(2)
if not s then
s = turtle.enableGPS(2)
end
if not pt and config.destructive then
if not s and config.destructive then
turtle.setPolicy('turtleSafe')
pt = GPS.getPointAndHeading(2)
s = turtle.enableGPS(2)
end
if not pt then
if not s then
error('Unable to get GPS position')
end
@@ -34,18 +29,12 @@ if turtle and device.wireless_modem then
turtle.setPolicy('turtleSafe')
end
Util.print('Setting turtle point to %d %d %d', pt.x, pt.y, pt.z)
turtle.setPoint(pt)
turtle.getState().coordSystem = 'GPS'
if not turtle.pathfind(homePt) then
error('Failed to return home')
end
end
end)
turtle.setPolicy('none')
if not s and m then
error(m)
end