1
0
mirror of https://github.com/kepler155c/opus synced 2024-11-05 08:26:16 +00:00
opus/apps/scripts/moveTo
kepler155c@gmail.com 46d0c8d43d Initial commit
2016-12-11 16:36:36 -05:00

31 lines
625 B
Plaintext

turtle.run(function()
require = requireInjector(getfenv(1))
local GPS = require('gps')
local Socket = require('socket')
local id = {COMPUTER_ID}
local pt = GPS.getPointAndHeading()
if not pt or not pt.heading then
error('turtle: No GPS found')
end
turtle.setPoint(pt)
local socket = Socket.connect(id, 161)
if not socket then
error('turtle: Unable to connect to ' .. id)
end
socket:write({ type = 'gps' })
local pt = socket:read(3)
if not pt then
error('turtle: No GPS response')
end
if not turtle.pathfind(pt, nil, 64) then
error('Unable to go to location')
end
end)