Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Simple shutdown and reboot after 3 seconds
- local function shutdownscreen(reboot)
- -- Colors for the screen
- local bgcolor = colors.cyan
- local txtcolor = colors.white
- -- Function to render the shutdown or reboot message
- local function render()
- term.setBackgroundColor(bgcolor)
- term.clear()
- term.setTextColor(txtcolor)
- term.setCursorPos(1, 1)
- if reboot then
- print("Restarting in 3 seconds...")
- else
- print("Shutting down in 3 seconds...")
- end
- end
- -- Render the screen
- render()
- os.sleep(3) -- Wait for 3 seconds before proceeding
- -- Perform the shutdown or reboot using _G.os to access the original methods
- if reboot then
- _G.os.reboot() -- Call the original reboot behavior from _G
- else
- _G.os.shutdown() -- Call the original shutdown behavior from _G
- end
- end
- -- Override os.shutdown and os.reboot to prevent loops
- local original_shutdown = _G.os.shutdown
- local original_reboot = _G.os.reboot
- function _G.os.shutdown()
- shutdownscreen(false) -- Call with false for shutdown
- os.exit() -- Prevent further triggering after shutdown
- end
- function _G.os.reboot()
- shutdownscreen(true) -- Call with true for reboot
- os.exit() -- Prevent further triggering after reboot
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement