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

Turtle peripheral persistance

Started by Xfel, 27 August 2012 - 05:02 AM
Xfel #1
Posted 27 August 2012 - 07:02 AM
Adding persistant data to a normal peripheral is easy, as they simply extend the TileEntity class. However, turtle peripherals don't have that option. All data saved in them is lost when the turtle gets unloaded. Commands scheduled through the issueCommand method are lost, too. So, my suggestion would be to add readFromNBT and writeToNBT methods to the ITurtlePeripheral interface. The data would be saved in a sub-tag of the turtle's own nbt tag. When it's loaded again, the read method would be called on the new peripheral object.

If a named turtle gets destroyed, the nbt saving mechanism could even be used to persist the peripheral data, too.
Hackingroelz #2
Posted 27 August 2012 - 04:03 PM
You can already do this using an item to store the information.
Xfel #3
Posted 27 August 2012 - 05:31 PM
Er.. yes, but that is a very dirty way of doing this, you know? It would not so difficult to support this properly.
Cloudy #4
Posted 27 August 2012 - 06:36 PM
Good idea. Will see if can implement it for 1.3 port (as will be an API breaking change!).