Thread Tools Display Modes
06-22-20, 06:12 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Raid target in strings

Hi all

I am the author of a small addon Swarm.

I am looking for help in how to use the wow api to insert a target marker icon into a chat string; eg
Lua Code:
  1. SendChatMessage(({skull}.."Hello World"), 'CHANNEL', nil, 1)

I can do it easily in a macro but have yet to crack doing the same within my addon.

I have worked out how to add a texture to a frame or button but not how to add a raid target icon to a string.

Any help with this would be great.
  Reply With Quote
06-22-20, 06:25 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You have to use the escape sequence to put the texture in the string, I believe.
https://wow.gamepedia.com/UI_escape_sequences
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-22-20, 10:16 PM   #3
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
Adding on to what Seerah said:

The |T ... |t format is already partly populated in a table called ICON_LIST, so you can do something like this:

Lua Code:
  1. SendChatMessage(ICON_LIST[1].."0|t".."Hello World"), 'CHANNEL', nil, 1)


Source: https://authors.curseforge.com/forum...chat?comment=4
  Reply With Quote
06-22-20, 11:03 PM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Walkerbo View Post
how to use the wow api to insert a target marker icon into a chat string

What do you mean? You can just put {skull} or {rt8} (locale-independent) in your string
Lua Code:
  1. SendChatMessage("{skull} Hello World")
Unless you actually want to print() it instead of SendChatMessage()
  Reply With Quote
06-23-20, 06:17 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Ketho View Post
What do you mean? You can just put {skull} or {rt8} (locale-independent) in your string
Lua Code:
  1. SendChatMessage("{skull} Hello World")
Unless you actually want to print() it instead of SendChatMessage()
That's what I was thinking, but I assumed maybe they had tried that already.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-23-20, 09:02 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
FYI: The server won't let you send the |T escape sequence. The only escape codes that can be sent are valid links (must include color code too).
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-23-20, 10:06 PM   #7
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi all.

Thanks for your suggestions, I still have not been able to make it work but I have not given up just yet.
The print solution only prints it into my chat, it does not broadcast it to general.

From reading the escape sequences page it seems it should be as easy as
Lua Code:
  1. local chatString =  ("\124TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8.png:0\124t")
  2. SendChatMessage(chatString, 'CHANNEL', nil, 1)
However when I run it in game I keep getting the following error
Lua Code:
  1. 1x SendChatMessage(): Invalid escape code in chat message
  2. [string "=[C]"]: ?
  3. [string "=[C]"]: in function `SendChatMessage'
  4. [string "@Swarm\Swarm-SR 2.7.8.32.lua"]:208: in function <Swarm\Swarm.lua:199>
  5. [string "@Swarm\Swarm-SR 2.7.8.32.lua"]:267: in function `func'
  6. [string "@FrameXML\UIDropDownMenu.lua"]:895: in function `UIDropDownMenuButton_OnClick'
  7. [string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>
  8.  
  9. Locals:
  10. (*temporary) = "|TTargetingFrame\UI-RaidTargetingIcon_8.png:0|t"
  11. (*temporary) = "CHANNEL"
  12. (*temporary) = nil
  13. (*temporary) = "1"

I tried a number combinations yet each time I got the same Invalid escape code in chat message error

I also tried just using the naked {rt8}
Lua Code:
  1. local chatString =  ({rt8})
  2. SendChatMessage(chatString, 'CHANNEL', nil, 1)
When I run this I get the following error
Lua Code:
  1. 1x Usage: SendChatMessage(text [,type] [,language] [,targetPlayer])
  2. [string "=[C]"]: ?
  3. [string "=[C]"]: in function `SendChatMessage'
  4. [string "@Swarm\Swarm-SR 2.7.8.32.lua"]:208: in function <Swarm\Swarm.lua:199>
  5. [string "@Swarm\Swarm-SR 2.7.8.32.lua"]:267: in function `func'
  6. [string "@FrameXML\UIDropDownMenu.lua"]:895: in function `UIDropDownMenuButton_OnClick'
  7. [string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>
  8.  
  9. Locals:
  10. (*temporary) = <table> {
  11. }
  12. (*temporary) = "CHANNEL"
  13. (*temporary) = nil
  14. (*temporary) = 1
So I am still stumped.

Any further help or suggestions would be greatly appreciated.
  Reply With Quote
06-23-20, 10:16 PM   #8
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
{rt8} is not a string, it is a table. You need to surround it with quotes to make it a string.

Lua Code:
  1. local chatString =  "{rt8}"
  Reply With Quote
06-23-20, 10:53 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,308
You send the string "{rt8}" and the client on the receiving end converts it into the appropriate texture. In Classic, this is done by ChatFrame_ReplaceIconAndGroupExpressions(). In Modern, this was moved into C code and is handled by C_ChatInfo.ReplaceIconAndGroupExpressions().

Here's a list of these icon tags.
https://wow.gamepedia.com/Chat_substitutions
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-24-20, 09:11 PM   #10
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi All

Thanks for the further help, however, I am still stuck.

Kusya12 your comment indicates that you did manage to send an icon to general chat; how did you get it to work?

I have tried all of the following statements without success,
Lua Code:
  1. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions({rt8})
  2. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("{rt8}")
  3. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("\124{rt8}\124")
  4.  
  5. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions(Interface\\TargetingFrame\\UI-RaidTargetingIcon_8.png)
  6. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("Interface\\TargetingFrame\\UI-RaidTargetingIcon_8.png")
  7. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("\124Interface\\TargetingFrame\\UI-RaidTargetingIcon_8.png\124")
  8.  
  9. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions(Interface\\TargetingFrame\\UI-RaidTargetingIcon_8)
  10. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("Interface\\TargetingFrame\\UI-RaidTargetingIcon_8")
  11. local chatString = C_ChatInfo.ReplaceIconAndGroupExpressions("\124Interface\\TargetingFrame\\UI-RaidTargetingIcon_8\124")
I am just not making the connection, and it is probably just a simple mistake that is confounding me.

Any further help and advice would be great.
  Reply With Quote
06-24-20, 10:57 PM   #11
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
The functions that SDPhantom mentioned aren't functions you use, they are what transform the special {} strings into icons in clients that receive your message.

All you need to send a raid icon in chat is a certain string, no functions or anything special. Copy any of these and use them directly in your chat with nothing else to test them out:

Code:
{rt1}
{star}
{gold}
{rt2}
{circle}
{orange}
{rt3}
{diamond}
{purple}
{rt4}
{triangle}
{green}
{rt5}
{moon}
{silver}
{rt6}
{square}
{blue}
{rt7}
{cross}
{x}
{red}
{rt8}
{skull}
{white}
The following function call will send Hello World surrounded by skulls into the general channel:

Lua Code:
  1. SendChatMessage("{rt8} Hello {skull} World {white}", "CHANNEL", nil, 1)
  Reply With Quote
06-25-20, 01:47 AM   #12
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Kanegasi

Your solution did not work for me, all it did was print the string itself.
Lua Code:
  1. SendChatMessage("{rt8} Hello {skull} World {white}", "CHANNEL", nil, 1)
results in



Did you get it working in-game?
  Reply With Quote
06-25-20, 07:13 AM   #13
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Apparently the 17th payload value supressRaidIcons of CHAT_MSG_CHANNEL is true for General and Trade
So raid target icons will not be shown there. Which is good actually
  Reply With Quote
06-25-20, 09:32 AM   #14
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
Just imagining it makes me shudder...

Did someone say [Thunderfury, Blessed Blade of the Windseeker]?

Just replace smilies with raid markers. Yikes!
  Reply With Quote
06-25-20, 06:49 PM   #15
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Ketho

I see, that is why I couldn't get it working; thanks for letting me know, at least I now know I wasn't totally stupid

The answer is not the one I would like but now I know for sure; and I can see how it is probably a good thing that we cannot send icons to chat, as DahkCeles proves.

Thanks to everyone for the help and suggestions.

I love this forum; as a self-taught noob I really appreciate the great help and explanations.

Cheers all

Last edited by Walkerbo : 06-25-20 at 06:53 PM.
  Reply With Quote
06-25-20, 08:06 PM   #16
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can send them to chat. Just not trade or general. Did you test it in a whisper to yourself?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-25-20, 09:42 PM   #17
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Seerah

Yes, when I send to whisper it works.

Once again thanks for the help.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Raid target in strings

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off