Simba Code:
(*
FindObjEx
~~~~~~~~~
.. code-block:: pascal
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
Searches for an object using an array of colors and texts within the area
you specify. Will start searching from the middle and returns true if found.
Parameters:
- cx, cy: Coordinate Position of object if result is true
- Text: Array of string you want to search for
- Color: Array of colors you want to search for
- Tol: Tolerance of the colors you will allow
- Step: How big you want to make the search squares.
50 = Default. 30-70 Recommended
- xs, ys, xe, ye: Bounds you want to search in
.. note::
by Starblaster100
Example:
.. code-block:: pascal
*)
function FindObjEx(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
CurX, CurY, a, b, c, i: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
Start := True;
Break;
end;
end;
if (Start) then
begin
CurX := Round((xs + xe) div 2);
CurY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin //To allow for beginning offset and loop
a := a + 1;
i := 0;
CurY := CurY + Step;
end;
1: CurX := CurX + Step;
2: CurY := CurY - Step;
3: CurX := CurX - Step;
4: CurY := CurY + Step;
end;
if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], CurX-(Step div 2), CurY-(Step div 2), CurX+(Step div 2), CurY+(Step div 2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
If (WaitUptextMulti(Text, 300)) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (Result) or ((CurX > xe) and (CurY > ye))
end;
end;