collision - event.other to get object table index ?

I have a table of ball physics objects.
And a right border static object with bounce=1

I want to know which ball collided with the borderRight object

From the manual:
" each collision event includes event.other, which contains the table ID of the other Corona display object involved in the collision. "

So it seems it returns only the table ID and not the ID of the object in that table… ?
Otherwise, this would not return an error:

local onLocalPostCollision = function ( self, event )  
 local b = balls -- a table  
  
 b[event.other].x = 0  
 --Error: ... attempt to index field '?' (a nil value)   
end  
  
borderRight.postCollision = onLocalPostCollision  
borderRight:addEventListener( "postCollision", borderRight )  

So do I have to explicitly give each ball object a name on creation?
And can that name be a whole number ? [import]uid: 186251 topic_id: 33212 reply_id: 333212[/import]

give your balls an index … …

eg.
<br>balls[1].index = 1<br>

during creation. You should then be able to detect during the event.

There is also a table.indexOf method, but if you remove elements from the table, you may not receive the index you are expecting. :slight_smile: [import]uid: 21331 topic_id: 33212 reply_id: 132013[/import]

That works - thanks . [import]uid: 186251 topic_id: 33212 reply_id: 132093[/import]

give your balls an index … …

eg.
<br>balls[1].index = 1<br>

during creation. You should then be able to detect during the event.

There is also a table.indexOf method, but if you remove elements from the table, you may not receive the index you are expecting. :slight_smile: [import]uid: 21331 topic_id: 33212 reply_id: 132013[/import]

That works - thanks . [import]uid: 186251 topic_id: 33212 reply_id: 132093[/import]