Advertisement
DOGGYWOOF

Untitled

Aug 25th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.10 KB | None | 0 0
  1. -- Helper function to display ASCII art and message
  2. local function displayMessage(message)
  3. -- Clear the screen and set up colors
  4. term.clear()
  5. term.setBackgroundColor(colors.black)
  6. term.setTextColor(colors.white)
  7. term.clear()
  8.  
  9. -- Define the width and height of the screen
  10. local width, height = term.getSize()
  11.  
  12. -- Helper function to center text on the screen
  13. local function centerText(y, text, textColor)
  14. local x = math.floor((width - #text) / 2)
  15. term.setCursorPos(x, y)
  16. term.setTextColor(textColor)
  17. term.write(text)
  18. end
  19.  
  20. -- Define the dog ASCII art with white color and @ for eyes
  21. local dogArt = {
  22. " |\\_/| ",
  23. " | @ @ ",
  24. " | <> _ ",
  25. " | _/\\------____ ((| |))",
  26. " | `--' | ",
  27. " _____|_ ___| |___. ",
  28. "/_/_____/____/_______| "
  29. }
  30.  
  31. local startLine = math.floor((height - #dogArt) / 2) - 2
  32.  
  33. -- Display the dog ASCII art with white color
  34. term.setTextColor(colors.white)
  35. for i, line in ipairs(dogArt) do
  36. centerText(startLine + i, line, colors.white)
  37. end
  38.  
  39. -- Display the provided message below the ASCII art
  40. centerText(startLine + #dogArt + 2, message, colors.white)
  41. end
  42.  
  43. -- Initial Error Screen Code
  44. local function displayErrorScreen()
  45. -- Clear the screen and set up colors
  46. term.clear()
  47. term.setBackgroundColor(colors.black)
  48. term.setTextColor(colors.white)
  49. term.clear()
  50.  
  51. -- Define the width and height of the screen
  52. local width, height = term.getSize()
  53.  
  54. -- Helper function to center text on the screen
  55. local function centerText(y, text, textColor)
  56. local x = math.floor((width - #text) / 2)
  57. term.setCursorPos(x, y)
  58. term.setTextColor(textColor)
  59. term.write(text)
  60. end
  61.  
  62. -- Display the dog ASCII art with red Xes for eyes
  63. local dogArt = {
  64. " |\\_/| ",
  65. " | X X SYSTEM ERROR! ",
  66. " | <> _ ",
  67. " | _/\\------____ ((| |))",
  68. " | `--' | ",
  69. " _____|_ ___| |___. ",
  70. "/_/_____/____/_______| "
  71. }
  72.  
  73. local startLine = math.floor((height - #dogArt) / 2) - 2
  74.  
  75. -- Display the dog ASCII art with red Xes for eyes in red
  76. term.setTextColor(colors.red)
  77. for i, line in ipairs(dogArt) do
  78. centerText(startLine + i, line, colors.red)
  79. end
  80.  
  81. -- Display error message below the dog ASCII art in white
  82. term.setTextColor(colors.white)
  83. centerText(startLine + #dogArt + 2, "Fatal startup failure", colors.white)
  84. centerText(startLine + #dogArt + 3, "Error code: C633", colors.white)
  85.  
  86. -- Move "Press F1 for advanced options." to the bottom in white
  87. centerText(height - 2, "Press F1 for advanced options.", colors.white)
  88. end
  89.  
  90. -- Recovery Menu UI
  91. local function displayRecoveryMenu()
  92. -- Clear the screen and set up colors
  93. term.clear()
  94. term.setBackgroundColor(colors.black)
  95. term.setTextColor(colors.white)
  96. term.clear()
  97.  
  98. -- Define the width and height of the screen
  99. local width, height = term.getSize()
  100.  
  101. -- Helper function to center text on the screen
  102. local function centerText(y, text, textColor)
  103. local x = math.floor((width - #text) / 2)
  104. term.setCursorPos(x, y)
  105. term.setTextColor(textColor)
  106. term.write(text)
  107. end
  108.  
  109. -- Display a menu header
  110. local header = "Boot Failure Recovery Options"
  111. local options = {
  112. "1. Repair Bootloader",
  113. "2. Recover from /recovery",
  114. "3. Recover from external source",
  115. "4. Run recovery shell",
  116. "5. Exit"
  117. }
  118.  
  119. local startLine = math.floor((height - #options - 4) / 2)
  120.  
  121. -- Display the header
  122. term.setTextColor(colors.cyan)
  123. centerText(startLine, header, colors.cyan)
  124. term.setTextColor(colors.white)
  125. for i, option in ipairs(options) do
  126. centerText(startLine + i + 2, option, colors.white)
  127. end
  128. end
  129.  
  130. -- Repair Code Function
  131. local function repairBootloader()
  132. displayMessage("Repairing System Bootloader...")
  133.  
  134. -- Wait for 10 seconds to simulate the repair process
  135. sleep(10)
  136.  
  137. -- Delete existing startup and no-os files
  138. fs.delete("/startup")
  139. fs.delete("/no-os")
  140.  
  141. -- Copy the recovery files to the root directory
  142. fs.copy("/recovery/boot/error", "/startup")
  143. fs.copy("/recovery/bootloader/no-os.lua", "/no-os")
  144.  
  145. -- Display the "Repair Completed. Rebooting..." message in white
  146. displayMessage("Repair Completed. Rebooting...")
  147.  
  148. -- Wait for 3 seconds before rebooting
  149. sleep(3)
  150.  
  151. -- Reboot the system
  152. os.reboot()
  153. end
  154.  
  155. -- Recovery from /recovery Function
  156. local function recoverFromRecovery()
  157. displayMessage("Repairing File System")
  158.  
  159. -- Wait for 10 seconds to simulate the recovery process
  160. sleep(10)
  161.  
  162. -- Delete existing disk directory and copy files from /recovery
  163. fs.delete("/disk/")
  164. fs.copy("/recovery/", "/disk/")
  165.  
  166. -- Display the "Recovery Completed. Rebooting..." message in white
  167. displayMessage("Recovery Completed. Rebooting...")
  168.  
  169. -- Wait for 3 seconds before rebooting
  170. sleep(3)
  171.  
  172. -- Reboot the system
  173. os.reboot()
  174. end
  175.  
  176. -- Recovery from External Source Function
  177. local function recoverFromExternalSource()
  178. -- Clear the screen and set up colors
  179. term.clear()
  180. term.setBackgroundColor(colors.black)
  181. term.setTextColor(colors.white)
  182. term.clear()
  183.  
  184. -- Define the width and height of the screen
  185. local width, height = term.getSize()
  186.  
  187. -- Helper function to center text on the screen
  188. local function centerText(y, text, textColor)
  189. local x = math.floor((width - #text) / 2)
  190. term.setCursorPos(x, y)
  191. term.setTextColor(textColor)
  192. term.write(text)
  193. end
  194.  
  195. -- Define the dog ASCII art with white color and @ for eyes
  196. local dogArt = {
  197. " |\\_/| ",
  198. " | @ @ ",
  199. " | <> _ ",
  200. " | _/\\------____ ((| |))",
  201. " | `--' | ",
  202. " _____|_ ___| |___. ",
  203. "/_/_____/____/_______| "
  204. }
  205.  
  206. local startLine = math.floor((height - #dogArt) / 2) - 2
  207.  
  208. -- Display the dog ASCII art with white color
  209. term.setTextColor(colors.white)
  210. for i, line in ipairs(dogArt) do
  211. centerText(startLine + i, line, colors.white)
  212. end
  213.  
  214. -- Display the "Installing System Update from /disk2/" message in white
  215. centerText(startLine + #dogArt + 2, "Installing System Update from /disk2/", colors.white)
  216.  
  217. -- Wait for 10 seconds to simulate the update process
  218. sleep(10)
  219.  
  220. -- Check if /disk2 exists before copying
  221. if fs.exists("/disk2/") then
  222. fs.delete("/disk/")
  223. fs.copy("/disk2/", "/disk/")
  224. -- Display the "Update Completed. Rebooting..." message in white
  225. centerText(startLine + #dogArt + 4, "Update Completed. Rebooting...", colors.white)
  226. else
  227. -- Display an error message if /disk2 does not exist
  228. centerText(startLine + #dogArt + 4, "Error: /disk2 does not exist.", colors.red)
  229. end
  230.  
  231. -- Wait for 3 seconds before rebooting
  232. sleep(3)
  233.  
  234. -- Reboot the system
  235. os.reboot()
  236. end
  237.  
  238. -- Recovery Shell Function
  239. local function recoveryShell()
  240. -- Clear the screen and set up colors
  241. term.clear()
  242. term.setBackgroundColor(colors.black)
  243. term.setTextColor(colors.white)
  244. term.clear()
  245.  
  246. -- Alternative shell from CraftOS shell
  247. termutils = {}
  248.  
  249. termutils.clear = function()
  250. term.clear()
  251. term.setCursorPos(1,1)
  252. end
  253.  
  254. termutils.clearColor = function()
  255. term.setTextColor(colors.white)
  256. term.setBackgroundColor(colors.black)
  257. end
  258.  
  259. function input()
  260. term.setTextColor(colors.white)
  261. local dir = shell.dir().."/"..">"
  262. write(dir)
  263. termutils.clearColor()
  264. command = io.read()
  265. end
  266.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement