Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --os.pullEvent = os.pullEventRaw
- --Variables
- local inputU = ("")
- local inputP = ("")
- local os = ("DankOS")
- local osV = ("1.2")
- --Functions
- function rawread() --Key Input
- while true do
- local sEvent, param = os.pullEvent("key")
- if sEvent == "key" then
- if param == 44 then
- colorC()
- print("Admin override")
- colorW()
- break
- end
- end
- end
- end
- function clear() --Clear fucntion
- term.clear()
- term.setCursorPos(1,1)
- end
- function loadingS() --Loading screen
- colorC()
- textutils.slowPrint("<==========>", 10)
- colorW()
- sleep(1)
- end
- function bootS() --Boot screen
- clear()
- colorC()
- print("|----------|")
- write("|"..os)
- print(" "..osV.."|")
- print("|----------|")
- colorW()
- end
- function loginS() --Login screen
- file = fs.open("os/.User/"..passwordR,"r")
- local fileDataP = {}
- local line = file.readLine()
- repeat
- table.insert(fileDataP, line)
- line = file.readLine()
- until line == nil
- file.close()
- local pass = fileDataP[1]
- -- ------------------
- file = fs.open("os/.User/"..usernameR,"r")
- local fileDataU = {}
- local line = file.readLine()
- repeat
- table.insert(fileDataU,line)
- line = file.readLine()
- until line == nil
- file.close()
- local user = fileDataU[1]
- -- -------------------
- clear()
- colorC()
- print("Welcome!")
- write("Username: ")
- colorY()
- inputU = read()
- if inputU == user then
- colorG()
- print("Correct")
- colorW()
- end
- if inputU ~= user then
- colorR()
- print("Incorrect!")
- colorW()
- sleep(1)
- loginS()
- end
- colorC()
- write("Password: ")
- colorY()
- inputP = read("*")
- if inputP == pass then
- colorG()
- print("Correct") --Correct password
- colorW()
- sleep(1)
- clear()
- end
- if inputP ~= pass then --Incorrect password
- colorR()
- print("Incorrect!")
- colorW()
- sleep(1)
- loginS()
- end
- end
- function mainS() --Main screen
- bootS()
- end
- function yN() --Yes/No function "Ugly Code"
- local n=1
- while true do
- local x, y=term.getCursorPos()
- term.clearLine()
- if n==1 then write(">YES< NO") else write (" YES >NO<") end
- term.setCursorPos(x, y)
- a, b=os.pullEvent()
- while a~="key" do a, b=os.pullEvent() end
- if b==203 and n==2 then n=1 end
- if b==205 and n==1 then n=2 end
- if b==28 then print("") break end
- end
- if n==1 then return true end
- if n==2 then return false end
- return false
- end
- function startS() --Startup screen
- clear()
- colorC()
- write("Welcome to "..os)
- print(" "..osV)
- print("Do you want to create a user Y/N?")
- colorY()
- colorW()
- end
- function regS() --Register screen
- clear()
- colorC()
- bootS()
- print("Time to create a new user")
- colorC()
- write("Username: ")
- colorY()
- usernameR = read()
- colorC()
- write("Password: ")
- colorY()
- passwordR = read()
- colorW()
- fs.makeDir("os/.User")
- fs.makeDir("os/.User")
- local file = fs.open("os/.User/"..usernameR,"a")
- file.writeLine(usernameR)
- file.close()
- local file = fs.open("os/.User/"..passwordR, "a")
- file.writeLine(passwordR)
- file.close()
- end
- function colorW() -- White color
- term.setTextColor(colors.white)
- end
- function colorG() --Green color
- term.setTextColor(colors.green)
- end
- function colorR() --Red color
- term.setTextColor(colors.red)
- end
- function colorC() --Cyan color
- term.setTextColor(colors.cyan)
- end
- function colorY() --Yellow color
- term.setTextColor(colors.yellow)
- end
- --Main stuff
- startS()
- bootS()
- colorW()
- sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement