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.

doorHandler not behaving as expected

Featured Replies

Capture.png

 

when I try and leave the room with the spining wheel, doorHandler sometimes clicks the red door..It not a big deal, but it's happening a little tooo often imo. Im wondering how i can stop it from clicking the red door as it't not at all in my path. 

while (!map.canReach(STAIRS.getRandomPosition())) {
 doorHandler.handleNextObstacle(STAIRS);
 ConditionalSleep(10000);
}

I triple checked the coooords for my STAIRS area and the door is not inside the area! 

Edited by ni562

Capture.png

 

when I try and leave the room with the spining wheel, doorHandler sometimes clicks the red door..It not a big deal, but it's happening a little tooo often imo. Im wondering how i can stop it from clicking the red door as it't not at all in my path. 

while (!map.canReach(STAIRS.getRandomPosition())) {
 doorHandler.handleNextObstacle(STAIRS);
 ConditionalSleep(10000);
}

I triple checked the coooords for my STAIRS area and the door is not inside the area! 

 

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}

Edited by Explv

  • Author

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}

 

Wow i'll try that! How can i pass it a Script object? that it the only part i'm unsure about.. 

Wow i'll try that! How can i pass it a Script object? that it the only part i'm unsure about.. 

 

In your Script class where you extend Script...

 

final DoorHelper helper = new DoorHelper(this);
  • Author

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}
public RS2Object getDoor(Area doorArea){

//noinspection unchecked
return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
}

always returns null, any idea why? 

public RS2Object getDoor(Area doorArea){

//noinspection unchecked
return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
}

always returns null, any idea why? 

 

 

Maybe the door is not called "Door".

 

Or the area you passed does not contain the door.

  • Author

Maybe the door is not called "Door".

 

Or the area you passed does not contain the door.

AREA.setPlane(1); 

I had forgotten this. Thanks :P 

 

You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(RS2Object door){

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(door);
                }
            }.sleep();
        }
    }
}

Why is it that the ConditionalSleep in the openDoor() method seems to always wait the full 5 seconds and not stop the sleep when the door is open like I would expect it to?

Why is it that the ConditionalSleep in the openDoor() method seems to always wait the full 5 seconds and not stop the sleep when the door is open like I would expect it to?

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

public class DoorHelper {

    private final Script S;
    
    public DoorHelper(final Script S){
        
        this.S = S;
    }
    
    public RS2Object getDoor(Area doorArea){

        //noinspection unchecked
        return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj));
    }

    public boolean doorIsClosed(RS2Object door){

        return door.hasAction("Open");
    }

    public void openDoor(Area doorArea){

        RS2Object door = getDoor(doorArea);

        if(door != null && doorIsClosed(door)){

            door.interact("Open");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !doorIsClosed(getDoor(doorArea));
                }
            }.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.