Skillkiller

Hauptor

Aug 2nd, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. -- Benutzer Einstellungen
  2. openTime = tonumber("6")   -- Wann soll die Tür geöffnet werden
  3. warnTime = tonumber("5")   -- Wann soll gewanrt werden
  4. closeTime = tonumber("19") -- Wann soll die Tür geschloßen werden
  5. modul = "top"            -- Wo ist das Wireless Modul
  6.  
  7. function update()
  8.  
  9. if (os.time() > warnTime and os.time() < closeTime) then
  10. warnung(true)
  11. else
  12. warnung(false)
  13. end
  14.  
  15. if (os.time() > openTime and os.time() < closeTime) then
  16.  tag = true
  17. else
  18.  tag = false
  19. end
  20.  
  21. rednet.broadcast("status?", "1900Player")
  22. senderId, message, protocol = rednet.receive("1900Player", 10)
  23. if message == "Online" then
  24. POnline = true
  25. else
  26. POnline = false
  27. end
  28.  
  29. if (tag == true and POnline == true) then
  30. --Tür wird geöffnet
  31. redstone.setOutput("left", true)
  32. sleep(10)
  33. redstone.setOutput("left", false)
  34.  
  35. else
  36. --Tür wird geschlossen
  37. --Comming soon
  38.  
  39. end
  40. end
  41.  
  42. function warnung(an)
  43. if an == true then
  44.  rednet.broadcast("warn On", "1900Door")
  45. else
  46.  rednet.broadcast("warn Off", "1900Door")
  47. end
  48. end
  49.  
  50. function wecker()
  51.  local event = os.pullEvent("alarm")
  52.  update()
  53. end
  54.  
  55. rednet.open(modul)
  56. update()
  57.  
  58. while true do
  59.  os.setAlarm(openTime)
  60.  os.setAlarm(warnTime)
  61.  os.setAlarm(closeTime)
  62.  parallel.waitForAny(wecker)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment