SRL Archive - SRL Archives

Bank.scar CloseBank;


NCDS

2010-06-23 18:00:19

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:

{*******************************************************************************
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:

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;

bbri06

2010-06-23 18:06:30

The for-to-do loop that you've omitted is actually extremely useful and effective. It accounts for slower computers or just general server lag. Often times, the bank screen will still be detected after Wait(100).

NCDS

2010-06-23 18:12:22

From: bbri06
The for-to-do loop that you've omitted is actually extremely useful and effective. It accounts for slower computers or just general server lag. Often times, the bank screen will still be detected after Wait(100).


That's what the repeat..until is for. ;)

It uses the same basic method as the other one, just less lines really.

There, that should fix any lag problems now as well.

Narcle

2010-06-23 18:21:32

Well if we really wanted to shorten it:

function CloseBank: Boolean;
begin
Result := CloseWindow;
end;

/end

E:
Does the same thing.

NCDS

2010-06-23 18:24:05

From: Narcle
Well if we really wanted to shorten it:

function CloseBank: Boolean;
begin
Result := CloseWindow;
end;
/end


:duh: lol yeah, that works. I had assumed there was a reason for CloseBank; Apparently not?

Coh3n

2010-06-23 18:33:38

From: Narcle
Well if we really wanted to shorten it:

function CloseBank: Boolean;
begin
Result := CloseWindow;
end;

/end

E:
Does the same thing.

Wouldn't work because CloseWindow calls CloseBank right off the bat. You'd have to modify CloseWindow. But either way, it's pointless to have two. This will be one of the many good things about SRL 5. :p

@NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks. :)

Narcle

2010-06-23 18:57:24

From: Coh3n
Wouldn't work because CloseWindow calls CloseBank right off the bat. You'd have to modify CloseWindow. But either way, it's pointless to have two. This will be one of the many good things about SRL 5. :p

@NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks. :)


Yeah I thought it might of. The system is there tho… just have to add it in. Its kind of redundant now that we have it.

NCDS

2010-06-23 18:57:52

From: Coh3n

@NCDS: I'm not going to commit it, someone else might though. Since CloseBank and CloseWindow are working fine right now, I'm not going to change it. But you have brought to my attention this for SRL 5, so thanks. :)

That's fine man, I just noticed it was abnormally long and figured I would bring it to the peoples attention.

Coh3n

2010-06-24 06:05:17

From: NCDS
That's fine man, I just noticed it was abnormally long and figured I would bring it to the peoples attention.

Yeah, I'm sure there's a lot of that in SRL.