Advertisement
Marlingaming

CC Tweaked Personal Device os start screen

Jan 12th, 2022 (edited)
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. --this acts as the menu that appears between the boot area, and the main menu, and can act as Lock Screen
  2. settings.load(".settings")
  3. local w, h = term.getSize()
  4. local Password = settings.get("os_LockScreenPassword")
  5. local OsMenu = settings.get("os_DesktopLoc")
  6.  
  7. local function Clear()
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. end
  11.  
  12. local function CenterText(y,text)
  13.     local x = math.floor((w - string.len(text)) /2)
  14.     term.setCursorPos(x,y)
  15.     term.clearLine()
  16.     term.write(text)
  17. end
  18.  
  19. function DrawLockScreen()
  20. term.setBackgroundColor(colors.blue)
  21. Clear()
  22. CenterText(1,"Lock Screen")
  23. CenterText(4,"Login")
  24. CenterText(5,"--==Password==--")
  25. CenterText(7,"--==Continue==--")
  26. term.setCursorPos(w/3, 6)
  27. local event
  28. local input
  29. term.setTextColor(colours.yellow)
  30. while true do
  31.     local event = {os.pullEvent("key")}
  32.     if event[2] == keys.enter then break end
  33.     input = read("*")
  34. end
  35. term.setTextColor(colours.white)
  36. if input == Password then
  37.     shell.run(OsMenu)
  38. else
  39.     print("incorrect Password")
  40.     os.sleep(3)
  41.     DrawLockScreen()
  42. end
  43. end
  44.  
  45. local function StartMenu()
  46. term.setBackgroundColor(colors.purple)
  47. Clear()
  48. CenterText(2,"=Login=")
  49. CenterText(4,"User")
  50. CenterText(5,settings.get("os_Username"))
  51. CenterText(10,"Press Enter to continue")
  52. local event
  53. repeat
  54.     event = {os.pullEvent("key")}
  55. until event[2] == keys.enter
  56. if Password == "n" then
  57.     shell.run(OsMenu)
  58. else
  59.     DrawLockScreen()
  60. end
  61. end
  62.  
  63. local function Handler()
  64. Clear()
  65. StartMenu()
  66. end
  67.  
  68. Handler()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement