Advertisement
DOGGYWOOF

Repair Doggy OS Partition

Sep 4th, 2024 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 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. term.clear()
  6.  
  7. -- Define the width and height of the screen
  8. local width, height = term.getSize()
  9.  
  10. -- Helper function to center text on the screen
  11. local function centerText(y, text, textColor)
  12. local x = math.floor((width - #text) / 2)
  13. term.setCursorPos(x, y)
  14. term.setTextColor(textColor)
  15. term.write(text)
  16. end
  17.  
  18. -- Helper function to draw a loading bar
  19. local function drawLoadingBar(y, percent)
  20. local barWidth = math.floor(width * 0.6) -- Loading bar is 60% of the screen width
  21. local barX = math.floor((width - barWidth) / 2)
  22.  
  23. term.setCursorPos(barX, y)
  24. term.write("[")
  25. for i = 1, barWidth - 2 do
  26. if i <= (barWidth - 2) * (percent / 100) then
  27. term.write("=")
  28. else
  29. term.write(" ")
  30. end
  31. end
  32. term.write("]")
  33. end
  34.  
  35. -- Helper function to display an error screen
  36. local function showErrorScreen()
  37. term.clear()
  38. term.setTextColor(colors.red)
  39. print("ERROR: Failed to Repair Recovery Partition")
  40. sleep(5)
  41. end
  42.  
  43. -- Define the dog ASCII art with white color and @ for eyes
  44. local dogArt = {
  45. " |\\_/| ",
  46. " | @ @ ",
  47. " | <> _ ",
  48. " | _/\\------____ ((| |))",
  49. " | `--' | ",
  50. " _____|_ ___| |___. ",
  51. "/_/_____/____/_______| "
  52. }
  53.  
  54. local startLine = math.floor((height - #dogArt) / 2) - 2
  55.  
  56. -- Display the dog ASCII art with white color
  57. term.setTextColor(colors.white)
  58. for i, line in ipairs(dogArt) do
  59. centerText(startLine + i, line, colors.white)
  60. end
  61.  
  62. -- Display the "Initializing..." message in white
  63. centerText(startLine + #dogArt + 2, "Initializing...", colors.white)
  64.  
  65. -- Wait for 4 seconds to simulate initialization
  66. sleep(4)
  67.  
  68. -- Clear the "Initializing..." message
  69. term.clearLine()
  70. centerText(startLine + #dogArt + 2, "", colors.white)
  71.  
  72. -- Display the "Repairing Recovery Partition..." message in white
  73. centerText(startLine + #dogArt + 2, "Repairing Recovery Partition...", colors.white)
  74.  
  75. -- Simulate a loading bar for the repair process
  76. for i = 1, 100, 5 do
  77. drawLoadingBar(startLine + #dogArt + 4, i)
  78. sleep(0.75) -- Simulate repair process with each increment
  79. end
  80.  
  81. -- Attempt to copy the recovery files to the root directory
  82. local success = pcall(function()
  83. fs.delete("/recovery") -- Ensure previous recovery files are deleted
  84. fs.copy("/disk", "/recovery")
  85. end)
  86.  
  87. -- If the copy fails, show an error screen
  88. if not success then
  89. showErrorScreen()
  90. return -- Stop execution after showing error
  91. end
  92.  
  93. -- Clear the loading bar and "Repairing..." message
  94. term.clearLine()
  95. centerText(startLine + #dogArt + 2, "", colors.white)
  96.  
  97. -- Display the "Recovery Partition Repaired Successfully!" message in white
  98. centerText(startLine + #dogArt + 2, "Recovery Partition Repaired Successfully!", colors.white)
  99.  
  100. -- Display the countdown message
  101. for i = 5, 0, -1 do
  102. centerText(startLine + #dogArt + 4, "Rebooting in " .. i .. "...", colors.white)
  103. sleep(1)
  104. end
  105.  
  106. -- Display the "Rebooting..." message in white
  107.  
  108. -- Wait for 3 seconds before rebooting
  109.  
  110. -- Reboot the system
  111. os.reboot()
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement