Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Variablen
- wModul = "bottom"
- zone = "Schlafzimmer"
- lamp = "left"
- --Code
- rednet.open(wModul)
- alarm = false
- header = "Roter Alarm - " .. zone
- function start()
- dashboard("Ist gestoppt")
- updateRedstone()
- end
- function updateRedstone()
- redstone.setOutput(lamp, alarm)
- end
- function blink()
- while alarm do
- rednet.broadcast("Red Light on ALL", "1900Light")
- sleep(1)
- rednet.broadcast("Red Light off ALL", "1900Light")
- sleep(1)
- end
- end
- function dashboard(status, id)
- 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 = "Sende Befehle f\195\188r den Roten Alarm"
- 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 gesendet werden "
- term.setCursorPos(math.floor((maxX - string.len(warten)) / 2),maxY - 1)
- print(warten)
- end
- function check()
- if rs.getInput("top") == true then
- sleep(1)
- if (alarm == true) then
- alarm = false
- dashboard("Ist gestoppt")
- updateRedstone()
- rednet.broadcast("Alarm stop!", "1900Alarm")
- rednet.broadcast("Roter Alarm wurde gestoppt. Von Zone: " .. zone, "1900Crit")
- rednet.broadcast("Red Light off ALL", "1900Light")
- else
- alarm = true
- dashboard("Alarm l\195\164uft")
- updateRedstone()
- rednet.broadcast("Alarm start!", "1900Alarm")
- rednet.broadcast("Roter Alarm wurde ausgel\195\182st. Von Zone: " ..zone, "1900Crit")
- parallel.waitForAny(signal, blink)
- end
- else
- print("Redstone changed")
- end
- end
- function signal()
- local event = os.pullEvent("redstone")
- check()
- end
- --Einmalig alles Updaten
- start()
- --Endlosschleife
- while true do
- signal()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement