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

[lua] arrays and data storage

Started by callos, 12 November 2012 - 06:39 AM
callos #1
Posted 12 November 2012 - 07:39 AM
Ok, so I have a program that allows me to draw 3D shapes and then have them created by a turtle.
The position data for these shapes is stored in a massive array (1000 variables stored) and each variable is a 1-9 (representing the inventory slot to be accessed for the block to be placed

Anyhow, my problem is this. I can draw my shapes very nicely but I can't save my drawings

Is there any way to save the entirety of an array to an external file somehow?
Lyqyd #2
Posted 12 November 2012 - 07:48 AM
textutils.serialize() will convert a table to a serialized string (which can then be converted back to a table with textutils.unserialize(), but your table may be too large for this. You can try that, or try manually writing your table to the file and manually reading it back.
Espen #3
Posted 12 November 2012 - 08:03 AM
In case textutils.serialize() turns out not to work for your massive tables, then as an alternative you could try to store the table to the filesystem.

Two APIs come to mind, one from [member='Advert'] and one from [member='kazagistar']:
Vault (alpha) - save your data
Transparent recursive filesystem persistence API
callos #4
Posted 12 November 2012 - 09:45 AM
textutils was perfect guys, thanks