Advertisement
DOGGYWOOF

Untitled

Sep 4th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 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 display text at a specific position
  19. local function displayText(x, y, text, textColor)
  20. term.setCursorPos(x, y)
  21. term.setTextColor(textColor)
  22. term.write(text)
  23. end
  24.  
  25. -- Function to display the error screen
  26. local function displayErrorScreen()
  27. -- Display the dog ASCII art with red Xes for eyes
  28. local dogArt = {
  29. " |\\_/| ",
  30. " | X X RECOVERY ERROR! ",
  31. " | <> _ ",
  32. " | _/\\------____ ((| |))",
  33. " | `--' | ",
  34. " _____|_ ___| |___. ",
  35. "/_/_____/____/_______| "
  36. }
  37.  
  38. local startLine = math.floor((height - #dogArt) / 2) - 2
  39.  
  40. -- Display the dog ASCII art with red Xes for eyes in red
  41. term.setTextColor(colors.red)
  42. for i, line in ipairs(dogArt) do
  43. centerText(startLine + i, line, colors.red)
  44. end
  45.  
  46. -- Display updated error message below the dog ASCII art in white
  47. term.setTextColor(colors.white)
  48. centerText(startLine + #dogArt + 2, "System Recovery Disabled", colors.white)
  49. centerText(startLine + #dogArt + 3, "Error: /recovery/ cannot be mounted", colors.white)
  50.  
  51. -- Display "F1 - Ignore" on the left side, closer to the bottom
  52. displayText(3, height - 2, "F1 - Ignore", colors.white)
  53.  
  54. -- Display "F8 - Attempt Repairs" on the right side, closer to the bottom
  55. displayText(width - #("F8 - Attempt Repairs") - 3, height - 2, "F8 - Attempt Repairs", colors.white)
  56.  
  57. -- Wait for user input
  58. while true do
  59. local event, key = os.pullEvent("key")
  60. if key == keys.f1 then
  61. -- Run BIOS if F1 is pressed
  62. shell.run("/disk/boot/BIOS")
  63. break
  64. elseif key == keys.f8 then
  65. -- Attempt repairs if F8 is pressed
  66. shell.run("/disk/error/repair-recovery")
  67. break
  68. end
  69. end
  70. end
  71.  
  72. -- Main program logic
  73. if fs.exists("/recovery") then
  74. -- If /recovery exists, run the BIOS
  75. shell.run("/disk/boot/BIOS")
  76. else
  77. -- If /recovery does not exist, display the error screen
  78. displayErrorScreen()
  79. end
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement