Thread Tools Display Modes
09-22-10, 12:07 PM   #1
Eetabeetay
A Murloc Raider
Join Date: Aug 2007
Posts: 4
New to this, need help writing a simple addon.

Ok, my goal is to write an addon that types in raid chat whenever someone has died, but with nicknames for each person. Its meant as a joke addon to make fun of people who die in our raids. I also want it to be spam proof in case we wipe, so like have it auto disable itself for 30 seconds when 5 people die in 5 seconds or less. I've been trying to figure this out on wowwiki, but I'm still really confused.
All I have so far is a .toc file with this:
## Interface: 30300
## Title: (addonname)
## Notes: (addonname) has died.
(addonname).lua
(addonname).xml

i removed the addon name because its named after someone who I need to keep anonymous.
  Reply With Quote
09-25-10, 01:57 AM   #2
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
well lets say in your xml file you have this

*.xml
Code:
...

<Frame name="(addonname)Frame">
    <Scripts>
        <OnLoad>self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
        <OnEvent>(addonname)_OnEvent(self,event,...)</OnEvent>
    </Scripts>
</Frame>

...
and for your *.lua you wanna do

*.lua
Code:
local nicknames {}
  nickname["Actualname"] = "Fluffypinkbunnyman"
  nickname["Xubera"] = "Xub"

local counter = 0
local firstDeath = false

function (addonname)_OnEvent(self,event,...)
    local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...

    if type == "UNIT_DIED" then
       if nickname[destName] and counter <= 5 then
           SendChatMessage("EL OH EL!!! "..nickname[destName].." just got roflpwned by that boss guys!!", GetNumRaidMembers()>0 and "RAID" or GetNumPartyMembers()>0 and "PARTY" or "SAY")
           counter = counter + 1
       end
       if not firstDeath then
           firstDeath = GetTime()
       elseif firstDeath and firstDeath + 300 > GetTime() then --if its been 5 minutes since the first death, reset the counter and clock
           firstDeath = false
           counter = 0
       end
   end
end

I havent tested this, and if you have any questions, please feel free to ask me what ive done, why ive done it, and whats the point

**side note, in the .xml file, i left out the <Ui> tags, if you need helps on those too, just ask
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
09-27-10, 11:10 PM   #3
Eetabeetay
A Murloc Raider
Join Date: Aug 2007
Posts: 4
First of all, thanks for the help, but sadly it's not working for me.

is this supposed to be plural?
this is whats called a user defined function right?
Code:
local nicknames {}
also I was reading on wowwiki, trying to learn some more stuff. I came across this page - http://www.wowwiki.com/API_COMBAT_LOG_EVENT . is this unnecessary or did it just get left out?
Code:
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then

I'm probably completely wrong, but I changed it up to this. Its still not working so I'm guessing I'm wrong.

*.lua
Code:
local nickname {}
  nickname["Eeta"] = "Rollingeeta"

local counter = 0
local firstDeath = false

function Rollingpally_OnLoad()
  this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end


function (Rollingpally)_OnEvent(self,event,...)
    local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...

	if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
	 if (type=="UNIT_DIED") then
       if nickname[destName] and counter <= 5 then
           SendChatMessage(..nickname[destName].." has died.", GetNumRaidMembers()>0 and "RAID" or GetNumPartyMembers()>0 and "PARTY" or "SAY")
           counter = counter + 1
       end
       if not firstDeath then
           firstDeath = GetTime()
       elseif firstDeath and firstDeath + 300 > GetTime() then --if its been 5 minutes since the first death, reset the counter and clock
           firstDeath = false
           counter = 0
       end
    end
   end
end

*.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">
<Frame name="(addonname)Frame">
    <Scripts>
        <OnLoad>self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
        <OnEvent>(addonname)_OnEvent(self,event,...)</OnEvent>
    </Scripts>
</Frame>
</Ui>
  Reply With Quote
09-28-10, 03:34 AM   #4
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
actually im wrong lol, it should be

Code:
local nicknames = {}
i guess i forgot the equals sign, okay imma look through the rest and edit the post in a bit
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote
09-28-10, 03:42 AM   #5
Xubera
A Cobalt Mageweaver
 
Xubera's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 207
Originally Posted by Eetabeetay View Post
First of all, thanks for the help, but sadly it's not working for me.

is this supposed to be plural?
this is whats called a user defined function right?
Code:
local nicknames {}
alright, it was my bad,
Code:
local nicknames = {}
is the correct form, its a variable, we could name it whatever we want... we could name it "local cheezecake = {}" but that would just be silly.

also I was reading on wowwiki, trying to learn some more stuff. I came across this page - http://www.wowwiki.com/API_COMBAT_LOG_EVENT . is this unnecessary or did it just get left out?
Code:
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
It isnt necessary. its really used if you register for more than one event. Like say we also registered for CHAT_MSG_SAY... we would use the if statement to say, okay if the event was from the combat log, do this, if it was from a /say, then do this.




*.lua
Code:
--local nickname {}
local nickname = {} 
  nickname["Eeta"] = "Rollingeeta"

local counter = 0
local firstDeath = false

function Rollingpally_OnLoad(self)
  --this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
     self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end


--function (Rollingpally)_OnEvent(self,event,...)
function Rollingpally_OnEvent(self, event, ...)
    local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = ...

	if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
	 if (type=="UNIT_DIED") then
       if nickname[destName] and counter <= 5 then
           --SendChatMessage(..nickname[destName].." has died.", GetNumRaidMembers()>0 and "RAID" or GetNumPartyMembers()>0 and "PARTY" or "SAY")
            SendChatMessage(nickname[destName].." has died.", GetNumRaidMembers()>0 and "RAID" or GetNumPartyMembers()>0 and "PARTY" or "SAY")
           counter = counter + 1
       end
       if not firstDeath then
           firstDeath = GetTime()
       elseif firstDeath and firstDeath + 300 > GetTime() then --if its been 5 minutes since the first death, reset the counter and clock
           firstDeath = false
           counter = 0
       end
    end
   end
end

*.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">
<Frame name="RollingpallyFrame">
    <Scripts>
        <OnLoad>Rollingpally_OnLoad(self)</OnLoad>
        <OnEvent>Rollingpally_OnEvent(self,event,...)</OnEvent>
    </Scripts>
</Frame>
</Ui>
i didnt erase code, i just commented it out so you can see what i changed
__________________
Chat Consolidate is the solution to any out of control trade chat. Ignore lines, throttle chat, consolidate posts!Follow the link to find out how!

▲ ▲ WoWInterface wont let me triforce >.>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » New to this, need help writing a simple addon.


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