jonathonrox

computercraft advanced password lock

Apr 28th, 2012
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. choice=0
  2. z=0
  3.  
  4. function timer(fa)
  5.  for f = 1, fa do
  6.   term.clear()
  7.   term.setCursorPos(4,8)
  8.   print("You have been locked out for "..tostring(fa-f).." seconds.")
  9.   sleep(1)
  10.  end
  11. end
  12.  
  13. repeat
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. print("|----------------------------|")                            
  17. print("|    (Enter the password)    |")
  18. print("|----------------------------|")
  19. print("|                            |")
  20. print("|----------------------------|")
  21. print("[Q][W][E][R][T][Y][U][I][O][P]")
  22. print(" [a][s][d][f][g][h][j][k][l]")
  23. print("    [z][x][c][v][b][n][m]")
  24. term.setCursorPos(2,4)
  25.  
  26.   i=read("*")
  27.  if i ~= "pass" then
  28.   print("WRONG!")
  29.   sleep(.4)
  30.   choice=choice+1
  31.  end
  32.  if choice == 4 and z == 0 then
  33.     term.clear()
  34.   term.setCursorPos(1,1)
  35.   print("Did you forget your password?")
  36.     local n=1
  37. while true do
  38.   local x, y=term.getCursorPos()
  39.   term.clearLine()
  40.  if n==1 then write(">YES<   NO") else write(" YES   >NO<") end
  41.   term.setCursorPos(x, y)
  42. a, b=os.pullEvent()
  43.  while a~="key" do a, b=os.pullEvent() end
  44.   if b==203 and n==2 then n=1 end
  45.   if b==205 and n==1 then n=2 end
  46.   if b==28 then print("") break end
  47.  end
  48.   if n==1 then
  49.    print("password hint: the usual")
  50.    sleep(4)
  51.    z=z+1
  52.   elseif n==2 then
  53.    print("try again, but dont mess up otherwise your gonna get locked out")
  54.    sleep(4)
  55.    z=z+1
  56.  end
  57.  
  58.  elseif choice == 5 then
  59.   timer(101)
  60.  elseif choice > 5 then
  61.   timer(151)
  62.  end
  63. until i == "pass"
  64. -- put whatever you want it to do if the password is correct right here
  65. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment