Advertisement
Guest User

Security Program

a guest
Oct 11th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. function Security()
  4.   term.setTextColor(colors.cyan)
  5.   print("Please Provide Security Key\n")
  6.   print("Password: ")
  7.   password = read("*")
  8.   if password == "TestPass" then
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11.     term.setTextColor(colors.green)
  12.     print("Security Key Accepted")
  13.     print(" ")
  14.     print("Access Granted")
  15.     redstone.setOutput("right", true)
  16.     sleep(10)
  17.     redstone.setOutput("right", false)
  18.   else
  19.     term.setTextColor(colors.red)
  20.     print("User or Security Key is Invalid.")
  21.     sleep(1)
  22.   end
  23. end
  24.  
  25. function Authentication()
  26.   term.clear()
  27.   term.setCursorPos(1, 1)
  28.   term.setTextColor(colors.cyan)
  29.   print("Welcome. Please input User Identification Key\n")
  30.   print("User ID: ")
  31.   username = read()
  32.   if username == "TestName" then
  33.     term.clear()
  34.     term.setCursorPos(1, 1)
  35.     term.setTextColor(colors.green)
  36.     print("User Identification Key Accepted\n")
  37.     term.setTextColor(colors.purple)
  38.     print("Welcome.")
  39.     Security()
  40.   else
  41.     term.setTextColor(colors.red)
  42.     print("Invalid User. Session Terminated.")
  43.     sleep(1)
  44.   end
  45. end
  46.  
  47. function Start()
  48.   while true do --# start an infinite loop
  49.     Proximity = rs.getAnalogInput("left")
  50.     if Proximity == 5 then Authentication() end
  51.   end
  52. end
  53.  
  54. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement