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
  • Try asking for help in the chatbox
  • Clicking/Timing issue


    infallible
     Share

    Recommended Posts

    if (getBank().close()) {
                    Item herbs = getInventory().get(DirtyHerbName);
                     if (herbs.getAmount() > 0) {
                         MouseSettings.setSpeed(Calculations.random(500, 600));
                         for (int i = 0; i < herbs.getAmount(); i++) {
                            int herbCount = getInventory().count(DirtyHerbName);
                             herbs.interact("Clean");
                            sleepUntil(()-> (getInventory().count(DirtyHerbName)<herbCount), Calculations.random(1000, 1100));
                         }
                     }
                }
    

    Now, with my code, specifically the lambda part, it is needed or the bot clicks one herb 3-4 times until it is clean, then moves to the next. When I do have the lambda though, it clicks once but obviously doesn't move on until the herb is cleaned. How can I make the clicking of the (same item) in the inventory more fluid and quick? 

    Link to comment
    Share on other sites

     

    Why so much extra code? Can't you just:

     for (int i = 0; i <= 27; i++)
                        inv.slotInteract(i, "Clean");
    

    This code is cleaning perfectly, but it goes back through the inv and hovers over each clean herb again like its trying to clean em

    Link to comment
    Share on other sites

    This code is cleaning perfectly, but it goes back through the inv and hovers over each clean herb again like its trying to clean em

    Try something like this

    if (inv.onlyContains(item -> item != null && item.getName().startsWith("Grimy"))) {
    for (int i = 0; i <= 27; i++)
    inv.slotInteract(i, "Clean");
    } else {
    //bank
    }
    
    Link to comment
    Share on other sites

     

    Try something like this

    if (inv.onlyContains(item -> item != null && item.getName().startsWith("Grimy"))) {
    for (int i = 0; i <= 27; i++)
    inv.slotInteract(i, "Clean");
    } else {
    //bank
    }
    

    modified that a bit to get what I want, but I think I've got it. Thanks Volta.

    Link to comment
    Share on other sites

    modified that a bit to get what I want, but I think I've got it. Thanks Volta.

     

     

    If you want to make it so it can start and stop without having to refill its inventory with grimy you can do something like...

     

     

    for (int i = 0; i<= 27; i++) {
        if(getInventory().slotContains(i,herb -> herb != null && herb.getName().startsWith("Grimy")){
            getInventory().slotInteract(i, "Clean");
            sleepUntil(() -> getInventory().slotContains(i,herb -> herb != null && !herb.getName().startsWith("Grimy")),500);
        }else{
            sleep(50,100);
        }
    }
    

     

    Although I would personally suggest using the looping function of scripts to loop through the inventory just so you don't get locked in the for loop if the client closes or the script stops or something along those lines.

    Link to comment
    Share on other sites

     Share

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