• 0

    posted a message on LuaTexts Official Thread
    Quote from Shefki
    The second argument you're passing to Power() is rage or mana which isn't defined in the text so it's passing nil, which is the same as passing no 2nd argument at all. The power type is specified by passing an integer that corresponds to the power type.

    http://wowprogramming.com/docs/api_types#powerType

    However, even replacing the proper constants (mana with SPELL_POWER_MANA and rage with SPELL_POWER_RAGE) won't fix your code because Power() probably returns 0 for the current power type and 0 evaluates to true in Lua.

    You should just check the power type directly with UnitPowerType().

    E.g. UnitPowerType(unit) == SPELL_POWER_MANA


    Thank you for the very fast reply! Works like a charm.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    I'm trying to make the power text as dynamic as possible.
    I have - of course - checked the Pitbull Unit Frames 4.0 pages on WowAce, and various pages on Wowpedia.

    My code is as follows:
    local cpwr = Power(unit)
    local mpwr = MaxPower(unit)
    
    if Power(unit,rage) and Percent(cpwr,mpwr) >= 1 then
      return Power(unit)
    
    elseif Power(unit,mana) and Percent(cpwr,mpwr) >= 1 then
      return "%s/%s",Power(unit),MaxPower(unit)
    end


    Neither the rage check nor the mana check works.
    They do the opposite of what I want them to do.
    The rage check does "return "%s/%s",Power(unit),MaxPower(unit)"
    and the mana check does "return Power(unit)".

    I'm guessing it's just some pathetic error on my part, but it's annoying me.
    Anyone who can give me some insight on what's wrong with my code?
    Posted in: Unit Frames
  • To post a comment, please or register a new account.