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

chunk reload

Started by Brian87, 05 April 2014 - 12:25 PM
Brian87 #1
Posted 05 April 2014 - 02:25 PM
I was just wondering: if a chunk with a turtle (assuming the turtle is running a startup sript), gets unloaded and then reloaded, will the turtle start the script over from scratch, or will it resume from where it ended when the chunk got unloaded?
RoD #2
Posted 05 April 2014 - 02:34 PM
There's nothing like testing…
Becasue i tryed, it seems that the script will still run, even with the chunk not being loaded.
You only need to worry when you exit the map.
CometWolf #3
Posted 05 April 2014 - 02:37 PM
This is completely bull. If the chunk is actually unloaded the program will stop at whatever it was doing at the time. When the chunk is loaded again the computer will essentially be rebooted. So if it has a startup program, it will be run from the start.
Bomb Bloke #4
Posted 05 April 2014 - 03:31 PM
RoD, you may've been misled by a chunk remaining loaded when you were expecting it to unload - eg due to a nearby portalgun portal or something.
Brian87 #5
Posted 05 April 2014 - 03:33 PM
So if I run startup and the chunk gets unloaded and then reloaded, it will run the startup file from the beginning, and not resume?
Is there a way around this?
RoD #6
Posted 05 April 2014 - 03:42 PM
RoD, you may've been misled by a chunk remaining loaded when you were expecting it to unload - eg due to a nearby portalgun portal or something.
i only have cc installed…strange…
theoriginalbit #7
Posted 05 April 2014 - 03:43 PM
i only have cc installed…strange…
if its on a server the chunks don't unload right away.
RoD #8
Posted 05 April 2014 - 03:47 PM
i only have cc installed…strange…
if its on a server the chunks don't unload right away.
The minecraft 1.6.4 has internal server, so it may be that…
theoriginalbit #9
Posted 05 April 2014 - 03:49 PM
The minecraft 1.6.4 has internal server, so it may be that…
nah single player servers shutdown when you exit the world.
RoD #10
Posted 05 April 2014 - 03:51 PM
The minecraft 1.6.4 has internal server, so it may be that…
nah single player servers shutdown when you exit the world.
but ONLY when you exit, so the chunks may be still loaded.
Bomb Bloke #11
Posted 05 April 2014 - 03:52 PM
Suffice to say, even though SSP uses an internal server (and has done since ComputerCraft 1.3), it doesn't function in the same manner as SMP. And yes, this is even putting aside that the server shuts down when you quit a SSP world.

It's also possible that a turtle will load chunks around it which aren't automatically unloaded if a player isn't around (they do this simply by moving into them). You generally won't run into this situation unintentionally, however.

Is there a way around this?

Of course - practically speaking there aren't many limits on what you can code. The complexity depends on what it is the turtle's doing when the chunk unloads.

My preferred method of resuming is to use a GPS system so that the turtle can determine where it is when it boots back up - this typically gives it sufficient clues as to what it was doing and how it should attempt to carry on. Catch is, on its own a GPS system isn't much good for a turtle that doesn't just operate around a single static area.

Most methods you'll see suggested around here involve saving a file to the turtle's drive containing state information. I dislike this myself, as it's usually implemented by performing near-constant writes… but it only takes a little thought to limit the writes needed (for eg, if the turtle wants to travel twenty blocks, it need only record its intention, startpoint and the amount of fuel it had when it started - if it randomly reboots partway, it can infer how far it got by its remaining fuel level).
Brian87 #12
Posted 05 April 2014 - 04:05 PM
okay, thank you! Helped me much :D/>
Edited on 05 April 2014 - 02:05 PM