infallible 28 Share Posted January 22, 2017 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 More sharing options...
Volta 183 Share Posted January 22, 2017 Why so much extra code? Can't you just: for (int i = 0; i <= 27; i++) inv.slotInteract(i, "Clean"); Link to comment Share on other sites More sharing options...
rokaHakor 171 Share Posted January 22, 2017 Reduce this Calculations.random(1000, 1100)); to Calculations.random(550, 650)); Link to comment Share on other sites More sharing options...
infallible 28 Author Share Posted January 22, 2017 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 More sharing options...
Volta 183 Share Posted January 22, 2017 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 More sharing options...
infallible 28 Author Share Posted January 22, 2017 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 More sharing options...
Hopewelljnj 46 Share Posted January 25, 2017 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 More sharing options...
Dreamlicker 750 Share Posted January 25, 2017 Using a for loop is bad design. Scripts loop naturally, you should use that functionality instead because of the bugs you encountered. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.