mrpickle
2009-05-15 01:52:42
EDIT: Smoothed the explanation abit. + I just realized it works for DTM too… So i change name.
This is a function that waits until an object is located, or the maximal time is reached.
//Delay: how long to wait before it gives a tick to the "Timer"
//MaxTime: Secondary stopping condition: if the ticks on the "Timer" reaches over the maxtime quantity, it will stop.
//Bitmap: Will repeat until it finds this bitmap.
or as a procedure
This is a function that waits until an object is located, or the maximal time is reached.
//Delay: how long to wait before it gives a tick to the "Timer"
//MaxTime: Secondary stopping condition: if the ticks on the "Timer" reaches over the maxtime quantity, it will stop.
//Bitmap: Will repeat until it finds this bitmap.
// By Mixter
function WaitUntilBitmapFound(Delay, MaxTime, Bitmap : integer) : boolean;
var
T, x, y : integer;
begin
T := GetSystemTime;
Result := True;
while (GetSystemTime - T >= MaxTime) do
if (FindBitmap(Bitmap, x, y)) then
exit
else
wait(Delay);
Result := False;
end;
or as a procedure
//By: mrpickle
Procedure WaitForBitmap(DelayCounting, MaxDelayCounting, Bitmap:integer);
var timer:integer;
begin
repeat
wait(DelayCounting);
Timer := Timer + 1
If Timer > MaxDelayCounting then
Writeln ('Timed Out');
Break;
until (FindBitmap(Bitmap,x,y))
Timer := 0
end;