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 filter inventory items that only contains a certein action?

Featured Replies

I've tried a few things but none of them do exactly what I want it to do.

 

I don't want to write up all kind of food but instead I want to figure out what they use as food by checking their inventory. Now the problem is that they coud have different items beside food too in their inventory. 

This is why I came up with the idea to filter the items by the menu action they have. However, the API doesn't contain a method for that.

 

So now I'm working on my own method.

 

This is my concept idea;

 

  1. Get all items in inventory and put them in a arrayList
  2. Figure out if items in inventory has the action "Eat"
  3. If not, remove from arrayList.

Now I'm just not sure how I'm going to create this.

 

Any help is welcome!

inventory.filter(new Filter<Item>() {
            public boolean match(Item item) {
                return item.hasAction("Eat");
            }
        });

Something like this?

List<Item> items = Arrays.asList(getInventory().getItems()).stream().filter(s -> s.hasAction("Eat")).collect(Collectors.toList());

 

 

  • Author
inventory.filter(new Filter<Item>() {
            public boolean match(Item item) {
                return item.hasAction("Eat");
            }
        });

Something like this?

 

 

 

List<Item> items = Arrays.asList(getInventory().getItems()).stream().filter(s -> s.hasAction("Eat")).collect(Collectors.toList());

 

I'll try both of them. Looks promising. And way smoother than what I did.. haha Thanks!

I'll try both of them. Looks promising. And way smoother than what I did.. haha Thanks!

An even nicer and actually readable solution would be (if you want to use java 8 with lambda expressions):

 

List<Item> food = inventory.filter( item -> item.hasAction("Eat") );

 

This is where i need to learn better methods all the ones above look better than what i would have done lel.

I would have gotten a all the items in inventory then for each item check if it has the action and if it does add it to a array list >.>

 

My way seems t0o much -  Im such a nub atm aha

Edited by Fruity

This is where i need to learn better methods all the ones above look better than what i would have done lel.

I would have gotten a all the items in inventory then for each item check if it has the action and if it does add it to a array list >.>

 

My way seems t0o much -  Im such a nub atm aha

 

The methods above only became accessible to us a couple of weeks ago so dw, yours was pretty much the way to go before that ;)

  • Author

 

An even nicer and actually readable solution would be (if you want to use java 8 with lambda expressions):

 

List<Item> food = inventory.filter( item -> item.hasAction("Eat") );

 

I'll get look up on lambda first.  Didn't had time to study that. 

getInventory().filter(new ActionFliter<Item>(actions));

This will return a list of items with the action.

Actions I think is a varg aka array

getInventory().filter(new ActionFliter<Item>(actions));

This will return a list of items with the action.

Actions I think is a varg aka array

 

You should probably move on and start using the Java filter :x

The methods above only became accessible to us a couple of weeks ago so dw, yours was pretty much the way to go before that wink.png

 

Ah right made me feel better now ;) much loves

Create an account or sign in to comment

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.