Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local desktopBackground(colors.white)
- --Change this since you dont want you background
- -- to have a weird outline. Options are
- --colors.white, colors.green, colors.blue
- --colors.lightBlue, colors.red, colors.lightGrey,
- --colors.grey, colors.yellow, colors.pink,
- --colors.lime, colors.orange, colors.magenta,
- --colors.cyan, colors.purple, & colors.brown
- --os.pullEvent = os.pullEventRaw
- function deskReset()
- term.setBackgroundColor(colors.white)
- term.clear()
- end
- function loginButton()
- term.setCursorPos(1.5,1)
- print("[Login]")
- end
- function titleBar()
- term.setCursorPos(1,1)
- term.setBackgroundColor(8)
- term.setTextColor(colors.white)
- term.clearLine()
- term.setCursorPos(40,1)
- print("Rock OS V. 1")
- end
- function file()
- local FileList = fs.list("")
- term.setBackgroundColor(2048)
- term.clear()
- titleBarPost()
- term.setCursorPos(1,2)
- term.setTextColor(colors.white)
- local counter = 0
- for _, file in ipairs(FileList) do
- if counter % 2 == 0 then
- term.setBackgroundColor(colors.gray)
- else
- term.setBackgroundColor(colors.lightGray)
- end
- term.clearLine()
- print(file)
- counter = counter + 1
- end
- end
- function titleBarLogin()
- titleBar()
- loginButton()
- end
- function titleBarPost()
- titleBar()
- term.setCursorPos(2, 1)
- print("Hello, "..user)
- end
- function drawPreDesktop()
- deskReset()
- bground = paintutils.loadImage(".background")
- paintutils.drawImage(bground, 1, 1)
- titleBarLogin()
- loginWait()
- end
- function drawLoginDesktop()
- deskReset()
- bground = paintutils.loadImage(".background")
- paintutils.drawImage(bground, 1, 1)
- titleBar()
- end
- function drawDesktop()
- deskReset()
- bground = paintutils.loadImage(".background")
- paintutils.drawImage(bground, 1, 1)
- titleBarPost()
- icon = paintutils.loadImage(".icon")
- paintutils.drawImage(icon, 1, 1)
- end
- function loginWait()
- while true do
- local event, button, X, Y = os.pullEvent()
- if slc == 0 then
- if event == "mouse_click" then
- if X >=0.5 and X <= 7.5 and Y == 1 and button == 1 then
- login()
- else
- drawPreDesktop()
- end
- end
- end
- end
- end
- function deskWait()
- local event, button, X, Y = os.pullEvent()
- if event == "mouse_click" then
- if button == 1 then
- if X >= 2 and X <= 5 and Y >= 3 and Y <= 7 then
- file()
- end
- end
- end
- end
- function login()
- drawLoginDesktop()
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- username = {"this slot", "Zaydok", "test"}
- password = {"never works", "bobjeffjeff", "test"}
- i = # username
- write("Username: ")
- user = read()
- write("Password: ")
- pass = read()
- for i = 0, i do
- if user == username[i] and pass == password[i] then
- access = true
- else
- access = false
- end
- end
- if access == true then
- print("Logging in...")
- sleep(1)
- print("Welcome "..user)
- drawDesktop()
- deskWait()
- elseif access == false then
- print("Incorrect username and password combination")
- sleep(2)
- os.reboot()
- end
- end
- drawPreDesktop()
Advertisement
Add Comment
Please, Sign In to add comment