Advertisement
Vorakh

Door Switch

May 14th, 2013 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. -- Programma Switch
  2. -- Creato da Vorakh
  3. redstone.setOutput("front", true)
  4. -- Switch
  5. sw = "l"
  6. -- Control
  7. co = false
  8. -- Position
  9. po = "front"
  10. -- Case
  11. ex = true
  12. -- Key
  13. l = 38
  14. u = 22
  15. e = 18
  16. print("Gate Locked.")
  17. sleep(2)
  18. while ex do
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21.     print("Press:")
  22.     print("\"l\" to lock the gate")
  23.     print("\"u\" to unlock the gate")
  24.     print("\"e\" to exit program")
  25.     event, scancode = os.pullEvent("key")
  26.     sw = tostring(scancode)
  27.     term.clear()
  28.     term.setCursorPos(1,1)
  29.     if scancode == l then
  30.         redstone.setOutput(po, true)
  31.         co = true
  32.         print("Gate Locked.")
  33.     end
  34.     if scancode == u then
  35.         redstone.setOutput(po, false)
  36.         co = true
  37.         print("Gate Unlocked.")
  38.     end
  39.     if scancode == e then
  40.         ex = false
  41.         co = true
  42.         print("Good Bye :)")
  43.     end
  44.  
  45.     if co then
  46.     co = false
  47.     else
  48.     print("Wrong key, retry!")
  49.     end
  50.     sleep(2)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement