Jump to content

Widget not returning text


Chikan

Recommended Posts

Hey, so I'm trying to figure out how get a text value for this specific dialogue box.

895edea435a54d246d67f87ec07f4c6e.png

I've checked the widget debugger, and I've found

getWidgets().containingText(229, "You must ask the foreman's permisson before using the blast furnace") != null

This is what I can pull out of it, however when I go to try to use it

if (getWidgets().containingText(229, "You must ask the foreman's permisson before using the blast furnace") != null) {
	hasPayedForeman = false;
}

 

After this my script goes into the task to pay the foreman

 

NPC foreman = getNpcs().closest("Blast Furnace Foreman");
RS2Widget payWindow = c.getWidgets().get(219, 0, 0);
		
	if (payWindow == null) {
			foreman.interact("Pay");
			Timing.waitCondition(() -> getDialogues().inDialogue(), 3500, 1500);
			
	} else if (getDialogues().inDialogue()) {
			if (payWindow != null) {
				getDialogues().selectOption(1);
				hasPayedForeman = true;
			}	
		}		
	}

 

My problem is that it just loops between the two in I guess a kind of "spammy" fashion, instead of the boolean going to false while the widget is != null and then going back to true after the foreman is paid.

Link to comment
Share on other sites

getWidgets().containingText returns a List<RS2Widget>

You are checking that the result of getWidgets().containingText() is not null, however that will always be true, because containingText will never return a null List.

What you should be using instead is getWidgets().getWidgetContainingText() which returns an RS2Widget.

Link to comment
Share on other sites

Issue solved.

OP should have been using getWidgets().getWidgetContainingText not getWidgets().containingText

And also the message "You must ask the foreman's permisson before using the blast furnace" should contain a line break tag "<br>"

This line break tag is only visible if you look at the message in the widget debugger.

"You must ask the foreman's permisson before using the blast<br>furnace"

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

40 minutes ago, Explv said:

Issue solved.

OP should have been using getWidgets().getWidgetContainingText not getWidgets().containingText

And also the message "You must ask the foreman's permisson before using the blast furnace" should contain a line break tag "<br>"

This line break tag is only visible if you look at the message in the widget debugger.

"You must ask the foreman's permisson before using the blast<br>furnace"

Ty dad

59 minutes ago, Chris said:

Null check when you interact please.

>:c

  • Like 1
Link to comment
Share on other sites

  • Night locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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