1
0
mirror of https://github.com/kepler155c/opus synced 2024-10-01 08:20:41 +00:00
opus/sys/extensions/tgps.lua

43 lines
768 B
Lua
Raw Normal View History

2017-09-06 01:21:43 +00:00
if not turtle or turtle.enableGPS then
2016-12-11 19:24:52 +00:00
return
end
requireInjector(getfenv(1))
local GPS = require('gps')
local Config = require('config')
2016-12-11 19:24:52 +00:00
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 config = { }
Config.load('gps', config)
if config.home then
2017-05-24 23:48:48 +00:00
if turtle.enableGPS() then
turtle.pathfind(config.home)
2016-12-11 19:24:52 +00:00
end
end
end
function turtle.setGPSHome()
local config = { }
Config.load('gps', config)
2017-05-24 23:48:48 +00:00
if turtle.enableGPS() then
config.home = turtle.point
Config.update('gps', config)
2017-06-23 06:04:56 +00:00
turtle.gotoPoint(turtle.point)
2016-12-11 19:24:52 +00:00
end
end