Topic: One function for all clones

Hello, there's one thing that bugged me for quite some time, I want to make a single function working for all clones,
here's a simple picture to illustrate :

PunBB bbcode test

I want that when clone A or clone B collides with collision mesh, it start playing animation BUT :
1) not all clones at once (if clone A collides and play animation, clone B should not play)
2) without the need to copy & paste the whole function for each clones using cloneList[1] cloneList[2] etc

Currently i'm using method 2, but that's alot of trouble when i must tweak something

Hope i explained good enough, any tips on this ?

Re: One function for all clones

Do you mean only one clone at a time should play an animation ? even if both are in collision ?
If yes, you can stop the test when you find the first collision :

for clone in cloneList do

    if isCollisionBetween(clone, collisionMesh) then
        changeAnimation(clone, x)
        break -- break exit the for loop

Re: One function for all clones

To resume, i'm trying to make an AI that works more or less like a behavior ;
you spawn clones and they automatically receive the movements, animations, statistics etc, so you can spawn as many as you want and don't have to worry about anything

I think i'm getting closer, however i just past 12 hours trying to get that thing working (which still doesn't..), i'm out of juice. note that i'm not using any local or metatables things, that might be the problem..

If you don't mind checking, i'll upload the project i'm working on tomorrow

Re: One function for all clones

send me an exemple as simple as possible and explain what behavior you expect.

but yes, for something like that, the best will be to use a metatable (that I'm just starting to understand).