2018-01-14 23:28:23 +00:00
|
|
|
local modem = _G.device.wireless_modem
|
|
|
|
local turtle = _G.turtle
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2018-01-14 23:28:23 +00:00
|
|
|
if turtle and modem then
|
2016-12-11 19:24:52 +00:00
|
|
|
local s, m = turtle.run(function()
|
|
|
|
|
2018-01-14 23:28:23 +00:00
|
|
|
_G.requireInjector()
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-09-13 03:04:44 +00:00
|
|
|
local Config = require('config')
|
|
|
|
local config = {
|
|
|
|
destructive = false,
|
|
|
|
}
|
|
|
|
Config.load('gps', config)
|
2017-09-05 06:09:31 +00:00
|
|
|
|
2017-09-13 03:04:44 +00:00
|
|
|
if config.home then
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-05-24 23:48:48 +00:00
|
|
|
local s = turtle.enableGPS(2)
|
|
|
|
if not s then
|
|
|
|
s = turtle.enableGPS(2)
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
2017-05-24 23:48:48 +00:00
|
|
|
if not s and config.destructive then
|
2016-12-11 19:24:52 +00:00
|
|
|
turtle.setPolicy('turtleSafe')
|
2017-05-24 23:48:48 +00:00
|
|
|
s = turtle.enableGPS(2)
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
|
|
|
|
2017-05-24 23:48:48 +00:00
|
|
|
if not s then
|
2016-12-11 19:24:52 +00:00
|
|
|
error('Unable to get GPS position')
|
|
|
|
end
|
|
|
|
|
|
|
|
if config.destructive then
|
|
|
|
turtle.setPolicy('turtleSafe')
|
|
|
|
end
|
|
|
|
|
2017-09-13 03:04:44 +00:00
|
|
|
if not turtle.pathfind(config.home) then
|
2016-12-11 19:24:52 +00:00
|
|
|
error('Failed to return home')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
if not s and m then
|
|
|
|
error(m)
|
|
|
|
end
|
|
|
|
end
|