Advertisement
DOGGYWOOF

Untitled

Aug 31st, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 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. -- Define the dog ASCII art with white color and @ for eyes
  19. local dogArt = {
  20. " |\\_/| ",
  21. " | @ @ ",
  22. " | <> _ ",
  23. " | _/\\------____ ((| |))",
  24. " | `--' | ",
  25. " _____|_ ___| |___. ",
  26. "/_/_____/____/_______| "
  27. }
  28.  
  29. local startLine = math.floor((height - #dogArt) / 2) - 2
  30.  
  31. -- Display the dog ASCII art with white color
  32. term.setTextColor(colors.white)
  33. for i, line in ipairs(dogArt) do
  34. centerText(startLine + i, line, colors.white)
  35. end
  36.  
  37. -- Display the "Insert Disk" message
  38. centerText(startLine + #dogArt + 2, "Insert disk", colors.white)
  39.  
  40. -- Wait a moment to let the user see the "Insert Disk" message
  41. sleep(2)
  42.  
  43. -- Check if /disk2/ exists
  44. if fs.exists("/disk2/") then
  45. -- Display the confirmation prompt for update
  46. term.setCursorPos(1, height)
  47. term.setTextColor(colors.yellow)
  48. term.write("Press 'Y' to proceed with the update, 'N' to cancel: ")
  49.  
  50. -- Wait for user input
  51. local event, key = os.pullEvent("key")
  52. if key == keys.y then
  53. -- User confirmed to proceed with the update
  54. centerText(startLine + #dogArt + 2, "Emergency System Update...", colors.white)
  55.  
  56. -- Simulate progress with an animated progress bar
  57. local progressBarWidth = 30
  58. local progressBarStartY = startLine + #dogArt + 4
  59.  
  60. for i = 1, progressBarWidth do
  61. local progress = math.floor((i / progressBarWidth) * 100)
  62. local bar = string.rep("=", i) .. string.rep(" ", progressBarWidth - i)
  63.  
  64. -- Clear previous progress bar line
  65. term.setCursorPos(1, progressBarStartY)
  66. term.write(string.rep(" ", width))
  67.  
  68. -- Display updated progress bar
  69. term.setCursorPos(math.floor((width - progressBarWidth) / 2), progressBarStartY)
  70. term.setTextColor(colors.green)
  71. term.write("[" .. bar .. "] " .. progress .. "%")
  72.  
  73. -- Wait a bit to simulate progress
  74. sleep(0.5)
  75. end
  76.  
  77. -- Wait for additional 15 seconds to simulate finalizing the update
  78. sleep(15)
  79. elseif key == keys.n then
  80. -- User canceled the update
  81. centerText(startLine + #dogArt + 2, "Update canceled. Rebooting...", colors.red)
  82.  
  83. -- Wait for 5 seconds to let the user see the cancellation message
  84. sleep(5)
  85. else
  86. -- If the input is not 'Y' or 'N', assume cancellation
  87. centerText(startLine + #dogArt + 2, "Invalid input. Update canceled.", colors.red)
  88. sleep(5)
  89. end
  90. else
  91. -- Display an error message if /disk2/ doesn't exist
  92. centerText(startLine + #dogArt + 2, "Disk not found. Unable to update.", colors.red)
  93.  
  94. -- Wait for 5 seconds to let the user see the error message
  95. sleep(5)
  96. end
  97.  
  98. -- Display the "Rebooting..." message
  99. centerText(startLine + #dogArt + 4, "Rebooting...", colors.white)
  100.  
  101. -- Wait a few seconds before rebooting
  102. sleep(3)
  103.  
  104. -- Reboot the system
  105. os.reboot()
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement