SRL Archive - SRL Archives

FindObjBoxSkip, never looks at the same place twice!


Markus

2007-05-30 12:42:08

When testing some of SRL's object finding functions, I always had the same problem:
It was moving the mouse to places where it already moved the mouse too, thus making it detectable and very, very slow.
As I was very annoyed I created a new function using FindColorSkipBoxArrayTolerance.
It will start using tolerance zero and only raises the tolerance if necessary. The set tolerance will be the max. tol.

{*******************************************************************************
function FindObjBoxSkip(var x, y : integer; color, tolerance : integer; text : string) : boolean;
By: Markus
Description: Will find an object using the set color and text. If the uptext isn't the right one,
it will create a 20x20 box around the point and starts looking again for the color.
Starts with tolerance zero and will raise if necessary until the set tolerance
*******************************************************************************}
function FindObjBoxSkip(var x, y : integer; color, tolerance : integer; text : string) : boolean;
var
cx, cy : integer;
tries : integer;
temptol : integer;
Tempbox : TBox;
Skipbox : TBoxArray;
begin
repeat
if FindColorSkipBoxArrayTolerance(cx, cy, color, msx1, msy1, msx2, msy2, temptol, skipbox) then
begin
MMouse(cx, cy, 1, 1);
if IsUpText(text) then
begin
result := true;
x := cx;
y := cy;
exit;
end else
begin
SetArrayLength(SkipBox, GetArrayLength(skipbox) + 1);
Tempbox.x1 := cx - 10;
Tempbox.y1 := cy - 10;
Tempbox.x2 := cx + 10;
Tempbox.y2 := cy + 10;
Skipbox[tries] := Tempbox;
tries := tries + 1;
end;
end else
begin
temptol := temptol + 1;
end;
until(temptol > tolerance);
end;

Feel free to use this in any script, as long as you give credits.

shaunthasheep

2007-05-30 12:48:05

ooo this is teh s3xyin3ss!! lolz.
Nice work, ill try to find a use for it =p

Markus

2007-05-30 13:18:14

Try to use it at the ess mine and tell me your results, I can't test it there ATM.

Wizzup?

2007-05-30 13:20:58

From: markus
Try to use it at the ess mine and tell me your results, I can't test it there ATM.


Why the ess mine? :p

Markus

2007-05-30 13:23:53

Many of the same colors, and another reason is that I have to write some scripts as an alternative to others that are widely used and I need people to test if the alternatives of those widely used scripts have functions that can compete the other scrips one.
Short version: This will be used in my and Doofys essminer and that's why I want people to test this. This will be used in my tut runner too.