Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Global Alliance Tracker for CC
- local util = require("gab.util")
- local gfx = require("gab.gfx")
- local bigfont = require("bigfont")
- local DATA_URL = "http://147.135.59.131/all"
- local CACHE_FILE = ".total-cache.json"
- local mon, w, h = util.handleMonitorArg(...)
- local function stat(label, number, colour, y)
- local n = util.formatCommas(number)
- local colour = gfx.colourToBlit(colour or colours.white)
- bigfont.blitOn(mon, 1, string.format("%s: %s", label, n), ("0"):rep(#label + 2) .. colour:rep(#n), ("f"):rep(#label + 2 + #n), nil, y)
- end
- local function main()
- mon.clear()
- local centerY = gfx.drawLoading(mon)
- local data = util.cachedJSONRequest(DATA_URL, CACHE_FILE)
- gfx.clearLoading(mon, centerY)
- mon.setTextColour(colours.white)
- bigfont.writeOn(mon, 2, "Global Alliance Bank.", nil, 2)
- stat("Galleons Held: ", data.cases, colours.orange, 11)
- stat("Gold Held: ", data.deaths, colours.red, 15)
- stat("Total Transactions: ", data.recovered, colours.green, 19)
- mon.setTextColour(colours.lightGrey)
- local updated = "Last updated: " .. os.date("%Y/%m/%d %H:%M:%S", math.ceil(data.updated / 1000)) .. " UTC"
- gfx.writeCentred(mon, w, updated, h - 1)
- end
- util.mainLoop(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement