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

[any upcoming version] idea on how to make comps restart after restarting mc

Started by dus998, 21 October 2012 - 11:41 PM
dus998 #1
Posted 22 October 2012 - 01:41 AM
My idea is concerning computercraft computers remembering what line of what program it was running when, for example, you save and quit to title, and then when you start up again it continues where it left off.

I think it might be possible to make it write a short .txt in the computer folder in the world folder that contains this information then when you start up again it it checks for this file then if there is none then it just runs startup like it does now and if there is the file then it reads it and runs the program at the specified line.


cross post from Dan200's reddit post
PixelToast #2
Posted 22 October 2012 - 02:02 AM
you can just just make a program to save the currently running program
KaoS #3
Posted 22 October 2012 - 05:37 AM
I think they plan on saving the java code of the running computer. that way you don't have to save anything else. it will seamlessly resume without even being aware that it stopped
ChunLing #4
Posted 22 October 2012 - 05:46 AM
They do plan on adding that feature…I wasn't aware that saving the java code was necessary, though…they just need to save the lua variables and execution status. I mean…we can't change the java anyway, can we?
KaoS #5
Posted 22 October 2012 - 06:16 AM
yea but you see that will cause issues if you are half way through executing a function like turtle.forward(). it will resume waiting for the turtle_response event but never get it. saving the java engine ensures that it will resume without error (well I can't guarantee that but we have good DEVs, they will sort it out :)/>/> )
ChunLing #6
Posted 22 October 2012 - 08:49 AM
Ah…I remember when leaves would kill my turtles if they were moving when the leaves grew. We've come a long way.
Cloudy #7
Posted 22 October 2012 - 08:50 AM
We won't save the java code - but turtles already save what action they are doing - if you make a turtle go forward and quickly exit it will continue - then stop.
KaoS #8
Posted 22 October 2012 - 11:46 AM
but if you exit MC and re-open it then it will resume the code exactly where it was. if you have just started sleep(5) then it queued an event before you killed it, will that event still occur or will it keep waiting for it?
Cloudy #9
Posted 22 October 2012 - 12:57 PM
but if you exit MC and re-open it then it will resume the code exactly where it was. if you have just started sleep(5) then it queued an event before you killed it, will that event still occur or will it keep waiting for it?

We will obviously save anything needed when resuming - any timers, turtle moves etc - but we don't have to save java code state.
ChunLing #10
Posted 22 October 2012 - 08:09 PM
Well, that's good then. It's nice to know this feature is moving ahead without too many obstructions.
dus998 #11
Posted 22 October 2012 - 10:08 PM
thanks for the answer
it is good to know that this is being worked on
PixelToast #12
Posted 31 October 2012 - 05:42 PM
im working on an advanced serialization program that can convert the entire _G table and all the functions and function environments :3 :3 :3
autosave anyone?
ChunLing #13
Posted 31 October 2012 - 10:46 PM
Yikes! How close are you?
Sebra #14
Posted 02 November 2012 - 03:11 AM
How would you serialize functions with global names in it? Seems no way.
KaoS #15
Posted 02 November 2012 - 03:26 AM
you can dump most functions to a string and load them again but there are some functions that aren't all Lua and it errors when you try to save them