Pretty display for tables

Share your scripts and packages with other Mudlet users.
Post Reply
Ryan
Posts: 10
Joined: Mon Jun 22, 2009 1:15 am

Pretty display for tables

Post 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.
Attachments
display.xml
pretty display function
(2.29 KiB) Downloaded 280 times

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Pretty display for tables

Post 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.

Post Reply