Jump to content




textutils.tabulate & Table in Tables


  • You cannot reply to this topic
4 replies to this topic

#1 CCDan

  • New Members
  • 2 posts

Posted 01 July 2013 - 07:13 AM

I'm trying to use textutils.tabulate to output tables within tables. However the amount of tables are unknown. How can I loop through available tables within textutils.tabulate?

Example below:
local tTable = {
{"Heading1", "Heading2", "Heading3"},
{"Entry1a", "Entry1b", "Entry1c"},
{"Entry2a", "Entry2b", "Entry2c"}}
--tabulate tables, knowing first entry will always exist
textutils.tabulate(tTable[1], ???)

Thanks

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 01 July 2013 - 01:05 PM

Split into new topic.

#3 Zudo

  • Members
  • 800 posts
  • LocationUK

Posted 01 July 2013 - 01:36 PM

I think you need to do something like this
for x = 1, #tTables do
 textutils.tabulate(tTables[x])
end

This is probably not the best way to do it tho...

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 01 July 2013 - 01:53 PM

If you are using numerical indices, you can use unpack. unpack returns all the values stored in the table (only for numerical indices), so you can then pass them to the tabulate function. Like this:
textutils.tabulate(unpack(tTables))


#5 CCDan

  • New Members
  • 2 posts

Posted 02 July 2013 - 06:19 PM

Thank you MysticT this worked great.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users