Addon to split *emotes* out of messages
Basically, I'm looking for an addon that'll let me write *asterisk emotes* in a chat message and have those split into separate /emotes once the message is posted.
If I, for instance, write a message that goes: Quote:
Quote:
Vice versa, if I write the emote before the message, like this: Quote:
Quote:
Or if I do both several times within a message: Quote:
Quote:
Support for the game's built-in emotes would also be nice: Quote:
Quote:
|
I think I see what you mean, basically something like this I guess?
It should be possible by pre-hooking SendChatMessage I reckon. Code:
local orig = SendChatMessage |
Yeah, that's pretty much exactly what I'm after, though I'm judging by the third line that it would kick in whenever the channel is not EMOTE (I've programmed in AS3, but never in Lua). The best way would be if it only does its work when it's posted to the SAY channel. Still, that is pretty much what I'm after.
|
Quote:
|
The Lua patterns gods have spoken
Sorry, couldn't keep it down :D |
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:
|
Take a look on what I wrote and give me some feedback:
lua Code:
In short, match("message") will return either nil if nothing matched or a table containing {message, emote} that you can go trough each one, unpack each entry and send the message in the /say or /emote channels depending if it's a string or nil. Far better than my first sketch, aye? :D |
string.trim() does not exist in the Lua core, however, the WoW API supplies strtrim() to do this and the default character string is " \t\r\n" if left undefined.
I still prefer my string splitting approach plus the added features the OP requested. Also to note, DoEmote() requires an emote token to run, you need to send it through the EMOTE channel with SendChatMessage() for custom emotes. |
Quote:
|
Yes, you just gotta write it a .toc and put it in a folder so it becomes an addon.
Anyway gonna put this here http://pastey.net/149152 and now I can delete the local file from my PC, hehe. Both will work, you pick what ever you like. ;) |
It would be cool if a full-fledged addon was made for this (as I doubt I'm the only one who finds this a handy thing to be able to do), but it looks like I've got what I was looking for. Thanks a lot for the help, both of you.
EDIT: It seems I've run into a couple of issues. I can't seem to get the version from you, SDPhantom, working, even though I'm certain I've got everything right; and the one from you, Vladinator, is working as it should but locks the game up if the *emote* comes before the Say message. |
There's an addon called TotalRP 2 that does just what you're asking for, and more.
It hasn't updated in quite a while though. While it still works, I don't know if it's a discontinued project. |
Quote:
|
Are you sure you're doing it the right way? Otherwise this thread might help:
http://www.mmo-champion.com/threads/...lve-easy-steps |
Well i maintain the addon tongues and may add this to the addon come next update, but given that would you still want just this in an addon cuase i will see what i can do.
Edit:And there was an error i found and fixed line 38 should be tokencheck,tokenid=_G["EMOTE"..(tokenid+1).."_TOKEN"],tokenid+1; and its not stripping the trailing * at the moment. |
this should works maybe unless i made a glareing error
Code:
local Send=SendChatMessage; |
Hehe, fixed it in case you wish to look to learn or anything. http://pastey.net/149174 -not the only way to do this, I'm glad Aurorablade posts his variant too! :)
|
Wells its SDs variant i just fixed a few things.. I think.
|
Heh, wow. I come back at the end of the day to check for replies, and all the troubles I had earlier have been taken care of. Thanks a lot everyone (again).
|
Quote:
Thanks for pointing it out. Quote:
Edit: Maybe I should run my code through the game next time before posting, lol. The following has been fixed in my above code: -Removed the ";" at the end of the parameter list. -Fixed more of line 38, missing end bracket for index. -Replaced strsplit() with alternate code. (Function returns didn't match documentation.) |
All times are GMT -6. The time now is 10:37 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI