1. #1

    [WeakAura] Need help with UnitClassification custom trigger

    Hi there!

    I'll try to be brief but explain what I'm trying to accomplish as best as I can. I'll admit now I'm pretty newbie when it comes to LUA and only very recently started to develop an interest in it.

    As the title suggests, I'm trying to set up a WeakAura texture frame that will check unit classification and display if the target matches the condition. To give some context, I'm trying to set up a series of WeakAuras that will display a different texture depending on if the target is normal/trivial, rare, rare elite, or elite since my current unit frames don't include a visual representation. Here's my current code:

    Code:
    function()
        if ( UnitClassification("target") == "normal" or "trivial" or "minus" ) then
            return 
        end
    end
    The problem I have is that I have no idea what to return or how to tell WA to display the texture. I've created a few custom textures already and got them to load in-game, I just need help with the code to display them.

    Any help would be greatly appreciated,
    Kayla~

  2. #2
    Deleted
    Are you using different auras for each texture? Then you'd put the code you wrote into the trigger and just return true.
    If you want one aura that is always there if you got a target, then you can put your code into the custom texture area and return the name of the texture in quotation marks.

  3. #3
    Returning true works to display the textures, but the problem is that it continues to display even after I change targets. For example, if I target an elite mob, the elite icon shows up. If I then target a normal mob or another player however, the elite icon still shows. The same thing happens with the rare and rare elite icons. I've already tried adding "else return false", but unsurprisingly that didn't do much. I also couldn't get the texture info code to work. It would just display a green box even though the paths were correctly entered. What am I missing here? Do I need to add something to the untrigger event to get it to unload the icon when I switch or drop target? I have the events currently set to trigger on PLAYER_TARGET_CHANGED event to lighten the load instead of updating every frame, which didn't have any impact on this particular issue anyways.

  4. #4
    Take a brief look at that aura

    Code:
    dqKKuaWjQ0OuP6uQuMfbDlfWUavKHraDmQsTmQcptLOPbP6AubBtLKVPanoQsCoIIUhv0(avuhKiwivjvpKinrfsxKa1gPc9rvsLrsvs5KeALGYmHKUjOs7es8tfIHsuilLOGNkLPsvDvQI2kbYzPkjMlvjP9c8xiLblomPwmOcpgKjdXLv1MHQpRqnAqvNwYRjkuZwQUTcA3k9BvmCvclxrpNKPt56qz7eL(UkPQXtuDEcW7vjf3xLuA)ObEd8bnnWhyGMc08ao5nCsGWjVhe0gcAiGgcWh0uFhxgDQ1anV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gggggggMcNzpgJNBzcwEPm1DSTSBmg8)YmFdBUm)IqymmmmmmmmfoZEmgt6znDTQ7cscQIJIMuuL0AIokkvIV4iO0eYa11kvHxqARo7ngd(FzMVHnxMFrimgggggggM(bs3zW2YexKxUqgOUwPexKxoHXWWWWWWWGFMmLqzzQLPUqxt1DbjbvXrrtkQsAnrhfLkXxCeuA3yqoegdddddddddddtHZilJtNmEULjTRvQcVG0wD27yBz3ym4)LbBltCrE5mozkMFrimgggggggggggMcNrwgNozG6ALQWliTvNLXG)xgOUwPexKxoJtMI5xecJHHHHHHH5xecJHHHHHHHPWzW2YexKxoJEryG6ALsCrE5mg8)Yu4myBzIlYlNbo7KbQRvkXf5LZyW)lZ8nS5YytSN5xeMFrimgggggggM5ByZLbx3vpHXWWW8lcHXWWWmFdBUm39Cltub3AL21kvHxqARo7Dxtph)MRqg3Vx27EJrVim7Xy8Cltub3AL21kvHxqARo7Dxtph)MRqg3PE(FVS392nc7xeq7L9xtbAYiuL4veSmGMVez46eSpAs9Asq56e8OGge8pKmg0Ez)1animLDgIg8fYdAwn8ragOPrqkRoRUJMnRXJ)Pc4dmqBEmTvNfGI3x6bOjGrWXvVbC8QlV8sVLPdoCLdY0d0V0bpa4dG(GG2In0FwJh)tfafVbT(rJa8bnKchVGW6Maa(G2qSUvaFGbmqBQHEGpOneRBfWhyad0mD)xd4dAdX6wb8bgWanCnKvNf4dAdX6wb8bgWaT5P)aFqBiw3kGpWagWanOt)mb(au8a44vxjqh8yqzIUdxI(GxnOhdcWhWHlbOCjWrhUYbVDyWReOa9qMdI(GOlqa(aoCfaf0boELhEJUmVAq0VcDpK5vOJUxa4d4WLadyad0KfGI3O7H3adaa
    Last edited by Platinengel; 2015-11-28 at 03:04 PM.

  5. #5
    That aura works exactly how I wanted it! Thank you so much. I skimmed through the code, and there's no way I could have figured that all out. Most of it is still very confusing to me. :P Thank you very much for your help. I think I need to read through this code properly now and try to learn a thing or two, or twelve. Hehe

  6. #6
    The important part you missed is the correct "untrigger". At least thats my guess.

    Yours does also work as intended except of the untrigger.

  7. #7
    Deleted
    It seems you already got some help, but I thought it'd be good to really explain what's going on here. You know, teach a man to fish.

    Quote Originally Posted by Darsyek View Post
    Code:
    ( UnitClassification("target") == "normal" or "trivial" or "minus" )
    That expression can only be evaluated to true (boolean value) or "trivial" (string), which is then evaluated to true as a boolean expression by the if-statement. In other words the if statement is equivalent to this:
    Code:
    if ( true ) then

    First it evaluates
    Code:
    UnitClassification("target") == "normal"
    Which is either true or false. If it's true, then the whole expression is true. If it's false, then what has to be evaluated is this:
    Code:
    false or "trivial" or "minus"
    In lua or will always pass forward the first non-false value from left to right. For example:
    (4 or 5 or 6) is evaluated to 4
    (nil or "hello") is evaluated to "hello"
    (true or "hello") is evaluated to true
    As such (false or "trivial" or "minus") is evaluated to "trivial". The if-statement treats this as a boolean expression, and in lua everything other than nil or false is evaluated to true.

    I'm almost certain that WeakAuras checks the trigger with something like this:
    Code:
    if (YourTriggerFunction()) then
    	-- Do stuff
    end
    So going by what I explained earlier about how lua evaluates boolean expressions, any return value other than nil or false should work, but the convention is to just return true.

    Also, I'm pretty sure "trivial" isn't a possible return value for UnitClassification. You need to use UnitIsTrivial for that.

    Finally, UnitClassification seems to return "normal" when there is no target selected, so you need to check UnitExists("target"), too.

    I think this is what you were trying to write:
    Code:
    -- trigger
    function()
    	local classification = UnitClassification("target")
    	if (UnitExists("target") and (classification == "normal" or classification == "minus" or UnitIsTrivial("target"))) then
    		return true
    	end
    end
    
    --untrigger
    function()
    	local classification = UnitClassification("target")
    	if not (UnitExists("target") and (classification == "normal" or classification == "minus" or UnitIsTrivial("target"))) then
    		return true
    	end
    end
    PS. Something you might want to do for testing is printing stuff to see what's going on. If you add print("hello") in your trigger before returning true, you will see in your chat box when the trigger returns true, so you get some idea about whether the problem is in the trigger or somewhere else. Even better, you can even see what your expression evaluates to by doing something like this:
    Code:
    function()
        local test = UnitClassification("target") == "normal" or "trivial" or "minus"
        print(test)
        if test then
            return true 
        end
    end

  8. #8
    Thanks for such a detailed explanation. That makes a lot of sense. It had crossed my mind that I should include UnitExists but I (incorrectly, it seems :P) assumed that if I didn't have a target, then none of the conditions could be true. Like I say, I'm pretty new to LUA, so I'm making a lot of guesses and assumptions when I'm experimenting. Sometimes it works out, sometimes... Not so much. My original code did work reasonably well to show the icon when I had a target but hide it without a target, though I could just use the built-in target status check for that. Normally if I'm making a WeakAura that requires a target, I just check if target health percent is >= 0. That way, as long as I have a target, it'll show up. Obviously, not quite as useful when you're trying to have different icons for different unit classifications. :P I'm not sure if WeakAuras has a built-in UnitClassification check, but I didn't really look too much into it before I jumped straight into custom code for the fun of it. I also wasn't aware of the UnitIsTrivial condition. I had just used UnitClassification to check for trivial because the WoW Wikia for the LUA code included it as a possible value. wowprogramming.com however does not. Thanks for that, too.

  9. #9
    Deleted
    I did some digging around, and apparently "trivial" is a possible return value for UnitClassification, after all.

    On Wowpedia it says
    "Note that "trivial" is for low-level targets that would not reward experience or honor (UnitIsTrivial() would return '1'), whereas "minus" is for mobs that show a miniature version of the v-key health plates."
    This explanation is just retarded, because a level 1 Critter always has the classification "normal" just as a level 50 Elite always has the classification "elite". Classification is an inherent quality of a unit, whereas triviality is determined by the level difference, so either there is no classification called "trivial" or these things are unrelated.

    However, then I checked the edit history to see what kind of a brainiac thought it was a good idea to lie on the wiki, and to my surprise the real answer was there. On the WoWWiki/Wowpedia revision history page it has a short explanation for some edits, and one of the explanations was "Returns: Snake Trap Snakes are "trivial"". I made Glyph of Snake Trap for my Hunter and tested it out myself, and I was really surprised to see that it was true.

    I have no idea if there are any other units in the game with the same classification. Even Shaman's Totems, Priest's Mindbender, Army of the Dead Ghouls, and the Void Tendrils summoned by Touch of the Void are all classified "normal", and Warlock's Wild Imps are classified "minus", but for some mystical reason the Snake Trap snakes (which are of course level 100, so not trivial in the UnitIsTrivial sense) are "trivial". They could very well be the only units in the game with this bizarre classification.

  10. #10
    That seems very odd to me. Maybe it's because the snakes are basically aggressive critters instead of pets or minions like an imp or a ghoul would be. It may have something to do with the nameplates as well, since normal classification shows the normal nameplates, trivial has the small nameplates, and the snakes from snake trap don't have nameplates at all if I recall correctly. It's possible they made that classification just for the snakes so they don't cover up the whole screen with the nameplates when they pop up. I don't know, just a thought. :P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •