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
  • Filters!!!


    Big Buddha

    Recommended Posts

    I'm making a banana picker and after I finally completed it, IT DOESN'T START!

     

    I get how the super basics of scripting work now so I'm trying to step it up but this shit's so hard!

    Look at this filter mess I made, I don't know where to begin.

     

     

     

        //duel ring and glory euhm... filter stuff?
        Item duelring = getEquipment().get(new Filter<Item>(){
            public boolean match(Item dr) {
                if(dr == null || dr.getName() == null)
                    return false;
                if(!dr.getName().equals("Ring of dueling(8)") ||
                    !dr.getName().equals("Ring of dueling(7)") ||
                    !dr.getName().equals("Ring of dueling(6)") ||
                    !dr.getName().equals("Ring of dueling(5)") ||
                    !dr.getName().equals("Ring of dueling(4)") ||
                    !dr.getName().equals("Ring of dueling(3)") ||
                    !dr.getName().equals("Ring of dueling(2)") ||
                    !dr.getName().equals("Ring of dueling(1)"))
                    return false;
                if(getEquipment().contains(dr))
                    return true;
                return false;
            }
        });
        Item glory = getEquipment().get(new Filter<Item>(){
            public boolean match(Item ag) {
                if(ag == null || ag.getName() == null)
                    return false;
                if(!ag.getName().equals("Amulet of glory(1)") ||
                    !ag.getName().equals("Amulet of glory(2)") ||
                    !ag.getName().equals("Amulet of glory(3)") ||
                    !ag.getName().equals("Amulet of glory(4)") ||
                    !ag.getName().equals("Amulet of glory(5)") ||
                    !ag.getName().equals("Amulet of glory(6)") ||
                    !ag.getName().equals("Amulet of glory"))
                    return false;
                if(getEquipment().contains(ag))
                    return true;
                return false;
            }    
        });

     

     

     

    Here's the full thing if you think it might be something else.

    But BEWARE it's sloppy!! :3

     

     

     

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.methods.filter.Filter;
    import org.dreambot.api.methods.map.Area;
    import org.dreambot.api.methods.map.Tile;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.utilities.impl.Condition;
    import org.dreambot.api.wrappers.interactive.GameObject;
    import org.dreambot.api.wrappers.items.Item;
    
    @ScriptManifest(author = "Big Buddha", category = Category.MONEYMAKING, name = "Banana Picker", version = 1.0)
    public class MainClass extends AbstractScript{
        
        private final Area BANK_AREA = new Area(2436,3095,2443,3082);
        private final Area BANANA_AREA = new Area(2905,3178,2933, 3152);
        private final Tile BANK_TILE = new Tile(2443,3083);
    
        //duel ring and glory euhm... filter stuff?
        Item duelring = getEquipment().get(new Filter<Item>(){
            public boolean match(Item dr) {
                if(dr == null || dr.getName() == null)
                    return false;
                if(!dr.getName().equals("Ring of dueling(8)") ||
                    !dr.getName().equals("Ring of dueling(7)") ||
                    !dr.getName().equals("Ring of dueling(6)") ||
                    !dr.getName().equals("Ring of dueling(5)") ||
                    !dr.getName().equals("Ring of dueling(4)") ||
                    !dr.getName().equals("Ring of dueling(3)") ||
                    !dr.getName().equals("Ring of dueling(2)") ||
                    !dr.getName().equals("Ring of dueling(1)"))
                    return false;
                if(getEquipment().contains(dr))
                    return true;
                return false;
            }
        });
        Item glory = getEquipment().get(new Filter<Item>(){
            public boolean match(Item ag) {
                if(ag == null || ag.getName() == null)
                    return false;
                if(!ag.getName().equals("Amulet of glory(1)") ||
                    !ag.getName().equals("Amulet of glory(2)") ||
                    !ag.getName().equals("Amulet of glory(3)") ||
                    !ag.getName().equals("Amulet of glory(4)") ||
                    !ag.getName().equals("Amulet of glory(5)") ||
                    !ag.getName().equals("Amulet of glory(6)") ||
                    !ag.getName().equals("Amulet of glory"))
                    return false;
                if(getEquipment().contains(ag))
                    return true;
                return false;
            }    
        });
        
        
        
        
        private State state;
        
        private enum State{
            BANK, WALK_TO_BANK, WALK_TO_BANANAS, PICK_BANANAS
        }
        
        private State getState(){
            if(!getInventory().contains(5376)){
                if(BANK_AREA.contains(getLocalPlayer())){
                    return State.BANK;
                }
                else{
                    return State.WALK_TO_BANK;
                }
            }
            else{
                if(BANANA_AREA.contains(getLocalPlayer())){
                    return State.PICK_BANANAS;
                }
                else{
                    return State.WALK_TO_BANANAS;
                }
            }
        }
        
        
        
        @Override
        public int onLoop() {
            
            if(getLocalPlayer().isMoving()){
                Tile dest = getClient().getDestination();
                if(getLocalPlayer().getTile().distance(dest) > 4){
                    return Calculations.random(200, 400);
                }
            }
            
                state = getState();
                switch(state){
                case BANK:
                    
                    //Remove depleted Glory
                    if(getEquipment().contains(1704)){
                        getEquipment().get(1704).interact("Remove");
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return !getEquipment().contains(1704);
                            }
                        },Calculations.random(600, 1500));
                    }
                    
                    //Deposit all items, withdraw more baskets
                    if(getBank().isOpen() && getInventory().contains(5416)){
                        getBank().depositAllItems();
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return getInventory().isEmpty();
                            }
                        },Calculations.random(1800, 2400));
                        getBank().withdraw(5376, 23);
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return getInventory().contains(5376);
                            }
                        },Calculations.random(1800, 2400));
                        
                        //Withdraw duel ring if none equipped
                        if(duelring == null){
                            getBank().withdraw(2552);
                            sleepUntil(new Condition(){
                                public boolean verify(){
                                    return getInventory().contains(2552);
                                }
                            },Calculations.random(800,1200));
                        }
                        //Withdraw glory if none equipped
                        if(glory == null){
                            getBank().withdraw(11978);
                            sleepUntil(new Condition(){
                                public boolean verify(){
                                    return getInventory().contains(11978);
                                }
                            },Calculations.random(800,1200));
                        }
                        
                        //Closing bank!
                        getBank().close();
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return !getBank().isOpen();
                            }
                        },Calculations.random(1500, 2600));
                            
                            //Equip duel ring
                            if(getInventory().contains(2552)){
                                Calculations.random(500,800);
                                getInventory().get(2552).interact("Wear");
                                sleepUntil(new Condition(){
                                    public boolean verify(){
                                        return !getInventory().contains(2552);
                                    }
                                },Calculations.random(750, 1300));
                            }
                            //Equip glory
                            if(getInventory().contains(11978)){
                                getBank().close();
                                Calculations.random(500,800);
                                getInventory().get(11978).interact("Wear");
                                sleepUntil(new Condition(){
                                    public boolean verify(){
                                        return !getInventory().contains(11978);
                                    }
                                },Calculations.random(750, 1300));
                            }
                        
                    }
                    
                    //Open bank if not open yet
                    else{
                        GameObject bank = getGameObjects().closest(new Filter<GameObject>(){
                            public boolean match(GameObject go){
                                if(go == null || go.getName() == null)
                                    return false;
                                if(!go.getName().equals("Bank chest"))
                                    return false;
                                return true;
                            }
                        });
                        if(bank != null){
                            bank.interact("Use");
                        }
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return getBank().isOpen();
                            }
                        },Calculations.random(800, 1200));
                    }
                    break;
                    
                    
                case PICK_BANANAS:
                    
                    if(getInventory().isFull() || getInventory().contains(5376)){
                        getInventory().get(5376).interact("Fill");
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return !getInventory().isFull();
                            }
                        },Calculations.random(500, 1200));
                    }
                    else {
                        GameObject tree = getGameObjects().closest(new Filter<GameObject>(){
                            public boolean match(GameObject bt){
                                if(bt == null || bt.getName() == null)
                                    return false;
                                if(!bt.getName().equals("Banana Tree"))
                                    return false;
                                if(bt.getName().equals("Banana Tree") && bt.hasAction("Search"))
                                    return false;
                                return true;
                            }
                        });
                        if(tree != null){
                            tree.interact("Pick");
                            Calculations.random(200, 450);
                        }
                    }
                    break;
                case WALK_TO_BANANAS:
                    
                    //Glory -> Karamja
                    if(BANK_AREA.contains(getLocalPlayer()))
                        glory.interact("Karamja");
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return BANANA_AREA.contains(getLocalPlayer());
                            }
                        },Calculations.random(1800, 2800));
                    break;
                case WALK_TO_BANK:
                    
                    //Duel -> CW
                    if(BANANA_AREA.contains(getLocalPlayer()))
                        duelring.interact("Castle Wars");
                        sleepUntil(new Condition(){
                            public boolean verify(){
                                return BANK_AREA.contains(getLocalPlayer());
                            }
                        },Calculations.random(1800, 2800));
                    break;
                default:
                    break;
                }
                
                
            return Calculations.random(200, 400);
        }
    
    }

     

     

    Link to comment
    Share on other sites

     Item duelring = getEquipment().get(new Filter<Item>(){
            public boolean match(Item dr) {
                if(dr == null || dr.getName() == null)
                    return false;
                if(!dr.getName().equals("Ring of dueling(8)") ||
                    !dr.getName().equals("Ring of dueling(7)") ||
                    !dr.getName().equals("Ring of dueling(6)") ||
                    !dr.getName().equals("Ring of dueling(5)") ||
                    !dr.getName().equals("Ring of dueling(4)") ||
                    !dr.getName().equals("Ring of dueling(3)") ||
                    !dr.getName().equals("Ring of dueling(2)") ||
                    !dr.getName().equals("Ring of dueling(1)"))
                    return false;
                if(getEquipment().contains(dr))
                    return true;
                return false;
            }
        });
        Item glory = getEquipment().get(new Filter<Item>(){
            public boolean match(Item ag) {
                if(ag == null || ag.getName() == null)
                    return false;
                if(!ag.getName().equals("Amulet of glory(1)") ||
                    !ag.getName().equals("Amulet of glory(2)") ||
                    !ag.getName().equals("Amulet of glory(3)") ||
                    !ag.getName().equals("Amulet of glory(4)") ||
                    !ag.getName().equals("Amulet of glory(5)") ||
                    !ag.getName().equals("Amulet of glory(6)") ||
                    !ag.getName().equals("Amulet of glory"))
                    return false;
                if(getEquipment().contains(ag))
                    return true;
                return false;
            }    
        });
    
    ->

     

        Item duelring = getEquipment().get(item -> item != null && item.getName().contains("duel"));
        Item glory = getEquipment().get(item -> item != null && item.getName().contains("glory")); 
        //Lambda expression, it is retrieving the item that matches these conditions. 
        //"item" is a random name and can be made up
    
    
    Link to comment
    Share on other sites

     Item duelring = getEquipment().get(new Filter<Item>(){
            public boolean match(Item dr) {
                if(dr == null || dr.getName() == null)
                    return false;
                if(!dr.getName().equals("Ring of dueling(8)") ||
                    !dr.getName().equals("Ring of dueling(7)") ||
                    !dr.getName().equals("Ring of dueling(6)") ||
                    !dr.getName().equals("Ring of dueling(5)") ||
                    !dr.getName().equals("Ring of dueling(4)") ||
                    !dr.getName().equals("Ring of dueling(3)") ||
                    !dr.getName().equals("Ring of dueling(2)") ||
                    !dr.getName().equals("Ring of dueling(1)"))
                    return false;
                if(getEquipment().contains(dr))
                    return true;
                return false;
            }
        });
        Item glory = getEquipment().get(new Filter<Item>(){
            public boolean match(Item ag) {
                if(ag == null || ag.getName() == null)
                    return false;
                if(!ag.getName().equals("Amulet of glory(1)") ||
                    !ag.getName().equals("Amulet of glory(2)") ||
                    !ag.getName().equals("Amulet of glory(3)") ||
                    !ag.getName().equals("Amulet of glory(4)") ||
                    !ag.getName().equals("Amulet of glory(5)") ||
                    !ag.getName().equals("Amulet of glory(6)") ||
                    !ag.getName().equals("Amulet of glory"))
                    return false;
                if(getEquipment().contains(ag))
                    return true;
                return false;
            }    
        });
    
    ->

     

        Item duelring = getEquipment().get(item -> item != null && item.getName().contains("duel"));
        Item glory = getEquipment().get(item -> item != null && item.getName().contains("glory")); 
        //Lambda expression, it is retrieving the item that matches these conditions. 
        //"item" is a random name and can be made up
    
    

    That makes so much more sense haha, thanks :)

    Is there anyway for me to find these basic things cause the API still confuses me too much atm.

    I'd like to take the time to learn it properly instead of the age old trial and error.

    Link to comment
    Share on other sites

    That makes so much more sense haha, thanks :)

    Is there anyway for me to find these basic things cause the API still confuses me too much atm.

    I'd like to take the time to learn it properly instead of the age old trial and error.

    I have an API and Filter tutorial on Youtube here

     

    It might not be too great, so sorry for that.

    Link to comment
    Share on other sites

    I have an API and Filter tutorial on Youtube here

     

    It might not be too great, so sorry for that.

    It's not great it's amazing! :D

    Exactly what I needed to level up! I was so lost in that API I didn't know where to look. Atleast now I know what the main class is and I can build on that.

    Thanks dude!

    Link to comment
    Share on other sites

    It's not great it's amazing! :D

    Exactly what I needed to level up! I was so lost in that API I didn't know where to look. Atleast now I know what the main class is and I can build on that.

    Thanks dude!

     

    Glad it helped =] There are other videos on my channel that might help out too. I think that one may be the most "advanced" though.

     

    I like your voice :)

    Thanks ;)

    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.