Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Security #1
- -- Password lock
- -- Code written by jag_e_nummer_ett
- local oldPull = os.pullEvent;
- os.pullEvent = os.pullEventRaw;
- function login()
- local password = "password"
- local inputPass = ""
- local tries = 5
- while inputPass ~= password do
- term.clear()
- if tries < 5 then
- term.setCursorPos(3,5)
- print("Incorrect password!")
- end
- term.setCursorPos(3,2)
- print("Please enter password")
- term.setCursorPos(3,4)
- print("Tries left: "..tries)
- term.setCursorPos(3,3)
- write("Password: ")
- inputPass = read("*")
- tries = tries - 1
- if tries == 0 then
- return false
- end
- end
- return true
- end
- if login() then
- term.clear()
- term.setCursorPos(3,2)
- print("Login successful!")
- sleep(1.5)
- else
- term.clear()
- term.setCursorPos(3,2)
- print("Login failed!")
- sleep(1.5)
- os.shutdown()
- end
- os.pullEvent = oldPull;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement