Advertisement
Asioron

Internet_Time

Jan 25th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. -------------------------------------------------
  2. -- Программа для контроллера с интернет платой --
  3. --    Бинарные часы для мода OpenComputers     --
  4. --       проект http://computercraft.ru        --
  5. --                2017, © Asior                --
  6. -------------------------------------------------
  7.  
  8. int = component.proxy(component.list("internet")())
  9. mod = component.proxy(component.list("modem")())
  10. mod.open(1)
  11. while true do
  12.   a=int.request("https://script.google.com/macros/s/AKfycbyd5AcbAnWi2Yn0xhFRbyzS4qMq1VucMVgVvhul5XqS9HkAyJY/exec")
  13.   local s, vr, n, h, m = '', '',0 ,0 ,0
  14.   repeat
  15.     vr = vr..s
  16.     s = tostring(a.read())
  17.   until s == 'nil'
  18.     a.close()
  19.     _, n = string.find(vr, '"hours":')
  20.     if n ~= nil then
  21.       h = string.sub(vr, n+1, n+2)
  22.       if not tonumber(h) then h = tonumber(string.sub(h, 1, 1)) end
  23.       _, n = string.find(vr, '"minutes":')
  24.       m = string.sub(vr, n+1, n+2)
  25.       if not tonumber(m) then m = tonumber(string.sub(m, 1, 1)) end
  26.       mod.broadcast(1, h, m)
  27.     else
  28.       mod.broadcast(1, 255, 255)
  29.     end
  30.   computer.pullSignal(10)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement