Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to determine if an item is a "Members object"

Featured Replies

  • Author

Thanks a lot for the code.
Why does the API always require the tabSlot and the absoluteSlot. Wouldn't the absoluteSlot only be sufficient to locate the item?
Might be a sily question, but why does the API itself not provide a method to find the tabSlot?

Personally, I'd just make a list of all members objects and then see if that id shows on that list, if it does then it's members, else it isn't.

  • Author
3 minutes ago, Satire said:

Personally, I'd just make a list of all members objects and then see if that id shows on that list, if it does then it's members, else it isn't.

But that would require me updating the list every time new content/items are released. Not very keen on that tbh.

Edited by Adept

Just now, Adept said:

But that would require me updating the list every time new content is released. Not very keen on that tbh.

First of all, why do you need this feature?  For every new content, there will be a few items. If you're really that lazy to add 3 things to a list then welcome to being a programmer :kappa:

Seriously tho, if you're that lazy to add 2 -3 strings every so often, then it'll be hard doing it. You could do it the other way around tho. Add all F2P items and if it doesn't match, then it's a members item. That way, you don't need to update the  list much. Since F2P hardly gets any new items.

  • Author
14 minutes ago, Satire said:

First of all, why do you need this feature?  For every new content, there will be a few items. If you're really that lazy to add 3 things to a list then welcome to being a programmer :kappa:

Seriously tho, if you're that lazy to add 2 -3 strings every so often, then it'll be hard doing it. You could do it the other way around tho. Add all F2P items and if it doesn't match, then it's a members item. That way, you don't need to update the  list much. Since F2P hardly gets any new items.

You call seeking a better, more efficient solution being "lazy"?
If you check previous replies you'll find the answer to your question and that another user has already provided a working method which does not require managing a list.
Nonetheless, I appreciate your will to help and your attempt at being humorous. Keepo

Edited by Adept

7 minutes ago, Adept said:

You call seeking a better, more efficient solution being "lazy"?
If you check previous replies you'll find the answer to your question and that another user has already provided a working method which does not require managing a list.
Nonetheless, I appreciate your will to help and your pathetic attempt at being humorous. Keepo

 

You said, "But that would require me updating the list every time new content/items are released. Not very keen on that tbh" for the method I suggested. You could've just said that you have another method or you don't want to use this method because it isn't efficient.  You made it sound like you didn't want to bother updating the list if you used that method.  Anyway, I didn't fully read the case you wanted this for and for what you want, this does indeed seem unethical. 

I do apologize for that. 

56 minutes ago, Adept said:

Thanks a lot for the code.
Why does the API always require the tabSlot and the absoluteSlot. Wouldn't the absoluteSlot only be sufficient to locate the item?
Might be a sily question, but why does the API itself not provide a method to find the tabSlot?

There is a private method in the Bank class for getting the tab slot, not sure why it is not public.

  • Author
6 hours ago, Explv said:

There is a private method in the Bank class for getting the tab slot, not sure why it is not public.

I keep getting this error when I include the code you provided:
 

[ERROR][Bot #1][02/17 04:51:44 PM]: Error in script executor!
java.lang.IllegalStateException: Bank tab count calculation failed!
	at org.osbot.rs07.api.Bank.getItemCountForTab(tf:48)
	at org.osbot.rs07.api.Bank.getItemsInTab(tf:12)
	at MassAccountCleaner.getTabSlot(MassAccountCleaner.java:270)
	at MassAccountCleaner.onLoop(MassAccountCleaner.java:210)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(wh:281)
	at java.lang.Thread.run(Unknown Source)

P.S. I changed the for loop statement in the getTabForItem method to the following:
 

for(int tab = 0; tab < getBank().getTabsAvailable(); tab++) {

 

39 minutes ago, Adept said:

I keep getting this error when I include the code you provided:
 


[ERROR][Bot #1][02/17 04:51:44 PM]: Error in script executor!
java.lang.IllegalStateException: Bank tab count calculation failed!
	at org.osbot.rs07.api.Bank.getItemCountForTab(tf:48)
	at org.osbot.rs07.api.Bank.getItemsInTab(tf:12)
	at MassAccountCleaner.getTabSlot(MassAccountCleaner.java:270)
	at MassAccountCleaner.onLoop(MassAccountCleaner.java:210)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(wh:281)
	at java.lang.Thread.run(Unknown Source)

P.S. I changed the for loop statement in the getTabForItem method to the following:
 


for(int tab = 0; tab < getBank().getTabsAvailable(); tab++) {

 

Did you check that the item you are passing to the methods is not null?

If you have, then I will take a look at this when I get home from work

Edited by Explv

  • Author
16 minutes ago, Explv said:

Did you check that the item you are passing to the methods is not null?

If you have, then I will take a look at this when I get home from work

Yep, I checked.
EDIT: I found the issue! It's due to the comparison used in the getTabSlot method. Comparing the item objects does not return true (similarly to Strings I assume). Comparing item IDs is the way to go.
 

if(itemsInTab[i].getId() == item.getId()) {

Edited by Adept

25 minutes ago, Adept said:

Yep, I checked.
EDIT: I found the issue! It's due to the comparison used in the getTabSlot method. Comparing the item objects does not return true (similarly to Strings I assume). Comparing item IDs is the way to go.
 


if(itemsInTab[i].getId() == item.getId()) {

Ah, good catch. Yes it looks like getBank().getItems() returns new instances of Item each time, so using == will not work.

In that case if you are using ids, you can use the following code:

Item item = getBank().getItem("Yew logs");
if (item != null) {
    getBank().scrollToSlot(getTabSlot(item.getId()), getBank().getSlot(item.getId()));
}

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;
}

 

  • Author
7 minutes ago, Explv said:

Ah, good catch. Yes it looks like getBank().getItems() returns new instances of Item each time, so using == will not work.

In that case if you are using ids, you can use the following code:


Item item = getBank().getItem("Yew logs");
if (item != null) {
    getBank().scrollToSlot(getTabSlot(item.getId()), getBank().getSlot(item.getId()));
}

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;
}

 

Thank you very much. Currently trying to solve another issue.
After withdrawing one item, the getTabSlot method breaks since getting the items in the tab does not take into consideration the empty slot left by the item withdrawn. 

Edited by Adept

4 minutes ago, Adept said:

Thank you very much. Currently trying to solve another issue.
After withdrawing one item, the getTabSlot method breaks since getting the items in the tab does not take into consideration the empty slot left by the item withdrawn. 

In what way does it break? Did you make sure to null check before comparing IDs like in the updated getTabSlot() method I just posted?

  • Author
8 minutes ago, Explv said:

In what way does it break? Did you make sure to null check before comparing IDs like in the updated getTabSlot() method I just posted?

Consider a tab of 10 items.
I withdraw the 6th item of the tab, leaving me with the first five items, an empty slot and the remaining 4 items.

when I then attempt to get the tabSlot for the 8th item like so getTabSlot(8thItemiId), the method creates the itemsInTab array with the remaining 9 items, hence int i returned is 7 when it should be 8 due to the empty slot left over from the item withdrawn still occupying one tab  slot.

Edited by Adept

7 minutes ago, Adept said:

Consider a tab of 10 items.
I withdraw the 6th item of the tab, leaving me with the first five items, an empty slot and the remaining 4 items.

when I then attempt to get the tabSlot for the 8th item like so getTabSlot(8thItemiId), the method creates the itemsInTab array with the remaining 9 items, hence int i returned is 7 when it should be 8 due to the empty slot left over from the item withdrawn still occupying one tab  slot.

Ok I see the issue, I'll take a look when I'm home.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.