Combining tables
Posted: Fri Jul 03, 2009 10:28 am
I wrote a small function that takes two tables, list1 and list2 and combines them. I use it for concatenating lists of enemies. Is there an easier way to do this?
Code: Select all
function combinelists(list1 , list2)
index = {}
for i = 1, #list2 do
for v = 1, #list1 do
if list2[i] == list1[v] then
table.insert(index,i)
end
end
end
for i = 0, #index-1 do
table.remove(list2,index[#index-i])
end
for i = 1,#list2 do
table.insert(list1,list2[i])
end
return(list1)
end