Advertisement
DOGGYWOOF

Error

Jan 15th, 2024
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. local term = peripheral.wrap("monitor_1") -- Replace "monitor_1" with your monitor's label
  2.  
  3. local width = 40 -- Adjust the width of the box as needed
  4. local height = 5 -- Adjust the height of the box as needed
  5.  
  6. -- Function to center text on the screen
  7. local function centerText(y, text)
  8. local x = math.floor((term.getSize() - string.len(text)) / 2) + 1
  9. term.setCursorPos(x, y)
  10. term.write(text)
  11. end
  12.  
  13. -- Function to display the fatal system error message with a fancy box
  14. local function displayError()
  15. term.clear()
  16.  
  17. local startX = math.floor((term.getSize() - width) / 2) + 1
  18. local startY = math.floor((term.getSizeY() - height) / 2) + 1
  19.  
  20. -- Draw the box
  21. for i = 0, width do
  22. for j = 0, height do
  23. term.setCursorPos(startX + i, startY + j)
  24.  
  25. if i == 0 or i == width or j == 0 or j == height then
  26. term.write("*")
  27. else
  28. term.write(" ")
  29. end
  30. end
  31. end
  32.  
  33. centerText(startY + math.floor(height / 2), "Fatal system error:")
  34. centerText(startY + math.floor(height / 2) + 1, "Missing system files")
  35. end
  36.  
  37. -- Function to display a blinking cursor
  38. local function blinkCursor(x, y)
  39. while true do
  40. term.setCursorBlink(true)
  41. sleep(0.5)
  42. term.setCursorBlink(false)
  43. sleep(0.5)
  44. end
  45. end
  46.  
  47. -- Function to reboot the system
  48. local function rebootSystem()
  49. term.clear()
  50. term.setCursorPos(1, 1)
  51. term.write("Rebooting system...")
  52. os.reboot()
  53. end
  54.  
  55. -- Main program
  56. term.clear()
  57. parallel.waitForAny(displayError, blinkCursor)
  58.  
  59. while true do
  60. local event, key = os.pullEvent("key")
  61. if event == "key" and key == 28 then -- Enter key
  62. rebootSystem()
  63. end
  64. end
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement