Page 2 of 2

PostPosted: Sun Jan 07, 2007 4:28 pm
by Troodon
It says:
Error line 27 Wrong number of arguments for MoveTo

PostPosted: Sun Jan 07, 2007 4:33 pm
by makslane
You don't need change the MoveTo line.
What's the code?

PostPosted: Sun Jan 07, 2007 4:35 pm
by Troodon
Here is the full code:
Code: Select all
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, "tree") == 0) //On tree actors
    {
       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", "");
}

PostPosted: Sun Jan 07, 2007 4:54 pm
by makslane
If you are using a version prior the 1.3.6, remove the last argument ("") of the MoveTo function.

PostPosted: Sun Jan 07, 2007 5:04 pm
by Troodon
I'm still using the 1.3.3 version. :oops:
Now it accepted the code but there is no effect in the game. Is this correct?
Code: Select all
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, "tree") == 0) //On tree actors
    {
       double d = distance(sini.x, sini.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");
}


The SINI actor is suppoesed to move towards the closest Tree actor.

PostPosted: Sun Jan 07, 2007 10:43 pm
by makslane
I think is a better idea you download the 1.3.6 version and see the sample working.

PostPosted: Tue Jan 09, 2007 2:51 pm
by Troodon
I downloaded the 1.3.6 demo and I'll try it some days. Why it's so hmm...dark? :lol:
I couldn't get it work yet, but I'll keep trying with the 1.3.6 and when I succeed, I'll just copy the code.
This is also a good oportunity for me to see the latest tutorials and games! :D