Thread Tools Display Modes
06-20-17, 12:38 PM   #1
Skeetism
A Kobold Labourer
Join Date: Jun 2017
Posts: 1
Need help in Lua! Add0n code

Hey guys first time posting and making an add0n.

Idea behind it is:
- Check yourself and all members in your party for the Blinding Peck Debuff from the Eye of Aszhara dungeon.
- If debuff is found on someone, play soud snipette.

I'm new to Lua and everything I have done has been from reverse engineering other addons similiar to the one I want to make however I cannot get it to work and I'm unsure as to where I have gone wrong.

Anyone with the ability to help me please do I'll love you forever!

Code:
local BLINDING_PECK_ID = 195561

local BLINDING_PECK = GetSpellInfo(BLINDING_PECK_ID)

local frame = CreateFrame("FRAME")

frame:RegisterEvent("UnitDebuff", "player", "party1", "party2", "party3", "party4")

frame:SetScript("OnEvent", eventHandler)
	local name = UnitDebuff("player", "party1", "party2", "party3", "party4" BLINDING_PECK)

local function eventHandler(self, event, ...)
 PlaySoundFile([[Interface\AddOns\Segullspeck\media\Seagullspeck.ogg]], "Master")
end
  Reply With Quote
06-20-17, 01:10 PM   #2
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
First thing i notice: UnitDebuff is not an event. Events are written in all capital letters. The event you are looking for is UNIT_AURA.

this should do it:
Lua Code:
  1. local Blinding_Peck = GetSpellInfo(195561)
  2.  
  3. local frame = CreateFrame("FRAME")
  4.  
  5. frame:RegisterUnitEvent("UNIT_AURA", "player", "party1", "party2", "party3", "party4")
  6.  
  7. frame:SetScript("OnEvent", function(self, event, unitID)
  8.    
  9.     if UnitDebuff(unitID, Blinding_Peck) then
  10.         PlaySoundFile("Interface\\AddOns\\Segullspeck\\media\\Seagullspeck.ogg", "Master")
  11.     end
  12. end)

Last edited by pas06 : 06-20-17 at 01:12 PM.
  Reply With Quote
06-20-17, 04:12 PM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Did RegisterUnitEvent change, because last time I looked it took a maximum of two units, yet your example code lists five.

If that is still true, then use RegisterEvent instead, and check the unit.
  Reply With Quote
06-21-17, 01:55 AM   #4
pas06
A Theradrim Guardian
Join Date: Apr 2009
Posts: 62
My bad didn't check that. Then this should do it:

Lua Code:
  1. local Blinding_Peck = GetSpellInfo(195561)
  2. local Group_UnitIDs = {
  3. player = true,
  4. party1 = true,
  5. party2 = true,
  6. party3 = true,
  7. party4 = true
  8. }
  9. local frame = CreateFrame("FRAME")
  10.  
  11. frame:RegisterEvent("UNIT_AURA")
  12.  
  13. frame:SetScript("OnEvent", function(self, event, unitID)
  14.    
  15.     if Group_UnitIDs[unitID] and UnitDebuff(unitID, Blinding_Peck) then
  16.         PlaySoundFile("Interface\\AddOns\\Segullspeck\\media\\Seagullspeck.ogg", "Master")
  17.     end
  18. end)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help in Lua! Add0n code


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