Thread Tools Display Modes
09-28-10, 07:12 AM   #1
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
ChangeChatColor()

Hi people!

I need a little help, I think this should be pretty easy and obvious, but well... I can't figure it out.

I want to change the color of the whisper, so that when I receive a whisper it will differentiate from the ones I send. This is something Blizzard had and somehow, dunno why took back from the default options.

The Whispers we receive are triggered by the event "CHAT_MSG_WHISPER" and the ones we send by "CHAT_MSG_WHISPER_INFORM".

By using the method ChangeChatColor() ingame it's easy to set the Color of the Message Type we want, the one I'm looking for is "WHISPER". Setting it this way contrary to what Blizzard Color picker does, only sets the color for "WHISPER" and not also for "WHISPER_INFORM".

My problem is somehow, dunno why, when using ChangeChatColor inside an addon, it just doesn't do nothing, no errors but no output either. Simply calling it ChangeChatColor("WHISPER", 1, 0, 0.45) inside a function and nothing.

What am I missing?

Thanks.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote
09-28-10, 07:25 AM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
You might need a function.

Like

Code:
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function()
	ChangeChatColor("WHISPER", 1, 0, 0.45)
end)
f:RegisterEvent("eventwhichiscalledwhenyousendorgetawhisper")
  Reply With Quote
09-28-10, 07:39 AM   #3
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
The thing is, I would be registering the color each time a whisper would come. What this method does is it changes the color one time per char and that's it. It would be more than enough to call this each time the plugin would be loaded, which is what I'm doing, but simply does nothing. But used inside the game with a /script ... it does change the font color of the whisper or any other message type if desired. :S

Well, anyway going to do it that way since I'm not seeing any other way. :P Thought it could be done without an event, but maybe not. Thanks mate.
__________________
My oUF Layout: oUF Lumen

Last edited by neverg : 09-28-10 at 07:44 AM.
  Reply With Quote
09-28-10, 07:58 AM   #4
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
It works with a /script? Then you probably simply need to delay the code. Try registering PLAYER_ENTERING_WORLD and see if it works.

Otherwise, do something like this:

Code:
local msg = "eventwhichiscalledwhenyousendorgetawhisper"
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(event)
	if event == msg then
		ChangeChatColor("WHISPER", 1, 0, 0.45)
		f:UnregisterEvent(msg)
	end
end)
f:RegisterEvent(msg)
  Reply With Quote
09-28-10, 08:07 AM   #5
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Originally Posted by Haleth View Post
It works with a /script? Then you probably simply need to delay the code. Try registering PLAYER_ENTERING_WORLD and see if it works.

Otherwise, do something like this:

Code:
local msg = "eventwhichiscalledwhenyousendorgetawhisper"
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(event)
	if event == msg then
		ChangeChatColor("WHISPER", 1, 0, 0.45)
		f:UnregisterEvent(msg)
	end
end)
f:RegisterEvent(msg)

Thanks mate. That is exactly what I did. With the Addon loaded event wasn't working but with player entering world it is, most probably a problem with a delay or something.

Thanks!
__________________
My oUF Layout: oUF Lumen

Last edited by neverg : 09-28-10 at 08:10 AM.
  Reply With Quote
09-28-10, 08:10 AM   #6
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Glad it works

If you want you can unregister it as well after the first call to avoid the function from being called when you go through a portal (though it's exactly a huge function).
  Reply With Quote
09-28-10, 09:26 AM   #7
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Ah, that is a nice idea. Anything that forces the game to load triggers Player_Entering_World I suppose?

Thanks Haleth for the help.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote
09-28-10, 12:04 PM   #8
Dainton
A Flamescale Wyrmkin
 
Dainton's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 115
Are the colors not saving between sessions? I just use a slash command to set my chat colors for new characters and I don't have any issues afterward.
Code:
SlashCmdList["SETCHAT"] = function()
    local chatColors = {
        CHANNEL1 = {1, 0.36078, 0.75686},
        CHANNEL2 = {0.57647, 0.79608, 1},
        CHANNEL3 = {1, 0.51372, 0.33725},
        CHANNEL4 = {1, 0.84314, 0.41176},
        CHANNEL5 = {0, 1, 0.95294},
        WHISPER = {0.92157, 0.26667, 1},
        WHISPER_INFORM = {0.81960, 0.44314, 1},
    }

    for k, v in pairs(chatColors) do
        ChangeChatColor(tostring(k), v[1], v[2], v[3])
    end
end
SLASH_SETCHAT1 = "/setchat"
  Reply With Quote
09-28-10, 12:17 PM   #9
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Yes Dainton they are saved between sessions. But this way I set it for all my chars using the same addon, just set it and forget it.

But that is another way to do it.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote
09-28-10, 02:06 PM   #10
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
you can edit your chat-cache.txt file, it has the color settings as well i do believe


inside chat-cache.txt

Code:
...
COLORS
...
WHISPER 255 128 255 N
WHISPER_FOREIGN 255 128 255 N
WHISPER_INFORM 255 128 255 N
...
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ChangeChatColor()


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