1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-04 16:06:16 +00:00
opus/sys/extensions/tgps.lua
kepler155c@gmail.com fc243a9c12 Initial commit
2016-12-11 14:24:52 -05:00

41 lines
762 B
Lua

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