Determine the index of a value in a Lua table?

I’m setting up arrays of objects that I garbage collect once they’ve gone off screen. For example, spawning a bad guy every 2 seconds and then table.insert(badGuyArray, badGuyObject) so I can find it later when I need to clean them up. Sometimes however, I need to table.remove() prior to my normal checking when I’d just iterate through the whole list. Obviously, when I’m iterating through if the object meets a certain condition I have it’s index number from the iterator variable and I can just call a remove directly.

Is there however a faster way to do this if I just have the object itself, for example in a collision event listener? Is there a way to simply get the index so I can call table.remove immediately, or do I have to iterate through the array until the value=object and then call remove on that index? [import]uid: 75335 topic_id: 12583 reply_id: 312583[/import]