PDA

View Full Version : More efficient way to gameTabs.openTab(TAB_BACKPACK)



Parade
10-10-2015, 12:01 AM
I seem to be having issues with

gameTabs.openTab(TAB_BACKPACK);
I'm trying to come up with a new method to replace the include with that will have fewer misclicks. Any ideas?

nickrules
10-10-2015, 04:20 AM
I'm assuming you mean SRL-6. The function itself seems like a reasonable place to start:

{*
__openViaNavBar
---------------

.. code-block:: pascal

function TRSGameTabs.__openViaNavBar(tab: integer): boolean;

Helper function for TRSGametabs.openTab(). Opens the gametab **tab** via the
navigation bar and moves the mouse to close.

.. note::

- by Olly
- Last Updated: 21 November 2013 by Olly

Example:

.. code-block:: pascal

gameTabs.__openViaNavbar(TAB_BACKPACK);
*}
{$IFNDEF CODEINSIGHT}
function TRSGameTabs.__openViaNavBar(tab: integer): boolean;
var
p: TPoint;
b: TBox;
begin
mouseBox(self.navButtons[self.tabs[tab]._navBarID][0], MOUSE_MOVE); // hover over the nav button
wait(250 + random(250));
mouseBox(self.navButtons[self.tabs[tab]._navBarID][self.tabs[tab]._navBarBoxIndex], MOUSE_LEFT, MOUSE_ACCURATE);
wait(20 + random(200));

b := self.navButtons[self.tabs[tab]._navBarID][0];

if (random(2) = 1) then // move the mouse to the side so the menu closes
p := point(b.x1 - 8 - random(5), b.y1 + randomRange(-10, 50))
else
p := point(b.x2 + 8 + random(5), b.y1 + randomRange(-10, 50));

mouse(p);
end;
{$ENDIF}

(*
openTab
-------

.. code-block:: pascal

function TRSGameTabs.openTab(tab: integer): boolean;

Returns true if it successfully open the gametab **tab**

.. note::

- by Coh3n
- Last Updated: 26 July 2013 by Coh3n

Example:

.. code-block:: pascal

if gameTabs.openTab(TAB_EQUIPMENT) then
writeLn('The equipment is open!);
*)
function TRSGameTabs.openTab(tab: integer): boolean;
var
b: TBox;
begin
if (not inRange(tab, TAB_TASK, TAB_MUSIC)) then // check tab is vaild
begin
print('TRSGameTabs.openTab('+toStr(tab)+'): The tab isnt vaild!, result = ' + toStr(result), TDebug.ERROR);
exit(false);
end;

print('TRSGameTabs.openTab('+toStr(tab)+')', TDebug.HEADER);

if (self.isTabActive(tab)) then
begin
print('Tab is already open, exiting');
print('TRSGameTabs.openTab('+toStr(tab)+'): = '+toStr(result), TDebug.FOOTER);
exit(true);
end;

if (self.areMultiOpen) then
if (self.isTabVisible(tab, b)) then
begin
print('Tab is already visible, bringing to front');
mouseBox(b, MOUSE_LEFT);

wait(50 + random(100));
print('TRSGameTabs.openTab('+toStr(tab)+'): = '+toStr(result), TDebug.FOOTER);
exit(true);
end;

print('Opening tab via gametab navigation bar');
self.__openViaNavBar(tab);

result := self.waitTabActive(tab, 4000 + random(1000));

print('TRSGameTabs.openTab('+toStr(tab)+'): result = '+toStr(result), TDebug.FOOTER);
end;


Note that I've included two functions. The one you call (openTab) is the lower of the two. That function is almost entirely failsafes. The top function is the one which actually opens the tab.

I'm not terribly familiar with the RS3 interface anymore, but I would say that brushing up on DTM or bitmap searching would likely be a top notch way to find some arbitrary tab and open it.

Alternatively, you could try to figure out /why/ these functions are failing. Depending on your use case, this may actually be easier. You can freely modify the SRL include/the gametab.simba file to help with debugging, but remember that any change will affect ALL SRL-6 scripts you run. So make a backup. If you do find the issue, you can contact one of the SRL developers with your suggestion (or ideally, implemented and thoroughly tested fix), and possibly improve SRL for all it's users.

KeepBotting
10-10-2015, 01:17 PM
tabBackpack.open();

That's the simplest way to do it.