Lua table identifier

Started by
2 comments, last by inavat 12 years, 11 months ago
I am writing a Lua debugger that displays all variables, and the contents of all tables. One problem is that tables can reference other tables, and easily create infinite loops. In fact, the default Lua state with libraries loaded does exactly this.

Is there any way to get a unique id for each table, so that I know if a table has already been analyzed? It would make things much easier for me. Right now, I am trying to dynamically query tables over the network as the user opens treeview nodes, but I am getting a random memory error, and it feels really shaky.

[attachment=2151:Image2.png]

10x Faster Performance for VR: www.ultraengine.com

Advertisement
Programming in lua covers serialization of tables with cycles (which I guess is pretty similar to what you want). It just uses a "saved" table to keep the names of everything that's been serialized already.
Thanks, I think I will just have a set depth level it drills down to, like 3 or 4 levels. It's unlikely the user will need to drill down 20 recursive levels of tables.

10x Faster Performance for VR: www.ultraengine.com

Why not use one of the existing Lua debuggers? Decoda is the most well known one, though it's not free. I think it's only $50 for an indie license, however, and I'm sure writing one yourself would take at least $50 of your time. There are free ones as well.

If you're writing it for the sake of writing it, then go for it, good luck :)

This topic is closed to new replies.

Advertisement