Jump to content

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


moeotterson

Recommended Posts

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?

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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: 

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