SHOW:
|
|
- or go back to the newest paste.
| 1 | local function serverTime() | |
| 2 | - | http.request("http://mc.ov-gaming.com:25566")
|
| 2 | + | |
| 3 | --Server to pull time from | |
| 4 | http.request("http://mc.ov-gaming.com/cc/time.php")
| |
| 5 | ||
| 6 | - | while requesting do |
| 6 | + | |
| 7 | - | local event, url, sourceText = os.pullEvent() |
| 7 | + | |
| 8 | - | |
| 8 | + | while requesting do |
| 9 | - | if event == "http_success" then |
| 9 | + | local event, url, sourceText = os.pullEvent() |
| 10 | - | local respondedText = sourceText.readAll() |
| 10 | + | local respondedText = sourceText.readAll() |
| 11 | - | |
| 11 | + | if event == "http_success" then |
| 12 | - | sourceText.close() |
| 12 | + | |
| 13 | - | --Print the reply if successful; debug info for now |
| 13 | + | |
| 14 | - | print("Reply was: " .. respondedText)
|
| 14 | + | sourceText.close() |
| 15 | - | |
| 15 | + | --Print the reply if successful; debug info for now |
| 16 | - | requesting = false |
| 16 | + | --print("Reply was: " .. respondedText)
|
| 17 | - | elseif event == "http_failure" then |
| 17 | + | |
| 18 | - | print("Server didn't respond.")
|
| 18 | + | |
| 19 | - | |
| 19 | + | requesting = false |
| 20 | - | requesting = false |
| 20 | + | elseif event == "http_failure" then |
| 21 | - | end |
| 21 | + | print("Server didn't respond.")
|
| 22 | - | end |
| 22 | + | |
| 23 | requesting = false | |
| 24 | end | |
| 25 | return(respondedText) | |
| 26 | end | |
| 27 | end | |
| 28 | ||
| 29 | print(serverTime()) |