Advertisement
DOGGYWOOF

Installer with loading bar

Sep 17th, 2024 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. -- Clear the screen and set up colors
  2. term.clear()
  3. term.setBackgroundColor(colors.black)
  4. term.setTextColor(colors.white)
  5.  
  6. -- Define the width and height of the screen
  7. local width, height = term.getSize()
  8.  
  9. -- Helper function to center text on the screen
  10. local function centerText(y, text, textColor)
  11. local x = math.floor((width - #text) / 2)
  12. term.setCursorPos(x, y)
  13. term.setTextColor(textColor)
  14. term.write(text)
  15. end
  16.  
  17. -- Helper function to draw a loading bar
  18. local function drawLoadingBar(y, percent)
  19. local barWidth = math.floor(width * 0.6) -- Loading bar is 60% of the screen width
  20. local barX = math.floor((width - barWidth) / 2)
  21.  
  22. term.setCursorPos(barX, y)
  23. term.write("[")
  24. for i = 1, barWidth - 2 do
  25. if i <= (barWidth - 2) * (percent / 100) then
  26. term.write("=")
  27. else
  28. term.write(" ")
  29. end
  30. end
  31. term.write("]")
  32. end
  33.  
  34. -- Define the dog ASCII art with white color and @ for eyes
  35. local dogArt = {
  36. " |\\_/| ",
  37. " | @ @ ",
  38. " | <> _ ",
  39. " | _/\\------____ ((| |))",
  40. " | `--' | ",
  41. " _____|_ ___| |___. ",
  42. "/_/_____/____/_______| "
  43. }
  44.  
  45. local startLine = math.floor((height - #dogArt) / 2) - 2
  46.  
  47. -- Display the dog ASCII art with white color
  48. term.setTextColor(colors.white)
  49. for i, line in ipairs(dogArt) do
  50. centerText(startLine + i, line, colors.white)
  51. end
  52.  
  53. -- Display the "Please Wait..." message in white
  54. centerText(startLine + #dogArt + 2, "Please wait...", colors.white)
  55.  
  56. -- Wait for 4 seconds to simulate initialization
  57. sleep(4)
  58.  
  59. -- Clear the "Please Wait..." message
  60. term.clearLine()
  61. centerText(startLine + #dogArt + 2, "", colors.white)
  62.  
  63. -- Display the "Installation in Progress..." message in white
  64. centerText(startLine + #dogArt + 2, "Doggy OS System Installation...", colors.white)
  65.  
  66. -- Simulate a loading bar for the installation process
  67. for i = 1, 100, 5 do
  68. drawLoadingBar(startLine + #dogArt + 4, i)
  69. sleep(0.75) -- Simulate installation process with each increment
  70. end
  71.  
  72. -- Clear the loading bar and "Installing Doggy OS..." message
  73. term.clearLine()
  74. centerText(startLine + #dogArt + 2, "", colors.white)
  75.  
  76. -- Execute the installation commands
  77. fs.copy("/disk/", "/root")
  78. sleep(0.1)
  79. disk.eject("top")
  80. disk.eject("bottom")
  81. disk.eject("left")
  82. disk.eject("right")
  83. sleep(0.1)
  84. shell.run("rename", "/root", "/disk")
  85. sleep(0.1)
  86. fs.copy("/disk/.settings",".settings")
  87. fs.copy("/disk/", "/recovery")
  88. sleep(0.1)
  89.  
  90. -- Display the "Installation Complete!" message in white
  91. centerText(startLine + #dogArt + 2, "Installation Complete!", colors.white)
  92.  
  93. -- Display the countdown message
  94. for i = 5, 0, -1 do
  95. centerText(startLine + #dogArt + 4, "Rebooting in " .. i .. "...", colors.white)
  96. sleep(1)
  97. end
  98.  
  99. -- Wait for 3 seconds before rebooting
  100. sleep(0.5)
  101.  
  102. -- Reboot the system
  103. shell.run("/disk/install-assist")
  104.  
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement