1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-28 01:20:27 +00:00
opus/sys/extensions/tgps.lua
2017-05-24 19:48:48 -04:00

36 lines
694 B
Lua

if not turtle then
return
end
require = requireInjector(getfenv(1))
local GPS = require('gps')
function turtle.enableGPS(timeout)
if turtle.getState().coordSystem == 'GPS' then
return turtle.point
end
local pt = GPS.getPointAndHeading(timeout)
if pt then
turtle.setPoint(pt)
turtle.getState().coordSystem = 'GPS'
return true
end
end
function turtle.gotoGPSHome()
local homePt = turtle.loadLocation('gpsHome')
if homePt then
if turtle.enableGPS() then
turtle.pathfind(homePt)
end
end
end
function turtle.setGPSHome()
if turtle.enableGPS() then
turtle.storeLocation('gpsHome', turtle.point)
turtle.gotoPoint(tturtle.point)
end
end