Player & target health text

before todays patch the follow script would just show the current HP 845k for exp and not the total / current

broke after the patch today. any one have a fix?

hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(statusFrame, textString, value, valueMin, valueMax)
    if valueMax > 0 then
        textString:SetText(tostring(AbbreviateLargeNumbers(value)).."");
    else
        textString:SetText("0");
    end
    if(statusFrame.LeftText and statusFrame.RightText) then
        statusFrame.LeftText:Hide();
        statusFrame.RightText:Hide();
        textString:Show();
    end
end)

It looks like they’ve gotten rid of using global functions for most statusbars and are using a Mixin for each one instead which means you would have to hook the individual function for each bar you want to effect (the new unit frame structures also make it pretty ugly and given they are not identical makes it even uglier).

Eg. for the PlayerFrame and TargetFrame health and mana bars you could use:

local function UpdateBarText(self, textString, value, valueMin, valueMax)
    if valueMax > 0 then
        textString:SetText(tostring(AbbreviateLargeNumbers(value)).."");
    else
        textString:SetText("0");
    end
    if(self.LeftText and self.RightText) then
        self.LeftText:Hide();
        self.RightText:Hide();
        textString:Show();
    end
end

hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.HealthBarArea.HealthBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.HealthBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.ManaBarArea.ManaBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.ManaBar, "UpdateTextStringWithValues", UpdateBarText)

I have’t dug into the makeup of the text status bar to see if that has changed.

1 Like

it worked! just didnt update the powerbar text but ill see what i can do with new format, thank you so much!

Add these to the list of hooks (for Player and Target frames only).

hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.ManaBarArea.ManaBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.ManaBar, "UpdateTextStringWithValues", UpdateBarText)

Updated in my OP also.

1 Like

there are still good people in the world! thanks again!

Is it possible to do for player frame only % hp , for target current and (%) ?

You just need to format the values the way you want for each unit eg.

local function AsPercent(value, valueMin, valueMax)
	return format("%.0f%%", value/valueMax * 100)
end

local function PercentOnly(self, textString, value, valueMin, valueMax)
    if value > 0 then
    	textString:SetText(AsPercent(value, valueMin, valueMax))
    else
    	textString:SetText(0)
    end
    textString:Show()
end

local function ValAndPercent(self, textString, value, valueMin, valueMax)
    if value > 0 then
    	textString:SetText(format("%s  (%s)", AbbreviateLargeNumbers(value), AsPercent(value, valueMin, valueMax)))
    else
    	textString:SetText(0)
    end
    textString:Show()
end

hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.HealthBarArea.HealthBar, "UpdateTextStringWithValues", PercentOnly)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.HealthBar, "UpdateTextStringWithValues", ValAndPercent)
2 Likes

Thanks ! and may be u know script how to hide name and level on player and target frames ?

PlayerName:Hide()
PlayerLevelText:Hide()
PlayerLevelText:HookScript("OnShow", function(self) self:Hide() end)
TargetFrame.TargetFrameContent.TargetFrameContentMain.Name:Hide()
TargetFrame.TargetFrameContent.TargetFrameContentMain.LevelText:Hide()
TargetFrame.TargetFrameContent.TargetFrameContentMain.LevelText:HookScript("OnShow", function(self) self:Hide() end)

You can export the game UI and find the elements yourself.

https://warcraft.wiki.gg/wiki/Viewing_Blizzard%27s_interface_code

1 Like