Jump to content

How to loop more table datas under each other?


Turbesz

Recommended Posts

Posted

for example i have 2 table with 2 different data and i want to show them in a column like this: 

[Table name1]:
Data1
Data2
[Table name2]:
Anotherdata1
Anotherdata2

How can i do it this with loops?

  • Moderators
Posted
2 hours ago, Turbesz said:

How can i do it this with loops?

You can combine the tables first with for example this method table.merge. (make sure to copy the code)

And then loop through them.

 

Keep in mind that the table.merge method is mutating the first table. (mutating = changing the content of the table, instead of returning a new one)

table1 = {1,2,3}
table2 = {4,5,6}

----

local newTable = {}

table.merge(newTable, table1, table2)
-- or with table names
table.merge(newTable, {"table1"}, table1, {"table2"}, table2)

 

 

  • Thanks 1
Posted
18 hours ago, IIYAMA said:

You can combine the tables first with for example this method table.merge. (make sure to copy the code)

And then loop through them.

 

Keep in mind that the table.merge method is mutating the first table. (mutating = changing the content of the table, instead of returning a new one)


table1 = {1,2,3}
table2 = {4,5,6}

----

local newTable = {}

table.merge(newTable, table1, table2)
-- or with table names
table.merge(newTable, {"table1"}, table1, {"table2"}, table2)

 

 

Thank you, that's exactly what I want!

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...