Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Settings
- passwords={"PepsiMax", "PepsiMin"} --password(s) for the terminal
- matchcase=true --require capital/lowercase letters to match?
- sides={"left", "right"} --side(s) to activate on correct password
- triggerfor=5 --how long to activate redstone after success
- lockout=2 --lockout period after incorrect password
- antiguess=true --increase lockout for each incorrect password?
- function passprompt()
- term.clear()
- term.setCursorPos(1,1)
- term.write("Enter password: ")
- entry=read("*")
- for i=1, #passwords do
- if((entry==passwords[i]) or ((matchcase == false) and (string.lower(value) == string.lower(passwords[i])))) then
- term.write("correct.")
- attempts=0
- cycledoor()
- return true
- end
- end
- term.write("incorrect.")
- attempts=attempts+1
- if(antiguess) then
- sleep(lockout*attempts)
- else
- sleep(lockout)
- end
- end
- function setsides(toggle)
- for i=1, #sides do redstone.setOutput(sides[i], toggle) end
- end
- function cycledoor()
- setsides(true)
- sleep(triggerfor)
- setsides(false)
- end
- attempts=0
- os.pullEvent = os.pullEventRaw
- while true do passprompt() end
Advertisement
Add Comment
Please, Sign In to add comment