Quantcast
Making prettier chat messages - WoWInterface
 
Thread Tools Display Modes
07-26-09, 05:07 AM   #1
Hat
A Defias Bandit
Join Date: Apr 2006
Posts: 2
Making prettier chat messages

My guild uses its own points system to allocate loot, and I'm in the process of writing a web-based system to manage it. One of the features of that system is going to be an addon in-game to report the number of points someone has when they roll. I have a couple of questions about this:

1) Is there a way to gag or append to a chat message that's coming in? I can use CHAT_MSG_SYSTEM and DEFAULT_CHAT_FRAME:AddMessage() to add another line, but I'd really like it to say "Joe rolls 15 (1-100) (15 points)" to save some space.

2) Is there a way to set the chat colour for individual parts of a message? It'd be nice if I could colour, say, the points value differently to the rest of the text.

Thanks in advance for your help
  Reply With Quote
07-26-09, 05:19 AM   #2
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by Hat View Post
My guild uses its own points system to allocate loot, and I'm in the process of writing a web-based system to manage it. One of the features of that system is going to be an addon in-game to report the number of points someone has when they roll. I have a couple of questions about this:

1) Is there a way to gag or append to a chat message that's coming in? I can use CHAT_MSG_SYSTEM and DEFAULT_CHAT_FRAME:AddMessage() to add another line, but I'd really like it to say "Joe rolls 15 (1-100) (15 points)" to save some space.

2) Is there a way to set the chat colour for individual parts of a message? It'd be nice if I could colour, say, the points value differently to the rest of the text.

Thanks in advance for your help
The normal clean way to alter a chat message is using http://wowprogramming.com/docs/api/C...ageEventFilter. I'm not sure if there's a CHAT_MSG_* event for rolls though.

You can change the color of text in local messages, but you cannot change the color of text in a chat channel. This limitation shouldn't be a problem if you're trying to alter the message locally anyway. You do it with color escape codes.

print("|cAARRGGBBText|r")

A = Alpha, R = Red, G = Green, B = Blue hex values.

print("|cffFF0000This text is red|r This text is white |cff00FF00This text is green|r |cff0000FFThis text is blue|r")
  Reply With Quote
07-26-09, 05:44 AM   #3
Hat
A Defias Bandit
Join Date: Apr 2006
Posts: 2
Thanks for that pointer on chat filters, that's very useful. It's CHAT_MSG_SYSTEM for rolls btw.

But I can't get your examples of changing chat colours to work in-game. If I enter /script print("|cffFF0000This text is red|r This text is white |cff00FF00This text is green|r |cff0000FFThis text is blue|r") into a chat window, the colour codes aren't removed, they're printed verbatim.
  Reply With Quote
07-26-09, 06:12 AM   #4
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
Originally Posted by Hat View Post
Thanks for that pointer on chat filters, that's very useful. It's CHAT_MSG_SYSTEM for rolls btw.

But I can't get your examples of changing chat colours to work in-game. If I enter /script print("|cffFF0000This text is red|r This text is white |cff00FF00This text is green|r |cff0000FFThis text is blue|r") into a chat window, the colour codes aren't removed, they're printed verbatim.
The chat system doesn't interpret the pipe character | correctly. If you're doing this via an editbox in game, you have to use \124 which is the escape code for said character.

print("\124cffFF0000This text is red\124r")

The pipe character will work correctly when used in an addon's lua file, though.
  Reply With Quote
07-26-09, 06:18 AM   #5
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Hat View Post
Thanks for that pointer on chat filters, that's very useful. It's CHAT_MSG_SYSTEM for rolls btw.

But I can't get your examples of changing chat colours to work in-game. If I enter /script print("|cffFF0000This text is red|r This text is white |cff00FF00This text is green|r |cff0000FFThis text is blue|r") into a chat window, the colour codes aren't removed, they're printed verbatim.
The default editbox escapes the pipe symbol by replacing "|" with "||".
  Reply With Quote
07-26-09, 06:51 AM   #6
shkm
A Chromatic Dragonspawn
 
shkm's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 186
Any chance you'll be releasing this system? I'd be interested in giving it a go if you are.
__________________
Quit WoW again on 17/04/2014.
  Reply With Quote
09-09-20, 10:28 AM   #7
blocker147
A Deviate Faerie Dragon
Join Date: Apr 2020
Posts: 12
Code:
colors = {
	{
		title = 'LIGHTBLUE',
		color = 'cff00ccff',
	},
	{
		title = 'LIGHTRED',
		color = 'cffff6060',
	},
	{
		title = 'SPRINGGREEN',
		color = 'cff00FF7F',
	},
	{
		title = 'GREENYELLOW',
		color = 'cffADFF2F',
	},
	{
		title = 'BLUE',
		color = 'cff0000ff',
	},
	{
		title = 'PURPLE',
		color = 'cffDA70D6',
	},
	{
		title = 'GREEN',
		color = 'cff00ff00',
	},
	{
		title = 'RED',
		color = 'cffff0000',
	},
	{
		title = 'GOLD',
		color = 'cffffcc00',
	},
	{
		title = 'GOLD2',
		color = 'cffFFC125',
	},
	{
		title = 'GREY',
		color = 'cff888888',
	},
	{
		title = 'WHITE',
		color = 'cffffffff',
	},
	{
		title = 'SUBWHITE',
		color = 'cffbbbbbb',
	},
	{
		title = 'MAGENTA',
		color = 'cffff00ff',
	},
	{
		title = 'YELLOW',
		color = 'cffffff00',
	},
	{
		title = 'ORANGEY',
		color = 'cffFF4500',
	},
	{
		title = 'CHOCOLATE',
		color = 'cffCD661D',
	},
	{
		title = 'CYAN',
		color = 'cff00ffff',
	},
	{
		title = 'IVORY',
		color = 'cff8B8B83',
	},
	{
		title = 'LIGHTYELLOW',
		color = 'cffFFFFE0',
	},
	{
		title = 'SEXGREEN',
		color = 'cff71C671',
	},
	{
		title = 'SEXTEAL',
		color = 'cff388E8E',
	},
	{
		title = 'SEXPINK',
		color = 'cffC67171',
	},
	{
		title = 'SEXBLUE',
		color = 'cff00E5EE',
	},
	{
		title = 'SEXHOTPINK',
		color = 'cffFF6EB4'
	},
}
function printColors()
	--print("\124cffFF0000This text is red\124r") --This is red color
	local startLine = '\124'
	local endLine = '\124r'
	for i = 1, table.getn(colors) do
		print(startLine .. colors[i].color .. colors[i].title .. endLine)
	end
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Making prettier chat messages

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