Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wrapping my head around conditional sleeps

Featured Replies

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

 

 

  • Developer
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

  • Author
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?

  • Developer
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

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.