Jump to content

Wrapping my head around conditional sleeps


Lil Ugly Mane

Recommended Posts

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

 

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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()

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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