SCAR Code:
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Waiting Routines --//
//-----------------------------------------------------------------//
// * Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean; // By Marpis & N1ke! & Rasta Magician
// * Function WaitOption(S: String; Time: Integer): Boolean; // By Marpis edited by N1ke!
// * Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean; // By Marpis & N1ke!
// * Function WaitUptext(S: String; Time: Integer): Boolean; // By Marpis edited by N1ke!
// * Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean; // By Rasta Magician
// * Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean; // By Rasta Magician
{*******************************************************************************
Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
By: Marpis & N1ke! & Rasta Magician
Description: Waits for a TStringArray of options and selects one of them
*******************************************************************************}
Function WaitOptionMulti(S: TStringArray; Time: Integer): Boolean;
var
T, a, b, c: Integer;
begin
T := GetSystemTime + Time;
repeat
Result := OptionsExist(S, True);
Wait(10+Random(10));
until(Result)or(GetSystemTime > T);
//from Mouse, but to be faster so we don't call GetMousePos twice.
Wait(60 + Random(30));
GetMousePos(b, c);
HoldMouse(b, c, left);
repeat
Wait(20 + Random(30));
a := a + 1;
until (a > 4);
GetMousePos(b, c);
ReleaseMouse(b, c, left);
Wait(100 + Random(100));
end;
{*******************************************************************************
Function WaitOption(S: String; Time: Integer): Boolean;
By: Marpis edited by N1ke!
Description: Waits for an Option and selects it
*******************************************************************************}
Function WaitOption(S: String; Time: Integer): Boolean;
begin
Result := WaitOptionMulti([S], Time);
end;
{*******************************************************************************
Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;
By: Marpis & N1ke!
Description: Waits for a TStringArray of UpText, returns true if found
*******************************************************************************}
Function WaitUptextMulti(S: TStringArray; Time: integer): Boolean;
var
T: Integer;
begin
T := GetSystemTime + Time;
repeat
Result := IsUpTextMultiCustom(S);
Wait(10+Random(10));
until(Result)or(GetSystemTime > T);
end;
{*******************************************************************************
Function WaitUptext(S: String; Time: Integer): Boolean;
By: Marpis edited by N1ke!
Description: Waits for an UpText, returns true if found
*******************************************************************************}
Function WaitUptext(S: String; Time: Integer): Boolean;
begin
Result := WaitUptextMulti([S], Time);
end;
{*******************************************************************************
Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
By: Rasta Magician
Description: Waits for a color at (x, y) with tolerance Tol, returns true if found
*******************************************************************************}
Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
var
Time: integer;
begin
Time := GetSystemTime;
while GetSystemTime - Time < MaxTime do
if SimilarColors(GetColor(x, y), Color, Tol) then
begin
Result := true;
exit;
end;
end;
{*******************************************************************************
Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean;
By: Rasta Magician
Description: Waits Color count in box (x1, y1, x2, y2) with Tol
*******************************************************************************}
Function WaitColorCount(x1, y1, x2, y2, Color, Tol, MinCount, MaxCount, MaxTime: integer):boolean;
var
Time: integer;
TPA: TPointArray;
begin
Time := GetSystemTime;
while GetSystemTime - Time < MaxTime do
if FindColorsTolerance(TPA, Color, x1, y1, x2, y2, Tol) then
if InRange(Length(TPA), MinCount, MaxCount) then
begin
Result := true;
exit;
end;
end;