Advertisement
DOGGYWOOF

Untitled

Sep 23rd, 2024 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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. -- Add a delay to simulate crash delay
  19. local function crashDelay(seconds)
  20. sleep(seconds)
  21. end
  22.  
  23. -- Function to log the crash event
  24. local function logCrashEvent()
  25. local timeStamp = os.date("%Y-%m-%d %H:%M:%S")
  26. local reason = "Terminated to shell"
  27. local logMessage = string.format("Time: %s\nReason: %s\n\n", timeStamp, reason) -- Added extra newline
  28.  
  29. local file = fs.open("/disk/crash_log", "a")
  30. if file then
  31. file.write(logMessage)
  32. file.close()
  33. end
  34. end
  35.  
  36. -- Display the dog ASCII art with red Xes for eyes
  37. local dogArt = {
  38. " |\\_/| ",
  39. " | X X RUNTIME ERROR ",
  40. " | <> _ ",
  41. " | _/\\------____ ((| |))",
  42. " | --' | ",
  43. " _____|_ ___| |___. ",
  44. "/_/_____/____/_______| "
  45. }
  46.  
  47. local startLine = math.floor((height - #dogArt) / 2) - 2
  48.  
  49. -- Display the dog ASCII art with "SYSTEM ERROR!" in red
  50. for i, line in ipairs(dogArt) do
  51. centerText(startLine + i, line, colors.red)
  52. crashDelay(0.1) -- Add slight delay between each line
  53. end
  54.  
  55. -- Log the crash event
  56. logCrashEvent()
  57.  
  58. -- Display error message below the dog ASCII art in white
  59. crashDelay(1) -- Pause before showing the error code
  60. term.setTextColor(colors.white)
  61. centerText(startLine + #dogArt + 2, "Device shutdown to protect File System", colors.white)
  62. centerText(startLine + #dogArt + 3, "", colors.white)
  63.  
  64. -- Reboot countdown in 5 seconds
  65. for i = 5, 0, -1 do
  66. crashDelay(1)
  67. centerText(height - 2, "Rebooting in " .. i .. " seconds...", colors.white)
  68. end
  69.  
  70. -- Clear the screen after countdown and reboot immediately
  71. term.clear()
  72.  
  73. -- Reboot the system
  74. os.reboot()
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement