I've found the movetoclosestactor code very handy (code follows) but I'd like to get the closest clones object number too. How can I extract the actual number of (closest->clonename) ready for display in a text.number ?
movetoclosestactor code:
int n;
double mindist = 10000; //Initialize min distance with some high value
Actor *actors, *closest = NULL;
//Get all actors that collides with the sensor actor
actors = getAllActorsInCollision("Event Actor", &n);
if(actors)
{
int i;
for(i = 0; i < n; i++)
{
if(strcmp(actors[i].name, "player") != 0) //Ignore the player actor
{
double d = distance(player.x, player.y, actors[i].x, actors[i].y);
if(d < mindist)
{
//Hold the closest actor
closest = (actors + i);
mindist = d;
}
}
}
}
//Move the closest actor, if any
if(closest)
{
MoveTo(closest->clonename, 0, 0, 5, "player", "");
}