This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Wilobate's profile picture

Is there a way to detect a shutdown or reboot?

Started by Wilobate, 15 April 2017 - 12:46 AM
Wilobate #1
Posted 15 April 2017 - 02:46 AM
I have a program, but i need to detect if the computer is about to shutdown/reboot.
The program will be in an unfocused multishell. Is it possible to do it?

Basically the main question is, can i detect a shutdown or reboot. If so, can i have it detected even when that multishell is not on focus?

Im pretty bad at explaining, if you need more info, let me know and ill do my best.
Lyqyd #2
Posted 15 April 2017 - 05:26 AM
Nope. Shutdowns and reboots can occur with no warning. It is possible to modify the os.shutdown and os.reboot functions to do something before calling the original functions, but the hotkeys don't call those functions when they're pressed, and you can't do anything when the chunk unloads anyway.
Wilobate #3
Posted 15 April 2017 - 06:14 AM
after some stuffing around. i was about to detect user caused shutdowns/reboots. Thats all i needed on that. I do have another question, unrelated to this topic, so ill create a new topic for it.