Copy a table?

Post Reply
Alaran
Posts: 27
Joined: Sat Dec 19, 2009 2:51 pm

Copy a table?

Post by Alaran »

How do I copy a table? I tried various solutions on the net for lua but none seemed to work in mudlet. (I didn't get an error message in the debug window either :/ )

On that note, the table.* functions didn't seem to work either. Like table.foreach, table.sort, table.concat .. am I doing something wrong or is there a reason for that? And how do you sort a table then?

Alaran
Posts: 27
Joined: Sat Dec 19, 2009 2:51 pm

Re: Copy a table?

Post by Alaran »

Right, ignore me. The copy problem was entirely my fault. :oops:

I'm still curious about the table.* functions though, if anyone knows.

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Copy a table?

Post by Vadi »

Code: Select all

t = { 3,2,5,1,4}
display(t)
t = table.sort(t)
display(t)
or

Code: Select all

t = { 3,2,5,1,4}
display(t)
t = t:sort()
display(t)

Post Reply