SHOW:
|
|
- or go back to the newest paste.
| 1 | local time_url = "http://www.worldtimeserver.com/current_time_in_US-CA.aspx" --Replace this | |
| 2 | - | rs.setOutput("back",true)
|
| 2 | + | |
| 3 | local function getTime() | |
| 4 | - | sleep (5) |
| 4 | + | local request = http.get(time_url) |
| 5 | - | c = rs.getInput("bottom")
|
| 5 | + | local time_content = request.readAll() |
| 6 | - | if c == true then |
| 6 | + | request.close() |
| 7 | - | rs.setOutput("back", false)
|
| 7 | + | local search_text = [[<div id="analog%-digital">.-<span class="font7">(.-)</span>]] |
| 8 | - | local x = getTime() |
| 8 | + | local _,_, global_time = time_content:find(search_text) |
| 9 | - | print ("Circuit Tripped at "..(x))
|
| 9 | + | local global_time = global_time:gsub("%s", "")
|
| 10 | - | sleep (3600) |
| 10 | + | print(global_time) |
| 11 | - | rs.setOutput("back", true)
|
| 11 | + | |
| 12 | while true do | |
| 13 | rs.setOutput("back", true)
| |
| 14 | os.pullEvent("redstone") --Waits until redstone changes states
| |
| 15 | if not rs.getInput("back") then
| |
| 16 | - | local request = http.get(time_url) |
| 16 | + | print("Circuit tripped at: "..getTime())
|
| 17 | - | local time_content = request.readAll() |
| 17 | + | end |
| 18 | - | request.close() |
| 18 | + |