1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-18 22:54:51 +00:00
opus/sys/extensions/tgps.lua

35 lines
633 B
Lua
Raw Normal View History

2016-12-11 19:24:52 +00:00
if not turtle then
return
end
requireInjector(getfenv(1))
2016-12-11 19:24:52 +00:00
local GPS = require('gps')
2017-05-24 23:48:48 +00:00
function turtle.enableGPS(timeout)
2017-07-30 23:53:43 +00:00
if turtle.point.gps then
2017-05-24 23:48:48 +00:00
return turtle.point
end
local pt = GPS.getPointAndHeading(timeout)
2016-12-11 19:24:52 +00:00
if pt then
2017-07-24 02:37:07 +00:00
turtle.setPoint(pt, true)
return turtle.point
2016-12-11 19:24:52 +00:00
end
end
function turtle.gotoGPSHome()
local homePt = turtle.loadLocation('gpsHome')
if homePt then
2017-05-24 23:48:48 +00:00
if turtle.enableGPS() then
2016-12-11 19:24:52 +00:00
turtle.pathfind(homePt)
end
end
end
function turtle.setGPSHome()
2017-05-24 23:48:48 +00:00
if turtle.enableGPS() then
turtle.storeLocation('gpsHome', turtle.point)
2017-06-23 06:04:56 +00:00
turtle.gotoPoint(turtle.point)
2016-12-11 19:24:52 +00:00
end
end