Jump to content

Getting all object in a range


erenjwz

Recommended Posts

To get every object, you'll need to use streams:

int rad = 10;
String name = "bird snare"; //case doesn't matter
List<Entity> list = getObjects().getAll().stream().filter((e) -> (e != null && e.exists() && e.getName().equalsIgnoreCase(name) && getMap().distance(e) <= rad)).collect(Collectors.toList());

Take a look at my streams tutorial to learn more.

 
 
 
EDIT: getObjects() also has a filter() method, however I prefer streams.
Edited by Bobrocket
  • Like 1
Link to comment
Share on other sites

List<RS2Object> objs = getObjects().filter(o -> myPosition().distance(o) < 10 && "Bird snare".equals(o.getName()));

Thanks for the code but getting error on the ( -> )  , osbot syntax error on "-" -- expected.

 

Does "o" supposed have value?

or do i have to import something?

 

(Srry, I'm not to familiar with these types of complicated code in OSbot)

Link to comment
Share on other sites

Thanks for the code but getting error on the ( -> )  , osbot syntax error on "-" -- expected.

 

Does "o" supposed have value?

or do i have to import something?

 

(Srry, I'm not to familiar with these types of complicated code in OSbot)

 

Like soldtodie said, you have to install Java 8, and set the source version of your project to 8

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...