Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function httpGet(url)
- http.request(url)
- while true do
- local e, rUrl, rmsg = os.pullEvent()
- if (e == "http_success") and (rUrl == url) then
- if rmsg then
- local data = rmsg.readAll()
- rmsg.close()
- if data then
- return "success", data
- else
- http.request(url)
- end
- else
- http.request(url)
- end
- elseif (e == "http_failure") and (rUrl == url) then
- return "failure"
- elseif (e == "chat_command") and rUrl == "cancel" then
- return "cancel"
- end
- end
- end
- function betterSleep(time)
- os.startTimer(time)
- local startTime = os.clock()
- while true do
- os.pullEvent()
- if os.clock() >= startTime+time then return true end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement