I have a piece of code that runs through a table to see if anything in that table matches. More specifically, the code checks if the current floor matches any “.floor” value in the table. The problem is, once it’s checked, I’d like to delete that value from the table altogether, but I don’t know how to do that. My current method doesn’t work because if you run ‘function selectPeople’ twice, it throws and error because “persontable[i]:removeSelf()” appears to try to remove a nil value. What is the proper way to delete a value in a table completely?
local function selectPeople(floor)
local i
for i = 1,table.maxn(persontable) do
if ( persontable[i].floor == floor ) then
persontable[i]:removeSelf()
table.remove (persontable[i])
end
end
Hope that makes sense - thanks! [import]uid: 78150 topic_id: 21499 reply_id: 321499[/import]