SRL Archive - SRL Archives

MultiUTWait, and UTWait.


Nava2

2009-02-14 13:19:04

Both ideas came from Narcle's scripts… ANYWAYS

Here is the code I use:

//Waits until the required uptext appears. Max of 500 Original Credits to munk.
function MultiUTWait(Texts: TStringArray): Boolean;

var
iTime: Integer;

begin
iTime := GetTimeRunning + 500;
Result := StrInArr(GetUpText, Texts);
while (iTime > GetTimeRunning) and not (Result) do
begin
Wait(RandomRange(10, 50));
Result := StrInArr(RS_GetUpText, Texts);
end;
end;

// See MultiUTWait
function UTWait(Text: String): Boolean;
begin
Result := MultiUTWait([Text]);
end;

So, it waits a max of 500ms for the correct uptext to appear. Otherwise, it will return false.

This allows for lag w/ computers!

Comments?

Also, I attached the string array functions of Narcle's. They should be added…

//Narcle
function StrInArr(str : string; arrS : TStringArray) : Boolean;

var
I, L, H: Integer;

begin
Result := True;
Str := LowerCase(Str);
L := Low(arrS); H := High(arrS);
for I := L to H do
if Pos(Str, LowerCase(arrS[I])) > 0 then
Exit;
Result := False;
end;

//Narcle
function ArrInStr(arrS : TStringArray; str : string) : Boolean;

var
I, L, H: Integer;

begin
Result := True;
Str := LowerCase(Str);
L := Low(arrS); H := High(arrS);
for I := L to H do
if Pos(LowerCase(arrS[I]), Str) > 0 then
Exit;
Result := False;
end;

//Narcle
function CombineStrArray(Ar1, Ar2: TStringArray): TStringArray;
var
Temp: TStringArray;
L, H, i: integer;
begin
SetArrayLength(Temp, Length(Ar1) + Length(Ar2));
L := Low(Ar1);
H := High(Ar1);
For i := L to H do
Temp[i] := Ar1[i];
L := H + 1;
H := High(Temp);
for i := L to H do
Temp[i] := Ar2[i-L];
Result := Temp;
end;

Narcle

2009-02-14 15:37:48

UTWait is originally munks (mines a bit different), I made MultiUTWait based off that.

I believe StrInArr is already in, cept it requires a var to return the point which it was found - think its n3ss3s's.

Nava2

2009-02-14 15:44:35

Nah, InStrArr is different, it checks for the exact occurance, rather than yours which use a Pos check.

And I will add munk's credit.

Narcle

2009-02-14 15:45:21

From: Nava2
Nah, InStrArr is different, it checks for the exact occurance, rather than yours which use a Pos check.

And I will add munk's credit.


Ah I see, was wondering about that.