WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to get a channel chat color? (https://www.wowinterface.com/forums/showthread.php?t=58028)

Zax 05-26-20 03:46 AM

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.

Ketho 05-26-20 04:07 AM

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

Zax 05-26-20 08:44 AM

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?

Ketho 05-26-20 09:01 AM

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)

Zax 05-26-20 09:10 AM

Great, just what I needed :)
Thank you very much Ketho!


All times are GMT -6. The time now is 02:22 PM.

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