TRiLeZ
2009-08-29 06:30:38
{*******************************************************************************
function WaitColors(var FoundColor: Integer; X, Y: Integer; Color: TIntegerArray; Tol, MaxTime: Integer): Boolean;
By: TRiLeZ
Description: Waits for multiple colours at (x, y) with tolerance, returns true if found one colour.
*******************************************************************************}
function WaitColors(var FoundColor: Integer; X, Y: Integer; Color: TIntegerArray; Tol, MaxTime: Integer): Boolean;
var
Time, I: Integer;
begin
Time := GetSystemTime + MaxTime;
while (GetSystemTime < Time) do
begin
for I := 0 to High(Color) do
begin
if (GetSystemTime > Time) then Exit;
if SimilarColors(GetColor(X, Y), Color[i], Tol) then
begin
FoundColor := GetColor(X, Y);
Result := True;
Exit;
end;
Wait(1 + Random(2));
end;
end;
end;
{*******************************************************************************
function WaitFindColors(var X, Y, FoundColor: Integer; Color: TIntegerArray; x1, y1, x2, y2, Tol, MaxTime: Integer): Boolean;
By: TRiLeZ
Description: Waits for multiple colours in an area with tolerance, returns true if found one colour.
*******************************************************************************}
function WaitFindColors(var X, Y, FoundColor: Integer; Color: TIntegerArray; x1, y1, x2, y2, Tol, MaxTime: Integer): Boolean;
var
Time, I: Integer;
begin
Result := False;
Time := GetSystemTime + MaxTime;
while (GetSystemTime < Time) do
begin
for I := 0 to High(Color) do
begin
if (GetSystemTime > Time) then Exit;
if FindColorTolerance(X, Y, Color[i], x1, y1, x2, y2, Tol) then
begin
FoundColor := GetColor(X, Y);
Result := True;
Exit;
end;
Wait(2 + Random(4));
end;
end;
end;
{*******************************************************************************
function WaitFindColorsSpiral(var x, y, FoundColor: integer; Color: TIntegerArray; x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
By: TRiLeZ
Description: Searches for multiple colours in an area with tolerance using FindColorSpiralTolerance, returns true if found one colour.
*******************************************************************************}
function WaitFindColorsSpiral(var x, y, FoundColor: integer; Color: TIntegerArray; x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
var
Time, I: Integer;
begin
Result := False;
Time := GetSystemTime + MaxTime;
while (GetSystemTime < Time) do
begin
for I := 0 to High(Color) do
begin
if (GetSystemTime > Time) then Exit;
if (FindColorSpiralTolerance(X, Y, Color[i], x1, y1, x2, y2, Tol)) then
begin
FoundColor := GetColor(X, Y);
Result := True;
Exit;
end;
Wait(2 + Random(4));
end;
end;
end;
If your thinking "Why not replace WaitColor, WaitFindColor and WaitFindColorSpiral" then heres your answer: it will break some scripts.
Tell me what to think and If youll include them.
They could be called WaitColorMulti, WaitFindColorMulti and WaitFindColorMultiSpiral if you think those are a more suitable name.