1. #1
    The Patient Buttonmasher's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    Seattle, the land where we have good internet.
    Posts
    278

    Is there a way to get the values of a chat channel colour?

    For example, I want to get the colour of the Creature Whisper for an addon I'm making so that if the player ever changes the colour, the addon changes with it rather than being a standard set in stone colour. At the moment all I have is
    Code:
    print("|cFFF8B0DENPC Whispers...")
    etc.

    I'd rather be using something that utilises it in such a way that the colour will dynamically change with the NPC whisper colour.

    Last edited by Buttonmasher; 2017-01-29 at 09:53 AM.

  2. #2
    Please wait Temp name's Avatar
    10+ Year Old Account
    Join Date
    Mar 2012
    Location
    Under construction
    Posts
    14,631
    You can just get the colour from the picture you just took using a photo manipulation program like Gimp. Paint might have something like it too, but I'm not sure

  3. #3
    The Patient Buttonmasher's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    Seattle, the land where we have good internet.
    Posts
    278
    Quote Originally Posted by Mehman View Post
    You can just get the colour from the picture you just took using a photo manipulation program like Gimp. Paint might have something like it too, but I'm not sure
    That's not what I'm talking about, though. I'm talking about say grabbing the chat colour through a function (something like GetChatColor()) but that doesn't exist as a function.

    I know the ID of the channel (16) and the Event name (MONSTER_WHISPER) but I can't find a function to grab the chat colour if the player sets it to a new colour. I want my addon's messages to update dynamically with the colour set to this specific chat colour so that they're always the same.

  4. #4
    https://mods.curse.com/addons/wow/colorpickerplus


    might help, or any of the other color addons, once you click the color on specific channel it should open window with the current value.

    might be able to grab the code from that.
    "The speed of light is faster than the speed of sound.
    That's why so many people look smart until they start talking."

    FC-0404-6893-4293 Fire safari Larvesta/Growlithe/Braixen IGN: X Archimand, Y Shina.

  5. #5
    The Patient Buttonmasher's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    Seattle, the land where we have good internet.
    Posts
    278
    I actually have that installed, didn't think of seeing how it grabs the colour though.

    - - - Updated - - -

    Quote Originally Posted by Archimand View Post
    https://mods.curse.com/addons/wow/colorpickerplus


    might help, or any of the other color addons, once you click the color on specific channel it should open window with the current value.

    might be able to grab the code from that.
    It appears to be using this function here: https://wow.gamepedia.com/API_ColorSelect_GetColorRGB

    I'm unsure how I would get the colour specifically of the creature message chat though. I don't think it really even can, I think it's specifically from when the colour wheel is open.
    Last edited by Buttonmasher; 2017-01-29 at 10:45 AM. Reason: spelling

  6. #6
    This information is available in the global table ChatTypeInfo.

  7. #7
    The Patient Buttonmasher's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    Seattle, the land where we have good internet.
    Posts
    278
    Quote Originally Posted by quthar View Post
    This information is available in the global table ChatTypeInfo.
    This doesn't appear to change anything of the table. If I'm reading this correctly, when the chat changes colour, the RGB values should change. However, the RGB values remain at 00 00 00 even after I change it.

  8. #8
    It's updating for me when I change colors in the chat settings.

    Note that this follows WoW's convention of representing RGB values as floating point numbers between 0 and 1. To get a hex representation you need to do something like this
    Code:
    ("ff%.2x%.2x%.2x"):format(ChatTypeInfo["MONSTER_WHISPER"].r * 255, ChatTypeInfo["MONSTER_WHISPER"].g * 255, ChatTypeInfo["MONSTER_WHISPER"].b * 255)

  9. #9
    Deleted
    I would personally not use print for something like this:

    Code:
    local msg = "lörs lärä"
    local sender = "Kalolt"
    local info = ChatTypeInfo["MONSTER_WHISPER"]
    local body = CHAT_WHISPER_GET:format(sender) .. msg
    DEFAULT_CHAT_FRAME:AddMessage(body, info.r, info.g, info.b, info.id)
    CHAT_WHISPER_GET should be localized version of "%s whispers: ".

    The info.id part makes it so that the color updates dynamically when you change the color of the message type, so even already sent messages will always be the right color.

    I suggest always taking a look at how the default UI does things. Either extract the interface code yourself or check this for example:
    https://github.com/Gethe/wow-ui-source

    In this particular case I took a look at FrameXML\ChatFrame.lua, and searched for things like "whisper" and "addmessage".

  10. #10
    Quote Originally Posted by Kalolt View Post
    I suggest always taking a look at how the default UI does things. Either extract the interface code yourself or check this for example:
    https://github.com/Gethe/wow-ui-source
    Instructions on how to extract Blizzard's UI and how to enable console.

    Also, I personally use Townlong-Yak's code browser for new stuff. They extract PTR as it becomes available.
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  11. #11
    The Patient Buttonmasher's Avatar
    10+ Year Old Account
    Join Date
    May 2013
    Location
    Seattle, the land where we have good internet.
    Posts
    278
    Thank you for the replies. I got exactly what I needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •