Advertisement
Skillkiller

Türschloss

Mar 1st, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. -- Benutzer Variablen
  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. RedOutput = "bottom"       -- Wo soll das Redstone Signal ausgegeben werden
  5.  
  6. -- System Variablen
  7. -- Nichts verändern ohne Lua Kenntnisse
  8.  
  9. tag = "Nein"
  10.  
  11. shell.run("clear")
  12.  
  13. function wecker()
  14. local event = os.pullEvent("alarm")
  15. update()
  16. end
  17.  
  18. function update()
  19. if (os.time() > openTime and os.time() < closeTime) then
  20.  redstone.setOutput(RedOutput, true)
  21.  tag = "Ja"
  22. else
  23.  redstone.setOutput(RedOutput, false)
  24.  tag = "Nein"
  25. end
  26. end
  27.  
  28. function eingabe()
  29. antwort = read("*")
  30. if antwort == "Tekkit" then
  31.  redstone.setOutput(RedOutput,true)
  32.  sleep(5)
  33.  redstone.setOutput(RedOutput, false)
  34. else
  35.  print("Access denied")
  36. end
  37. os.reboot()
  38. end
  39.  
  40. function dashboard()
  41. shell.run("clear")
  42. print("Haupteingang")
  43. print("Tag: " .. tag)
  44. if tag == "Nein" then
  45.  write("Passwort: ")
  46. end
  47. end
  48.  
  49. -- Einmalig
  50. update()
  51.  
  52. while true do -- Schleife
  53.  os.setAlarm(openTime)
  54.  os.setAlarm(closeTime)
  55.  dashboard()
  56.  if tag == "Ja" then
  57.   wecker()
  58.  else
  59.   parallel.waitForAny(eingabe, wecker)
  60.  end
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement