View difference between Paste ID: Pexr8GpL and 71vYYGhv
SHOW: | | - or go back to the newest paste.
1
--Settings
2
passwords={"PepsiMax", "PepsiMin"} --password(s) for the terminal
3-
side="left"                        --side to activate on correct password
3+
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-
  entry=io.read()
11+
12
  term.write("Enter password: ")
13
  entry=read("*")
14-
      term.write("correct.") 
14+
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-
  sleep(2)
20+
21
  end
22
  term.write("incorrect.")
23
  attempts=attempts+1
24-
  redstone.setOutput(side, true)
24+
  if(antiguess) then
25-
  sleep(5)
25+
    sleep(lockout*attempts)
26-
  redstone.setOutput(side, false)
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