Quantcast
How to get a channel chat color? - WoWInterface
Thread Tools Display Modes
05-26-20, 03:46 AM   #1
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
How to get a channel chat color?

Hello,

I found ChangeChatColor("channelname", red, green, blue) tu change a channel chat color, but I didn't find how to retreive a channel's color, something like:
Code:
r,g,b = GetChatColor("channelname")
Thank you.
  Reply With Quote
05-26-20, 04:07 AM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 932
You can use Chat_GetChannelColor()

For example
Code:
local r, g, b = Chat_GetChannelColor(ChatTypeInfo.CHANNEL1)
The colors themselves are received from the server in UPDATE_CHAT_COLOR
  Reply With Quote
05-26-20, 08:44 AM   #3
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
Well,
Code:
local r, g, b = Chat_GetChannelColor(ChatTypeInfo.CHANNEL1)
works, but I'm unable to know the name of indexed chans, aka "CHANNELX"

Besides, UPDATE_CHAT_COLOR only returns lots of nil values.

Any tips of how to get the RGB color of, for instance, "OFFICER" channel?
  Reply With Quote
05-26-20, 09:01 AM   #4
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 932
There is GetChannelName()

For Officer that would be this, it should be available after at least PLAYER_ENTERING_WORLD
Lua Code:
  1. local function OnEvent(self, event)
  2.     local info = ChatTypeInfo.OFFICER
  3.     print(info.r, info.g, info.b)
  4. end
  5.  
  6. local f = CreateFrame("Frame")
  7. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  8. f:SetScript("OnEvent", OnEvent)
or from UPDATE_CHAT_COLOR
Lua Code:
  1. local function OnEvent(self, event, name, r, g, b)
  2.     if name == "OFFICER" then
  3.         print(event, name, r, g, b)
  4.     end
  5. end
  6.  
  7. local f = CreateFrame("Frame")
  8. f:RegisterEvent("UPDATE_CHAT_COLOR")
  9. f:SetScript("OnEvent", OnEvent)
  Reply With Quote
05-26-20, 09:10 AM   #5
Zax
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 75
Great, just what I needed
Thank you very much Ketho!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to get a channel chat color?

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