Jump 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.

Better Conditional Sleep

Featured Replies

I was messing around with the conditional sleep class last night and it was very inconsistent. The deviations, intervals and sleep times seemed to have random effects and I couldn't figure out what the problem was. I ended up pretty much rewriting a conditional sleep and now it works how I expected it should.

import org.osbot.rs07.script.MethodProvider;

public abstract class BotTimer {
    
    int maxSleep;
    int intervalCheck;
    int deviation;
    
    public BotTimer(int maxSleep, int intervalCheck) {
        this.maxSleep = maxSleep;
        this.intervalCheck = intervalCheck;
        deviation = 0;
    }
    
    public BotTimer(int maxSleep, int intervalCheck, int deviation) {
        this.maxSleep = maxSleep;
        this.intervalCheck = intervalCheck;
        this.deviation = deviation;
    }
    
    public boolean sleep() throws InterruptedException {
        int randSleep;
        while (maxSleep > 0 && !breakCondition()) {
            randSleep = MethodProvider.random(intervalCheck - deviation, intervalCheck + deviation);
            maxSleep -= randSleep;
            MethodProvider.sleep(randSleep);
        }
        return true;
    }
    
    public abstract boolean breakCondition();

}

Using it in your bot would still be the same:

new BotTimer(5000, 100) {
    public boolean breakCondition() {
        return interfaceOnScreen(465, 21, 25);
    }
}.sleep();

This timer would, at a maximum, call the breakCondition() up to 50 times exactly, or until the interface is shown on screen. Whereas, with ConditionalSleep(5000, 100), it would've execute around 1800 times for me.

Edited by apa

  • Author

ur name

 

>:D I'll sell it for $5000

I like how you used breakCondition() instead of condition() (the API version of that method), makes more sense IMO.

Gj

ur name

I wanna say his name comes from avatar the last air bender but I have no clue.

sleepTime is not used, for whatever reason.

Oh forreal, so your telling me the Api version is bugged
  • 8 months later...

Since conditionalSleep is no longer in the API documentation, is it preferred to use this method? How well does it work compared to the one from the API? 

Since conditionalSleep is no longer in the API documentation, is it preferred to use this method? How well does it work compared to the one from the API? 

 

you don't see it in the api documents but it still part of osbot.

 

example call conditional sleep to have it wait

            if (getInventory().contains(getEnergy())) {
                getBank().depositAll();
                new ConditionalSleep(2000, 100) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().isEmpty();
                    }
                }.sleep();
            }

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.