View Single Post
04-16-11, 03:39 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by Vladinator View Post
Code:
local orig = SendChatMessage
function SendChatMessage(text, chan, ...)
  if chan ~= "EMOTE" then
    local emote = text:match("*(.+)*")
    if emote then
      text = text:gsub("*(.+)*", "")
      orig(text, chan, ...)
      return DoEmote(emote)
    end
  end
  return orig(text, chan, ...)
end
There's a couple errors in the pattern. The asterisk is a magic character that needs to be escaped. Also, you need the capture to match as little as possible so it doesn't try to overflow outside the terminating asterisk if another one exists in the message or multiple emotes are in the message. You should use either "%*([^%*]-)%*" or "%*(.-)%*".
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote