erenjwz Posted November 8, 2015 Share Posted November 8, 2015 How do I get all Objects in a range? Lets say i wanna get all Bird_snare object in a range of 10 what whould be the best way to do that? Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 8, 2015 Share Posted November 8, 2015 (edited) 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 November 8, 2015 by Bobrocket 1 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted November 8, 2015 Share Posted November 8, 2015 (edited) List<RS2Object> objs = getObjects().filter(o -> myPosition().distance(o) < 10 && "Bird snare".equals(o.getName())); Edited November 8, 2015 by FrostBug 3 Quote Link to comment Share on other sites More sharing options...
erenjwz Posted November 8, 2015 Author Share Posted November 8, 2015 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) Quote Link to comment Share on other sites More sharing options...
Soldtodie Posted November 8, 2015 Share Posted November 8, 2015 you need java 8 1 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted November 8, 2015 Share Posted November 8, 2015 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 1 Quote Link to comment Share on other sites More sharing options...
erenjwz Posted November 17, 2015 Author Share Posted November 17, 2015 Like soldtodie said, you have to install Java 8, and set the source version of your project to 8 i have changed my JDK java from 1.7 to 1.8 but it seems the problem is still ocuring in eclipse would you mind helping me : - ) (or pushing me in the right direction) Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted November 17, 2015 Share Posted November 17, 2015 i have changed my JDK java from 1.7 to 1.8 but it seems the problem is still ocuring in eclipse would you mind helping me : - ) (or pushing me in the right direction) You probably need to enable it in your IDE. 2 Quote Link to comment Share on other sites More sharing options...