Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local json = require("json")
- local gpu = component.gpu
- local terminal = require("term")
- local fs = require("filesystem")
- local shell = require("shell")
- local unicode = require("unicode")
- gpu.setResolution(37, 17)
- local w, h = gpu.getResolution()
- local color = {
- green = 0x00ff00,
- yellow = 0xffb600,
- red = 0xff0000
- }
- local url = "https://api.minetools.eu/query/s9.mcskill.net/25675"
- local owners = {
- "FERROUS",
- "Hedboys",
- "deadinsideclown",
- "xixiii"
- }
- local status = {
- "online ",
- "offline"
- }
- function dump(table)
- if type(table) == 'table' then
- local s = '{ '
- for k,v in pairs(table) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(table)
- end
- end
- function parseJson(string)
- return json:decode(string)
- end
- function readFile()
- local dataFromFile
- if fs.exists("/home/infoServer.json") then
- local file = io.open("/home/infoServer.json", "r")
- dataFromFile = file:read("*a")
- file:close()
- end
- return dataFromFile
- end
- function drawBorder()
- gpu.setForeground(color.green)
- gpu.fill(1, 1, w, 1, "-")
- gpu.fill(1, h, w, 1, "-")
- gpu.fill(1, 0, 1, h + 1, "|")
- gpu.copy(1, 0, 1, h + 1, w - 1, 0)
- end
- function drawOwners(owner, yPos, indexStatus, colorStatus)
- gpu.setForeground(color.yellow)
- gpu.set(w / 5, (yPos * 2) + yPos, owner)
- gpu.setForeground(colorStatus)
- gpu.set(w - 10, (yPos * 2) + yPos, status[indexStatus])
- end
- for i = 1, #owners do
- computer.addUser(owners[i])
- end
- while true do
- terminal.clear()
- local center = (w / 2) / 2
- drawBorder()
- gpu.setForeground(color.green)
- gpu.set(center, 1, "[")
- gpu.setForeground(color.yellow)
- gpu.set(center + 1, 1, "Владельцы /warp SKY")
- gpu.setForeground(color.green)
- gpu.set(center + unicode.len("Владельцы /warp SKY") + 1, 1, "]")
- gpu.setForeground(color.green)
- gpu.set(w / 5 - 2, h - 2, "По всем вопросам: /w nickname")
- local downloadFile = shell.execute("wget " .. url .. " " .. "/home/infoServer.json" .. " -fQ")
- local response = readFile()
- if response then
- local list = parseJson(response)["Playerlist"]
- for i = 1, #owners do
- drawOwners(owners[i], i, 2, color.red)
- if list then
- for j = 1, #list do
- if owners[i] == list[j] then
- drawOwners(owners[i], i, 1, color.green)
- end
- end
- end
- end
- end
- os.sleep(60)
- end
Add Comment
Please, Sign In to add comment