Whenever I print a table it comes up with table:something. How do I turn the table into text or a string?
[Question]How do you turn a table into text.
Started by whatsfast, Nov 29 2012 01:30 PM
4 replies to this topic
#1
Posted 29 November 2012 - 01:30 PM
#2
Posted 29 November 2012 - 01:34 PM
If you want to print what's in a table, you have to either go through it with a loop,
or just use table.concat().
for i=1, #someTable do print(someTable[i]) end
or just use table.concat().
print(table.concat(someTable,', ')) -- prints every part of the table with a comma in between each of them
#3
Posted 29 November 2012 - 01:51 PM
textutils.serialize(table)
#4
Posted 29 November 2012 - 02:39 PM
It the table contains strings and numbers, then Kingdaro's suggestion:
print(table.concat(someTable,',\n'))and
textutils.tabulate(someTable)Might be the quickest and cleanest ways to print it readable.
#5
Posted 30 November 2012 - 10:01 AM
textutils.serialize is mainly intended for when you need to store/transmit a table (in a file or over rednet), but it can also be useful if you just want the maximum specificity on the layout of the table.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











