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 check if item is stackable?

Featured Replies

Tried searching the API/Google for this but no luck. So basically, the  script has a list of items to pick up. It checks the loot on the ground against the list of items to pick up and if any match and the inventory is not full, it'll pick it up. What I want to do though, is to pick up a stackable item if my inventory contains a stack already, regardless of if it's full or not.

 

Is there any way to check if an item on the ground is stackable?

if you already know your inventory is full and the item should be picked up you could try this

public boolean isStackable(final String itemName) {
    return getInventory().contains(itemName) && getInventory().getItem(itemName).getAmount() > 1;
}

not sure if this is the best way though, i only tested with coins and bones

  • Author

if you already know your inventory is full and the item should be picked up you could try this

public boolean isStackable(final String itemName) {
    return getInventory().contains(itemName) && getInventory().getItem(itemName).getAmount() > 1;
}

not sure if this is the best way though, i only tested with coins and bones

 

Thank you! I would have came up with something like that eventually, but I wanted to make sure there wasn't already such a method. Looks like that will have to do.

 

Edit: Just realized a (slight) problem. The method will return false even if an item is stackable but there's only 1 in the inventory. Any ideas to fix this?

 

Edit 2: Actually, I believe this will return true if the inventory contains more of one item, even if it's not in a stack.

Edited by Chromelte

Thank you! I would have came up with something like that eventually, but I wanted to make sure there wasn't already such a method. Looks like that will have to do.

 

Edit: Just realized a (slight) problem. The method will return false even if an item is stackable but there's only 1 in the inventory. Any ideas to fix this?

 

ooo yeah you're right feels.png maybe someone with more experience can help you out 

 

 

Edit 2: Actually, I believe this will return true if the inventory contains more of one item, even if it's not in a stack.

 

 

tested with 60 coins and 2 bones, should be ok. find a way to fix stackable and 1 in inventory tho sad.png

 

Edited by Stimpack

you said you had defined a list of items, maybe store a property of that item whether they are stackable or not? or you could check the noted id since a stackable item shouldn't have a noted id. ( i think returns -1 last time i checked).

Edited by Precise

  • Author

you said you had defined a list of items, maybe store a property of that item whether they are stackable or not? or you could check the noted id since a stackable item shouldn't have a noted id. ( i think returns -1 last time i checked).

 

Thank you! Checking for the noted id worked perfectly!

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.