WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Sending emotes targeting player to screen (https://www.wowinterface.com/forums/showthread.php?t=55850)

Joker119 11-15-17 03:50 AM

Sending emotes targeting player to screen
 
So, I've noticed this is something Prat used to do, but it no longer works(I personally couldn't get it to work, but name-pop ups did), but my chat addon I've made is decidedly more simplistic than prat, and I find the code hard to cipher through to figure out how to implement it in mine..

I've attempted to do this myself with no luck, and I honestly can't figure out why.
I have this function
lua Code:
  1. local function scrollingEmotes(self, event, message, ...)
  2.    if event == "CHAT_MSG_TEXT_EMOTE" or "CHAT_MSG_EMOTE" then
  3.       UIErrorsFrame:AddMessage(message)
  4.       print("Test of Emote Event")
  5.    end
  6. end
  7.  
  8. local a = CreateFrame("Frame")
  9.  a:RegisterEvent("CHAT_MSG_TEXT_EMOTE")
  10.  a:RegisterEvent("CHAT_MSG_EMOTE")
  11.  a:SetScript("OnEvent", scrollingEmotes)

It's event handler code I successfully use in other parts of my UI addon, but for some reason, it's simply not working here, and I don't know why. I get no errors, but when I see an emote, I get neither the debug message nor the emote printed to the UIErrors frame.

Ammako 11-15-17 02:02 PM

I wouldn't be able to tell you what's making it not work for you, 'cause it works just fine on my end. :s

p3lim 11-15-17 04:26 PM

You're trying to match first, then evaluate a string by itself.

lua Code:
  1. if event == "CHAT_MSG_TEXT_EMOTE" or "CHAT_MSG_EMOTE" then

should be

lua Code:
  1. if event == "CHAT_MSG_TEXT_EMOTE" or event == "CHAT_MSG_EMOTE" then

Joker119 11-16-17 12:15 AM

So I've got the event working, and it send emotes to the error frame like it should, but i'm having issues filtering out ones targeting the player.
According to WoWprogramming CHAT_MSG_TEXT_EMOTE contains message, sender, language, channelstring, target ... but target returns a nil value no matter what emote is used.

lua Code:
  1. local function scrollingEmotes(self, event, message, sender, language, channelstring, target, ...)
  2.     if event == "CHAT_MSG_EMOTE" or event == "CHAT_MSG_TEXT_EMOTE" then
  3.                         --debugging, print the message sender and target to chatframe
  4.             print(message, sender, target)
  5.             message = "|cffff4500"..(message).."|r"
  6.             UIErrorsFrame:AddMessage(message)
  7.             print("reeee")
  8.     end
  9. end

the print() should be giving me the emote message, the character sending it and the target, but that 'target' is always empty.

Ammako 11-16-17 02:36 PM

Wowprogramming is outdated and not really being maintained anymore, from what I've been told. Wowpedia is the one you should be relying on.
That being said, Wowpedia doesn't show target as being one of the args, but it's possible that their info is incomplete.

"target" seems to exist just fine for CHAT_MSG_EMOTE, but that doesn't really help with anything. I tried reading and printing all the args for CHAT_MSG_TEXT_EMOTE but none of them contain my target's name, so I guess it's just not there.

If anything it might be worth reporting as a bug.


All times are GMT -6. The time now is 10:13 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI