Jump to content

How to pull the value from a field taken from a third level widget?


Recommended Posts

Posted

I'm currently trying to get and print out a widget name from a third-level widget.

For example, I want to get the player name from the widget for a player added to my friend list (let's say this widget address is 432, 6, 1).

I can get the first, second, and third level ID's printed out (432, 6, 1) but that's not what I want. I want the actual player name to be what is returned. The field for the widget query that contains the player name is "Message". Alternatively, the field "Spell Name" also lists the player name for this third-level widget.

Anyone have any idea how to do this or a snippet of code that might work/has worked?

 

Posted
6 minutes ago, nosepicker said:

If I understood correctly, you want something like this?


RS2Widget widget = widgets.get(432, 6, 1);
	if (widget != null && widget.isVisible())
		String playerName = widget.getSpellName();

 

I should have thought of that. Thanks for saving me 2 hours of frustration.

This works perfectly, except I get the junk that is included (for the text color?) that is also included in the Spell Name. This may be a stupid question, but anyway to trim the output?

For example, when I tried it on my friend list widget for "SparcMac" it returned "<col=ff9040>SparcMac</col>"

Posted
2 minutes ago, moeotterson said:

I should have thought of that. Thanks for saving me 2 hours of frustration.

This works perfectly, except I get the junk that is included (for the text color?) that is also included in the Spell Name. This may be a stupid question, but anyway to trim the output?

For example, when I tried it on my friend list widget for "SparcMac" it returned "<col=ff9040>SparcMac</col>"

Either use regex "<.*?\\>"  or osbots #stripFormatting(String) method to remove the color tags

Posted
5 minutes ago, moeotterson said:

I should have thought of that. Thanks for saving me 2 hours of frustration.

This works perfectly, except I get the junk that is included (for the text color?) that is also included in the Spell Name. This may be a stupid question, but anyway to trim the output?

For example, when I tried it on my friend list widget for "SparcMac" it returned "<col=ff9040>SparcMac</col>"

stringName.replaceAll("[^a-zA-Z0-9]","")

Just now, Vilius said:

Either use regex "<.*?\\>"  or osbots #stripFormatting(String) method to remove the color tags

or that :boge: 

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