Zummy Posted August 29, 2018 Share Posted August 29, 2018 I'm in the proces of converting all my webWalks to pathWalks but I'm wondering if it is possible to add a break condition. I ask this because I think my onLoop gets stuck at these pathwalks. Quote Link to comment Share on other sites More sharing options...
d0zza Posted August 29, 2018 Share Posted August 29, 2018 Why are you converting all of your webWalks? WalkPath only uses the local loaded map to walk and it also can not interact with any objects while walking. So if you need to walk a long distance that might need to interact with a gate, door or stairs you'd more than likely need to use webWalk. To set a break condition for a webWalk take a look at https://osbot.org/api/org/osbot/rs07/event/WebWalkEvent.html To set a break condition for a WalkingEvent take a look at https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html Quote Link to comment Share on other sites More sharing options...
Zummy Posted August 30, 2018 Author Share Posted August 30, 2018 15 hours ago, d0zza said: Why are you converting all of your webWalks? WalkPath only uses the local loaded map to walk and it also can not interact with any objects while walking. So if you need to walk a long distance that might need to interact with a gate, door or stairs you'd more than likely need to use webWalk. To set a break condition for a webWalk take a look at https://osbot.org/api/org/osbot/rs07/event/WebWalkEvent.html To set a break condition for a WalkingEvent take a look at https://osbot.org/api/org/osbot/rs07/event/WalkingEvent.html Because webWalk is using too much RAM and my paths do not require object interaction. I know breaking conditions are possible for both walkingEvents and webWalking but why not for pathWalking? Quote Link to comment Share on other sites More sharing options...
dreameo Posted August 30, 2018 Share Posted August 30, 2018 6 hours ago, Zummy said: Because webWalk is using too much RAM and my paths do not require object interaction. I know breaking conditions are possible for both walkingEvents and webWalking but why not for pathWalking? You could try creating a path: ArrayList<Position> path and then use WalkingEvent to traverse to each point. Quote Link to comment Share on other sites More sharing options...
Zummy Posted August 30, 2018 Author Share Posted August 30, 2018 32 minutes ago, dreameo said: You could try creating a path: ArrayList<Position> path and then use WalkingEvent to traverse to each point. WalkingEvent only accepts a single Position, not a list or array. Quote Link to comment Share on other sites More sharing options...
Chris Posted August 30, 2018 Share Posted August 30, 2018 12 minutes ago, Zummy said: WalkingEvent only accepts a single Position, not a list or array. Look at these examples public boolean walkToDestination(final Position dest, final BooleanSupplier bc, final boolean walkExact){ WalkingEvent walkingEvent = new WalkingEvent(dest); walkingEvent.setEnergyThreshold(10); walkingEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return bc.getAsBoolean(); } }); if (walkExact) walkingEvent.setMinDistanceThreshold(0); return getScript().execute(walkingEvent).hasFinished(); } public boolean walkToDestination(final Position[] positions, final BooleanSupplier bc, final boolean walkExact){ WalkingEvent walkingEvent = new WalkingEvent(); walkingEvent.setPath(new LinkedList<>(Arrays.asList(positions))); walkingEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return bc.getAsBoolean(); } }); if (walkExact) walkingEvent.setMinDistanceThreshold(0); walkingEvent.setMiniMapDistanceThreshold(0); walkingEvent.setEnergyThreshold(random(5, 15)); return getScript().execute(walkingEvent).hasFinished(); } public boolean walkToDestination(LinkedList<Position> path, BooleanSupplier bc, boolean walkExact) { WalkingEvent walkingEvent = new WalkingEvent(); walkingEvent.setPath(path); walkingEvent.setBreakCondition(new Condition() { @Override public boolean evaluate() { return bc.getAsBoolean(); } }); if (walkExact) walkingEvent.setMinDistanceThreshold(0); walkingEvent.setMiniMapDistanceThreshold(0); return getScript().execute(walkingEvent).hasFinished(); } 1 Quote Link to comment Share on other sites More sharing options...
dreameo Posted August 30, 2018 Share Posted August 30, 2018 38 minutes ago, Zummy said: WalkingEvent only accepts a single Position, not a list or array. ... -.- You can look at Chris's example or literally do what I said.. For each Position.. use the WalkingEvent until there are no more positions.. Quote Link to comment Share on other sites More sharing options...
Zummy Posted September 2, 2018 Author Share Posted September 2, 2018 On 8/31/2018 at 12:01 AM, dreameo said: ... -.- You can look at Chris's example or literally do what I said.. For each Position.. use the WalkingEvent until there are no more positions.. I'm sorry you're right, I followed a tutorial which looked pretty official on this forum that stated you could only use 1 position for walkingEvents. I tried using a list of positions regardless but couldn't figure it out so I thought the guy was telling the truth. On 8/30/2018 at 11:36 PM, Chris said: Look at these examples Thanks Chris! 1 Quote Link to comment Share on other sites More sharing options...
dreameo Posted September 2, 2018 Share Posted September 2, 2018 8 hours ago, Zummy said: I'm sorry you're right, I followed a tutorial which looked pretty official on this forum that stated you could only use 1 position for walkingEvents. I tried using a list of positions regardless but couldn't figure it out so I thought the guy was telling the truth. Thanks Chris! Code: Spoiler private boolean walk(){ WalkingEvent walkingEvent; for(Position position : path) { walkingEvent = new WalkingEvent(position); Event event = getBot().getEventExecutor().execute(walkingEvent); if(event.hasFailed()) { return false; } else { path.remove(position); } } return true; } So I just tried that and it seems to work fine. You just fill in whatever break condition you want. (You need to keep a temporary path so that as you traverse to each node, you delete it and then continue to next -> really depends on how you write your logic to START the walker) Quote Link to comment Share on other sites More sharing options...
Juggles Posted September 2, 2018 Share Posted September 2, 2018 Chris is the man, the mod, and a great coder! I trust his knowledge 1 Quote Link to comment Share on other sites More sharing options...
SpritexCodeine Posted September 2, 2018 Share Posted September 2, 2018 same is happening with me, thank you for working on it Quote Link to comment Share on other sites More sharing options...