elliottdehn Posted May 3, 2015 Share Posted May 3, 2015 int x = trapPosition.getX(); int y = trapPosition.getY(); List<RS2Object> objectsAtPos = script.objects.get(x, y); List<GroundItem> itemsAtPos = script.groundItems.get(x, y); the last two lines give me errors: get(int, int) is not a method of Objects/groundItems. int x = trapPosition.getX(); int y = trapPosition.getY(); List<RS2Object> objectsAtPos = script.objects.getAll(); List<GroundItem> itemsAtPos = script.groundItems.getAll(); does not give errors but i would like to use the first section of code. Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted May 3, 2015 Share Posted May 3, 2015 (edited) Looks like get(x,y) is gone (or it's new, still using the 2.3.58 api)But you can always use a filter:objects.filter(obj -> obj.getPosition().equals(trapPosition)); Edited May 3, 2015 by Flamezzz Quote Link to comment Share on other sites More sharing options...
elliottdehn Posted May 3, 2015 Author Share Posted May 3, 2015 (edited) I have never used filters. Can you please explain how to make and use them? It would be greatly appreciated.Also, edit: what you're saying is List<RS2Object> objectsAtPos = script.objects.filter(obj -> obj .getPosition().equals(trapPosition)); will return a List of RS2Objects matching trapPosition? Edited May 3, 2015 by elliottdehn Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted May 3, 2015 Share Posted May 3, 2015 Well you pass a Filter of a specific type to objects.filter, groundItems.filter, npcs.filter etc. A Filter has the method match, in which you specify when an object/npc/grounditem meets certain requirements. Using Java 8 lambda expressions (probably needs to be enabled in your IDE) you can specify this as:objects.filter(variable -> requirements)Which is the same as ( Java < 8 ):objects.filter( new Filter<RS2Object>() { public boolean match(RS2Object variable) { if (requirements) return true; else return false; }});Each time you return true for a specific object/npc/grounditem it passes the filter and is added to the list, which will be returned Quote Link to comment Share on other sites More sharing options...
elliottdehn Posted May 3, 2015 Author Share Posted May 3, 2015 Thank you bunches! Quote Link to comment Share on other sites More sharing options...