Bad Boy JH
2010-02-24 03:40:37
This makes the WaitFunc wait until the function is either true or false depending on what the scripter wants.
function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer; WaitTrue:Boolean): Boolean;
var
T: Integer;
begin
T := GetSystemTime + MaxTime;
while (GetSystemTime < T) do
begin
if (Func()) xor Not(WaitTrue) then
begin
Result := True;
Exit;
end;
Wait(WaitPerLoop);
end;
end;