Your code basically defeat the purpose of a TPA function. TPA stands for an array of TPoints. The way you use it, you only use a single TP. You need to add a loop to go through each TP found.
Example:
Simba Code:
function FindObject(var x, y : Integer; Obj: MSObject; X1, Y1, X2, Y2:integer) : Boolean;
var
a : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
Box : TBox;
begin
if not LoggedIn then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Obj.Hue, Obj.Sat);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Obj.Col, X1, Y1, X2, Y2, Obj.Tol);
SortTPAFrom(TPA, point(MSCX,MSCY));
ATPA := TPAtoATPAEx(TPA, 15, 15);
for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
if MP.x = 0 then
Continue;
Box := IntToBox((MP.x - 20), (MP.y - 20), (MP.x + 20), (MP.y + 20));
MMouse(MP.x,MP.y,4,4);
if(WaitUpText(Obj.UpText, 400))then
begin
x := MP.x; y := MP.y;
Result := True
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2,0.2);
end;
To add CountColor in your function, you call add a line in the loop similar to:
Simba Code:
if CountColorTolerance(Color, Box.x1, Box.y1, Box.x2, Box.y2, Tolerance) < 100 then
Continue;
EDIT: Just to make sure "Continue;" is understood... what it does is basically skip the rest of the loop and go directly to the next TP. For example, if you were at the TPA[3] and you get it to Continue, it would jump straight to TPA[4] starting at the beginning of the loop.
This explanation is HORRIBLY worded, but hopefully you do understand.