Biopsy

Mincraft Lock V4

Apr 27th, 2012
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Settings
  2. passwords={"PepsiMax", "PepsiMin"} --password(s) for the terminal
  3. matchcase=true                     --require capital/lowercase letters to match?
  4. sides={"left", "right"}            --side(s) to activate on correct password
  5. triggerfor=5                       --how long to activate redstone after success
  6. lockout=2                          --lockout period after incorrect password
  7. antiguess=true                     --increase lockout for each incorrect password?
  8.  
  9. function passprompt()
  10.   term.clear()
  11.   term.setCursorPos(1,1)
  12.   term.write("Enter password: ")
  13.   entry=read("*")
  14.   for i=1, #passwords do
  15.     if((entry==passwords[i]) or ((matchcase == false) and (string.lower(value) == string.lower(passwords[i])))) then
  16.       term.write("correct.")
  17.       attempts=0
  18.       cycledoor()
  19.       return true
  20.     end
  21.   end
  22.   term.write("incorrect.")
  23.   attempts=attempts+1
  24.   if(antiguess) then
  25.     sleep(lockout*attempts)
  26.   else
  27.     sleep(lockout)
  28.   end
  29. end
  30.  
  31. function setsides(toggle)
  32.   for i=1, #sides do redstone.setOutput(sides[i], toggle) end
  33. end
  34.  
  35. function cycledoor()
  36.   setsides(true)  
  37.   sleep(triggerfor)
  38.   setsides(false)
  39. end
  40.  
  41. attempts=0
  42. os.pullEvent = os.pullEventRaw
  43. while true do passprompt() end
Advertisement
Add Comment
Please, Sign In to add comment