Jump to content

Help on gettting Widget Text (Solved)


Recommended Posts

Posted (edited)

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
  • Ex0rcism changed the title to Help on gettting Widget Text (Solved)
Posted
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.

Posted (edited)

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

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