r/ComputerCraft • u/topHatCatGoBrrrrr • Apr 14 '22
lua objects/tables on floppy disks?
hi, i was wondering how to get a lua object onto a floppy disk?
so far ive been trying to use fs.open() and textutils.serialize() but when i try to read the table there are backslashes whenever theres a new line. is there a way to get rid of them/ignore them?
3
u/fatboychummy Apr 15 '22
Assuming you are dumping a string with newlines into a file?
If so, that won't preserve newlines in the way you expect. It does preserve them, but it replaces them with \n because you cannot insert an actual newline into a string delimited with ".
"this is not
a valid string"
"this is \na valid string"If you use textutils.unserialize when reading back the file, those will be inserted as newlines properly.
Or are you just looking at the direct output of textutils.serialize? If so, \n will be written as an actual newline, \\n will be written as \n.
1
u/IKnowATonOfStuffAMA Apr 14 '22 edited Apr 15 '22
Try using textutils.serializeJSON instead
Edit: Ok, what happened? It didn't work?
2
u/topHatCatGoBrrrrr Jun 14 '22
I completely forgot that I made this thread, I’ve sorted it out now, I just used texturizes.unserialise