January 5, 201610 yr 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, 201610 yr by ni562
January 5, 201610 yr 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, 201610 yr by Explv
January 5, 201610 yr 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..
January 5, 201610 yr 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);
January 5, 201610 yr 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?
January 5, 201610 yr 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.
January 5, 201610 yr 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
January 8, 201610 yr 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?
January 8, 201610 yr 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