Double Events
Alright, I`m no stranger to coding, but I`m a bit new to WoW API Lua. So, for my first challenge, I`m making a chat bot. So, I decided to make it have a welcoming message. This is what I had so far.
Code:
Quote:
|
Have you tried dumping out the arguments from the event?
You could either add some code to your existing addon to do this, or you might like to use the eventtrace tool (/eventtrace). |
Quote:
|
How do you load your posted code ?
I've seen cases where it was loaded twice resulting in double events. Is it loaded in the toc and in a xml ? |
.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" Code:
Code:
## Interface: 30100 |
You're loading HelloWorld.lua twice, once in the .toc and once in the .xml. Ergo, you get double messages.
|
So should I remove the .lua as a dependency in my .toc?
Edit: Or should I remove '<Script File="HelloWorld.lua"/>' from .xml? Editedit: I removed the line from the first edit and it works now, thanks guys! Editeditedit: How do I get the name of the joining player to a variable? |
If the code you posted is the entire code, I'd just remove the xml-file completely. It doesn't seem to have any purpose, since you create the frame anyway in the lua-file.
|
Thanks, Ailae. Also, how do I get the name of the triggering player?
|
You can get the arguments passed with the event from wowprogramming or wowwiki
change your event handler routine to use the passed arguments like: Code:
local function autoResponse(event, _, sender, _, channelString, _, _, _, channelNumber, channelName, _, _) |
Actually the first arg is a reference the the frame that belongs to the event handler. Then comes the event that occurred, etc.
|
Code:
frame:SetScript("OnEvent", function(self, event, ...) if self[event] then self[event](self, ...) end end) Code:
local frame = CreateFrame("frame") |
Alright, I set it to display the second argument, but it is displaying CHAT_MSG_CHANNEL_JOIN anyway. The second argument is the joining player, according to the wowwiki article.
Quote:
Code:
local frame = CreateFrame("FRAME", "MParent"); Code:
/script SendChatMessage("Welcome!" ,"WHISPER" ,nil ,pname); |
Quote:
yj589794 said it's the 3rd return, but the player's name will actually be the 4th return. |
All times are GMT -6. The time now is 10:44 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI