ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: ToxicGLaDOS on Jul 26, 2023, 10:48 PM

Title: What happens when a chunk with a turtle in it is unloaded?
Post by: ToxicGLaDOS on Jul 26, 2023, 10:48 PM
I can't seem to find any docs on what exactly happens when a turtle is unloaded. Is the current line of lua finished and then the program is stopped? The reason this matters is for building programs that can withstand chunk unloads. If it's possible for a chunk unloading to interrupt a program like this

handle = fs.open("my_file", "w")
handle.write("some data")
-- Chunk unloads
handle.close()

Then it seems like it would be impossible to write programs that can consistently work through an unload.
Title: What happens when a chunk with a turtle in it is unloaded?
Post by: SamH on Aug 08, 2023, 08:21 PM
When a chunk is unloaded the turtle (or any computer) looses all information on what it is doing. I'm not sure if code execution abruptly ends or the current line gets finished, but for sure the turtle does not return to what it was doing when the chunk is loaded again.

You could probably use GPS (https://tweaked.cc/guide/gps_setup.html) to figure out where the turtle is and carry on building from their.