Quantcast Transforming an existing addon - Page 3 - WoWInterface
Thread Tools Display Modes
10-08-11, 01:20 AM   #41
Dzib
A Deviate Faerie Dragon
Join Date: Nov 2010
Posts: 16
I've tried [7] but that does'nt work
  Reply With Quote
10-11-11, 01:49 PM   #42
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Numbered channels (including custom ones) are part of the "CHANNEL" chat type. You'd need to look at the fourth argument to SendChatMessage (the actual channel, by number, for "CHANNEL" messages, or the recipient's name for "WHISPER" messages) in addition to the second one (the chat type). Your current code mistakenly names the second argument "channel"; you should always check the API documentation and try to stick with the "official" argument names, to avoid confusion.

Lua Code:
  1. local chatTypesToProcess = {
  2.     ["GUILD"] = true,
  3.     ["SAY"] = true,
  4.     ["YELL"] = true,
  5.     ["CHANNEL"] = true,
  6. }
  7.  
  8. local channelsToProcess = {
  9.     ["RP"] = true,
  10. }
  11.  
  12. local old = SendChatMessage
  13.  
  14. SendChatMessage = function(message, chatType, language, channel)
  15.     if chatType and chatTypesToProcess[chatType] and message:len() > 0 and not message:match("^[%(*/]") then
  16.         if chatType == "CHANNEL" then
  17.             -- Get the channel's name from its number. We don't want to
  18.             -- use channel numbers in the list, because they can change.
  19.             local _, channelName = GetChannelName(channel)
  20.             if channelName and channelsToProcess[channelName:upper()] then
  21.                 -- We need to uppercase the channel's name, because the
  22.                 -- capitalization can change too.
  23.                 message = message:gsub("r", "rr"):gsub("rrrr", "rr"):gsub("R", "RR"):gsub("RRRR", "RR")
  24.             end
  25.         else
  26.             message = message:gsub("r", "rr"):gsub("rrrr", "rr"):gsub("R", "RR"):gsub("RRRR", "RR")
  27.         end
  28.     end
  29.     old(message, chatType, language, channel)
  30. end

See also:
http://www.wowpedia.org/API_SendChatMessage
http://www.wowpedia.org/API_GetChannelName

Last edited by Phanx : 10-11-11 at 01:57 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Transforming an existing addon

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