OK
i made it work ( not really) Im still implementing some features to make it more reallistic but the OVERALL IDEA works but with ONE BLOODY PROBLEM.
here is the code
Code:

function put_grass()
{

if(grass_index < 200)
{

teste2 =grass_index; //just for debugging purposes
you = grass_pointer[grass_index];

you.x = nearest_pos_x;
you.y = nearest_pos_y;

grass_index += 1;

}

return;

}


function define_nearest_pos()
{
grass_index = 0; //reset
grass_array_index = 0; //reset


while(grass_array_index < 1000)
{
if(vec_dist(global_player_pos.x,grass_array_x[grass_array_index] ) < 8000)&&(vec_dist (global_player_pos.y, grass_array_y[grass_array_index]) < 8000)
{

nearest_pos_x = grass_array_x[grass_array_index];
nearest_pos_y = grass_array_y[grass_array_index];
put_grass();
}

grass_array_index += 1;
}

}

function initial_grass_func()
{
my.passable = on;
my.scale_x = 0.5;
my.scale_y = 0.5;
my.scale_z = 0.5;
my.z = 64;

}


function define_grass_and_positions()
{
i_max_grass = 0;//reset
i_grass_array_index = 0; //reset


while(i_grass_array_index < 1000)
{
grass_array_x[i_grass_array_index] = random(10000);
grass_array_y[i_grass_array_index] = random(10000);
i_grass_array_index += 1;
}

while(i_max_grass < 200)
{
grass_pointer[i_max_grass] = ent_create (grass1, nullvector, initial_grass_func);
i_max_grass += 1;
}

if(i_grass_array_index >= 1000)&&(i_max_grass >= 200){define_nearest_pos();}//IF its has finished defining and creating ...

}



At first the "define_grass_and_positions()" function is called first, then down the road the function "define_nearest_pos()" is called by another function(not listed here) eveytime the variable "grass_array_index" gets to a 1000 so its always updating.


The problem is
Everytime I start the Engine sometimes its just doesnt work, the variable "grass_index" stays at 0 (zero) and sometimes it works fine.


anyone has any idea why?