Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function drawErrorMessage(errorMessage)
- term.setBackgroundColor(colors.black)
- term.clear()
- -- Draw error message box
- paintutils.drawFilledBox(5, 5, 35, 15, colors.red)
- -- Display error message
- term.setCursorPos(10, 8)
- term.setTextColor(colors.white)
- print("System Error")
- term.setCursorPos(8, 10)
- print(errorMessage)
- -- Draw acknowledge button
- drawButton(15, 12, 20, "Acknowledge", colors.blue, colors.white)
- end
- local function drawButton(x, y, width, label, backgroundColor, textColor)
- paintutils.drawFilledBox(x, y, x + width - 1, y + 3, backgroundColor)
- term.setCursorPos(x + math.floor((width - #label) / 2), y + 1)
- term.setTextColor(textColor)
- print(label)
- end
- local function handleClick(x, y)
- if x >= 15 and x <= 34 and y == 12 then
- -- Acknowledge button clicked, close error GUI
- term.clear()
- print("Error acknowledged.")
- -- You can add additional actions here if needed
- sleep(2) -- Allow time for the user to read the acknowledgement message
- return true -- Signal to close the GUI
- end
- end
- local function displayError(errorMessage)
- local monitor = peripheral.wrap("top") -- Replace "top" with your monitor's side
- if not monitor then
- print("Monitor not found!")
- return
- end
- drawErrorMessage(errorMessage)
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- if event == "monitor_touch" and side == "top" then
- if handleClick(x, y) then
- term.clear()
- return
- end
- end
- end
- end
- -- Example usage:
- displayError("Critical system error occurred!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement