SRL Archive - OSR Help

FindTree;


ReadySteadyGo

2010-02-04 11:17:11

This was working a few days ago, it's not now. I have changed added a new colour and cts settings etc but no luck. Can anyone help?

function FindTree : Boolean;
var
TempCTS, i, H : Integer;
TPA : TPointArray;
TempTBox : TBox;
ATPA : T2DPointArray;
begin
Result := False;
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.05, 0.97);
FindColorsTolerance(TPA, 15029504, MSX1, MSY1, MSX2, MSY2, 10);
ATPA := TPAToATPA(TPA, 50);
SortATPASize(ATPA, True);
H := High(ATPA);
for i := 0 to H do
begin
TempTBox := GetTPABounds(ATPA[i]);
if Distance(TempTBox.x1, TempTBox.y1, TempTBox.x2, TempTBox.y2) < 10 then
begin
SetArrayLength(ATPA, i);
Break;
end;
end;
H := High(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
if WaitUpTextMulti(['hop', 'own', 'ew' ], RandomRange(500, 1000)) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
Result := True;
Break;
end;
end;
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

Naum

2010-02-04 11:45:00

Owning to the fact of you using TPAToATPA, making the TPA's into individual 50 radii circles. Your error is, I gather, in this line:

 if Distance(TempTBox.x1, TempTBox.y1, TempTBox.x2, TempTBox.y2) < 10 then

I don't really think the distance of any of you TPA Bounds will be less than ten, but rather greater. However, If you can explain what you're trying to do with that line hopefully it will make it more clear.

ReadySteadyGo

2010-02-04 12:06:58

Sorry yes, that use of that line is specific to the Edgeville yews. It makes sure it ignores the leaflike plants to the left of the two yew trees. I'm not getting an error, it just isn't finding the tree and moving the mouse to it.

Gu3st...

2010-02-04 12:17:13

Have you tried debugging the TPA?
{.Include SRL/SRL/misc/Debug.scar}

and

DebugTPA; or DebugATPA;

ReadySteadyGo

2010-02-04 13:25:35

Sorry should have done that. Will do.