I just noticed it seemed unnecessarily long.
The two functions have less than a 5 ms difference in speed I just figured I would post for the criticism and explanations.
SRL's:
SCAR Code:
{*******************************************************************************
function CloseBank: Boolean;
By: Starblaster100
Description: Closes the bank window - Tries twice before exiting
*******************************************************************************}
function CloseBank: Boolean;
var
i, Timer: Integer;
begin
Result := False;
if BankScreen then
begin
Timer := GetTimeRunning + 8000;
repeat
Mouse(483, 28, 10, 12, True);
for i := 0 to 30 do
begin
if not BankScreen then
begin
Result:= True;
Break;
end;
Wait(100);
end;
Wait(Random(100));
until (GetTimeRunning > Timer) or Result;
end;
end;
Mine:
SCAR Code:
function N_CloseBank: Boolean;
var
t: Integer;
begin
if not BankScreen then
Exit;
t := GetTimeRunning + 8000;
repeat
Mouse(483, 28, 10, 12, True);
while (BankScreen) and (GetTimeRunning < (t / 2)) do
Wait(100);
Result := not BankScreen;
until(Result) or (GetTimeRunning > t);
end;