Jump to content

Help on gettting Widget Text (Solved)


Ex0rcism

Recommended Posts

I'm trying to develop my own mining script for motherlode mine, I need to verify how many Pay-dirt the player has in the sack before moving on to the next step.

Does anyone have a solution on retrieving a widget text and returning it as an int?

vBJbiwi.png

Note: I Have censored this heavily because I'm using my main, I don't need Jagex banning my account just by using a 3rd party client or for writing a script. All surrounding players have been censored too just in case they are a bot or Jagex staff. All the information you need is in the picture without any of my personal account details.

 

*UPDATE*:

I have managed to figure it out thanks for the help anyways.

sackValue = Integer.parseInt(getWidgets().get(382, 4, 2).getMessage());

Please close thread.

Edited by Ex0rcism
Figured it out on my own. Thanks to bot's API
Link to comment
Share on other sites

  • Ex0rcism changed the title to Help on gettting Widget Text (Solved)
17 minutes ago, Malcolm said:

Although you can get away with using child widgets I would suggest finding another way to do this without using child widgets.

Jagex change these widgets and if they do that your script will break.

You could look into sprites and even colors and find which index the widget you're looking for is at.

Sprite Ids don't change? Wonder how this could be achieved, because you're right I don't want to keep updating the script every Thursday lol.

Link to comment
Share on other sites

So this should be efficient enough to use:

private int getSackWidgetRootId() {
	RS2Widget sackWidgetRoot = getWidgets().singleFilter(getWidgets().getAll(), w -> w.getSpriteIndex2() == -1 && w.getHeight() == 68 && w.getWidth() == 68);

	if (sackWidgetRoot != null) {
		return sackWidgetRoot.getRootId();
	}
  
	return -1;
}
	
private int getSackValue() {
	List<RS2Widget> sackWidget = getWidgets().matchingTextColour(getSackWidgetRootId(), 13158600);

	if (sackWidget != null) {
		RS2Widget messageWidget = sackWidget.get(0);
		return Integer.parseInt(messageWidget.getMessage());
	}

	return -1;
}

 

Thank you @Malcolm and @MasterOfData for all the help I needed to achieve this!

Topic can now be closed.

Edited by Ex0rcism
  • Like 1
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...