Lil Ugly Mane Posted May 8, 2023 Share Posted May 8, 2023 In this instance, I'm trying to set a conditional sleep to sleep after my script has interacted with lure until my player is animating ie player has reached the spot so that the script doesn't spam other spots whilst tying to run to one. public void Fish() throws InterruptedException { NPC spot = getNpcs().closest("Rod fishing spot"); if ((!myPlayer().isAnimating()) && spot != null) { spot.interact("Lure"); new ConditionalSleep(10000) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } So, if the player is not animating and the spot is not equal to null, interact with lure, then sleep until the player is animating OR 10 seconds has elapsed? Am I writing this correctly? Additionally, what are the two other values that ConditionalSleep can take? Cheers Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted May 8, 2023 Share Posted May 8, 2023 (edited) 31 minutes ago, Lil Ugly Mane said: In this instance, I'm trying to set a conditional sleep to sleep after my script has interacted with lure until my player is animating ie player has reached the spot so that the script doesn't spam other spots whilst tying to run to one. public void Fish() throws InterruptedException { NPC spot = getNpcs().closest("Rod fishing spot"); if ((!myPlayer().isAnimating()) && spot != null) { spot.interact("Lure"); new ConditionalSleep(10000) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } } So, if the player is not animating and the spot is not equal to null, interact with lure, then sleep until the player is animating OR 10 seconds has elapsed? Am I writing this correctly? Additionally, what are the two other values that ConditionalSleep can take? Cheers it sleeps for maximum 10 seconds OR until it starts animating Make sure to wrap the interact in an if too, so you won't be waiting 10 seconds if the interaction failed if(spot.interact("Lure")){ new ConditionalSleep(10000) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html For more info Edited May 8, 2023 by Khaleesi Quote Link to comment Share on other sites More sharing options...
Lil Ugly Mane Posted May 8, 2023 Author Share Posted May 8, 2023 24 minutes ago, Khaleesi said: it sleeps for maximum 10 seconds OR until it starts animating Make sure to wrap the interact in an if too, so you won't be waiting 10 seconds if the interaction failed if(spot.interact("Lure")){ new ConditionalSleep(10000) { @Override public boolean condition() { return myPlayer().isAnimating(); } }.sleep(); } https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html For more info Thanks for your help Another thing - do you think it's human behaviour to move your mouse outside of the screen everytime you've interacted with a spot? Currently I've set it up with a random variable between 1-10, and if its 8 or below it will move the mouse off else it just stays hovered over the spot. What do you think? Would it also be wise to place another conditonal sleep outside the first if statement to sleep until the player is not animating/the spot is no longer null, or is it not necessary? Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted May 8, 2023 Share Posted May 8, 2023 20 minutes ago, Lil Ugly Mane said: Thanks for your help Another thing - do you think it's human behaviour to move your mouse outside of the screen everytime you've interacted with a spot? Currently I've set it up with a random variable between 1-10, and if its 8 or below it will move the mouse off else it just stays hovered over the spot. What do you think? Would it also be wise to place another conditonal sleep outside the first if statement to sleep until the player is not animating/the spot is no longer null, or is it not necessary? ya I believe it's nice, just don't overdo it for every few seconds You could add it in the same conditional sleep, !spot.exists() Quote Link to comment Share on other sites More sharing options...