Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Can't get item filter to work for Inventory.


    Empyrean GB

    Recommended Posts

    Hello everyone,

    I've been trying to work with an Item filter. if I use the setup it works for the Bank.depositAllExcept(Filter<Item> filter) method. However when I try to apply it on an actual Item taken from my Inventory I can't get it to work. I've tried tweaking around with it in a small AbstractScript that generates an output. The script is as following:

    private Filter<Item> itemWithID(Integer... ids){
            for(int i: ids){
                log("" + i);
            }
            List<Integer> test = Arrays.asList(ids);
            for(int i: test){
                log("" + i);
            }
            
            return new Filter<Item>(){
                List<Integer> items = Arrays.asList(ids);
                @Override
                public boolean match(Item i) {
                    log("in match");
                    for(int in: items){
                        log("item with id " + in);
                    }
                    return items.contains(i.getID());
                }
            };
        }
    
        @Override
        public int onLoop() {
            Filter filter = itemWithID(303, 323, 666);
            List<org.dreambot.api.wrappers.items.Item> itemsToDeposit = Game.getInstance().get().getInventory().getCollection();
            
            for(org.dreambot.api.wrappers.items.Item i:itemsToDeposit){
                log("Checking item: " + i.getName() + " with id: " + i.getID());
                if(filter.equals(i)){
                    log("filter was true");
                }else{
                    log("filter was false");
                }
            }
            
            this.stop();
            return 5000;
        }

     

    When running it it generates the following output:

    303
    323
    666
    303
    323
    666
    Checking item: Raw anchovies with id: 321
    filter was false
    Checking item: Small fishing net with id: 303
    filter was false
    Checking item: Anchovies with id: 319
    filter was false
    Checking item: Raw shrimps with id: 317
    filter was false
    Checking item: Burnt fish with id: 323
    filter was false

     

    How do I use the filter in a way that will get in the right branch of the if statement for the small fishing net and burnt fish?

     

    EmpyreanGB

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.