SRL Archive - SRL Archives

WaitColor and WaitFindColor Fixed


TRiLeZ

2009-07-24 04:42:33

Yesterday, I made some functions and they all ready existed and RM showed me them.
I tested them out and they didnt work =/
I edited them and now they work so here they are.


{*******************************************************************************
Function WaitColor(x, y, Color, Tol, MaxTime: integer): Boolean;
By: Rasta Magician fixed by TRiLeZ
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
Result := False;
Time := GetSystemTime + MaxTime;
repeat
if SimilarColors(GetColor(x, y), Color, Tol) then
begin
Result := True;
Exit;
end else
Wait(1);
until (Time < GetSystemTime);
end;

{*******************************************************************************
Function WaitFindColor(var x, y: integer; Color, Tol, x1, y1, x2, y2, MaxTime: integer): Boolean;
By: Rasta Magician fixed by TRiLeZ
Description: Waits for a color at (x1, y1, x2, y2) with tolerance Tol, returns true if found, coords returned to (x, y)
*******************************************************************************}
Function WaitFindColor(var x, y: integer; Color, x1, y1, x2, y2, Tol, MaxTime: integer): Boolean;
var
Time: integer;
begin
Result := False;
Time := GetSystemTime + MaxTime;
repeat
if FindColorTolerance(x, y, Color, x1, y1, x2, y2, Tol) then
begin
Result := true;
exit;
end else
Wait(1);
until (GetSystemTime < Time);
end;

EvilChicken!

2009-07-24 04:50:18

Thanks for pointing this out, TRiLeZ. I'll fix this briefly.

TRiLeZ

2009-07-24 04:52:47

From: EvilChicken!
Thanks for pointing this out, TRiLeZ. I'll fix this briefly.

I already fixed it…

Da 0wner

2009-07-24 04:56:32

I think he meant he would commit it briefly.

EvilChicken!

2009-07-24 05:13:31

Fix the bug in SRL.

Which by the way is done now.
Thanks again. :)

Sir R. M8gic1an

2009-07-24 12:50:17

errr… the only change is While do -> repeat until?

~RM

TRiLeZ

2009-07-24 13:00:49

From: Rasta Magician
errr… the only change is While do -> repeat until?

~RM

And some wait time so it dosnt freeze up.

EvilChicken!

2009-07-24 13:26:20

RM, read the revision descriptions next time! :p