Binarybunny 0 Share Posted March 8, 2018 so sleepUntil.. let's say I ahve this //If the player is fishing. if (getLocalPlayer().getAnimation() == 621) { //sleep until te player is idle or 2000 sleepUntil(() -> getLocalPlayer().getAnimation() == -1, 2000); } If 2 seconds pass will it run the if (getLocalPlayer().getAnimation() == 621) again? Or just keep moving down to the next line of code? Link to comment Share on other sites More sharing options...
Nex 2542 Share Posted March 8, 2018 //If the player is fishing. if (getLocalPlayer().getAnimation() == 621) { //sleep until te player is idle or 2000 sleepUntil(() -> getLocalPlayer().getAnimation() == -1, 2000); } Going from ur code, this will make the bot sleep untill ur character is idle or if 2 seconds passed also a good thing to add would be getDialogues().inDialogue() (for lv ups) but thats more if u do a longer sleep. u can also sleepWhile the player is doing a certain animation And yes this will repeat untill ur players animation isnt 621. Link to comment Share on other sites More sharing options...
Pyth 127 Share Posted March 8, 2018 If 2 seconds pass will it run the if (getLocalPlayer().getAnimation() == 621) again? Or just keep moving down to the next line of code? It'll keep moving to the next line of code. Link to comment Share on other sites More sharing options...
Xephy 237 Share Posted March 8, 2018 Exactly what Pyth said. It'll keep looping through the sleepUntil until the return condition is true or the timeout has elapsed. Whichever comes first. Then it will move on to the next line of code regardless. I believe it loops every 20ms or so. Link to comment Share on other sites More sharing options...
Dinh 496 Share Posted March 8, 2018 Maybe this helps a bit, this is what it COULD BE DOING code wise if (getLocalPlayer().getAnimation() == 621) { sleepUntil(() -> getLocalPlayer().getAnimation() == -1, 2000); } private boolean sleepUntil(Condition condition, long timeout) { long start = System.currentTimeMillis(); while((System.currentTimeMillis() - start) < timeout) { if (condition.verify()) { return true; } } return false; } Link to comment Share on other sites More sharing options...
dQw4w9WgXcQ 184 Share Posted March 8, 2018 Maybe this helps a bit, this is what it COULD BE DOING code wise if (getLocalPlayer().getAnimation() == 621) { sleepUntil(() -> getLocalPlayer().getAnimation() == -1, 2000); } private boolean sleepUntil(Condition condition, long timeout) { long start = System.currentTimeMillis(); while((System.currentTimeMillis() - start) < timeout) { if (condition.verify()) { return true; } } return false; } if (getLocalPlayer().getAnimation() == 621) { sleepUntil(() -> getLocalPlayer().getAnimation() == -1, 2000); } private boolean sleepUntil(Condition condition, long timeout) { long start = System.currentTimeMillis(); while((System.currentTimeMillis() - start) < timeout) { if (condition.verify()) { return true; } MethodProvider.sleep(25);<-- u 4got this! } return false; } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.