Jump to content

WalkingEvent problem


Recommended Posts

Posted

Hello, I'm rewriting my script because I'm using too much WebWalking.

WalkingEvent toEdgeBank = new WalkingEvent(edgeBank);
                        toEdgeBank.setOperateCamera(true);
                        toEdgeBank.setEnergyThreshold(50);
                        toEdgeBank.setBreakCondition(new Condition() {
                            @Override
                            public boolean evaluate() {
                                return edgeBank.getRandomPosition().distance(myPlayer()) <= 6;
                            }
                        }).execute();

This is throwing a NullPointer and I have no idea why.

Posted (edited)

Does "edgeBank" exist?

 

Have you set the Position before running the execute?

Area edgeBank = Banks.EDGEVILLE;

Thats what I have as a variable for edgeBank

do script.execute(event) , not event.execute()

 

That's what I tried before posting this. Still didn't work :s

Edited by GaetanoH
Posted (edited)

When I'm testing it, it seems that it never gets to setting the condition... Anyone an idea how that comes?

 

Depends what your code looks like now.

 

In the OP, the snippet posted would throw an nullpointer exception on setting the condition, because of the appended '.execute()'. calling execute on an event always throws NPE, because it is for the EventExecutor's internal use (and the executor sets some vars on the event before calling it).

 

Removing that, there's no way the snippet in the OP can throw an NPE, unless the area is null.

Edited by FrostBug
Posted

Depends what your code looks like now.

 

In the OP, the snippet posted would throw an nullpointer exception on setting the condition, because of the appended '.execute()'. calling execute on an event always throws NPE, because it is for the EventExecutor's internal use (and the executor sets some vars on the event before calling it).

 

Removing that, there's no way the snippet in the OP can throw an NPE, unless the area is null.

 

Walking to the fishing spot works now, however walking back to the bank doesn't.

 WalkingEvent toEdgeBank = new WalkingEvent(Banks.EDGEVILLE);
                        toEdgeBank.setOperateCamera(true);
                        toEdgeBank.setEnergyThreshold(50);
                        toEdgeBank.setBreakCondition(new Condition() {
                            @Override
                            public boolean evaluate() {
                                return Banks.EDGEVILLE.getRandomPosition().distance(myPlayer()) <= 6;
                            }
                        });
                        getBot().getEventExecutor().execute(toEdgeBank);
Posted (edited)

 

Walking to the fishing spot works now, however walking back to the bank doesn't.

 WalkingEvent toEdgeBank = new WalkingEvent(Banks.EDGEVILLE);
                        toEdgeBank.setOperateCamera(true);
                        toEdgeBank.setEnergyThreshold(50);
                        toEdgeBank.setBreakCondition(new Condition() {
                            @Override
                            public boolean evaluate() {
                                return Banks.EDGEVILLE.getRandomPosition().distance(myPlayer()) <= 6;
                            }
                        });
                        getBot().getEventExecutor().execute(toEdgeBank);

 

Nothing wrong with that code as far as I can tell. So it's probably not reached. Try logging

Also, in WalkingEvent you can use setMinDistanceThreshhold(6) instead of breaking at a radius of 6

 

Also, since this is the LocalWalker, make sure the position is actually loaded :E

Otherwise nothing's gonna happen.

Edited by FrostBug
Posted

Nothing wrong with that code as far as I can tell. So it's probably not reached. Try logging

Also, in WalkingEvent you can use setMinDistanceThreshhold(6) instead of breaking at a radius of 6

 

Also, since this is the LocalWalker, make sure the position is actually loaded :E

Otherwise nothing's gonna happen.

 

Removing the condition somehow got it working. Gonna try a few more times.

Nothing wrong with that code as far as I can tell. So it's probably not reached. Try logging

Also, in WalkingEvent you can use setMinDistanceThreshhold(6) instead of breaking at a radius of 6

 

Also, since this is the LocalWalker, make sure the position is actually loaded :E

Otherwise nothing's gonna happen.

 

What do you mean by loading the position?

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...