ni562 Posted January 5, 2016 Share Posted January 5, 2016 (edited) 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 January 5, 2016 by ni562 Quote Link to comment Share on other sites More sharing options...
Explv Posted January 5, 2016 Share Posted January 5, 2016 (edited) 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 January 5, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 5, 2016 Author Share Posted January 5, 2016 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.. Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted January 5, 2016 Share Posted January 5, 2016 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); Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 5, 2016 Author Share Posted January 5, 2016 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? Quote Link to comment Share on other sites More sharing options...
Explv Posted January 5, 2016 Share Posted January 5, 2016 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. Quote Link to comment Share on other sites More sharing options...
ni562 Posted January 5, 2016 Author Share Posted January 5, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
ikk Posted January 8, 2016 Share Posted January 8, 2016 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? Quote Link to comment Share on other sites More sharing options...
Explv Posted January 8, 2016 Share Posted January 8, 2016 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(); } } } Quote Link to comment Share on other sites More sharing options...