Advertisement
Maxstripe

TrackerGlasses

Dec 21st, 2014
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. glassy = 0
  2.     function extract(s)
  3.       local t = {}
  4.       local name, armor, account, health, world, x, y, z
  5.       local a = 0
  6.       local b = 0
  7.       while (true) do
  8.         a, b, name, armor, account, health, z, y, world, x = string.find(s, "\"sort\":0,\"name\":\"([^\"]+)\",\"armor\":(%d+),\"account\":\"([^\"]+)\",\"health\":(%d+),\"type\":\"player\",\"z\":([-0-9.]+),\"y\":([-0-9.]+),\"world\":\"([^\"]+)\",\"x\":([-0-9.]+)", b + 1)
  9.         if (a == nil) then
  10.           break
  11.         end
  12.         t[account] = {}
  13.         t[account].armor = tonumber(armor)
  14.         t[account].name = name
  15.         t[account].health = tonumber(health)
  16.         t[account].world = world
  17.         t[account].loc = vector.new(tonumber(x), tonumber(y), tonumber(z))
  18.         local offset = here - t[account].loc
  19.         t[account].dist = math.floor(math.sqrt(offset.x * offset.x + offset.z * offset.z))
  20.       end
  21.       return t
  22.     end
  23.      
  24.      
  25.     fh = http.get("http://tekkit.craftersland.net:25800/up/world/world/111")
  26.     txt = fh.readAll()
  27.     fh.close()
  28.     _,_,ts = string.find(txt, "{\"timestamp\":(%d+).")
  29.      
  30.     here = vector.new(1125, 88, 1029)
  31.     glass = peripheral.wrap("top")
  32.     players = {}
  33.     while (true) do
  34.       fh = http.get("http://tekkit.craftersland.net:25800/up/world/world/" .. ts)
  35.       if (fh) then
  36.         txt = fh.readAll()
  37.         fh.close()
  38.         _,_,ts = string.find(txt, "{\"timestamp\":(%d+),")
  39.         if (ts) then
  40.           players = extract(txt)
  41.         end
  42.       end
  43.       local i = 1
  44.       st = {}
  45.       for key in pairs(players) do
  46.         st[#st+1] = key
  47.       end
  48.       table.sort(st, function(a, b) return players[a].dist < players[b].dist end)
  49.       glass.clear()
  50.       glassy = 0
  51.       for k = 1, #st do
  52.         account = st[k]
  53.         if (players[account].world == "world") then
  54.         glassy = glassy+9
  55.           glass.addText(5,glassy,account.." - "..math.floor(players[account].loc.x).." "..math.floor(players[account].loc.y).." "..math.floor(players[account].loc.z).." - armor "..players[account].armor.." - health "..players[account].health.." - distance "..players[account].dist.." - "..players[account].world,0x50A550)
  56.           i = i + 1
  57.         end
  58.       end  
  59.      
  60.       os.sleep(5.0)
  61.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement