WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Raid target in strings (https://www.wowinterface.com/forums/showthread.php?t=58064)

Walkerbo 06-22-20 06:12 PM

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.

Seerah 06-22-20 06:25 PM

You have to use the escape sequence to put the texture in the string, I believe.
https://wow.gamepedia.com/UI_escape_sequences

DahkCeles 06-22-20 10:16 PM

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

Ketho 06-22-20 11:03 PM

Quote:

Originally Posted by Walkerbo (Post 336208)
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()

Seerah 06-23-20 06:17 PM

Quote:

Originally Posted by Ketho (Post 336211)
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. :rolleyes:

SDPhantom 06-23-20 09:02 PM

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

Walkerbo 06-23-20 10:06 PM

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.

Kanegasi 06-23-20 10:16 PM

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

SDPhantom 06-23-20 10:53 PM

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

Walkerbo 06-24-20 09:11 PM

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.

Kanegasi 06-24-20 10:57 PM

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)

Walkerbo 06-25-20 01:47 AM

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?

Ketho 06-25-20 07:13 AM

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

DahkCeles 06-25-20 09:32 AM

Just imagining it makes me shudder...

:D:):confused::o Did :confused: someone :mad: say [Thunderfury, Blessed Blade of the Windseeker]:D?:):confused::confused:

Just replace smilies with raid markers. Yikes!

Walkerbo 06-25-20 06:49 PM

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 :)

Seerah 06-25-20 08:06 PM

You can send them to chat. Just not trade or general. Did you test it in a whisper to yourself?

Walkerbo 06-25-20 09:42 PM

Hi Seerah

Yes, when I send to whisper it works.

Once again thanks for the help.:)


All times are GMT -6. The time now is 02:41 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI