Advertisement
Guest User

startup

a guest
May 20th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. function realTime()
  2.   local time = http.get("http://worldtimeapi.org/api/timezone/Europe/Stockholm.txt").readAll()
  3.   local date = tostring(string.sub(time, 30, 39))
  4.   local timeset = tostring(string.sub(time, 41, 48))
  5.   return date, timeset
  6. end
  7.  
  8. modem = peripheral.wrap("front")
  9. lastmessage = 0
  10. modem.open(3)
  11. while true do
  12.   local event, shit, shit2, shit3, message = os.pullEvent("modem_message")
  13.   if (message == 1 and message ~= lastmessage) then
  14.     redstone.setOutput("left", true)
  15.     sleep(10)
  16.     redstone.setOutput("left", false)
  17.     date, time = realTime()
  18.     print("Door opened at ", time, "; ", date)    
  19.   end
  20.   if (message == 2 and message ~= lastmessage) then
  21.     redstone.setOutput("right", true)
  22.     sleep(10)
  23.     redstone.setOutput("right", false)
  24.   end
  25.   lastmessage = message
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement