Advertisement
Shuudoushi

door program

Oct 10th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local sides = {"bottom", "back"}
  2. local password = "<password>"
  3. local sleepTime = 5
  4. local debug = "1243"
  5. local oldPull = os.pullEvent
  6. os.pullEvent = os.pullEventRaw
  7. for k, v in pairs(rs.getSides()) do
  8.   rs.setOutput(v, false)
  9. end
  10. local function getPass()
  11.   term.clear()
  12.   term.setCursorPos(1,1)
  13.   write("Password:")
  14.   input = read("*")
  15.   if input == password then
  16.     print("Correct password!")
  17.     rs.setOutput(sides[1], true)
  18.     sleep(0)
  19.     rs.setOutput(sides[2], false)
  20.     sleep(sleepTime)
  21.     rs.setOutput(sides[1], true)
  22.     sleep(0)
  23.     rs.setOutput(sides[2], false)
  24.   else
  25.     print("You fail.")
  26.   end
  27. end
  28.  
  29. local function loopGetPass()
  30.   while true do
  31.     getPass()
  32.    if input == debug then
  33.     break
  34.    end
  35.   end
  36. end
  37.  
  38. local function getInput()
  39.   while true do
  40.     if rs.getInput(sides[2]) then
  41.       sleep(1)
  42.       term.clear()
  43.       term.setCursorPos(1,1)
  44.       print("Please wait.")
  45.       rs.setOutput(sides[1], true)
  46.       sleep(0)
  47.       rs.setOutput(sides[1], false)
  48.       sleep(sleepTime)
  49.       rs.setOutput(sides[1], true)
  50.       sleep(0)
  51.       rs.setOutput(sides[1], false)
  52.     end
  53.   end
  54. end
  55.  
  56. parallel.waitForAny(loopGetPass, getInput)
  57. os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement