Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --os.pullEvent = os.pullEventRaw
- local monitor = peripheral.find("monitor")
- pro = shell.getRunningProgram()
- credentialsFile = pro.."Creds"
- userInput = ""
- passInput = ""
- promptInput = ""
- function lock()
- if fs.exists(credentialsFile) then
- local file = fs.open(credentialsFile, "r")
- user = file.readLine(1)
- pass = file.readLine(2)
- prompt = file.readLine(3)
- file.close()
- end
- -------------------------------------
- if prompt == nil then
- term.clear()
- term.setCursorPos(1,1)
- textutils.slowPrint("Hello, what would you like your username to be?")
- term.setTextColor(colors.yellow)
- userInput = read()
- term.setTextColor(colors.white)
- textutils.slowPrint("Hello "..userInput..". \nWhat would you like your password to be?")
- term.setTextColor(colors.yellow)
- passInput = read()
- term.setTextColor(colors.white)
- textutils.slowPrint("What would you like your message to say before \ndisplaying your login prompt?")
- term.setTextColor(colors.yellow)
- promptInput = read()
- term.setTextColor(colors.white)
- -------------------------------------
- while true do
- if not fs.exists(credentialsFile) then
- local file = fs.open(credentialsFile, "w")
- file.write(userInput)
- file.write("\n"..passInput)
- file.write("\n"..promptInput)
- file.close()
- break
- end
- end
- -------------------------------------
- textutils.slowPrint("Okay, setup finished. Rebooting in 2 seconds")
- sleep(2)
- os.reboot()
- end
- -------------------------------------
- if peripheral.find("monitor") then
- monitor.setTextScale(3)
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- monitor.setCursorPos(2,5)
- monitor.write("Currently Locked")
- end
- -------------------------------------
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- textutils.slowPrint(prompt)
- term.setTextColor(colors.white)
- sleep(1)
- textutils.slowWrite("Username: ")
- input1= term.setTextColor(colors.yellow)
- input1 = read()
- term.setTextColor(colors.white)
- textutils.slowWrite("Password: ")
- input2 = term.setTextColor(colors.yellow)
- input2 = read("*")
- if user == input1 and pass == input2 then
- if peripheral.find("monitor") then
- monitor.setTextScale(3)
- monitor.setBackgroundColor(colors.green)
- monitor.clear()
- monitor.setCursorPos(2,5)
- monitor.write("Currently Unlocked")
- end
- term.setTextColor(colors.green)
- term.setCursorPos(1,4)
- textutils.slowPrint("Valid Login Credentials. Welcome to the System.")
- sleep(2)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- print(os.version())
- term.setCursorPos(1,2)
- else
- term.setCursorPos(1,4)
- term.setTextColor(colors.red)
- textutils.slowPrint("Invalid Login Credenials, Please Don't Try Again.")
- sleep(2)
- lock()
- end
- end
- if not fs.exists("startup") then
- local file = fs.open("startup", "w")
- file.write("shell.run(\"")
- file.write(pro)
- file.write("\")")
- file.close()
- os.reboot()
- else
- local file = fs.open("startup", "r")
- local readFile = file.readAll()
- file.close()
- if not string.find(readFile,"shell.run") then
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- textutils.slowPrint("You already have a startup, would you like to delete it (y/n)?")
- local input = read()
- if input == "y" then
- textutils.slowPrint("Deleting startup.")
- fs.delete("startup")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- textutils.slowPrint("Finished, now rebooting")
- sleep(1)
- os.reboot()
- end
- end
- end
- lock()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement