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

Continue program were it left off on restart

Started by ender917, 06 August 2012 - 05:11 PM
ender917 #1
Posted 06 August 2012 - 07:11 PM
Hello. The title pretty much sums it up. Is is at all possible to continue a program where it left off at restart? Right now I have a turtle doing a 32x32 excavation. Every time I close the game out and come back, though. I have to dig down to get to him and reset him at the start then issue the command again. I then have to wait for him to dig through ALL the open space to get back to where he left off. So I was wondering, is it possible to resume him to where he left off?

I was thinking about adding a startup program that gets him back to the start location and oriented correctly then running the excavate program then. But does this program actually run at startup, or do I need to go over and start him up? I was then going to edit the excavate script to go down if there is empty space before he begins the cycle. It all makes sense but the hard part is trying to get him back to the start location. I need to have GPS in order to do that and I can't figure out the GPS API for life of me… Thanks in advance and I'm sorry if this is not clear / too difficult.
wilcomega #2
Posted 06 August 2012 - 08:42 PM
you should write the progres on shutdown and load it when your program starts. idk how you are going to detect a world unload but yeah
Boldy97 #3
Posted 06 August 2012 - 10:16 PM
Hello. The title pretty much sums it up. Is is at all possible to continue a program where it left off at restart? Right now I have a turtle doing a 32x32 excavation. Every time I close the game out and come back, though. I have to dig down to get to him and reset him at the start then issue the command again. I then have to wait for him to dig through ALL the open space to get back to where he left off. So I was wondering, is it possible to resume him to where he left off?

I was thinking about adding a startup program that gets him back to the start location and oriented correctly then running the excavate program then. But does this program actually run at startup, or do I need to go over and start him up? I was then going to edit the excavate script to go down if there is empty space before he begins the cycle. It all makes sense but the hard part is trying to get him back to the start location. I need to have GPS in order to do that and I can't figure out the GPS API for life of me… Thanks in advance and I'm sorry if this is not clear / too difficult.

I'm not a genius at this, but I'd say making your own coordinate system. For every block your machine moves, let it also edit one of 4 numbers (x,y,z,o) where o is the orientation (for example 1 being north, 2 east, 3 south, 4 west) The only thing you need is a central point (0,0,0), this would ideally be your drop off, since it'll have to go there a few times to stop it from filling up…

Best regards,
Boldy97
Cranium #4
Posted 07 August 2012 - 09:25 PM
You could also have the turtle copy it's (x,y,z) coordinates to a file as it's digging… It's a little hard work, but totally worth it if you can get it to go through. I'm currently trying to get a status file working for my program as well…
Pharap #5
Posted 08 August 2012 - 04:34 AM
It all depends on how your function currently works. If it's using nested loops, tracking it's progress on each loop and whatever other variables you have would be the answer, then add something that allows it to load that data and continue from where it left off.
Lion4ever #6
Posted 07 September 2012 - 11:41 PM
is there any pogress related to this? did anybody of you wrote a program like that? i am interessted in this as well :D/>/>