Jump to content

Wrapping my head around conditional sleeps


Recommended Posts

Posted

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

 

 

Posted (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 by Khaleesi
Posted
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?

Posted
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 :D
You could add it in the same conditional sleep, !spot.exists()

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...