Skillkiller

Eingangs Verwaltung

Feb 10th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. -- Benutzer Einstellungen
  2. openTime = tonumber("6")   -- Wann soll die Tür geöffnet werden
  3. closeTime = tonumber("19") -- Wann soll die Tür geschloßen werden
  4. modul = "right"            -- Wo ist das Wireless Modul
  5. online = "left"            -- Wo ist der Online Player Detector
  6. protokoll = "1600"         -- Auf welchem Protokoll soll das Signal gesendet werden
  7.  
  8.  
  9. -- Programm Variablen
  10. besitzer = "Offline"
  11. tag = "Nein"
  12.  
  13. -- Funktionen
  14. function dashboard()
  15. shell.run("clear")
  16. print("Eingangs Verwaltung")
  17. print("Besitzer: " .. besitzer)
  18. print("Tag: " .. tag)
  19. end
  20.  
  21. function update()
  22. if (os.time() > openTime and os.time() < closeTime) then
  23.  tag = "Ja"
  24. else
  25.  tag = "Nein"
  26. end
  27.  
  28. if rs.getInput(online) == true then
  29.  besitzer = "Online"
  30. else
  31.  besitzer = "Offline"
  32. end
  33. dashboard()
  34. if (besitzer == "Online" and tag == "Ja") then
  35.  rednet.broadcast(protokoll .. "aufmachen")
  36. else
  37.  rednet.broadcast(protokoll .. "zumachen")
  38. end
  39. end
  40.  
  41. function redstone()
  42.  local event = os.pullEvent("redstone")
  43.  update()
  44. end
  45.  
  46. function wecker()
  47.  local event = os.pullEvent("alarm")
  48.  update()
  49. end
  50.  
  51. -- Einmalig nach dem Start
  52. -- Programm
  53. rednet.open(modul)
  54. update()
  55. ------------------------------------
  56. -- In der Scheilfe
  57. while true do
  58.  os.setAlarm(openTime)
  59.  os.setAlarm(closeTime)
  60.  parallel.waitForAny(redstone, wecker)
  61. end
Add Comment
Please, Sign In to add comment