Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wModul = "back"
- sound = "top"
- function wartenAlarm()
- print("Warten auf Alarm")
- senderId1, message1, protocol = rednet.receive("1900Alarm")
- print("Alarm empfangen")
- print("Message: " .. message1)
- if message1 == "Alarm start!" then
- alarmStart()
- elseif message1 == "Alarm stop!" then
- alarmStop()
- end
- end
- function alarmStart()
- print("Funktion alarmStart")
- rednet.broadcast("status?", "1900Player")
- senderId2, message2, protocol = rednet.receive("1900Player")
- if message == "Online" then
- myTimer = os.startTimer(300)
- elseif message == "Offline" then
- myTimer = os.startTimer(60)
- else
- print("Irgendwas ging schief?!")
- print("Online Abfrage")
- end
- redstone.setOutput(sound, true)
- end
- function alarmStop()
- if not (myTimer == "") then
- os.cancelTimer(myTimer)
- end
- redstone.setOutput(sound, false)
- dashboard("Alarm wurde deaktiviert")
- end
- function wartenTimer()
- local event, timerID = os.pullEvent("timer")
- if timerID == myTimer then
- redstone.setOutput(sound, false)
- rednet.broadcast("Roter Alarm wurde automatisch deaktiviert", "1900Warn")
- end
- end
- --Einmalig
- rednet.open(wModul)
- while true do
- wartenAlarm()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement