Advertisement
Guest User

ComputerCraft Door Lock

a guest
May 2nd, 2016
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw -- Prevent user from terminating program
  2.  
  3. local side = "" -- Side to output redstone
  4. local password = "" -- Password to type to gain access
  5. local admin = "" -- Password to terminate program
  6. local time = 0 -- Enter time to output redstone for (seconds)
  7. local open = true -- Redstone value to output if door is closed
  8.  
  9. while true do
  10.  
  11.     rs.setOutput(side, open) -- Makes sure redstone is outputting correctly
  12.    
  13.     term.clear()
  14.     term.setCursorPos(1, 1)
  15.    
  16.     write("Enter access code: ")
  17.     local input = read("*")
  18.    
  19.     if input == password then
  20.        
  21.         print("Access granted!")
  22.         print("Opening door for " .. time .. " seconds...")
  23.         rs.setOutput(side, not open)
  24.         sleep(time)
  25.         rs.setOutput(side, open)
  26.        
  27.     elseif input == admin then
  28.        
  29.         write("Terminating program in 3")
  30.         sleep(1)
  31.         write(", 2")
  32.         sleep(1)
  33.         print(", 1")
  34.         sleep(1)
  35.         break;
  36.        
  37.     else
  38.        
  39.         print("Access denied")
  40.         sleep(2)
  41.        
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement