Jump to content

The LocalWalker changed


Recommended Posts

Posted

Hi,

Had been gone for 2 yearsl lost my Scripter 2 status :( /  :p
I'm still rusty.

But okay so one of my script doesnt work anymore since the localwalker has changed I tried:
    private Position[] path1 = { new Position(random(3274, 3278), random(3176, 3178), 0 ) };
    to
    private List path1 = (random(3274, 3278), random(3176, 3178), 0 );

But i don't get how Lists, I think I'm doing something wrong, can somebody push me in the right directions.

 

Much Thanks...

Posted
1 hour ago, erenjwz said:

Hi,

Had been gone for 2 yearsl lost my Scripter 2 status :( /  :p
I'm still rusty.

But okay so one of my script doesnt work anymore since the localwalker has changed I tried:
    private Position[] path1 = { new Position(random(3274, 3278), random(3176, 3178), 0 ) };
    to
    private List path1 = (random(3274, 3278), random(3176, 3178), 0 );

But i don't get how Lists, I think I'm doing something wrong, can somebody push me in the right directions.

 

Much Thanks...

Well that's just a problem of using data structures in java, I don't think this is scripting related at all

https://www.tutorialspoint.com/java/java_data_structures.htm

Check out a few tutorials on java arrays, collections, (and streams for java 8/9) etc

https://www.tutorialspoint.com/java/java_arrays.htm

https://www.tutorialspoint.com/java/java_collections.htm

https://www.tutorialspoint.com/java8/java8_streams.htm

        // walk to some position, make sure the bot can reach that position
        // (loaded into the current region, no obstacles between
        // the bot and the destination, also check the Z coordinate because 
        // it used to not be taken into account and probably remained like this
        // for backwards compatibility)
        Position destination = new Position(someX, someY, someZ);
        if (myPosition().getZ() == destination.getZ() && getMap().canReach(destination)) {
            log(String.format("walking to %s: %b", destination, getWalking().walk(destination)));
        } else {
            // doge
        }

        // or if you want to walk a certain path, for cases where the end position may be too
        // far away to be loaded into the current region but you (assume) can 
        // reach it by advancing into the path
        Position[] path = {destination1, destination2, destination3, destination4};
        log(String.format("walking path %s: %b", Arrays.toString(path), getWalking().walkPath(Stream.of(path)
                .collect(Collectors.toList()))));

        // or just look up the LocalPathFinder in the API docs for lower level 
        // access to local region path finding 
        LocalPathFinder lpf = new LocalPathFinder(getBot());

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...