Sayomie550

Untitled

Jan 17th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local doorSide = "left"
  2. local alarmSide = "top"
  3. local password = "open"
  4. local alarmCode = "stop"
  5. local opentime = 5
  6. local alarm = false
  7. local attempts = 0
  8.  
  9. while true do
  10.  term.clear()
  11.  term.setCursorPos(1,1)
  12.  write("Password: ")
  13.  local input = read("*")
  14.  if input == password then
  15.   term.clear()
  16.   term.setCursorPos(1,1)
  17.   print("Password correct!")
  18.   rs.setOutput(doorSide,true)
  19.   sleep(opentime)
  20.   rs.setOutput(doorSide,false)
  21.  else
  22.   print("Password incorrect!")
  23.   rs.setOutput(alarmSide,true)
  24.   alarm = true
  25.   sleep(2)
  26.   while alarm == true do
  27.     term.clear()
  28.     term.setCursorPos(1,1)
  29.     write("Alarm Reset Code: ")
  30.     local alarmInput = read("*")
  31.     print("attempts: "..attempts)
  32.     if alarmInput == alarmCode then
  33.         rs.setOutput(alarmSide,false)
  34.         alarm = false
  35.         attempts = 0
  36.         term.clear()
  37.         term.setCursorPos(1,1)
  38.         print("Alarm Reset")
  39.         sleep(2)
  40.     else
  41.         attempts = attempts + 1
  42.     end
  43.   end
  44.  end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment