SRL Archive - Research & Development Lounge

First TPA function - FindObjTPAEx


Cazax

2008-03-11 20:06:53

My first TPA function :)

function FindObjTPAEx(var x,y : Integer; Color,Tol,CTS,ObjWidth,ObjHeight,MinPoints : Integer; UpText : String; x1,y1,x2,y2 : Integer) : Boolean;
var
fx,CurrentCTS,yx,i,a,b : Integer;
Points : TPointArray;
PointsEx : T2DPointArray;
begin
CurrentCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
a := GetSystemTime;
FindColorsSpiralTolerance(fx, yx, Points, Color, x1, y1, x2, y2, Tol)
if Length(Points) < MinPoints then
begin
PointsEx := TPAToATPAEx(Points, ObjWidth, ObjHeight);
for i:=0 to Length(PointsEx)-1 do
begin
if Length(Points) < MinPoints then
MiddleTPAEx(PointsEx[i], fx, yx);
MMouse(fx, yx, 5, 5);
if IsUpText(UpText) then
begin
GetMousePos(x,y);
Result := True;
ColorToleranceSpeed(CurrentCTS);
b := GetSystemTime - a;
Writeln('Finding Obj took : '+inttostr(b)+' msecs');
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;
end else
Result := False;
ColorToleranceSpeed(CurrentCTS);
end;

Da 0wner

2008-03-11 20:52:33

Example pl0x?

R0b0t1

2008-03-11 21:58:43

Franky, there is so many of these I'm not really impressed…


But I'm sure you learned something in the process. :)

n3ss3s

2008-03-12 08:47:47

Hmm, some things -


Result := False;
ColorToleranceSpeed(CurrentCTS);


No need to return the CTS if you ain't going to use Exit :rolleyes:


Length(PointsEx)-1


High(PointsEx).

gerauchert

2008-03-12 08:55:38

looks like you got the hang of TPAs … gratz man ;)

Cazax

2008-03-12 16:05:46

From: Da 0wner
Example pl0x?

What's hard there?
e.g:
 if FindObjTPAEx(x, y, 51564, 10, 1, 20, 15, 2, 'Oak', MSX1, MSY1, MSX2, MSY2) then
Mouse(x, y, 5, 5, True)
blabla...

From: R0b0t1
Franky, there is so many of these I'm not really impressed…


But I'm sure you learned something in the process. :)

:)

From: n3ss3s
Hmm, some things -



No need to return the CTS if you ain't going to use Exit :rolleyes:




High(PointsEx).

Kk im learning :)

From: gerauchert
looks like you got the hang of TPAs … gratz man ;)


You know ;)