Originally Posted by SDPhantom
I put together some code to do exactly what was described. It only operates on /say and it will attempt to use the emote slash command if it finds one that matches, otherwise, it'll send the emote out through the emote channel. Theoreticly, the slash command emotes support a target argument that lets you specify what UnitID to target. This option has been added in to this code as well.
lua Code:
local Send=SendChatMessage; function SendChatMessage(msg,chan,...); chan=chan:upper();-- Convert to make checks easier (channel is case-insensitive) if chan=="SAY" then -- Strip all spaces around "*" and split into segments local pieces={strsplit("*",msg:gsub("%s*%*%s*","%*"))}; -- Iterate through pieces for i,j in ipairs(pieces) do if #j>0 then-- Don't do anything if string is empty if i%2>0 then-- Evaluates to 1 if say, 0 if emote Send(j,chan); else -- Try to separate command and args local cmd,arg=j:match("(%S+) (.+)"); if not cmd then cmd=j; end -- This is tricky, we need to check if the emote slash command exists local token; local tokencheck,tokenid=EMOTE1_TOKEN,1; while tokencheck do local cmdcheck,cmdid=_G["EMOTE"..tokenid.."_CMD1"],1; while cmdcheck do local slashcmd=cmdcheck:sub(2):lower();-- Skip the slash for the emote command if slashcmd==cmd:lower() then-- Command matches, token found token=tokencheck; break; end -- Increment command cmdcheck,cmdid=_G["EMOTE"..tokenid.."_CMD"..(cmdid+1)],cmdid+1; end -- Break if token found if token then break; end -- Increment token tokencheck,tokenid=_G["EMOTE"..(tokenid+1)"_TOKEN",tokenid+1; end if token then DoEmote(token,arg);-- Performs the same emote operation as supported by chat else Send(j,"EMOTE"); end end end end else Send(msg,chan,...); end end
|
So basically, I could take that code, put it in a .lua file, write a .toc file for it, put them in a folder and place it in the AddOns folder, and it'll work right out of the box? (Though it'd probably be better if someone who knows their way around the stuff does it, so that more people than just myself can benefit from it.
)