1. #1
    Deleted

    Weakauras 2 - Change progress bar color when target is tapped

    Hello there! First thread ever.

    In my ui i have a target health bar which is in red color.
    What can i do to change it to gray if the target is "tapped" by another player?

    Bonus question: How can i have the bar in different color depending on class?
    Bonus question: How can i have a bar in different color depending on power type?

    Thanks in advance.

  2. #2
    I assume you built that bar with WeakAuras. Sounds like you need a custom animation function that controls the color, and to implement your logic in there to return whatever state it should currently be in.

  3. #3
    Deleted
    That's correct. I'm just hoping someone who knows to custom code it.

  4. #4
    Quote Originally Posted by Skoite View Post
    That's correct. I'm just hoping someone who knows to custom code it.
    Oh. You should be clearer in your topic, then: "can someone please write the code to change the color of a target health bar for me when blah blah blah". I assumed you were having trouble figuring out which part, exactly, of WA you needed to write your own lua code for. (...and, so, sorry that I wasn't helpful.

  5. #5
    Deleted
    This should pretty much cover the logic you need:

    if UnitIsTapped("target") and not UnitIsTappedByPlayer("target") then
    return 0x58/0xff, 0x58/0xff, 0x58/0xff, 1
    else
    return 1, 0, 0, 1
    end

    Obviously you can change the colors, but basically it checks if a target is tapped at all and not tapped by the player which results in #585858 being used as a color (a shade of grey) and otherwise, meaning untapped or tapped by the player, returns #FF0000 (bright red).

  6. #6
    The following should cover cases where the unit counts for all players who tap it.
    This is just to play on the side of safety, not that you ignore something that you did not have to.
    Code:
    if UnitIsTapped("target") and not UnitIsTappedByAllThreatList("target") and not UnitIsTappedByPlayer("target") then
    	return 0x58/0xff, 0x58/0xff, 0x58/0xff, 1
    else
    	return 1, 0, 0, 1
    end


    Forgive my bad syntax but I have not used WeakAuras in a while. I had all these in mine when I made a UI using only WeakAuras... only problem was not being able to interact with frames.
    Code:
    -- power types
    local r, g, b = PowerBarColor[UnitPowerType("target")]
    return r, g, b, 1
    Code:
    -- class colors
    local r, g, b = RAID_CLASS_COLORS[UnitClass("target")]
    return r, g, b, 1
    "I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

  7. #7
    Quote Originally Posted by Hamsda View Post
    This should pretty much cover the logic you need:
    When doing code or PowerAura/WeakAura import strings or similar then try putting it in tags.
    The post below yours by ThePrideless shows that.
    Can do that manually, or in the Advanced Editor by clicking "Go Advanced".
    Quote Originally Posted by DeadmanWalking View Post
    Your forgot to include the part where we blame casuals for everything because blizzard is catering to casuals when casuals got jack squat for new content the entire expansion, like new dungeons and scenarios.
    Quote Originally Posted by Reinaerd View Post
    T'is good to see there are still people valiantly putting the "Ass" in assumption.

  8. #8
    Deleted
    Quote Originally Posted by ComputerNerd View Post
    When doing code or PowerAura/WeakAura import strings or similar then try putting it in tags.
    The post below yours by ThePrideless shows that.
    Can do that manually, or in the Advanced Editor by clicking "Go Advanced".
    Every time I did this so far, my post didn't show up at all... don't know if it's because of my low post count, but I'd rather give someone an answer than it not being there but being pretty :/

  9. #9
    Quote Originally Posted by Hamsda View Post
    Every time I did this so far, my post didn't show up at all... don't know if it's because of my low post count, but I'd rather give someone an answer than it not being there but being pretty :/
    As far as I know the only requirements are for links/images, and that is 10 posts unless something changed.
    It is not just about "looking pretty", but often readability too.
    Also import strings may be messed about if not contained in something which prevents unnecessary formatting.
    Quote Originally Posted by DeadmanWalking View Post
    Your forgot to include the part where we blame casuals for everything because blizzard is catering to casuals when casuals got jack squat for new content the entire expansion, like new dungeons and scenarios.
    Quote Originally Posted by Reinaerd View Post
    T'is good to see there are still people valiantly putting the "Ass" in assumption.

  10. #10
    Deleted
    Quote Originally Posted by ComputerNerd View Post
    As far as I know the only requirements are for links/images, and that is 10 posts unless something changed.
    It is not just about "looking pretty", but often readability too.
    Also import strings may be messed about if not contained in something which prevents unnecessary formatting.
    Again, I did it a few times, couldn't post and said screw this. I tried it again and could post without problems now, apparently the 10 posts is also for "too long" posts aka posts containing import codes.
    I'm well aware that it's not about "pretty" :P

  11. #11
    Deleted
    Thanks for the replies.
    I've tried adding the codes you wrote but they just keep giving me errors.

  12. #12
    Quote Originally Posted by Skoite View Post
    Thanks for the replies.
    I've tried adding the codes you wrote but they just keep giving me errors.
    My apologies, that was my bad. The following should work.
    Code:
    -- power types
    local color = PowerBarColor[UnitPowerType("target")]
    return color.r, color.g, color.b, 1
    Code:
    -- class colors
    local _, CLASS = UnitClass("target")
    local color = RAID_CLASS_COLORS[CLASS]
    return color.r, color.g, color.b, 1
    "I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Posting Permissions

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