Walking, what am i doing wrong?

Discussion in 'Developer Support' started by Sweden, Jul 26, 2015.

  1. Sweden

    Joined:
    Jul 20, 2015
    Messages:
    27
    Likes Received:
    4
    Im trying to walk from point a to b, using:
    public void walkToPoint(String... args) {
    PredefinedPath path = PredefinedPath.create(new Coordinate(2098, 3919, 0), new Coordinate(2102, 3915, 0), new Coordinate(2107, 3915, 0), new Coordinate(2112, 3912, 0), new Coordinate(2112, 3907, 0), new Coordinate(2112, 3902, 0), new Coordinate(2112, 3897, 0), new Coordinate(2112, 3892, 0), new Coordinate(2113, 3887, 0), new Coordinate(2117, 3883, 0), new Coordinate(2118, 3878, 0), new Coordinate(2122, 3875, 0), new Coordinate(2126, 3872, 0), new Coordinate(2130, 3869, 0), new Coordinate(2134, 3866, 0), new Coordinate(2135, 3861, 0), new Coordinate(2140, 3860, 0), new Coordinate(2145, 3861, 0), new Coordinate(2150, 3863, 0), new Coordinate(2155, 3864, 0));

    path.step();


    }

    But whenever i use this in my mainloop it starts walking, and then instantly starts doing the next thing in the loop, in this case bankWithdraw.

    public class Astrals extends LoopingScript {
    @Overridepublic void onLoop() {
    bankWithdraw();
    walkToPoint();
    //Note that i've left out some methods
    }
     
  2. Natfoth

    Joined:
    Jul 17, 2015
    Messages:
    25
    Likes Received:
    3
    Doing path.step() will only step once which is why it is a step. So you need to keep calling it over and over until you have reached where you actually want to walk to which is the bank. So you need a range check.
     
  3. Sweden

    Joined:
    Jul 20, 2015
    Messages:
    27
    Likes Received:
    4
    Any effective method of doing so? perhaps a while loop?
     
  4. Ozzy

    Joined:
    Nov 5, 2014
    Messages:
    504
    Likes Received:
    159
    You need to adjust your logic so that pathing/banking are only called when they are necessary instead of procedurally every time, .step() will then be called again and will step onto the next tile in your path.

    Something like this (I've left out generating the path and null checking everything, you'd need to do that too):

    Code (Text):
    1. Area targetArea = null; // you would define the area
    2.  
    3. if (targetArea.contains(Players.getLocal()) {
    4.      // we are in the area, call banking
    5. } else {
    6.     // we need to path to the area
    7.     path.step(true); // pass true so the path clicks are managed for you
    8. }
     
  5. Sweden

    Joined:
    Jul 20, 2015
    Messages:
    27
    Likes Received:
    4
    Thanks! I've created an area with areamaker, but i get "Cannot resolve symbol Circular"
     
  6. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    2,964
    Likes Received:
    871
    Area.Circular
     

Share This Page

Loading...