Jump to content

Wilderness ditch, webwalk help


sonda

Recommended Posts

I know this has probably been talked about quite a bit, but i was unsuccessful in finding a relevant answer ( that worked for me ) 

 Here is what i currently have 

at the top of my onloop '

	if (widgets.get(475, 11) != null) {
				widgets.get(475, 11).interact();
				log("Crossing Wilderness Ditch");
				sleep(500);
				walking.webWalk(midgy);
				log("Resuming trek");
			}

 


			if (!Areal.contains(me) && inventory.getAmount(selectedFood) >= 4) {
				status = "Walking to place";
				log("Walking to Area");

				WebWalkEvent evt = new WebWalkEvent(midgy);
				evt.setBreakCondition(new Condition() {

					@Override
					public boolean evaluate() {
						return widgets.get(475, 11).isVisible();
					}
				});
				execute(evt);

			}

but It seems to not work, im sure its something i did , or didn't do correctly. Any help is appreciated. 

 

[ERROR][Bot #1][11/26 08:53:40 AM]: Error executing event : org.osbot.rs07.event.WebWalkEvent@2413fe0
java.lang.NullPointerException
	at thing.main$2.evaluate(main.java:210)
	at org.osbot.rs07.event.WebWalkEvent.execute(co:266)
	at org.osbot.rs07.event.EventExecutor$2.run(zj:212)
	at org.osbot.rs07.event.EventExecutor.execute(zj:22)
	at org.osbot.rs07.script.MethodProvider.execute(ql:744)
	at thing.main.onLoop(main.java:213)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(cg:72)
	at java.lang.Thread.run(Thread.java:748)

 

line 210 : 	return widgets.get(475, 11).isVisible();

line 213: 			execute(evt);

 

IF i manually click the ditch, it works great after.

I know i can walk TO the ditch, HANDLE the ditch, then WALK to my area, trying to avoid all that mess if possible.

Edited by sonda
Link to comment
Share on other sites

7 minutes ago, Explv said:

@sonda

In your break condition:


return widgets.get(475, 11).isVisible();

You need to make sure the widget returned by .get() is not null before calling isVisible. Otherwise an NPE will be thrown.

 

i just went ahead and changed it to !=null instead. and that seems to work, duh! thanks explv!

  It does seem to take a good 5-10 seconds to tackle this task however, is that normal?

Link to comment
Share on other sites

  if (s.getObjects().closest("Wilderness Ditch") != null) {
                    status = "Entering Wilderness.";
                    if (s.getWidgets().getWidgetContainingText("Enter Wilderness") != null && s.getWidgets().getWidgetContainingText("Enter Wilderness").isVisible()) {
                        s.getWidgets().getWidgetContainingText("Enter Wilderness").interact();
                        Sleep.sleepUntil(() -> WAIT_AREA.contains(s.myPlayer()), 5000);
                    } else {
                        RS2Object WildyDitch = s.getObjects().closest("Wilderness Ditch");
                        status = "Clicking Ditch.";
                        if (WildyDitch != null && WildyDitch.isVisible()) {
                            WildyDitch.interact("Cross");
                            Sleep.sleepUntil(() -> s.getWidgets().getWidgetContainingText("Enter Wilderness").isVisible(), 5000);
                        }
                    }

This is what I did in an old script of mine. I just broke the webwalkevent when the ditch was on screen, called this handleDitch method and then re-made a webwalkevent. I'd recommend checking the interact methods prior to sleeping though, I was obviously shitter than I am now when writing this script lmao.

Edited by HeyImJamie
  • Like 1
Link to comment
Share on other sites

27 minutes ago, sonda said:

No the widget clicking part is quick, its the clicking the ditch that takes a minute(gets to the ditch and waits), then a few seconds after crossing the ditch to resume walking (2-3 seconds here, not bad)

 

You could maybe try handling the ditch crossing yourself.

The delay before might be an issue where WebWalkEvent takes a while to break, i'm not really sure though.

Edited by Explv
  • Like 1
Link to comment
Share on other sites

2 hours ago, sonda said:

Alright, thank you. 

Btw , is this the proper method for handling something like this? First time running across an issue like this, could i use this going forward with other similar issues?

Pretty much yes, although with larger scripts simply putting it at the top of onLoop can cause issues. Break the webwalk event - handle whatever - continue on

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