Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function realTime()
- local time = http.get("http://worldtimeapi.org/api/timezone/Europe/Stockholm.txt").readAll()
- local date = tostring(string.sub(time, 30, 39))
- local timeset = tostring(string.sub(time, 41, 48))
- return date, timeset
- end
- modem = peripheral.wrap("front")
- lastmessage = 0
- modem.open(3)
- while true do
- local event, shit, shit2, shit3, message = os.pullEvent("modem_message")
- if (message == 1 and message ~= lastmessage) then
- redstone.setOutput("left", true)
- sleep(10)
- redstone.setOutput("left", false)
- date, time = realTime()
- print("Door opened at ", time, "; ", date)
- end
- if (message == 2 and message ~= lastmessage) then
- redstone.setOutput("right", true)
- sleep(10)
- redstone.setOutput("right", false)
- end
- lastmessage = message
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement