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

Issue with immibis serialization api

Started by Monochrome, 17 May 2014 - 08:28 PM
Monochrome #1
Posted 17 May 2014 - 10:28 PM
Hi all,

I'm working on a project and felt the need for an improved serialization function. Thus I used Immibis' script which is pretty well known across the boards. (http://www.computercraft.info/forums2/index.php?/topic/302-api-proper-serialization/) However, it doesn't work..

From the lua terminal:

a = serialize.serialize("ABC")
(returns 03?ABC, which I think, is good)
b = serialize.deserialize(a)
(returns nil)

No matter what kind of data I try to deserialize, it ALWAYS deserializes to nil. Naturally, I checked that the fuction is found properly:
type(serialize.serialize) returns me "function"
I really have no clue what is wrong.. I have been digging around in the code but can't seem to find a problem :-( Only by manually using the serializeInt and deserializeInt functions I have been able to get a correctly deserialized integer.. yay?

lastly, I copied the code + the "usage" proof of concept code to a separate program too, to eliminate the possibility of api-engine related problems.. again, it serializes properly, but deserializes to nil..

Anyone experienced similar behavior on 1.6? Any idea what might be the problem here?
Monochrome #2
Posted 17 May 2014 - 10:49 PM
Okay, I seem to have solved it.. The code seems to contain a bug, although I really can't understand how so many have been able to use it already..

For anyone running into this: try replacing all type identifier strings (that consist of a zero followed by another number) by a single character number. So, "05" becomes "5". Do this for all identifiers (00 up to 06) in both the serialize and deserialize functions. Hope this helps anyone else, because it took me a couple of hours ;-)