local base, world, timestamp = "https://dynmap.sc3.io/", "SwitchCraft", os.epoch() -- "DIM1" local out = {} --[[Player object: { afk = false, name = "hugeblank", ... } ]] out.getPositions = function() local response, data = out.getWorld() if response then local players = data.players for _, player in ipairs(players) do player.afk = player.name:find("?") ~= 1 -- Players who are afk have ??? prefixing their name in this field player.name = player.account player.account, player.health, player.armor, player.sort, player.type = nil, nil, nil, nil, nil -- defunct/useless values end return true, players else return false end end out.getWorld = function() local response, err = http.get(base.."up/world/"..world.."/"..timestamp) if response then local data = textutils.unserialiseJSON(response.readAll()) response.close() return true, data else return false end end local function min(t) local m = t[1] for i = 2, #t do m = math.min(m, t[i]) end return m end local function max(t) local m = t[1] for i = 2, #t do m = math.max(m, t[i]) end return m end --[[ Claim Object { uuid = string, label = string, color = string, fillcolor = string, -- Same as `color` generally desc = string, -- HTML tag. Generally use `owner` instead. owner = string, xmin = number, xmax = number, zmin = number, zmax = number, ytop = number, -- Default: 64 ybottom = number, -- Default: 64 weight = number, -- Default: 2 markup = boolean, -- Default: false opacity = number, -- Default: 0.8 fillopacity = number, -- Default: 0.2 x = table, -- Raw x values passed in by dynmap. Use xmin/xmax instead. z = table, -- Raw z values passed in by dynmap. Use zmin/zmax instead. } ]] out.getClaims = function(includeAdmin, filterOwner) local response, err = http.get("https://dynmap.sc3.io/tiles/_markers_/marker_SwitchCraft.json") if response then local data = textutils.unserialiseJSON(response.readAll()) response.close() local unparsed = data.sets["claimkit.claims"].areas if includeAdmin then for k, v in pairs(data.sets["claimkit.adminclaims"].areas) do v.owner = v.desc:gsub("