Advertisement
SpaceRanger4321

Password OS

Dec 31st, 2019
1,661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.31 KB | None | 0 0
  1. --[[
  2.  
  3. Startup file created by SpaceRanger4827
  4. GUI Created by Just Does Games on Discord
  5.  
  6. Dev notes:
  7. - [JDG] make sure you hide the password better so people cannot easily access them and edit them
  8. - [JDG] you code only allows for one password and not for many, i modified that to allow multiple and added a username section for those passwords
  9. - [JDG] same issues with startup, you should really check to see if the files exists or not, use fs.exists(file_name) < it returns a true or false depending on if the file exists
  10. - [JDG] I will eventually create an api for my shortcuts later down the line instead of importing them, but have not gotten to it
  11.  
  12.  
  13. ]]
  14.  
  15. -- Inported some of my shortcut functions -- (Just Does Games was here! :))
  16.  
  17. function clr() return term.clear() end
  18. function cp(x,y) return term.setCursorPos(x,y) end
  19. function setText(col) return term.setTextColor(colors[col]) end
  20. function setBack(col) return term.setBackgroundColor(colors[col]) end
  21. function notnil(vari) if vari == nil then return false else return true end end
  22.  
  23. -- Inported some of my shortcut functions -- (Just Does Games was here! :))
  24.  
  25. local w,h = term.getSize()
  26.  
  27. --Vars
  28.   icon = paintutils.loadImage("/.os/.backgrounds/pIcon")
  29.   bkColor = colors.gray
  30.   lnColor = colors.lightGray
  31.   txtColor = colors.lime
  32.   local logins = {{"admin", "root"}} -- {username, password}
  33. --Functions
  34.  
  35.  
  36. --Code
  37. function passwordDraw()
  38.   local running = true
  39.   while running do
  40.     setBack("yellow") setText("white") clr()
  41.     paintutils.drawFilledBox(2,2,13,10,colors["lightBlue"])
  42.     paintutils.drawFilledBox(2,13,w,17,colors["ligthGray"])
  43.     paintutils.drawLine(1,12,w,12,colors["gray"])
  44.     paintutils.drawLine(1,18,w,18,colors["gray"])
  45.     paintutils.drawLine(1,12,1,18,colors["gray"])
  46.    
  47.     paintutils.drawImage(icon,3,3) cp(2,14) setBack("lightBlue")
  48.     write("Username » ") user = read() cp(2,16)
  49.     write("Password » ") pass = read(string.char(7))
  50.     local login = false
  51.     for i=1, #logins do
  52.       if logins[i][1] == user and logins[i][2] == pass then
  53.         login = true
  54.       end
  55.     end
  56.     if login then
  57.       shell.run("/.os/.gui")
  58.       running = false
  59.     else
  60.       paintutils.drawFilledBox(1,3,w,6,colors["blue"])
  61.       cp(w/2-(string.len("Username or Password is incorrect.")/2),4) print("Username or Password is incorrect.")
  62.       cp(w/2-(string.len("Please try again.")/2),5) print("Please try again.")
  63.       paintutils.drawLine(1,2,w,2,colors["lightBlue"])
  64.       paintutils.drawLine(1,7,w,7,colors["lightBlue"])
  65.       sleep(2)
  66.     end
  67.   end
  68. end
  69. -- shell.run("/.os/.gui") -- SUCCESS!
  70. local ok, err = pcall(passwordDraw)
  71.  
  72. if not ok then
  73.     setBack("yellow") setText("white") clr()
  74.   setBack("gray") cp(1,h/2-4) term.clearLine() cp(1,h/2-4)
  75.   print("Yellow screen of Death") setText("yellow")
  76.   setBack("white")
  77.   cp(1,h/2-3)
  78.   for i=1, w do
  79.     write(" ")
  80.   end
  81.   setBack("lightGray")
  82.   for i=1, 7 do
  83.     cp(1,h/2-3+i)
  84.     term.clearLine()
  85.   end
  86.   cp(1,h/2-2)
  87.   print("A yellow screen error (also called a stop error) can occur if a problem causes your device to shut down or restart unexpectedly. Your device ran into a problem and needs to restart.")
  88.   print("")
  89.   write("Error Code: ")
  90.   printError(err)
  91.     term.setCursorBlink(false)
  92. else
  93.     print("Exited without Errors")
  94. end
  95. pcall(sleep, 5)
  96. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement