Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wModul = "back"
- sound = "top"
- function dashboard(status)
- shell.run("clear")
- maxX, maxY = term.getSize()
- term.setCursorPos(1,2)
- text = ""
- for i = 0, maxX - 1, 1 do
- text = text .. "#"
- end
- print(text)
- term.setCursorPos(math.floor((maxX - string.len(header)) / 2), 4)
- print(header)
- term.setCursorPos(math.floor((maxX - string.len(status)) / 2),math.floor(maxY / 2))
- print(status)
- text = ""
- text = "Warte auf Befehle"
- term.setCursorPos(math.floor((maxX - string.len(text)) / 2),math.floor(maxY / 2) + 1)
- print(text)
- text = ""
- term.setCursorPos(1,maxY)
- for i = 0, maxX - 1, 1 do
- text = text .. "#"
- end
- print(text)
- warten = " Signal kann empfangen werden "
- term.setCursorPos(math.floor((maxX - string.len(warten)) / 2),maxY - 1)
- print(warten)
- end
- end
- function wartenTimer()
- local event, timerID = os.pullEvent("timer")
- if timerID == myTimer then
- redstone.setOutput(sound, false)
- dashboard("Alarm wurde automatisch deaktiviert")
- rednet.broadcast("Roter Alarm wurde automatisch deaktiviert", "1900Warn")
- end
- end
- function 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)
- end
- redstone.setOutput(sound, true)
- dasboard("Alarm ist an!")
- parallel.waitForAny(wartenPlayer, wartenAlarm, wartenTimer)
- end
- function alarmStop()
- os.cancelTimer(myTimer)
- redstone.setOutput(sound, false)
- dashboard("Alarm wurde deaktiviert")
- end
- function wartenAlarm()
- senderId1, message1, protocol = rednet.receive("1900Alarm")
- if message == "Alarm start!" then
- alarmStart()
- elseif message == "Alarm stop!" then
- alarmStop()
- end
- end
- --Einmalig
- rednet.open(wModul)
- dashboard("Alarm wurde deaktiviert")
- while true do
- parallel.waitForAny(wartenAlarm)
- end
Add Comment
Please, Sign In to add comment