SRL Archive - SRL Archives

Bank.scar BankScreen;


NCDS

2010-02-10 18:35:34

The current one seems to have some unnecessary code, though I could just be misunderstanding it.
Current function:

{*******************************************************************************
function BankScreen: Boolean;
by: SRL Dev Team
Description: Finds Bankscreen. Returns true if Found.
*******************************************************************************}

function BankScreen: Boolean;
var
c: Integer;
begin
if (CountColor(0, MSX1, MSY1, MSX2, MSY2) > 113000) then
begin
MouseBox(26, 138, 489, 157, 1);
c := GetTimeRunning + 45000;
while (not BankScreen) and (GetTimeRunning < c) do
Wait(50);
Wait(RandomRange(100, 150));
end;
Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
end;

My version:

function BankScreen: Boolean;
var
i: Integer;
begin
if not LoggedIn then Exit;
for i := 0 to 1 do
begin
Result := CountColor(4106994, 194, 25, 322, 44) = 423;
if Result then
Exit
else
MouseBox(35, 67, 449, 271, 3);
end;
end;

They both work at the same speed so it really doesn't matter, just posting for opinions..

code841

2010-02-10 18:38:35

Why does your function need to loop twice?
Also isn't it a bit unsafe to have it set for a fixed colour count?

NCDS

2010-02-10 18:41:45

From: code841
Why does your function need to loop twice?
Also isn't it a bit unsafe to have it set for a fixed colour count?


It loops twice because it counts the color in the title and incase the mouse the over the name, then it moves the mouse and searches for the title again.

And it's not unsafe to have a fixed color count because it doesn't change ;)

I have tested this many times and used in many of my scripts.

i luffs yeww

2010-02-10 19:01:16

From: NCDS
It loops twice because it counts the color in the title and incase the mouse the over the name, then it moves the mouse and searches for the title again.

And it's not unsafe to have a fixed color count because it doesn't change ;)

I have tested this many times and used in many of my scripts.


No need for the loop, as far as I know.. Have your mouse over the title, run it, and I'm sure it'll work without looping.

If I recall correctly, SCAR doesn't take the mouse into effect for color searches?

code841

2010-02-10 19:12:38

No it doesn't. Another thing to consider is the lag, the bank doesn't always open open up instantly for me. I think the wait times are good.

Heysus

2010-02-10 19:22:36

imo it should just be this (like it used to be)


function BankScreen: Boolean;
begin
Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
end;


not sure what all that other code is for…

NCDS

2010-02-10 21:14:49

From: i luffs yeww
No need for the loop, as far as I know.. Have your mouse over the title, run it, and I'm sure it'll work without looping.

If I recall correctly, SCAR doesn't take the mouse into effect for color searches?

Doesn;t matter anyways as if it finds it on the first loop through it will exit the function anyways, so it doesn't waist any time.

From: code841
No it doesn't. Another thing to consider is the lag, the bank doesn't always open open up instantly for me. I think the wait times are good.

IMO Lag should be compensated for in the script it self. Functions in SRL are meant to do sole purpose. It is the script writers responsibility to take Lag into factor when coding.

From: Heysus
imo it should just be this (like it used to be)


function BankScreen: Boolean;
begin
Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
end;


not sure what all that other code is for…


I'm assuming the reason it isn't like that any more is because RS went through a bit of a phase where they changed there text's around a bit. By using color searches, that doesn't effect the functions.