April 18, 20187 yr Hello i want make my bot walk with a position path like this I have this error. did i need to read through a for loop? for (int i = 0, i < HILLS_PATH.length() , i++ { getWalking.walk(HILLS_PATH[ i ]); } thx for the help ps: normally i make the position path as a constant with a final Edited April 18, 20187 yr by m3nbersures
April 18, 20187 yr Author 2 minutes ago, MattGP said: I think it has to be an array list not an array any code exemple can help because aray list is a new element but i want new position do you mean : new ArrayList(new Position(0,0,0))) ?
April 18, 20187 yr Bruh you should look into some java tutorials. Then you would know that walkPath accepts a list of positions and not an array.
April 18, 20187 yr Author 5 minutes ago, dreameo said: Bruh you should look into some java tutorials. Then you would know that walkPath accepts a list of positions and not an array. i never use a list in input my data but can a for loop works? im not on my computer right now let give you feedback later
April 18, 20187 yr 29 minutes ago, m3nbersures said: any code exemple can help because aray list is a new element but i want new position do you mean : new ArrayList(new Position(0,0,0))) ? that should do the trick
April 18, 20187 yr private List<Position> path = Arrays.asList(new Position(x,y,z), new Position(x,y,z)); script.getWalking().walkPath(path); I believe something like this is what you are after?
April 19, 20187 yr you need a LinkedList for walking events. I included a break condition as well for better efficiency and responsiveness. Happy scripting!
April 19, 20187 yr Author 1 hour ago, 01053 said: private List<Position> path = Arrays.asList(new Position(x,y,z), new Position(x,y,z)); script.getWalking().walkPath(path); I believe something like this is what you are after? yes thank you very much 1 minute ago, superuser said: you need a LinkedList for walking events. I included a break condition as well for better efficiency and responsiveness. Happy scripting! wow i like the effort you make for that very apreciated ++ rep Edited April 19, 20187 yr by m3nbersures
April 19, 20187 yr 2 hours ago, m3nbersures said: yes thank you very much wow i like the effort you make for that very apreciated ++ rep Also make sure you populate the LinkedList when the script starts in the onStart() method. So you're not having to spend time repopulating the List everytime you call the HILLS_RUN() method, not a major problem but good practise. Also another thing I'd probably do is - Change wEvent.setPath(HILLS_PATH); To w.setPath(HILLS_PATH).setMinDistanceThreshold(2).setMiniMapDistanceThreshold(2); So you aren't literally walking to the exact same tile every time. Edited April 19, 20187 yr by 01053
April 19, 20187 yr 6 hours ago, 01053 said: Also make sure you populate the LinkedList when the script starts in the onStart() method. So you're not having to spend time repopulating the List everytime you call the HILLS_RUN() method, not a major problem but good practise. Also another thing I'd probably do is - Change wEvent.setPath(HILLS_PATH); To w.setPath(HILLS_PATH).setMinDistanceThreshold(2).setMiniMapDistanceThreshold(2); So you aren't literally walking to the exact same tile every time. The default min distance threshold is 3, and the default mini map distance threshold is 5 so I don't think he really needs to change those values. Also mini map distance threshold does not affect whether the player walks to the same position or not: "This method sets the property of this walking event that determines whether the next position you're walking to in the path from A to B will be walked to by using the mini map or the main screen. The next location you're walking to is not necessarily the destination of this event, but the next clickable position in the path from A to B. If the distance to the next clickable position is equal or higher than the mini map distance threshold, this event will walk using the mini map. If not, it will use the main screen. The default value of this property is 5." 8 hours ago, superuser said: you need a LinkedList for walking events. I included a break condition as well for better efficiency and responsiveness. Happy scripting! This is correct, can be simplified a little though (and you shouldn't create the LinkedList every time you want to walk) public static final Area HILLS_AREA = new Area(1, 2, 3, 4); public static final LinkedList<Position> HILLS_PATH = new LinkedList<>( Arrays.asList( new Position(1, 2, 0), new Position(2, 3, 0) ) ); public final void someMethod() { WalkingEvent walkingEvent = new WalkingEvent(); walkingEvent.setPath(HILLS_PATH); walkingEvent.setBreakCondition(new Condition() { return HILLS_AREA.contains(myPosition()); }); execute(walkingEvent); } If you don't need to use setBreakCondition or any of the other functions though, then this will do: private static final List<Position> HILLS_PATH = Arrays.asList(new Position(1, 2, 0), new Position(2, 3, 0)); public final void someMethod() { getWalking().walkPath(HILLS_PATH); } Edited April 19, 20187 yr by Explv
April 19, 20187 yr 3 hours ago, Explv said: This is correct, can be simplified a little though (and you shouldn't create the LinkedList every time you want to walk) public static final Area HILLS_AREA = new Area(1, 2, 3, 4); public static final LinkedList<Position> HILLS_PATH = new LinkedList<>( Arrays.asList( new Position(1, 2, 0), new Position(2, 3, 0) ) ); public final void someMethod() { WalkingEvent walkingEvent = new WalkingEvent(); walkingEvent.setPath(HILLS_PATH); walkingEvent.setBreakCondition(new Condition() { return HILLS_AREA.contains(myPosition()); }); execute(walkingEvent); } If you don't need to use setBreakCondition or any of the other functions though, then this will do: private static final List<Position> HILLS_PATH = Arrays.asList(new Position(1, 2, 0), new Position(2, 3, 0)); public final void someMethod() { getWalking().walkPath(HILLS_PATH); } yeah i know i wrote it like that because i was just expanding on what he had. in hindsight i should have just wrote it the proper way so he doesn't develop bad habits. this is how i actually do things normally Edited April 19, 20187 yr by superuser deleted duplicate image
April 19, 20187 yr 2 hours ago, superuser said: yeah i know i wrote it like that because i was just expanding on what he had. in hindsight i should have just wrote it the proper way so he doesn't develop bad habits. this is how i actually do things normally Yeah fair enough, you don't need those for loops though, you can create a LinkedList<Position> like so: public static final LinkedList<Position> HILLS_PATH = new LinkedList<>( Arrays.asList( new Position(1, 2, 0), new Position(2, 3, 0) ) );
April 20, 20187 yr Author thx to everyone my question was just why my walking cant take my array argument and now i just do Arrays.asList and it works i thought i needed to do a for loop to read through the array but finally i dont need to
Create an account or sign in to comment