1
0
mirror of https://github.com/kepler155c/opus synced 2024-12-28 17:40:26 +00:00
opus/sys/extensions/tgps.lua

36 lines
694 B
Lua
Raw Normal View History

2016-12-11 19:24:52 +00:00
if not turtle then
return
end
require = requireInjector(getfenv(1))
local GPS = require('gps')
2017-05-24 23:48:48 +00:00
function turtle.enableGPS(timeout)
if turtle.getState().coordSystem == 'GPS' then
return turtle.point
end
local pt = GPS.getPointAndHeading(timeout)
2016-12-11 19:24:52 +00:00
if pt then
turtle.setPoint(pt)
2017-05-24 23:48:48 +00:00
turtle.getState().coordSystem = 'GPS'
2016-12-11 19:24:52 +00:00
return true
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)
turtle.gotoPoint(tturtle.point)
2016-12-11 19:24:52 +00:00
end
end