Advertisement
Shuudoushi

ComputerCraft door

Mar 12th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local sleepTime = 2.5
  2. local debug = "0000" -- This can be changed to anything you want. If you are going to be using this program to protect a ComputerCraft computer, use this code and don't worry about making the rest of the files.
  3. local oldPull = os.pullEvent
  4. s = fs.open(".doorSide", "r") --.doorSide, .passWord and .userName hidden text files need to be made for this program to work for doors. And I hope what should be in these files is not needed to be said...
  5.  texts = s.readAll()
  6.   s.close()
  7. p = fs.open(".passWord", "r")
  8.  textp = p.readAll()
  9.   p.close()
  10. u = fs.open(".userName", "r")
  11.  textu = u.readAll()
  12.   u.close()
  13. os.pullEvent = os.pullEventRaw
  14.   while true do
  15.    term.clear()
  16.    term.setCursorPos(1,1)
  17.      write("User: "..textu)
  18.    term.setCursorPos(1,2)
  19.      write("Password: ")
  20.    input = read("*")
  21.   if input == debug then
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.      print("Entering debug mode...")
  25.       sleep(sleepTime)
  26.     term.clear()
  27.     term.setCursorPos(1,1)
  28.      break
  29.   elseif input == textp then
  30.    term.clear()
  31.    term.setCursorPos(1,1)
  32.     write("Password correct!")
  33.     rs.setOutput(texts, true)
  34.     sleep(sleepTime)
  35.     rs.setOutput(texts, false)
  36.   else
  37.    term.clear()
  38.    term.setCursorPos(1,1)
  39.     write("Password incorrect...")
  40.     sleep(sleepTime)
  41.  end
  42. end
  43. os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement