Minion Beta! - Help us test our new AddOn updater. Get it now!
Download
(2 Kb)
Download
Updated: 10-14-14 06:56 PM
Pictures
File Info
Compatibility:
Warlords of Draenor Pre-Patch (6.0.3)
Updated:10-14-14 06:56 PM
Created:02-03-10 08:23 PM
Downloads:12,939
Favorites:65
MD5:
6.0.3

TargetPercent  Popular! (More than 5000 hits)

Version: r55
by: funkydude [More]

Adds a health percentage to the Blizzard target, focus & boss frames.
Movable with ALT-drag if you dislike the default positions.

Post A Reply Comment Options
Unread 07-07-11, 05:07 AM  
Pixol
A Deviate Faerie Dragon
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 62
Uploads: 8
Thanks I modified your code a bit to show current truncated (divided by 1000 with a "k") hp and mana values for target. This helps me see how much hp a tank has or if they're ret or holy, etc. I like to display the percent on the hp bar itself as the other option blizzard offers tends to block out the entire health bar.


TargetPercent.lua
Code:
local registerOnShow = function(frame) frame:RegisterEvent("UNIT_HEALTH") end
local unregisterOnHide = function(frame) frame:UnregisterEvent("UNIT_HEALTH") end

local startDrag = function(frame) if IsAltKeyDown() then frame:StartMoving() end end
local stopDrag = function(frame) frame:StopMovingOrSizing() end

local healthUpdate = function(frame, _, unit)
	if not unit or unit == frame.target then
		local hp = UnitHealth(frame.target)
		if hp > 0 then
			--hp = hp / UnitHealthMax(frame.target) * 100
			--frame.text:SetFormattedText("%.1f%%", hp)
			frame.text:SetFormattedText("%.1fk", hp/1000)
		else
			--frame.text:SetText("0%")
			frame.text:SetText("0.0k")
		end
	end
end

local manaUpdate = function(frame, _, unit)
	if not unit or unit == frame.target then
		local mp = UnitPower(frame.target)
		local mp_type = UnitPowerType(frame.target)
		if mp_type == 0 then
      if mp > 0 then
        --hp = hp / UnitHealthMax(frame.target) * 100
        --frame.text:SetFormattedText("%.1f%%", hp)
        frame.text:SetFormattedText("%.1fk", mp/1000)
      else
        --frame.text:SetText("0%")
        frame.text:SetText("0.0k")
      end
    else
      frame.text:SetText("")
    end
	end
end

local t_hpFrame = CreateFrame("Frame", "TargetPercent", TargetFrameHealthBar)
t_hpFrame:SetPoint("LEFT", TargetFrameHealthBar, "LEFT", -54, 0)
t_hpFrame:SetWidth(50)
t_hpFrame:SetHeight(20)
t_hpFrame.text = t_hpFrame:CreateFontString("TargetPercentText", "OVERLAY")
t_hpFrame.text:SetAllPoints(t_hpFrame)
t_hpFrame.text:SetFontObject(TextStatusBarText)
t_hpFrame.text:SetJustifyH("RIGHT")
t_hpFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
t_hpFrame:SetScript("OnShow", registerOnShow)
t_hpFrame:SetScript("OnHide", unregisterOnHide)
t_hpFrame:EnableMouse(false)
t_hpFrame:RegisterForDrag("LeftButton")
t_hpFrame:SetClampedToScreen(true)
t_hpFrame:SetMovable(true)
t_hpFrame:SetScript("OnDragStart", startDrag)
t_hpFrame:SetScript("OnDragStop", stopDrag)
t_hpFrame:SetScript("OnEvent", healthUpdate)
t_hpFrame.target = "target"

local t_mpFrame = CreateFrame("Frame", "TargetPercent", TargetFrameManaBar)
t_mpFrame:SetPoint("LEFT", TargetFrameManaBar, "LEFT", -54, 0)
t_mpFrame:SetWidth(50)
t_mpFrame:SetHeight(20)
t_mpFrame.text = t_mpFrame:CreateFontString("TargetPercentText", "OVERLAY")
t_mpFrame.text:SetAllPoints(t_mpFrame)
t_mpFrame.text:SetFontObject(TextStatusBarText)
t_mpFrame.text:SetJustifyH("RIGHT")
t_mpFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
t_mpFrame:SetScript("OnShow", registerOnShow)
t_mpFrame:SetScript("OnHide", unregisterOnHide)
t_mpFrame:EnableMouse(false)
t_mpFrame:RegisterForDrag("LeftButton")
t_mpFrame:SetClampedToScreen(true)
t_mpFrame:SetMovable(true)
t_mpFrame:SetScript("OnDragStart", startDrag)
t_mpFrame:SetScript("OnDragStop", stopDrag)
t_mpFrame:SetScript("OnEvent", manaUpdate)
t_mpFrame.target = "target"
Last edited by Pixol : 07-07-11 at 05:09 AM.
Pixol is offline Report comment to moderator  
Reply With Quote
Unread 01-01-12, 04:23 AM  
BadWarlock
A Kobold Labourer

Forum posts: 0
File comments: 7
Uploads: 0
Hello! tell me how to add here the ability to change color and size text?
Last edited by BadWarlock : 01-01-12 at 04:25 AM.
BadWarlock is offline Report comment to moderator  
Reply With Quote
Unread 05-29-13, 12:14 PM  
spiralofhope
A Deviate Faerie Dragon
 
spiralofhope's Avatar

Forum posts: 11
File comments: 209
Uploads: 0
I didn't like showing anything when the unit has maximum health.

So I changed healthUpdate:

Lua Code:
  1. local healthUpdate = function(frame, _, unit)
  2.     unit = unit or frame.unit
  3.     local hp = UnitHealth(unit)
  4.     local maxhp = UnitHealthMax(unit)
  5.     if hp == maxhp then
  6.         addon[unit]:SetText("")
  7.     elseif hp > 0 then
  8.         hp = hp / UnitHealthMax(unit) * 100
  9.         addon[unit]:SetFormattedText("%.1f%%", hp)
  10.     else
  11.         addon[unit]:SetText("0%")
  12.     end
  13. end
__________________
spiralofhope.com
spiralofhope is offline Report comment to moderator  
Reply With Quote
Unread 12-06-14, 02:08 AM  
Langepac
A Kobold Labourer

Forum posts: 0
File comments: 97
Uploads: 0
Will there be any update?
Langepac is offline Report comment to moderator  
Reply With Quote
Unread 12-06-14, 07:11 AM  
funkydude
A Deviate Faerie Dragon
 
funkydude's Avatar
AddOn Author - Click to view AddOns

Forum posts: 13
File comments: 423
Uploads: 35
For what exactly? It's already up to date.

Originally Posted by Langepac
Will there be any update?
funkydude is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.