1. Hi,

    I am trying to make the TargetText addon from your book. I am now creating the function TargetText:UpdatePowerType() on page 197. But I can't get the ManaBarColor to work.

    It gives me the error:

    Attempt to index global 'ManaBarColor' (a nil value).

    I also have a little problem with the UnitClass update function. If I select a target, it won't give me a class but it gives me his name again. The color of the class is good.

    Can you please help me?

    Hi,

    I am trying to make the TargetText addon from your book. I am now creating the function TargetText:UpdatePowerType() on page 197. But I can't get the ManaBarColor to work.

    It gives me the error:

    Attempt to index global 'ManaBarColor' (a nil value).

    I also have a little problem with the UnitClass update function. If I select a target, it won't give me a class but it gives me his name again. The color of the class is good.

    Can you please help me?

    I can't edit this post, so I reply to it.



    I only have the UnitClass program on NPC's. So it will give me a class back perfectly for players. But it gives me the name of the unit if it is a NPC.

    Every patch to WoW brings potential changes to the UI and 3.0.x is one of them.  For one, the references to "Mana" in the interface have been changed to "Power", so the table you are looking for is now called PowerBarColor.  In addition the way UnitClass() works for NPCs has changed, as detailed on that API page (http://wowprogramming.com/docs/api/UnitClass).

    In short, you should use PowerBarColor and UnitClassBase() instead of UnitClass() when dealing with an NPC.

    Thank you very much for your fast answer. It works perfect!



    I have one more question about the TargetText addon. How does UnitReactionColor work (page 204)? Is that also changed in version 3.0.x ? I keep getting errors from it, and my text stays blue.

    Thanks :)

    Yes, UnitReactionColor has been removed. You can use the following method instead:

    local r, g, b

    local reaction = UnitReaction(unit, "player");

    if ( reaction ) then

      r = FACTION_BAR_COLORS[reaction].r;

      g = FACTION_BAR_COLORS[reaction].g;

      b = FACTION_BAR_COLORS[reaction].b;

    end

    And again, it works perfect!



    Thank you very much.

    Where do we put this new code? does it go into each of the different reactions?

    sorry about double post but it won't let me edit.

    I figured it out, maybe i should try it more before asking.

    The following code works a treat for me in place of the bloated code listed earlier.

    color = FACTION_BAR_COLORS[reaction]

     

    It should be pretty straightforward where to put this.