SHOW:
|
|
- or go back to the newest paste.
| 1 | --Variablen | |
| 2 | wModul = "bottom" | |
| 3 | - | zone = "Schalfzimmer" |
| 3 | + | zone = "Schlafzimmer" |
| 4 | lamp = "right" | |
| 5 | --Code | |
| 6 | rednet.open(wModul) | |
| 7 | open = true | |
| 8 | - | function schleife() |
| 8 | + | header = zone |
| 9 | ||
| 10 | ||
| 11 | function start() | |
| 12 | - | function warten() |
| 12 | + | rednet.broadcast(zone .. " status?", "1900Door") |
| 13 | senderId = rednet.receive("1900Door",3)
| |
| 14 | if (open == true) then | |
| 15 | - | rednet.broadcast("Roter Alarm wurde von der Zone " .. zone .. " ausgel\195\182st", "1900Crit")
|
| 15 | + | dashboard("Zimmer offen", senderId)
|
| 16 | - | while rs.getInput("top") do
|
| 16 | + | else |
| 17 | - | rednet.broadcast("Red Light on ALL", "1900Light")
|
| 17 | + | dashboard("Derzeit geschlossen", senderId)
|
| 18 | - | sleep(1) |
| 18 | + | |
| 19 | - | rednet.broadcast("Red Light off ALL", "1900Light")
|
| 19 | + | updateRedstone() |
| 20 | - | sleep(1) |
| 20 | + | |
| 21 | ||
| 22 | - | rednet.broadcast("Roter Alarm wurde deaktiviert" , "1900Crit")
|
| 22 | + | function updateRedstone() |
| 23 | if (open == true) then | |
| 24 | redstone.setOutput(lamp, true) | |
| 25 | else | |
| 26 | redstone.setOutput(lamp,false) | |
| 27 | end | |
| 28 | end | |
| 29 | - | warten() |
| 29 | + | |
| 30 | function dashboard(status, id) | |
| 31 | shell.run("clear")
| |
| 32 | maxX, maxY = term.getSize() | |
| 33 | term.setCursorPos(1,2) | |
| 34 | text = "" | |
| 35 | for i = 0, maxX - 1, 1 do | |
| 36 | text = text .. "#" | |
| 37 | end | |
| 38 | print(text) | |
| 39 | ||
| 40 | term.setCursorPos(math.floor((maxX - string.len(header)) / 2), 4) | |
| 41 | print(header) | |
| 42 | ||
| 43 | term.setCursorPos(math.floor((maxX - string.len(status)) / 2),math.floor(maxY / 2)) | |
| 44 | print(status) | |
| 45 | ||
| 46 | text = "" | |
| 47 | text = "Sende Befehle an den Computer " .. tostring(id) | |
| 48 | term.setCursorPos(math.floor((maxX - string.len(text)) / 2),math.floor(maxY / 2) + 1) | |
| 49 | print(text) | |
| 50 | ||
| 51 | ||
| 52 | ||
| 53 | ||
| 54 | ||
| 55 | text = "" | |
| 56 | term.setCursorPos(1,maxY) | |
| 57 | for i = 0, maxX - 1, 1 do | |
| 58 | text = text .. "#" | |
| 59 | end | |
| 60 | print(text) | |
| 61 | ||
| 62 | warten = " Signal kann gesendet werden " | |
| 63 | term.setCursorPos(math.floor((maxX - string.len(warten)) / 2),maxY - 1) | |
| 64 | print(warten) | |
| 65 | end | |
| 66 | ||
| 67 | function signal() | |
| 68 | local event = os.pullEvent("redstone")
| |
| 69 | if rs.getInput("top") then
| |
| 70 | rednet.send(senderId, zone .. " status?", "1900Door") | |
| 71 | senderId, message, protocol = rednet.receive("1900Door",3)
| |
| 72 | if (message == true) then | |
| 73 | rednet.send(senderId, zone .. " zu", "1900Door") | |
| 74 | open = false | |
| 75 | updateRedstone() | |
| 76 | rednet.broadcast("Die T\195\188r " .. zone .. " wurde geschlossen", "1900Info")
| |
| 77 | elseif (message == false) then | |
| 78 | rednet.send(senderId, zone .. " auf", "1900Door") | |
| 79 | open = true | |
| 80 | updateRedstone() | |
| 81 | rednet.broadcast("Die T\195\188r f\195\188r " .. zone .. " wurde ge\195\182ffnet", "1900Info")
| |
| 82 | end | |
| 83 | end | |
| 84 | end | |
| 85 | ||
| 86 | --Einmalig alles Updaten | |
| 87 | start() | |
| 88 | ||
| 89 | --Endlosschleife | |
| 90 | while true do | |
| 91 | signal() | |
| 92 | end |