So, I ended up making my own.
Do note, this isn't optimized in any way, and probably produces serialized strings far larger than what they need to be. This demo will print a table using simple print() statements. It will then serialize that table, unserialize the resulting string, and print the new table, using the same printing method.
It can serialize any of the following:
- Numbers
Code: Select all
n = 1000234123.324
serialize(n)
Code: Select all
n = "Lalala I'm so pretty!"
serialize(n)
Code: Select all
n = {}
n.numbah = 123
n.string = "No, you're uggly!"
table.insert(n,321)
table.insert(n,"WHAT IS THIS I DON'T EVEN")
n.self = n
serialize(n)
It can't serialize any of the following:
- Metatables of tables (You could, theoretically, serialize the metatable apart and then re-join after unserializing)
Code: Select all
n = {}
meta = {}
meta.something = "that" -- I don't even know how to use metatables!
table.setMetatable(n,meta) -- Or whatever it is
serialize(n) -- The metatable will be lost!
Code: Select all
gimmeAZero = function() return 0 end
serialize(gimmeAZero) -- Will return AN EMPTY STRING (Not nil)
n = {}
n.func = gimmeAZero
serialize(n) -- n.func will be lost!