SCAR Code:
program FindObject;
{.include SRL\SRL.scar}
var
x, y: Integer;
function FindObject(var fx, fy: Integer): Boolean;
var
arP, arAP: TPointArray;
arC, arUC: TIntegerArray;
ararP: T2DPointArray;
tmpCTS, i, j, arL, arL2: Integer;
P: TPoint;
H, S, L: Extended;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
if (FindColorsTolerance(arP, 4021099, MSX1, MSY1, MSX2, MSY2, 11))then
Mouse(x, y, 2, 2, True);
if not(FindColorsTolerance(arP, 4021099, MSX1, MSY1, MSX2, MSY2, 11)) then
begin
Writeln('Failed to find the color, no object found.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
arUC := arC;
ClearSameIntegers(arUC);
arL := High(arUC);
arL2 := High(arC);
for i := 0 to arL do
begin
ColorToHSL(arC[i], H, S, L);
if (H >= 10.83) and (H <= 10.90) and (S >= 27.37) and (S <= 27.70) and (L >= 30.76) and (L <= 34.73) then
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 9.22) and (X <= 11.94) and (Y >= 9.48) and (Y <= 12.27) and (Z >= 5.20) and (Z <= 6.61) then
begin
for j := 0 to arL2 do
begin
if (arUC[i] = arC[j]) then
begin
SetLength(arAP, Length(arAP) + 1);
arAP[High(arAP)] := arP[j];
end;
end;
end;
end;
end;
SortTPAFrom(arAP, Point(MSCX, MSCY));
ararP := SplitTPAEx(arAP, 10, 10);
arL := High(ararP);
for i := 0 to arL do
begin
if (Length(ararP[i]) < 10) then Continue;
P := MiddleTPA(ararP[i]);
MMouse(P.x, P.y, 5, 5);
Wait(100 + Random(100));
if (IsUpText('Take')) then
begin;
Result := True;
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
begin
Writeln('FindObject could not find object.');
Exit;
end;
GetMousePos(fx, fy);
end;
begin
SetupSRL;
FindObject(x, y);
end.