moeotterson Posted January 6, 2018 Share Posted January 6, 2018 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? Quote Link to comment Share on other sites More sharing options...
Butters Posted January 6, 2018 Share Posted January 6, 2018 (edited) 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(); Edit: Or just use widget.getMessage(); instead of getSpellname(); Edited January 6, 2018 by nosepicker Quote Link to comment Share on other sites More sharing options...
moeotterson Posted January 6, 2018 Author Share Posted January 6, 2018 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>" Quote Link to comment Share on other sites More sharing options...
Vilius Posted January 6, 2018 Share Posted January 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted January 6, 2018 Share Posted January 6, 2018 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 Quote Link to comment Share on other sites More sharing options...
moeotterson Posted January 6, 2018 Author Share Posted January 6, 2018 (edited) Edit: Nevermind, got it working. Many thanks, Computron Sensei. Edited January 6, 2018 by moeotterson Quote Link to comment Share on other sites More sharing options...
Antonio Kala Posted January 8, 2018 Share Posted January 8, 2018 On 1/6/2018 at 3:35 PM, moeotterson said: Edit: Nevermind, got it working. Many thanks, Computron Sensei. Could you write your solution on the thread for the rest of us when we have the same question :). Quote Link to comment Share on other sites More sharing options...
moeotterson Posted January 8, 2018 Author Share Posted January 8, 2018 String y = widget.getSpellName(); String x = stripFormatting(y); Quote Link to comment Share on other sites More sharing options...
H0rn Posted January 10, 2018 Share Posted January 10, 2018 On 1/8/2018 at 11:30 PM, moeotterson said: String y = widget.getSpellName(); String x = stripFormatting(y); String y = stripFormatting(widget.getSpellName()); 1 Quote Link to comment Share on other sites More sharing options...