Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minif OS Login
- --Functions
- osBGImageExists = false
- osUserImageExists = false
- if fs.exists("/system/images/minif") then
- os_BGImage = paintutils.loadImage("/system/images/minif")
- osBGImageExists = true
- end
- function osPaintLockScreen()
- osFillBG(colors.black)
- if osBGImageExists then
- paintutils.drawImage(os_BGImage,1,1)
- end
- paintutils.drawFilledBox(1,1,osScreenSizeX,5,colors.white)
- paintutils.drawBox(2,4,osScreenSizeX-2,4,colors.lightGray)
- term.setBackgroundColor(colors.red)
- term.setCursorPos(osScreenSizeX-4,1)
- term.setTextColor(colors.black)
- term.write("Power")
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(2,2)
- term.write("Username:")
- end
- function osInputUserName()
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(2,4)
- osEnteredUser = read()
- end
- function osDrawUserProfile(user)
- if fs.exists("/system/user/" .. user .. "/icon") then
- os_UserImage = paintutils.loadImage("/system/user/"..user.."/icon")
- osUserImageExists = true
- paintutils.drawImage(os_UserImage,(osScreenSizeX/2)-3,8)
- end
- end
- function osInputUserPassword(user)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos((osScreenSizeX/2)-3,15)
- osEnteredPassword = read("*")
- if fs.exists("/system/user/"..user.."/.pass") then
- osPassword = fs.open("/system/user/"..user.."/.pass","r")
- if osEnteredPassword == osPassword.readAll() then
- if fs.exists("/system/desktop") then
- osPassword.close()
- shell.run("/system/desktop")
- else
- osPassword.close()
- if fs.exists("/disk/system/desktop") then
- osFillBG(colors.cyan)
- print("Found desktop file on disk")
- print("Copying file from disk...")
- fs.copy("disk/system/desktop","system/desktop")
- print("Done!")
- sleep(3)
- shell.run("/system/desktop")
- else
- osBSOD("Critical file missing.","/system/desktop is missing, and is needed to run.","Please re-install this file")
- end
- end
- else
- term.setCursorPos(2,1)
- term.setTextColor(colors.red)
- term.write("Invalid Password!")
- term.setTextColor(colors.black)
- sleep(1)
- end
- else
- osBSOD("Critical file missing.", "The user does not have a password file, and is needed to login", "You may need to re-configure the user.")
- end
- end
- function osCheckUser()
- if fs.isDir("/user/"..osEnteredUser) and not (osEnteredUser == "") then
- osDrawUserProfile(osEnteredUser)
- osInputUserPassword(osEnteredUser)
- osPaintLockScreen()
- else
- osPaintLockScreen()
- term.setCursorPos(2,1)
- term.setTextColor(colors.red)
- term.write("Invalid User!")
- term.setTextColor(colors.black)
- end
- end
- --Execution
- osPaintLockScreen()
- if fs.exists("/system/setupdata") then else
- if fs.exists("/system/tools/setup") then
- shell.run("/system/tools/setup")
- else
- osBSOD("Critical file missing.","/system/tools/setup is missing, and is needed to perform initial setup.","Please re-install this file")
- end
- osPaintLockScreen()
- end
- if fs.exists("/apps") then else
- fs.makeDir("/apps")
- end
- while true do
- osPEvent, osPB, osPX, osPY = os.pullEvent()
- if osPEvent == "key" then
- osInputUserName()
- osCheckUser()
- else
- if osPY == 4 then
- osInputUserName()
- osCheckUser()
- end
- if osPY == 1 and osPX >= osScreenSizeX-4 then
- os.shutdown()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement