mirror of
https://github.com/kepler155c/opus
synced 2024-11-06 00:46:16 +00:00
35 lines
653 B
Lua
35 lines
653 B
Lua
if not turtle or turtle.enableGPS then
|
|
return
|
|
end
|
|
|
|
requireInjector(getfenv(1))
|
|
local GPS = require('gps')
|
|
|
|
function turtle.enableGPS(timeout)
|
|
if turtle.point.gps then
|
|
return turtle.point
|
|
end
|
|
|
|
local pt = GPS.getPointAndHeading(timeout)
|
|
if pt then
|
|
turtle.setPoint(pt, true)
|
|
return turtle.point
|
|
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(turtle.point)
|
|
end
|
|
end
|