Thread Tools Display Modes
04-26-16, 03:18 PM   #1
flaicher
A Cyclonian
 
flaicher's Avatar
Join Date: Jan 2007
Posts: 46
UnitCreatureFamily and Warlocks?

I used this as a trigger in WeakAuras.
Code:
function()
    local _, autocast = GetSpellAutocast(134477)
    local petclass = UnitCreatureFamily("pet")
    if (not autocast) and petclass == "Felguard" then
        return true
    end
end
It worked like a charm. Now I replaced petclass == "Felguard" with (petclass == "Wrathguard" or "Felguard") as I got Grimoire of Supremancy talent and it's going whacko.

EDIT: (petclass == ("Wrathguard" or "Felguard")) fixed the problem.. but now I can't figure out what is the CreatureFamily of Voidlord. It certainly isn't Voidlord, nor Voidwalker..

Last edited by flaicher : 04-26-16 at 03:54 PM.
  Reply With Quote
04-26-16, 04:05 PM   #2
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 309
Easy way to figure that stuff out is to summon the void lord and do this:

Code:
/run print(UnitCreatureFamily("pet"))
__________________
AddOns: Tim @ WoWInterface
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-26-16, 04:25 PM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
Originally Posted by flaicher View Post
EDIT: (petclass == ("Wrathguard" or "Felguard")) fixed the problem
Actually, this doesn't work the way you think it does. The original line evaluated petclass == "Wrathguard" first and if that was false, it evaluated "Felguard", which anything that isn't strictly nil or false evaluates to true. This eventually made the condition to always evaluate to true no matter what happened.

Your edit evaluates "Wrathguard" or "Felguard" first because of the parenthesis. Both are true conditions, but because of how or operates, it returns the first operand if it's a true condition. This makes the line always try to evaluate petclass == "Wrathguard". Which isn't covering the Felguard condition.

To have the condition return correctly, you need to make the change highlighted below.
Code:
function()
	local _, autocast = GetSpellAutocast(134477)
	local petclass = UnitCreatureFamily("pet")
	if (not autocast) and (petclass == "Felguard" or petclass == "Wrathguard") then
		return true
	end
end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
04-26-16, 04:40 PM   #4
flaicher
A Cyclonian
 
flaicher's Avatar
Join Date: Jan 2007
Posts: 46
EDIT: I didn't refresh the page before posting this, so I missed SDPhantom's post.
Your advice fixed the problem I had with Voidwalker/Voidlord as well. I fixed Felguard/Wrathguard functions too.


It does claim that voidlord's creature family is "Voidlord"..
WeakAuras does recognize that I have a pet alive when a voidlord is summoned buuuuut this simple function doesn't return "true".
Code:
function()
    local petclass = UnitCreatureFamily("pet")
    if (petclass == ("Voidwalker" or "Voidlord")) then
        return true
    end
end
Nor does it recognize if I try to check for autocast states with voidlord summoned. Works just fine for voidwalker, felguard and wrathguard. I guess I'll have to bug WeakAuras author?

Last edited by flaicher : 04-26-16 at 05:03 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » UnitCreatureFamily and Warlocks?


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