Jump to content

Detect webWalk fail


feggit

Recommended Posts

I'm trying store a boolean whether webwalk can find a route. I'm doing this right now:

boolean a = getWalking().webWalk(some area);

But it gets stuck for a while, maybe 1 minute before the script continues, even though the console already said that no route is found the moment the line is read. Is there some way to fix this, or some other way to see if there is a route?

 

EDIT: That would be:

getMap().realDistance(some position/entity) == -1

 

Edited by feggit
found the answer
Link to comment
Share on other sites

Have you tried using a WebWalkingEvent?

Haven't tested this code but off the top of my head you may be able to do something like this:

WebWalkingEvent walkToDestination = new WebWalkingEvent(area);
Event event = execute(walkToDestination);
if (event.hasFailed()) {
	// Event failed do something
}

 

Link to comment
Share on other sites

On 9/26/2018 at 3:51 PM, FrostBug said:

Sure you aren't manually sleeping that minute somewhere? Or returning it from onLoop?

Yes I am sure, because immediately the next line I am printing the boolean and it took a very look time. Don't know why but it works now without any delay.

 

On 9/26/2018 at 10:45 AM, Ragnar Lothbrok said:

Have you tried using a WebWalkingEvent?

Haven't tested this code but off the top of my head you may be able to do something like this:


WebWalkingEvent walkToDestination = new WebWalkingEvent(area);
Event event = execute(walkToDestination);
if (event.hasFailed()) {
	// Event failed do something
}

 

I tried after this suggestion but it didn't work. It turns out that it is WebWalkEvent instead of WebWalkingEvent XD

But it worked after I used the correct class name, so thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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