Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- startup
- -- Function to display a full-screen error message
- function displayError(message)
- term.clear() -- Clear the screen
- term.setCursorPos(1, 1) -- Set the cursor to the top-left corner
- local width, height = term.getSize()
- local xPos = math.floor((width - string.len(message)) / 2) -- Center the text horizontally
- local yPos = math.floor(height / 2) -- Center the text vertically
- term.setCursorPos(xPos, yPos)
- term.write(message)
- sleep(3) -- Display the message for 3 seconds
- term.clear() -- Clear the screen after showing the error
- end
- -- Function to run a program with error handling
- function runWithErrorHandling(programName)
- local success, err = pcall(function()
- shell.run(programName)
- end)
- if not success then
- displayError("Error: " .. err)
- end
- end
- -- Execute the program with error handling
- runWithErrorHandling("program.lua")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement