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.

Filtering through NPC's help

Featured Replies

Hello, so im trying to make a filter that goes through all the npcs and find the one that is within 1 square of me and has a certain name. i think i got most of it right except when i go to use the list that the filter gives me, it says that it is full of "Objects" and not "NPC"s . even though i made the for npc objects. 

here is the filter object that i made:

myFilter = new Filter<NPC>() {
            public boolean match(NPC obj) {
                
                return (myArea.contains(obj)  && obj.getName() == "Npc name");
            }
        };

here is where i implement it: 

List npcs = getNpcs().filter(myFilter);
        for(NPC n : npcs)
        {
          code....  
        }

it says that "Type mismatch: cannot convert from element type Object to NPC" . sorry i dont understand filters too much i thought <NPC> would work, if anyone could help it would be appreciated :)

11 minutes ago, roguehippo said:

Hello, so im trying to make a filter that goes through all the npcs and find the one that is within 1 square of me and has a certain name. i think i got most of it right except when i go to use the list that the filter gives me, it says that it is full of "Objects" and not "NPC"s . even though i made the for npc objects. 

here is the filter object that i made:

myFilter = new Filter<NPC>() {
            public boolean match(NPC obj) {
                
                return (myArea.contains(obj)  && obj.getName() == "Npc name");
            }
        };

here is where i implement it: 

List npcs = getNpcs().filter(myFilter);
        for(NPC n : npcs)
        {
          code....  
        }

it says that "Type mismatch: cannot convert from element type Object to NPC" . sorry i dont understand filters too much i thought <NPC> would work, if anyone could help it would be appreciated :)

 

It returns a List<NPC> and you're storing it just as a List.

You need to specify the type:

List<NPC> npcs = getNpcs().filter(myFilter);


Also no need to define your own Filter for this, OSBot already has predefined ones:

getNpcs().closest(new NameFilter<>("NPC Name"), new AreaFilter<>(myArea));

Or if you don't care about whether it is the closest one:

getNpcs().singleFilter(getNpcs().getAll(), new NameFilter<>("NPC Name"), new AreaFilter<>(myArea));

 

Edited by Explv

  • Author

ahhh i see , that pesky list. thank you for helping and also giving great suggestions! so helpful as always

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.