PDA

View Full Version : First TPA function - FindObjTPAEx



Cazax
03-12-2008, 12:06 AM
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
03-12-2008, 12:52 AM
Example pl0x?

R0b0t1
03-12-2008, 01:58 AM
Franky, there is so many of these I'm not really impressed...


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

n3ss3s
03-12-2008, 12:47 PM
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
03-12-2008, 12:55 PM
looks like you got the hang of TPAs ... gratz man ;)

Cazax
03-12-2008, 08:05 PM
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...


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


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


Hmm, some things -



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




High(PointsEx).
Kk im learning :)


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

You know ;)