Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw -- Cancelles CTRL T
- -- Variables
- username = "finnanut"
- sudoUser = "toor"
- password = "inmybutt"
- attemptsMade = 0
- doorSide = "bottom"
- local center = function(text)
- maxW, mxH = term.getSize()
- cursorX, cursorY = term.getCursorPos()
- term.setCursorPos((maxW - #text) / 2, cursorY)
- write(text)
- term.setCursorPos(cursorX, cursorY + 1)
- end
- function checkAttempts()
- if attemptsMade > 2 then
- term.clear()
- term.setCursorPos(1, 1)
- center("Too many attempts have been made.")
- center("Please try again in 2 minutes.")
- sleep(120)
- os.reboot()
- end
- end
- function doLogin()
- checkAttempts()
- term.clear()
- if attemptsMade > 0 then
- center("Attempts made: " .. attemptsMade)
- end
- write("Username: ")
- userInput = read()
- if userInput == sudoUser then
- term.clear()
- term.setCursorPos(1, 1)
- center("Welcome into the computer.")
- elseif userInput == username then
- write("Password: ")
- passwordInput = read("*")
- if passwordInput == password then
- term.clear()
- term.setCursorPos(1, 1)
- center("Welcome back.")
- sleep(1)
- rs.setOutput(doorSide, true)
- sleep(2)
- rs.setOutput(doorSide, false)
- term.setCursorPos(1, 1)
- os.reboot()
- else
- term.clear()
- center("Incorrect password.")
- attemptsMade = attemptsMade + 1
- sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- doLogin()
- end
- else
- term.clear()
- term.setCursorPos(1, 1)
- center("Incorrect username.")
- attemptsMade = attemptsMade + 1
- sleep(1)
- term.clear()
- term.setCursorPos(1, 1)
- doLogin()
- end
- end
- doLogin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement