Jump to content
elliottdehn

objects.get(int, int) and groundItems.get(int, int) not working?

Recommended Posts

        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.

 

Link to comment
Share on other sites

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 by elliottdehn
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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