Would this be good to find a tree?
SCAR Code:
program New;
{.include SRL\SRL.scar}
const
TreeName = 'Tree';
Color = 0;
Color2 = 0;
function getTrees: TPoint;
var
treeATPA: T2DPointArray; //Largest
treePoints: TPointArray; //Medium
treePoint: TPoint; //Smallest
i: Integer;
begin
FindColorsTolerance(treePoints, Color, MSX1, MSY1, MSX2, MSY2, 0);
if Length(treePoints)=0 then
FindColorsTolerance(treePoints, Color2, MSX1, MSY1, MSX2, MSY2, 5);
treeATPA := TPAtoATPAEx(treePoints, 5, 5);
for i := 0 to High(treeATPA) do
begin
treePoint := MiddleTPA(treeATPA[i]);
MMouse(treePoint.x, treePoint.y, 0, 0);
Wait(350 + Random(350));
if IsUpText(TreeName) then
begin
case Random(2) of
0: begin
Mouse(treePoint.x, treePoint.y, 0, 0, True);
Result := Point(treePoint.x, treePoint.y);
Exit;
end;
1: begin
Mouse(treePoint.x, treePoint.y, 0, 0, False);
Wait(250 + Random(350));
if ChooseOption('Chop') then
begin
Result := Point(treePoint.x, treePoint.y);
Exit;
end;
end;
end;
end;
end;
end;
begin
SetupSRL;
WriteLn(IntToStr(getTrees.x) + ' ' + IntToStr(getTrees.y));
end.