oblinger

Tracker Server

Apr 6th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. rednet.open("back")
  2. print("Sending Location Data...")
  3. time = 0
  4.  
  5. locations = {
  6.  
  7. {name = "Home",
  8. x = -18,
  9. y = 64,
  10. z = 54,
  11. range = 50,
  12. },
  13.  
  14. {name = "Nix's Base",
  15. x = -50,
  16. y = 65,
  17. z = 361,
  18. range = 50,
  19. },
  20.  
  21. }
  22.  
  23. function getLocation()
  24.  
  25. for i = 1, #locations do
  26. current = vector.new(gps.locate())
  27. location = vector.new(locations[i][2],locations[i][3],locations[i][4])
  28.  
  29. currentLocation = location - current
  30.  
  31. if currentLocation.x < locations[i]["range"] and currentLocation.z < locations[i]["range"] then
  32. if not afk then
  33. pos = locations[i]["name"]
  34. break
  35. elseif time < 60 then
  36. pos = (locations[i]["name"].." (AFK "..math.floor(time).."s)")
  37. else
  38. pos = (locaitons[i]["name"].." (AFK "..math.floor(time/60).."m)")
  39. end
  40. else
  41. pos = "Unknown"
  42. end
  43. end
  44. end
  45.  
  46.  
  47. function checkForAFK()
  48.  
  49. x,y,z = gps.locate()
  50.  
  51. if x == pastX and z == pastZ and y == pastY then
  52. time = time + .5
  53. else
  54. time = 0
  55. end
  56.  
  57. if time >= 30 then
  58. afk = true
  59. else
  60. afk = false
  61. end
  62.  
  63. pastX = x
  64. pastY = y
  65. pastZ = z
  66.  
  67. end
  68.  
  69.  
  70. function send()
  71. rednet.send(84, {
  72. type = "Position",
  73. user = "Devin",
  74. x = x,
  75. y = y,
  76. z = z,
  77. status = pos,
  78. })
  79.  
  80. sleep(.5)
  81. end
  82.  
  83. while true do
  84. getLocation()
  85. checkForAFK()
  86. send()
  87. end
Advertisement
Add Comment
Please, Sign In to add comment