SHOW:
|
|
- or go back to the newest paste.
| 1 | - | if not fs.exists "json" then local a=http.get"https://raw.githubusercontent.com/rxi/json.lua/bee7ee3431133009a97257bde73da8a34e53c15c/json.lua"local b=fs.open("json","w")b.write(a.readAll())a.close()b.close() end
|
| 1 | + | local a=http.get"https://raw.githubusercontent.com/rxi/json.lua/bee7ee3431133009a97257bde73da8a34e53c15c/json.lua"local b=fs.open("json","w")b.write(a.readAll())a.close()b.close()
|
| 2 | local json = require "/json" | |
| 3 | - | local dynmap = settings.get "tracker.map" or "https://dynmap.switchcraft.pw/" |
| 3 | + | API = "https://dynmap.switchcraft.pw/up/world/world/" |
| 4 | - | local API = dynmap .. "up/world/world/" |
| 4 | + | |
| 5 | - | local mon = peripheral.find "monitor" |
| 5 | + | local function fetch(url, headers) |
| 6 | - | if mon then mon.setTextScale(0.5) term.redirect(mon) end |
| 6 | + | local h = http.get(url, headers) |
| 7 | local o = h.readAll() | |
| 8 | - | local function fetch(url) |
| 8 | + | |
| 9 | - | local h = http.get(url) |
| 9 | + | |
| 10 | end | |
| 11 | ||
| 12 | local m = peripheral.find "modem" | |
| 13 | ||
| 14 | while true do | |
| 15 | - | local worlds = {
|
| 15 | + | local data = json.decode(fetch(API .. os.epoch "utc", {
|
| 16 | - | world = "overworld", |
| 16 | + | Cookie = "JSESSIONID=abcd", |
| 17 | - | DIM1_the_end = "end", |
| 17 | + | })) |
| 18 | - | DIM1 = "end", |
| 18 | + | local tosend = {}
|
| 19 | - | ["DIM-1"] = "nether", |
| 19 | + | for _, player in pairs(data.players) do |
| 20 | - | ["DIM-11325"] = "deepdark" |
| 20 | + | if player.world == "DIM1_the_end" then |
| 21 | - | } |
| 21 | + | table.insert(tosend, { player.name, player.x, player.y, player.z })
|
| 22 | end | |
| 23 | - | local function render_coords(player) |
| 23 | + | |
| 24 | - | return ("%0d %0d %0d"):format(player.x, player.y, player.z)
|
| 24 | + | print("Broadcasting locations of", #tosend, "players")
|
| 25 | m.transmit(1103, 1103, tosend) | |
| 26 | ||
| 27 | - | local function render_pos(player) |
| 27 | + | sleep(1) |
| 28 | - | local coords = render_coords(player) |
| 28 | + |