SRL Archive - SRL Archives

GameTab


HyperSecret

2010-04-28 14:23:50

I was looking through the GameTab function today and thought I would bring something to attention.

The way it is now:


Tries := 0;
while (Tries < 3) do
begin
Mouse(tP.X, tP.Y, 0, 0, True);

T := GetSystemTime;
while (not Result) and (GetSystemTime - T < 2000) do
begin
Result := (GetCurrentTab = Tab);
Wait(100 + Random(100));
end;

Inc(Tries);
end;

Now the way I understand this (maybe I am wrong) but when it enters the 2nd while loop, if it ends up with a 'Result := True' it will then exit that loop, it will then inc(tries) go back up to Mouse again and repeat Mouse more times.

So shouldn't there be a 'If Result Then Exit' somewhere in this loop so we don't repeatedly Mouse to the GameTab?

Like I said, maybe I am wrong or missing something but that is how I understand it.

aran armath

2010-04-28 14:35:57

I think you are right. The 'If Result Then Exit' should go right before 'Inc(Tries)'.

Dgby714

2010-04-28 16:49:16

{*******************************************************************************
function GameTab(Tab: integer): boolean;
By: ZephyrsFury
Description: Switches to a specific game tab.
const
tab_Combat = 21;
tab_Stats = 22;
tab_Quest = 23;
tab_Diary = 24;
tab_Inv = 25;
tab_Equip = 26;
tab_Prayer = 27;
tab_Magic = 28;
tab_Objectives = 29;
tab_Friends = 30;
tab_Ignore = 31;
tab_Clan = 32;
tab_Options = 33;
tab_Emotes = 34;
tab_Music = 35;
tab_Notes = 36;
tab_LogOut = 37;
*******************************************************************************}
function GameTab(Tab: integer): boolean;
var
tP: TPoint;
T, Tries: integer;
begin
if (Tab < 20) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please update your script.', warn_AllVersions);
Exit;
end;

if (not (InRange(Tab, Tab_Combat, Tab_LogOut))) then
begin
SRL_Warn('GameTab', 'Tab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_AllVersions);
Exit;
end;

Result := (GetCurrentTab = Tab);
if (Result) then
Exit;

if (TabExists(Tab)) then
begin
tP := Point((Tab - 21) mod 8 * 30 + RandomRange(527, 545), (Tab - 21) div 8 * 298 + RandomRange(177, 197));
if (Tab = tab_LogOut) then
tP := Point(RandomRange(747, 760), RandomRange(3, 18));

Tries := 0;
while (not Result) and (Tries < 3) do
begin
Mouse(tP.X, tP.Y, 0, 0, True);

T := GetSystemTime;

while (not Result) and (GetSystemTime - T < 2000) do
begin
Result := (GetCurrentTab = Tab);
Wait(100 + Random(100));
end;

Inc(Tries);
end;

end else
SRL_Warn('GameTab', 'GameTab ' + IntToStr(Tab) + ' is not a valid tab number.', warn_Notice);
end;

Coh3n

2010-04-29 09:08:27

Can't you just do while (tries <3) and (not Result) do?

HyperSecret

2010-04-29 10:28:42

From: Coh3n
Can't you just do while (tries <3) and (not Result) do?


Yes, whatever works.

Dgby714

2010-04-29 13:34:23

From: Coh3n
Can't you just do while (tries <3) and (not Result) do?

disregard…

Coh3n

2010-04-29 13:38:42

From: Dgby714
s/and/or/


If you use or it will continue if one of them is true, with and it will break if one of them is true, which is what you want.

Dgby714

2010-04-29 13:43:23

From: Coh3n
If you use or it will continue if one of them is true, with and it will break if one of them is true, which is what you want.


wow i feel stupid now… lol

Wanted

2010-04-29 19:32:42

Good catch, I'm sure whoever did this did it by accident and it went undetected for a long time because it caused no major problems :)

i luffs yeww

2010-04-29 21:10:06

:p I always noticed this, but never realized that it was SRL. I thought that somehow I was clicking without clicking.

marpis

2010-04-30 08:06:47

From: icefire908
good catch, i'm sure whoever did this did it by accident and it went undetected for a long time because it caused no major problems :)


no! Mischief!

sabotage!

Coh3n

2010-04-30 08:56:03

From: Dgby714
wow i feel stupid now… lol

It happens to everyone. ;)

ZephyrsFury

2010-04-30 11:20:18

From: IceFire908
Good catch, I'm sure whoever did this did it by accident and it went undetected for a long time because it caused no major problems :)


T'was me :( Sowwy!

Coh3n

2010-04-30 12:40:27

From: ZephyrsFury
T'was me :( Sowwy!


MylesMadness

2010-04-30 15:44:11

From: Coh3n
That photo looks like the cropped it with real scissors and a 4 year old

Coh3n

2010-04-30 16:57:00

From: MylesMadness
That photo looks like the cropped it with real scissors and a 4 year old

Lol that's google. :p