3 posts
                
             
            
                Posted 23 July 2012 - 10:34 PM
                The door must be able to:
- Allow entry for 5 seconds after the correct password is entered (bottom redstone turned on)
 - Engage security after 5 failed password attempts (top redstone turned on)
 - Disengage security after the correct password is entered.
 
 
                
             
         
        
        
            
            
                
                    
                
                20 posts
                
             
            
                Posted 24 July 2012 - 12:44 AM
                Here it is. Just change the value of "pass" to adjust you password. "quits" is the way I left in the program for a user to exit the lock. Also,
--prevent ctrl+t escape
os.pullEvent = os.pullEventRaw
--print greeting and reset value of i
function greet()
term.clear()
term.setCursorPos(1,1)
print("Enter Password:")
i = 0
end
--declare passwords
local pass  = "bacon"
local quits = "quits"
--start the normal lock
function lock()
input = read("*") --set user input to look like asteriks
if input == pass then
  term.scroll(-1)
  term.clearLine()
  term.scroll(1)
  print("Password correct!")
  rs.setOutput("bottom",true)
  sleep(5)
  rs.setOutput("bottom",false)
  greet()
  lock()
elseif input == quits then --check to see if input allows the user to quit
  shell.programs() -- quit progarm
elseif i == 4 then -- make sure that you haven't exceeded your allotment of tries
  lock2()
else -- if your here, it means that you did't exceed your allotment of tries, and that you haven't put in the right pass
  i = i+1 --add to allotment count
  term.scroll(-1)
  term.clearLine()
  term.scroll(1)
  print("Incorrect. You have failed ", i," times")
  lock()
end
end
function lock2() --this is the "security" lockout
term.clear()
term.setCursorPos(1,1)
print("Enter Password:")
print("Please contact this console's owner to unlock this machine")
rs.setOutput("top",true)
input = read("*")
if input == pass then
  rs.setOutput("top",false)
  greet()
  lock()
else
  lock2()
end
end
greet()
lock()
Please let me know if this works.
Thanks,
Matt