Advertisement
Indie_Rogers

gps2.0

Jun 29th, 2022 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. local clock = os.clock
  2. function sleep(n)
  3. local t0 = clock()
  4. while clock() - t0 <= n do end
  5. end
  6.  
  7. function getGPS()
  8. local f=fs.open("/data/homepos", "r")
  9. local tbl = textutils.unserialise (f.readAll())
  10. f.close()
  11.  
  12. local curx, cury, curz = gps.locate(5)
  13.  
  14. local distx = curx-tbl.x
  15. local disty = curx-tbl.y
  16. local distz = curx-tbl.z
  17.  
  18. print ("x: "..distx)
  19. print ("y: "..disty)
  20. print ("z: "..distz)
  21. sleep(0.1)
  22. term.setCursorPos(1,1)
  23. term.clear()
  24. term.setCursorPos(1,1)
  25.  
  26. end
  27.  
  28. while true do
  29. getGPS()
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement