Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function extract(s)
- local t = {}
- local name, armor, account, health, world, x, y, z
- local a = 0
- local b = 0
- while (true) do
- 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)
- if (a == nil) then
- break
- end
- t[account] = {}
- t[account].armor = tonumber(armor)
- t[account].name = name
- t[account].health = tonumber(health)
- t[account].world = world
- t[account].loc = vector.new(tonumber(x), tonumber(y), tonumber(z))
- local offset = here - t[account].loc
- t[account].dist = math.floor(math.sqrt(offset.x * offset.x + offset.z * offset.z))
- end
- return t
- end
- function getDisplay()
- local plist = peripheral.getNames()
- local i, name
- for i, name in pairs(plist) do
- if peripheral.getType(name) == "monitor" then
- return peripheral.wrap(name)
- end
- end
- return term
- end
- fh = http.get("http://tekkit.craftersland.net:25800/up/world/world/111")
- txt = fh.readAll()
- fh.close()
- _,_,ts = string.find(txt, "{\"timestamp\":(%d+).")
- print ("Starting timestamp: ", ts)
- here = vector.new(-325, 80, -2538)
- mon = getDisplay()
- -- mon.setTextScale(0.8)
- cols, rows = mon.getSize()
- players = {}
- while (true) do
- fh = http.get("http://tekkit.craftersland.net:25800/up/world/world/" .. ts)
- if (fh) then
- txt = fh.readAll()
- fh.close()
- _,_,ts = string.find(txt, "{\"timestamp\":(%d+),")
- if (ts) then
- players = extract(txt)
- end
- end
- local i = 1
- st = {}
- for key in pairs(players) do
- st[#st+1] = key
- end
- table.sort(st, function(a, b) return players[a].dist < players[b].dist end)
- mon.clear()
- for k = 1, #st do
- account = st[k]
- if (players[account].world == "world") then
- mon.setCursorPos(1, i)
- mon.write(account.." - "..players[account].dist)
- -- mon.write(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)
- i = i + 1
- end
- end
- os.sleep(5.0)
- end
Add Comment
Please, Sign In to add comment