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

[not a bug][1.?-1.63][SSP/SMP]textutils.serialize with multiline strings

Started by MKlegoman357, 05 May 2014 - 07:07 PM
MKlegoman357 #1
Posted 05 May 2014 - 09:07 PM
ComputerCraft Version Information: Found using CC 1.63. I suspect this bug appeared either in CC 1.6 or earlier.

Description of Bug:
textutils.serialize doesn't serialize strings with newlines correctly and makes it impossible to unserialize it using textutils.unserialize.

Screenshot:


Not a bug. It's just how print function prints it.

Note to myself: check before posting, so you wouldn't waste your or anyone else's time…
Edited on 06 May 2014 - 09:08 AM
CometWolf #2
Posted 05 May 2014 - 09:39 PM
Why would you serialize a lone string in the first place…? I assume this happens if it's contained in a table aswell?
MKlegoman357 #3
Posted 05 May 2014 - 10:09 PM
Why would you serialize a lone string in the first place…? I assume this happens if it's contained in a table aswell?

Yes it does, textutils.serialize serializes everything that is in a table using itself.

I was testing my program, serializing a table and saving it to a file, and found this problem. I'm actually wondering how long this bug exists because I don't think Dan changed all of the serialize function when he updated to CC 1.6 and I think this bug may be living since the creation of this function…

EDIT:
Why would you serialize a lone string in the first place…?

If you're creating a config file and want values to be properly serialized before saving them, IDK.
Edited on 05 May 2014 - 08:14 PM
CometWolf #4
Posted 05 May 2014 - 11:05 PM
The serialize function was changed to make it's output more readable in 1.6. He added newlines to it, so it might be related. I can test this in 1.58 tomorrow just to be sure though.
Bomb Bloke #5
Posted 06 May 2014 - 01:06 AM
It works the same way prior to 1.6x.

Note "works" - textutils.unserialise() has no problems with that output.

Nice to see there's a textutils.unserialise() in 1.6, by the way.
Wojbie #6
Posted 06 May 2014 - 02:32 AM
It works the same way prior to 1.6x.

Note "works" - textutils.unserialise() has no problems with that output.

Nice to see there's a textutils.unserialise() in 1.6, by the way.

True - it just looks funky when you try to print it cause print in lua program prints serialized table again.
Also s thing. You would not believe how many times it happened to me.
Edited on 06 May 2014 - 12:33 AM
Lyqyd #7
Posted 06 May 2014 - 06:29 PM
Moved to Ask a Pro by request.