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

Why don't my turtles resume when reloaded?

Started by Truitedu18, 20 March 2013 - 12:20 PM
Truitedu18 #1
Posted 20 March 2013 - 01:20 PM
I play at Feed The Beast Ultimate and I decide to use the turtles to mine and to do lot of things.
But I have a very big bug : every time I reload my World or the chunk where my turtle is unload, the turtle is entirely reset.
It's very problematic when I use a turtle to excavate and when I have to replace it every time.
However, this mod is very very good, I love it !

Thanks
Lyqyd #2
Posted 21 March 2013 - 06:28 AM
Split into new topic.

All computers which were on when the chunk was unloaded are rebooted when it reloads.
Truitedu18 #3
Posted 21 March 2013 - 07:49 AM
Ah, so.

Are you a solution to use a turtle like an Quarry without restart it all the time ?
I thought to create a file in the turtle with this coordinates to be able to continue the excavation, it's possible ?

Thanks
Lyqyd #4
Posted 21 March 2013 - 07:53 AM
Yes, it's possible to write a script which can keep track of what it's doing and where it's at and resume after a reboot. It may be best to use GPS to determine the position and heading when the turtle starts up, since accurately tracking turtle location across reboots is somewhat tricky.
Truitedu18 #5
Posted 21 March 2013 - 08:49 AM
Okay, thank you, I will search more information on GPS to do better programs :)/>
Engineer #6
Posted 21 March 2013 - 12:30 PM
For the writing to files you should do something like this:

write coords:

local tCoords = {}
tCoords.x = yourX
tCoords.y = yourY
tCoords.z = yourZ
local fileName = "myfile"
local file = fs.open = ( fileName, "w" )
fs.write( textutils.serialize( tCoords ) )
file.close()

To read files:

local fileName = "myfile"
local file = fs.open( fileName, "r" )
local reader = file.readAll()
file.close()

local coords = textutils.unserialize( reader )
print( coords.x )
print( coords.y )
print( coords.z )

That should help you quite a lot if you have found some GPS stuff :)/>
All credits go to LBPHacker's tutorial: http://www.computercraft.info/forums2/index.php?/topic/10654-storing-variables-in-a-file/