Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent=os.pullEventRaw
- local function loadConfig(file)
- local fConfig = fs.open(file, "r")
- local ret = textutils.unserialize(fConfig.readAll())
- fConfig.close()
- return ret
- end
- local function saveConfig(table, file)
- local fConfig = fs.open(file, "w") or error("Cannot open file "..file, 2)
- fConfig.write(textutils.serialize(table))
- fConfig.close()
- end
- term.clear()
- term.setCursorPos(1,1)
- if not fs.exists("login") then
- term.setTextColor(colors.red)
- print [[
- +-----------------------------------+
- | |
- | |
- | Welcome to RedOS |
- | |
- | [ Press Any Key To Continue ] |
- | |
- | |
- +-----------------------------------+
- ]]
- if os.pullEvent("key") ~= nil then
- term.clear()
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | User not Registered |
- | |
- | [ Press Any Key To Continue ] |
- | |
- | |
- +-----------------------------------+
- ]]
- if os.pullEvent("key") ~= nil then
- term.clear()
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | Choose Your Username |
- | |
- | Username: |
- | |
- | |
- +-----------------------------------+
- ]]
- term.setCursorPos(12,6)
- term.setTextColor(colors.white)
- user=read()
- term.clear()
- term.setTextColor(colors.red)
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | Choose Your Password |
- | |
- | Password: |
- | |
- | |
- +-----------------------------------+
- ]]
- term.setCursorPos(12,6)
- term.setTextColor(colors.white)
- pass=read("*")
- term.clear()
- term.setTextColor(colors.red)
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | Choose Your Name |
- | |
- | Name: |
- | |
- | |
- +-----------------------------------+
- ]]
- term.setCursorPos(8,6)
- term.setTextColor(colors.white)
- name=read()
- saveConfig({user,pass,name},"login")
- term.clear()
- term.setTextColor(colors.red)
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | Registering Sucessful |
- | |
- | Now Rebooting |
- | |
- | |
- +-----------------------------------+
- ]]
- os.sleep(1)
- os.reboot()
- end
- end
- end
- -- End
- login = loadConfig("login")
- term.setTextColor(colors.red)
- print [[
- +-----------------------------------+
- | |
- | |
- | Welcome to RedOS |
- | |
- | [ Press Any Key To Continue ] |
- | |
- | |
- +-----------------------------------+
- ]]
- if os.pullEvent("key") ~= nil then
- term.clear()
- term.setCursorPos(1,1)
- print [[
- +-----------------------------------+
- | |
- | |
- | Username: |
- | |
- | Password: |
- | |
- | |
- +-----------------------------------+
- ]]
- term.setTextColor(colors.white)
- term.setCursorPos(12,4)
- username=read()
- term.setCursorPos(12,6)
- password=read("*")
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- if username == login[1] then
- if password == login[2] then
- print [[
- +-----------------------------------+
- | |
- | |
- | |
- | Correct Password |
- | |
- | |
- | |
- +-----------------------------------+
- ]]
- sleep(2)
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome, "..login[3])
- print("Today is day "..os.day())
- shell.run("cmdline")
- else
- print [[
- +-----------------------------------+
- | |
- | |
- | |
- | Wrong Password |
- | |
- | |
- | |
- +-----------------------------------+
- ]]
- sleep(2)
- term.clear()
- sleep(1)
- os.reboot()
- end
- else
- print [[
- +-----------------------------------+
- | |
- | |
- | |
- | Wrong Username |
- | |
- | |
- | |
- +-----------------------------------+
- ]]
- sleep(2)
- term.clear()
- sleep(1)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement