Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local clock = os.clock
- function sleep(n)
- local t0 = clock()
- while clock() - t0 <= n do end
- end
- function getGPS()
- local f=fs.open("/data/homepos", "r")
- local tbl = textutils.unserialise (f.readAll())
- f.close()
- local curx, cury, curz = gps.locate(5)
- local distx = curx-tbl.x
- local disty = cury-tbl.y
- local distz = curz-tbl.z
- local distsum=distx+disty+distz
- local absdist=math.abs(distsum)
- print ("I am "..math.floor(absdist+0.5).."m away from home")
- sleep(0.1)
- term.setCursorPos(1,1)
- term.clear()
- term.setCursorPos(1,1)
- end
- while true do
- getGPS()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement