PDA

View Full Version : FindDTMCustom



Abu
04-13-2012, 02:51 PM
{ FindDTMCustom
~~~~~~~~~~~

.. code-block:: pascal

function FindDTMCustom(DTM: TIntegerArray; Text: TStringArray; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;

Searches for Multiple DTMs with Multiple Uptext within the area xs, ys, xe, ye.
Leave Uptext Empty to stop the function moving the mouse.
If found, returns the x and y co-ordinates and results true.

.. note::

by abu_jwka

Example:

.. if FindDTMsCustom([Oak, Willow], ['ak l', 'illo'], x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Logs not burned yet! Clicking Tinderbox');
MouseTBox(InvBox(1),1);
end;
}

function FindDTMCustom(DTM: TIntegerArray; Text: TStringArray; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
var
b: Integer;
begin
for b := 0 to High(DTM) do
begin
if (FindDTM(DTM[b], x, y, xs, ys, xe, ye)) then
begin
if (Length(Text) > 0) then // if searching for uptext
begin
MMouse(x, y, 0, 0);
if WaitUptextMulti(Text, 2000) then
begin
GetMousePos(x, y);
Result := True;
Exit;
end;
end else //if not searching for uptext
begin
GetMousePos(x, y);
Result := True;
Exit;
end;
end;
end;
end;

What are the advantages? It stops people using multiple 'if FindDTM then' statements. So a cleaner looking script and less hassle. Also eliminates the need for moving the mouse and checking for uptext as the function does it for you. :)

Sin
04-13-2012, 02:54 PM
Erm, wouldn't it be easier just to use the regular DTM finder...?
Also, Mousing over the object/item seems to be a bit risky, DTMs are meant to be so that we don't have to mouse it over.
For example, i can find Molten Glass in my inventory without having to mouse it over via a DTM :s

Abu
04-13-2012, 03:01 PM
Erm, wouldn't it be easier just to use the regular DTM finder...?
Also, Mousing over the object/item seems to be a bit risky, DTMs are meant to be so that we don't have to mouse it over.
For example, i can find Molten Glass in my inventory without having to mouse it over via a DTM :s

Taking that into the consideration I've edited so that it only moves the mouse to check the uptext if an Uptext is put in. If no uptext is put in, it will simply find the DTMs and Result True as well as return the co-ordinates of the first found DTM

Coh3n
04-13-2012, 06:29 PM
Not a bad function, but I think it's something that should be left up to the scripter. Moving to SRL Snippets.

tehq
04-13-2012, 06:39 PM
How about a WaitFindDTMCustom? I believe that would be more useful.

Abu
04-13-2012, 06:49 PM
Nah there's already a WaitFindDTM function.

tehq
04-13-2012, 06:55 PM
Nah there's already a WaitFindDTM function.

I believe you misread.. I know there's WaitFindDTM and WaitFindDTMEx. I'm talking about your idea with the TStringArray combined with a wait and max time.