Thread Tools Display Modes
03-07-10, 12:04 AM   #1
Zinc
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
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:
  local frame = CreateFrame("FRAME", "MParent");
  frame:RegisterEvent("CHAT_MSG_CHANNEL_JOIN");

  local function autoResponse()
    print("|CFF00FF00Someone has entered the channel.|R");
  end

  frame:SetScript("OnEvent",autoResponse);
However, it is firing the event twice each time someone joins the channel, so it says:

Someone has entered the channel.
Someone has entered the channel.
  Reply With Quote
03-07-10, 03:09 AM   #2
Sekrin
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 150
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).
  Reply With Quote
03-07-10, 08:10 AM   #3
Zinc
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
Originally Posted by Sekrin View Post
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).
No idea how to do that.
  Reply With Quote
03-07-10, 10:19 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
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 ?
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
03-07-10, 10:57 AM   #5
Zinc
A Deviate Faerie Dragon
Join Date: Mar 2010
Posts: 13
.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="http://www.blizzard.com/wow/ui/ 
 ..\..\FrameXML\UI.xsd">
 
  <Script File="HelloWorld.lua"/>
  <Frame name="MParent">
  </Frame>

</Ui>
.lua
Code:
  local frame = CreateFrame("FRAME", "MParent");
  frame:RegisterEvent("CHAT_MSG_CHANNEL_JOIN");

  local function autoResponse()
    print("|CFF00FF00Someone has entered the channel.|R");
  end

  frame:SetScript("OnEvent",autoResponse);
.toc
Code:
## Interface: 30100
## Title: Hello World!
## Notes: All Purpose
## Dependencies: 
HelloWorld.lua
HelloWorld.xml
As you can see, I just modify one AddOn to serve as all my AddOns.

Last edited by Zinc : 03-07-10 at 11:03 AM.
  Reply With Quote
03-07-10, 11:14 AM   #6
Ailae
A Rage Talon Dragon Guard
 
Ailae's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 318
You're loading HelloWorld.lua twice, once in the .toc and once in the .xml. Ergo, you get double messages.
__________________
Oh, the simulated horror!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Double Events


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off