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.

ConditionalSleep's condition() doesn't work

Featured Replies

  • Author
1 hour ago, progamerz said:

@Sujamma
It doesn't work because theoretically, it never changes the value of gate again, so it is stored as an old object which is closed, what you can do is use this


new ConditionalSleep(5000, 600) {
    @Override
    public boolean condition() {
        return getObjects().closest(o -> o.getName().equals("Gate")
                && o.getPosition().equals(gate.getPosition()) && !o.hasAction("Open")) != null;
    }
}.sleep();

The way this works, is that it keeps checking every 600ms if the condition is true, here we are trying to find new object which has the same position as the gate which we interacted but is opened

I used your code, but the bot is still standing still for 5 seconds and only then runs to the mill. I'll just leave it as is, the script works anyway. Thanks for the help.  

15 minutes ago, Sujamma said:

I used your code, but the bot is still standing still for 5 seconds and only then runs to the mill. I'll just leave it as is, the script works anyway. Thanks for the help.  

If you want you can post the code on something like pastebin and i can help, most probs its not from the conditional sleep

  • Author
22 minutes ago, progamerz said:

If you want you can post the code on something like pastebin and i can help, most probs its not from the conditional sleep

https://pastebin.com/nLaKc3NX It's my first time using pastebin, so tell me if something's wrong. 

41 minutes ago, Sujamma said:

https://pastebin.com/nLaKc3NX It's my first time using pastebin, so tell me if something's wrong. 

private void GoToMill2() throws InterruptedException {
    Position outsideMill = new Position(3166, 3300, 0);
    Position insideMill = new Position(3166, 3305, 0);

    if (!getMap().canReach(outsideMill)) {
        if (getDoorHandler().handleNextObstacle(outsideMill)) {
            ConditionalSleep2.sleep(5000, 500, () -> getMap().canReach(outsideMill));
        }
    } else {
        WalkingEvent walk = new WalkingEvent(outsideMill);
        execute(walk);
    }

    // OR

    if (!getMap().canReach(outsideMill)) {
        RS2Object gate = getObjects().closest(o -> o.getName().equalsIgnoreCase("Gate") && o.hasAction("Open"));
        if (gate.interact("Open"))
            ConditionalSleep2.sleep(5000, 500, () -> getMap().canReach(outsideMill));
    } else {
        WalkingEvent walk = new WalkingEvent(outsideMill);
        execute(walk);
    }
}

Basically the first method, it tries to use the DoorHandler API, which you pass in the position where you want to go to, and it will handle the obstacles, that will not let it reach the position
https://osbot.org/api/org/osbot/rs07/api/DoorHandler.html

The second method, is you handling the obstacle manually(without using the DoorHandler API)
Both should work, but make sure to only keep one of the both methods.

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.