Page 1 of 1

Pretty display for tables

Posted: Sun Jul 12, 2009 12:56 pm
by Ryan
I got sick of trying to work with printTable, so I wrote my own display function. It can handle variables of any type including nested tables. It also lets you specify a format to use for number variables. Here's an example of how it looks on an arbitrary complex table:

Code: Select all

table {
  1: 'first'
  2: true
  3: false
  'key1': table {
    1: 'You see exits leading north and south.'
    2: 'exits'
    3: 'leading '
    4: 'north and '
    5: 'north'
    6: 'south'
    'full table': table {
      'a': 1
      'c': 3
      'b': 2
    }
    'blank table': table {}
  }
  'key2': 256
}
I haven't put it through industrial-strength testing, so if you notice something strange, it's probably a bug not a feature. Let me know and I'll fix it, or feel free to do it yourself and post an updated version of the package.

Re: Pretty display for tables

Posted: Sun Jul 12, 2009 7:47 pm
by Heiko
I'll add your pretty print display function to the general Lua API in luaGlobal.lua if you don't mind.
Then everybody can use it as a built in function.