function getapi()
repeat
local stat1, err1 = pcall(function()
aa = aa or {}
a = http.get("https://projects.dannysmc.com/apis/progutils.lua")
a = a.readAll()
local env = {}
a = loadstring(a)
local env = getfenv()
setfenv(a, env)
local status, err = pcall(a, unpack(aa))
if (not status) and err then
printError("Error loaing api")
return false
end
local returned = err
env = env
_G["progutils"] = env
end)
until stat1 == true
end
function drawchatfile(tchat)
print(type(tchat))
if type(tchat) == "table" then
tchat = textutils.unserialize(tchat.readAll())
if tchat <= i then
for i=1, 16 do
draw.texta("U: "..tchat[i][2].." | M: "..tchat[i][4], 1, i+1, false, "white", "black")
end
end
end
end
function test()
req = http.request(url, "ccsys=babble&cccmd=get_chat&room=test")
count = 0
while true do
local args = { os.pullEvent() }
if args[1] == "http_success" then
count = count + 1
draw.texta("Received: "..count, 1, 1, false, "grey", "white")
drawchatfile(req)
req = http.request(url, "ccsys=babble&cccmd=get_chat&room=test")
elseif args[1] == "http_failure" then
req = http.request(url, "ccsys=babble&cccmd=get_chat&room=test")
end
end
end
getapi()
test()