EDIT*
I am trying to find the minimum value of an array of enemy distances compared to each enemy that calls the function. I have been able to succesfuly store the distances but I am having trouble setting my.min_distance to the minimal value in the array.
The array ignores values of 0;
Here is the array code that deals with 4 enemies:
function find_min()
{
if (my.l < 4)
{
if(E2E[my.pos*4 + my.l] < 300 && E2E[my.pos*4 + my.l] != 0)
{
if(my.min_distance == 0)
{
my.min_distance = E2E[my.pos*4 + my.l];
}
else
{
if(E2E[my.pos*4 + my.l] < my.min_distance )
{
my.min_distance = E2E[my.pos*4 + my.l];
}
}
}
my.l += 1;
}
if(my.l >= 4){my.l = 0;}
}
No worries. Got it sorted. Seemed I needed a switch type value to kick off for the first value that wasnt 0 to make itself the first minimal value.
function find_min()
{
if (my.l < 4)
{
if(E2E[my.pos*4 + my.l] > 0 && my.first_value == 0)
{
my.temp_value = E2E[my.pos*4 + my.l];
my.first_value = 1;
}
if(E2E[my.pos*4 + my.l] > 0 && my.first_value == 1)
{
if(E2E[my.pos*4 + my.l] < my.temp_value)
{
my.temp_value = E2E[my.pos*4 + my.l];
}
}
if(my.l == 3 && my.first_value == 1)
{
my.min_distance = my.temp_value;
}
my.l += 1;
}
if(my.l >= 4){my.l = 0;my.first_value = 0;}
}