View difference between Paste ID: zQApsfxZ and bCtAfYca
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
3
local function getTime()
4-
                local request = http.get(time_url)
4+
   if not http then
5-
                local time_content = request.readAll()
5+
         print('HTTP is required')
6-
                request.close()
6+
         return "Needs http to be enabled in the config"
7-
                local search_text = [[<div id="analog%-digital">.-<span class="font7">(.-)</span>]]
7+
   end
8-
                local _,_, global_time = time_content:find(search_text)
8+
   local request = http.get(time_url)
9-
                local global_time = global_time:gsub("%s", "")
9+
   local time_content = request.readAll()
10-
                print(global_time)
10+
   request.close()
11
   local search_text = [[<div id="analog%-digital">.-<span class="font7">(.-)</span>]]
12
   local _,_, global_time = time_content:find(search_text)
13
   local global_time = global_time:gsub("%s", "")
14
   return global_time
15
end
16
17
while true do
18
  rs.setOutput("back", true)
19
  os.pullEvent("redstone") --Waits until redstone changes states
20
  if rs.getInput("bottom") then
21
        print("Circuit tripped at: "..getTime())
22
  rs.setOutput("back", false)
23
  sleep (60)
24
  end
25
end