Advertisement
DOGGYWOOF

error

Jan 3rd, 2024
2
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. local function drawErrorMessage(errorMessage)
  2. term.setBackgroundColor(colors.black)
  3. term.clear()
  4.  
  5. -- Draw error message box
  6. paintutils.drawFilledBox(5, 5, 35, 15, colors.red)
  7.  
  8. -- Display error message
  9. term.setCursorPos(10, 8)
  10. term.setTextColor(colors.white)
  11. print("System Error")
  12. term.setCursorPos(8, 10)
  13. print(errorMessage)
  14.  
  15. -- Draw acknowledge button
  16. drawButton(15, 12, 20, "Acknowledge", colors.blue, colors.white)
  17. end
  18.  
  19. local function drawButton(x, y, width, label, backgroundColor, textColor)
  20. paintutils.drawFilledBox(x, y, x + width - 1, y + 3, backgroundColor)
  21. term.setCursorPos(x + math.floor((width - #label) / 2), y + 1)
  22. term.setTextColor(textColor)
  23. print(label)
  24. end
  25.  
  26. local function handleClick(x, y)
  27. if x >= 15 and x <= 34 and y == 12 then
  28. -- Acknowledge button clicked, close error GUI
  29. term.clear()
  30. print("Error acknowledged.")
  31. -- You can add additional actions here if needed
  32. sleep(2) -- Allow time for the user to read the acknowledgement message
  33. return true -- Signal to close the GUI
  34. end
  35. end
  36.  
  37. local function displayError(errorMessage)
  38. local monitor = peripheral.wrap("top") -- Replace "top" with your monitor's side
  39.  
  40. if not monitor then
  41. print("Monitor not found!")
  42. return
  43. end
  44.  
  45. drawErrorMessage(errorMessage)
  46.  
  47. while true do
  48. local event, side, x, y = os.pullEvent("monitor_touch")
  49.  
  50. if event == "monitor_touch" and side == "top" then
  51. if handleClick(x, y) then
  52. term.clear()
  53. return
  54. end
  55. end
  56. end
  57. end
  58.  
  59. -- Example usage:
  60. displayError("Critical system error occurred!")
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement