SRL Archive - SRL Archives

MadnessFindObj


MylesMadness

2008-09-27 16:53:34

Everyone else was making some so I decided to make one.
Function MadnessFindObj(var x, y:Integer; Colors:TIntegerArray; UpText:String; x1, y1, x2, y2, tol:Integer):Boolean;
var
Points, ATPA:T2DPointArray;
TPA:TPointArray;
TP:TPoint;
I:Integer;
begin
SetArrayLength(Points, GetArrayLength(Colors));
For I:=0 to high(Colors)do
FindColorsSpiralTolerance(X, Y, Points[i], Colors[i], x1, y1, x2, y2, Tol);
For I:=0 to high(Colors)do
TPA:=CombineTPA(TPA, Points[i]);
SortTPAFrom(TPA, Point(x, y));
ATPA:=TPAtoATPA(TPA, 10);
For I:=0 to high(ATPA)do
begin
TP:=MiddleTPA(ATPA[i])
MMouse(TP.x, TP.y, 2, 2)
If IsUpText(UpText)then
begin
Result:=True;
GetMousePos(x, y);
exit;
end;
end;
end;

The x and y variable are also the screen middle point.

PvH

2008-09-27 16:57:08

Looks good.. but shouldn't it be:

Function MadnessFindObj(var x, y:Integer; Colors:TIntegerArray; UpText:String; x1, y1, x2, y2, tol:Integer):Boolean;
var
Points, ATPA:T2DPointArray;
TPA:TPointArray;
TP:TPoint;
I:Integer;
begin
SetArrayLength(Points, GetArrayLength(Colors));
For I:=0 to high(Colors)do
FindColorsSpiralTolerance(X, Y, Points[i], Colors[i], x1, y1, x2, y2, Tol);
For I:=0 to high(Colors)do
TPA:=CombineTPA(TPA, Points[i]);
SortTPAFrom(TPA, Point(x, y));
ATPA:=TPAtoATPA(TPA, 10);
For I:=0 to high(ATPA)do
begin
TP:=MiddleTPA(ATPA[i])
X:=Tp.x;
Y:=Tp.y;
MMouse(TP.x, TP.y, 2, 2)
If IsUpText(UpText)then
begin
Result:=True;
exit;
end;
end;
writeln('Failed to find the object');
end;

As you need the result :rolleyes:

PvH

noidea

2008-09-27 17:37:45

 If IsUpText(UpText)then
begin
getmousepos(x, y)
Result:=True;
exit;
end;
Maybe a getmousepos() at the end?(Just to verify the (x, y)?)

MylesMadness

2008-09-27 18:35:23

Alright, fixed