Jump to content
andrewboss

Bank item visibility

Recommended Posts

Here is the code that I currently use:

public boolean isVisible(String name) {
        return getBank().isSlotVisible(bot, getBank().getSlot(name), getBank().getSlot(name));
    }

It returns whether the item is visible or not. However, if the item is in the first row, it will always return false. Any ideas what is wrong, or any better implementation for checking?

Edited by andrewboss
Link to comment
Share on other sites

1 hour ago, Hannes7337 said:

I think it has something to do with the absolute slot value.

You could only use getbank.getslot(name) instead of getbank.isslotvissible(). If getslot returns null you know it's not there.

4

There is no way you could check if it is visible or not by that method. It will always return the slot number if exists, even if not visible.

Edited by andrewboss
Link to comment
Share on other sites

14 hours ago, andrewboss said:

Here is the code that I currently use:


public boolean isVisible(String name) {
        return getBank().isSlotVisible(bot, getBank().getSlot(name), getBank().getSlot(name));
    }

It returns whether the item is visible or not. However, if the item is in the first row, it will always return false. Any ideas what is wrong, or any better implementation for checking?

 

isSlotVisible takes two different slots as parameters, the tab slot and the absolute slot https://osbot.org/api/org/osbot/rs07/api/Bank.html#isSlotVisible-org.osbot.rs07.Bot-int-int-

Right now you are passing absolute slot for both of the parameters, which is incorrect.

I don't think there is a public method in the API to get the tab slot, there is a private one though.

You can try the following code:

 

public boolean isVisible(int itemID) {
    return getBank().isSlotVisible(bot, getTabSlot(itemID), getBank().getSlot(itemID));
}

private int getTabSlot(final int itemId) {
    int tabForItem = getBank().getTabForItem(itemId);
    if (tabForItem == -1) {
        return -1;
    }
    Item[] itemsInTab = getBank().getItemsInTab(tabForItem);
    for(int i = 0; i < itemsInTab.length; i++) {
        if(itemsInTab[i] != null && itemsInTab[i].getId() == itemId) {
            return i;
        }
    }
    return -1;
}



 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...