Hello, I use table.copy to copy a table and get 2 independent tables. With list tables it works :
t1={1}
t2={1}
t1=table.copy(t2)
t1[1]=0
print(t2[1]) – =>1 OK
But with 2 dimensionnal or more tables it doesn’t work :
t1={{1}}
t2={{1}}
t1=table.copy(t2)
t1[1][1]=0
print(t2[1][1]) --=>0 WHY?
Anyone know how I could copy complex tables? Thanxx
I think the table.copy only works for the first level. Could try this one: http://snippets.luacode.org/snippets/Deep_copy_of_a_Lua_Table_2
If you Google ‘lua table deep copy’ you find more.
This snippet recursivly copy the whole table, thanks a lot !
I think the table.copy only works for the first level. Could try this one: http://snippets.luacode.org/snippets/Deep_copy_of_a_Lua_Table_2
If you Google ‘lua table deep copy’ you find more.
This snippet recursivly copy the whole table, thanks a lot !