1. #1

    Help with Unit_Health handling

    I want to add a function to Need To Know to track health.
    Someone has gotten part of the way there but
    I don't really know how to get the rest of the way.

    So I'll quote what was said and hopefully one of you guys can help me out.
    Thanks for your time in advance. :3

    In NeedToKnowLoader.SetPowerTypeList, I added:

    Code:
    -- -2 - Health
    table.insert(NeedToKnowRMB.BarMenu_SubMenus.PowerTypeList,
          { Setting = "-2", MenuText = HEALTH } )
    And inside mfn_AuraCheck_POWER, I added an additional if statement:

    Code:
    if ( pt == -2 ) then
          curPower = UnitHealth("player")
          maxPower = UnitHealthMax("player")
    else
          curPower = UnitPower(bar.unit, pt)
          maxPower = UnitPowerMax(bar.unit, pt)
    end
    Then the addon's author replied:

    What you're missing is that power bars are only listening for UNIT_POWER to know to update, and health isn't a power. You need your health bar to listen for UNIT_HEALTH as well. Searching for how UNIT_POWER is handled should get you the rest of the way there.


    Any help is greatly appreciated.

  2. #2
    I'm going to assume that the second code snippet you added is actually the bottom two thirds of an if-elseif-else block, and you didn't cut out the combo points part....

    The author is referring to registering events. I don't know the NTK code base well, so I'll just give you a first attempt and you can see how it turns out.

    inside function NeedToKnow.SetScripts(bar): find
    Code:
        elseif ( "POWER" == bar.settings.BuffOrDebuff ) then
            if bar.settings.AuraName == "-1" then
              bar:RegisterEvent("UNIT_COMBO_POINTS")
            else
              bar:RegisterEvent("UNIT_POWER")
              bar:RegisterEvent("UNIT_DISPLAYPOWER")
            end
    replace with:
    Code:
        elseif ( "POWER" == bar.settings.BuffOrDebuff ) then
            if bar.settings.AuraName == "-2" then
              bar:RegisterEvent("UNIT_HEALTH")
            elseif bar.settings.AuraName == "-1" then
              bar:RegisterEvent("UNIT_COMBO_POINTS")
            else
              bar:RegisterEvent("UNIT_POWER")
              bar:RegisterEvent("UNIT_DISPLAYPOWER")
            end
    inside function NeedToKnow.ClearScripts(bar): find
    Code:
        bar:UnregisterEvent("UNIT_POWER")
    add:
    Code:
        bar:UnregisterEvent("UNIT_HEALTH")
    toward bottom of file: find
    Code:
    EDT["UNIT_POWER"] = fnAuraCheckIfUnitMatches
    add:
    Code:
    EDT["UNIT_HEALTH"] = fnAuraCheckIfUnitMatches

Posting Permissions

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