Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bar1 = paintutils.loadImage(".bar1")
- logo = paintutils.loadImage(".logo")
- icon = paintutils.loadImage(".icon")
- tBarC = 8
- tBartC = 1
- backColor = 1
- scroll = 0
- Version = "Alpha [0.1]"
- credCol = 32
- firstCol = 1
- secCol = 2048
- Author = "Mackan90096"
- ErrCol1 = 16384
- calcCol = 128
- --Desktop
- term.setBackgroundColor(backColor)
- term.clear()
- slc = 0
- function credits()
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(credCol)
- print("Credits")
- term.setCursorPos(1,3)
- print("Programs and apis:")
- term.setCursorPos(1,5)
- print("CCalendar - TheOriginalBIT")
- term.setCursorPos(1,6)
- print("Passgen - Conn332")
- term.setCursorPos(1,7)
- print("CCleverbot - 1lann and GravityScore")
- term.setCursorPos(1,9)
- print("Help in development:")
- term.setCursorPos(1,11)
- print("All the great people that helped me on the forums! - You know who you are :)")
- term.setCursorPos(1,13)
- write("To return type anything and hit enter: ")
- local input = read()
- if input == "1" then
- term.clear()
- drawDesktop()
- else
- term.clear()
- drawDesktop()
- end
- end
- function login()
- term.clear()
- term.setCursorPos(1,1)
- print("Logging in")
- term.setCursorPos(1,3)
- write("Username: ")
- usrName = read()
- write("Password: ")
- local pass = read("*")
- file = fs.open("users/"..usrName,"r")
- if not fs.exists("users/"..usrName) then
- term.clear()
- term.setCursorPos(1,1)
- print("Login failed")
- sleep(1)
- term.clear()
- drawDesktop()
- elseif fs.exists("users/"..usrName) then
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData, line)
- line = file.readLine()
- until line == nil -- readLine()
- file.close()
- local passFromFile = fileData[1]
- if pass == passFromFile then
- term.clear()
- term.setCursorPos(1,1)
- print("Login succeded!")
- sleep(1)
- term.clear()
- drawDesktop2()
- slc = 2
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Login failed!")
- sleep(1)
- term.clear()
- drawDesktop()
- end
- end
- end
- function register()
- term.clear()
- term.setCursorPos(1,1)
- print("Registering")
- term.setCursorPos(1,3)
- write("Username: ")
- local usrName = read()
- term.setCursorPos(1,4)
- write("Password: ")
- local pass = read("*")
- fs.makeDir("users")
- if not fs.exists("users/"..usrName) then
- local file = fs.open("users/"..usrName, "a")
- file.writeLine(pass)
- file.close()
- sleep(0.5)
- term.clear()
- term.setCursorPos(1,1)
- print("Registered!")
- sleep(0.5)
- term.clear()
- drawDesktop()
- elseif fs.exists("users/"..usrName) then
- term.clear()
- term.setCursorPos(1,1)
- print("Username already in use!")
- sleep(1)
- term.clear()
- drawDesktop()
- end
- end
- function titleBar2()
- term.setCursorPos(1,1)
- term.setBackgroundColor(tBarC)
- term.setTextColor(tBartC)
- term.clearLine()
- term.setCursorPos(3,1)
- print("[Begin]")
- term.setCursorPos(12,1)
- print("Logged in as: "..usrName)
- end
- function drawDesktop2()
- slc = 2
- term.setBackgroundColor(backColor)
- term.clear()
- paintutils.drawImage(logo,1,1)
- paintutils.drawImage(icon,2,3)
- titleBar2()
- end
- function drawMenu2()
- term.setTextColor(256)
- term.setBackgroundColor(128)
- term.setCursorPos(1,2)
- print(" ")
- term.setCursorPos(1,3)
- print("Logout ")
- term.setCursorPos(1,4)
- print("Calculator")
- term.setCursorPos(1,5)
- print("Games ")
- term.setCursorPos(1,6)
- print("Account ")
- term.setCursorPos(1,7)
- print("Calendar ")
- term.setCursorPos(1,8)
- print("Email ")
- term.setCursorPos(1,9)
- print("Shutdown ")
- term.setCursorPos(1,10)
- print("Reboot ")
- term.setCursorPos(1,11)
- print(" ")
- end
- function titleBar()
- term.setCursorPos(1,1)
- term.setBackgroundColor(tBarC)
- term.setTextColor(tBartC)
- term.clearLine()
- term.setCursorPos(3,1)
- print("[Begin]")
- end
- function drawDesktop()
- slc = 0
- term.setBackgroundColor(backColor)
- term.clear()
- paintutils.drawImage(logo,1,1)
- titleBar()
- end
- function drawMenu1()
- term.setTextColor(256)
- term.setBackgroundColor(128)
- term.setCursorPos(1,2)
- print(" ")
- term.setCursorPos(1,3)
- print(" Login ")
- term.setCursorPos(1,4)
- print(" Register ")
- term.setCursorPos(1,5)
- print(" Reboot ")
- term.setCursorPos(1,6)
- print(" Shutdown ")
- term.setCursorPos(1,7)
- print(" Passgen ")
- term.setCursorPos(1,8)
- print(" Credits ")
- term.setCursorPos(1,9)
- print(" ")
- end
- drawDesktop()
- while true do
- local event, button, X, Y = os.pullEventRaw()
- if slc == 0 then
- if event == "mouse_click" then
- if X >= 2 and X <= 8 and Y == 1 and button == 1 then
- drawMenu1()
- slc = 1
- drawDesktop()
- end
- end
- elseif slc == 1 then
- if X >= 1 and X <= 11 and button == 1 and Y == 3 then slc = 0
- login()
- elseif X >= 1 and X <= 11 and Y == 4 and button == 1 then slc = 0
- register()
- elseif X >= 1 and X <= 11 and Y == 5 and button == 1 then slc = 0
- os.reboot()
- elseif X >= 1 and X <= 11 and Y == 6 and button == 1 then slc = 0
- os.shutdown()
- elseif X >= 1 and X <= 11 and Y == 7 and button == 1 then slc = 0
- passgen()
- elseif X >= 1 and X <= 11 and Y == 8 and button == 1 then slc = 0
- credits()
- else slc = 0
- drawDesktop()
- end
- elseif slc == 2 then
- if X >= 1 and X <= 11 and button == 1 and Y == 3 then slc = 3
- elseif X >= 2 and X <= 5 and Y >= 3 and Y <= 9 and button == 1 then
- shell.run("file")
- else slc = 2
- drawDesktop2()
- end
- elseif slc == 3 then
- if X >= 2 and X <= 8 and Y == 1 and button == 1 then
- drawMenu2()
- slc = 2
- drawDesktop2()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement