Large Meta-Table Serialization

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
CanadianGamer
Party member
Posts: 132
Joined: Tue Jun 30, 2015 1:23 pm
Location: Canada
Contact:

Large Meta-Table Serialization

Post by CanadianGamer »

So I'm making a game that requires a fairly sizeable meta table to store game information in this meta table has arrays in it which also have more meta tables and integers etc. My question is how to serialize this. I've tried googling and searching the forums but it seems that most serialization libraries don't support meta tables. Any help would be appreciated.
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Large Meta-Table Serialization

Post by ivan »

Serialization is usually for data whereas metatables are not data, but moreover define the behavior when accessing and assigning keys in a table.
I think you need to include your code so we can see if what you're doing makes sense.
User avatar
CanadianGamer
Party member
Posts: 132
Joined: Tue Jun 30, 2015 1:23 pm
Location: Canada
Contact:

Re: Large Meta-Table Serialization

Post by CanadianGamer »

I'm not sure I was using the right terminology when I said meta tables but in any case, what I meant was something like this

Code: Select all

table1 = {field1 = 2, field2 = 1}
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Large Meta-Table Serialization

Post by MrFariator »

That's just a regular lua table, or perhaps in other words an associative array or dictionary. All tables in lua store data with key/value pairs, and you can read more about it here and here with examples.

As for your question, yes, you can serialize tables fairly easily, for example by using bitser, or just about any other serializer listed here.

You can read what meta tables (and meta methods) actually are from lua docs. For a lot of use cases you could just serialize the actual data in the table, and set the relevant meta tables or methods at run time after the data has been deserialized.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Large Meta-Table Serialization

Post by zorg »

Also, tables in tables are often called nested tables instead.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Semrush [Bot] and 11 guests