SRL Archive - SRL Suggestions

Fixed TabExists()


Gu3st...

2011-03-27 07:45:44

function TabExists(Tab: Integer): Boolean;
var
tP: TPoint;
begin
Result := false;
if (not loggedIn) then
exit;

if (tab < 20) then
begin
SRL_Warn('TabExists', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please upgrade your script.', warn_AllVersions);
Exit;
end;

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

if (Tab = tab_LogOut) then
begin
Result := (GetColor(746, 0) = 65536);
Exit;
end;

tP := Point(((Tab - 21) mod 8 * 30) + 537, ((Tab - 21) div 8 * 298) + 186);
Result := CountColorTolerance(5597817, tp.x-14, tp.y-17, tp.x+14, tp.y+14, 10) < 104; // the count is 104 when no icons are overlapping the GameTab.
end;
@@ -116,11 +116,8 @@
Exit;
end;

- tP := Point(((Tab - 21) mod 8 * 30) + 536, ((Tab - 21) div 8 * 298) + 187);
- if (Tab <> tab_Prayer) then
- Result := FindColorTolerance(tP.X, tP.Y, 591881, tP.X - 12, tP.Y - 12, tP.X + 12, tP.Y + 12, 15)
- else
- Result := FindColorTolerance(tP.X, tP.Y, 16448761, tP.X - 12, tP.Y - 12, tP.X + 12, tP.Y + 12, 15);
+ tP := Point(((Tab - 21) mod 8 * 30) + 537, ((Tab - 21) div 8 * 298) + 186);
+ Result := CountColorTolerance(5597817, tp.x-14, tp.y-17, tp.x+14, tp.y+14, 10) < 104;
end;

{*******************************************************************************

This fix was necessary because TabExists didn't work properly on the prayer tab (we had a "if tab = tab_Prayer then" which really isn't the best solution) and didn't work when the tab existed but was highlighted (http://img546.imageshack.us/i/192848543.png/)

Coh3n

2011-03-27 14:51:22

Committed, thanks. :)

TomTuff

2011-03-27 15:03:42

You must spread some Reputation around before giving it to Zyt3x again.

Nice job. Mine was just a quick fix :P

Gu3st...

2011-03-27 17:30:34

From: TomTuff
You must spread some Reputation around before giving it to Zyt3x again.

Nice job. Mine was just a quick fix :P
Ahahah! :p

Thanks both of you :)

Gu3st...

2011-03-29 17:37:42

Turns out it didn't work properly for tab_Combat, but this does:
{*******************************************************************************
function TabExists(Tab: Integer): Boolean;
By: ZephyrsFury & IceFire908; fixed by Zyt3x
Description: Returns True if the Tab exists.
*******************************************************************************}
function TabExists(Tab: Integer): Boolean;
var
tP: TPoint;
begin
Result := false;
if (not loggedIn) then
exit;

if (tab < 20) then
begin
SRL_Warn('TabExists', 'Tab ' + IntToStr(Tab) + ' is not using the new constants! Please upgrade your script.', warn_AllVersions);
Exit;
end;

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

if (Tab = tab_LogOut) then
begin
Result := (GetColor(746, 0) = 65536);
Exit;
end;

tP := Point(((Tab - 21) mod 8 * 30) + 537, ((Tab - 21) div 8 * 298) + 186);
Result := CountColorTolerance(5597817, tp.x-12, tp.y-12, tp.x+12, tp.y+12, 10) < 81; // the count when no icons are overlapping the GameTab.
end;

Coh3n

2011-03-29 22:49:06

Updated.