Advertisement
Skillkiller

Alarm Sound T2

Sep 8th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. wModul = "back"
  2. sound = "top"
  3.  
  4. function wartenAlarm()
  5. print("Warten auf Alarm")
  6. senderId1, message1, protocol = rednet.receive("1900Alarm")
  7. print("Alarm empfangen")
  8. print("Message: " .. message1)
  9. if message1 == "Alarm start!" then
  10.     alarmStart()
  11. elseif message1 == "Alarm stop!" then
  12.     alarmStop()
  13. end
  14. end
  15.  
  16. function alarmStart()
  17.     print("Funktion alarmStart")
  18.     rednet.broadcast("status?", "1900Player")
  19.     senderId2, message2, protocol = rednet.receive("1900Player")
  20.     if message == "Online" then
  21.         myTimer = os.startTimer(300)
  22.     elseif message == "Offline" then
  23.         myTimer = os.startTimer(60)
  24.     else
  25.         print("Irgendwas ging schief?!")
  26.         print("Online Abfrage")
  27.     end
  28.     redstone.setOutput(sound, true)
  29. end
  30.  
  31. function alarmStop()
  32.     if not (myTimer == "") then
  33.         os.cancelTimer(myTimer)
  34.     end
  35.     redstone.setOutput(sound, false)
  36.     dashboard("Alarm wurde deaktiviert")
  37. end
  38.  
  39. function wartenTimer()
  40. local event, timerID = os.pullEvent("timer")
  41. if timerID == myTimer then
  42.     redstone.setOutput(sound, false)
  43.     rednet.broadcast("Roter Alarm wurde automatisch deaktiviert", "1900Warn")
  44. end
  45. end
  46.  
  47. --Einmalig
  48. rednet.open(wModul)
  49.  
  50. while true do
  51. wartenAlarm()
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement