Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- users = { "calvin" , "andrew" , "adi" , "bob"}
- pass = { "3804" , "2971", "jammin" , "101" }
- accesslevels = { 6 , 5 , 5 , 2 }
- requiredaccess = 5
- repeat
- correctuser = false
- correctpassword = false
- canaccess = false
- accessed = false
- term.clear()
- term.setCursorPos(16,7)
- write("Username: ")
- user = read()
- for i,v in ipairs(users) do
- if user == v
- then
- correctuser = true
- password = pass[i]
- accesslevel = accesslevels[i]
- term.setCursorPos(16,8)
- write("Password: ")
- if read("*") == password
- then
- correctpassword = true
- if accesslevel >= requiredaccess
- then
- canaccess = true
- end
- end
- end
- end
- if correctuser == true and correctpassword == true and
- canaccess == true
- then term.setCursorPos(1,7)
- term.clear()
- print(" Access Allowed")
- print("")
- print(" Welcome Back "..user)
- accessed = true
- elseif correctuser == true and correctpassword == true and canaccess == false
- then
- n = tonumber(accesslevel)
- s = ""
- for i = 1, n do
- s = s.."*"
- end
- m = tonumber(requiredaccess)
- d = ""
- for i = 1, m do
- d = d.."*"
- end
- term.setCursorPos(1,6)
- term.clear()
- print(" Access Denied")
- print(" Failed Access check")
- print("")
- print("")
- print("")
- print(" Your Access is "..s)
- print(" This process requires "..d)
- sleep(5)
- elseif
- correctuser == false
- then
- term.setCursorPos(1,7)
- print(" Access Denied")
- print(" "..user.." is not a registered user")
- sleep(3)
- elseif
- correctuser == true and correctpassword == false
- then
- term.clear()
- term.setCursorPos(1,8)
- print(" Incorrect Password")
- sleep(2)
- --os.reboot()
- else
- print("Access Denied")
- end
- until
- accessed == true
- sleep(1)
Add Comment
Please, Sign In to add comment