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

[1.4] computer shutdown notify

Started by Xfel, 29 March 2012 - 05:58 PM
Xfel #1
Posted 29 March 2012 - 07:58 PM
Hi,

While writing a mining program, I noticed that there is no controlled notification on computer shutdown in cause of chunk unload or world shutdown. This means that my state-saving system doesn't work properly. Maybe there could be a "terminate" event and some time for the computer to stop and save it's state on its own?
xuma202 #2
Posted 29 March 2012 - 08:04 PM
Great idea.
Espen #3
Posted 29 March 2012 - 08:41 PM
In the mean-time I'd suggest to instruct your program to make periodic auto-saves.
This way you have at least the last state between shutdown and last autosave interval.
Don't know of any better way atm.
Maybe the ccsensors peripheral can detect players? I haven't tried it yet, but if it can, then you could check against your proximity to the computer in question and tell it to save as soon as you're a certain distance away from it.
But as I said, I have no idea if that's possible with ccsensors and I'm too lazy at the moment to check, sorry. :o/>/>
Liraal #4
Posted 29 March 2012 - 08:57 PM
just place a bunch of pressure plates :o/>/>
But seriously, this is a feature that should be added, because it prevents assholes from doing bad things to your stuff without being detected.
Xfel #5
Posted 29 March 2012 - 09:37 PM
@Espen:
It get's buggy if you remember a turtle's facing, make the turn, and get terminated before you can write the state file.