View Single Post
05-19-13, 02:34 PM   #9
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 583
Anyways I got it working now for the value text, how do I get it to show percentage as well? (I honestly can't find information on it so I'm sorry to bother you guys)

I imagine it's simply just make another frame for the text but rather than using "%d/%d" just use something else (not sure what though)
Lua Code:
  1. local currentHealthPercent, maxHealthPercent = UnitHealth("player"), UnitHealthMax("player")
  2. f.HealthPercentText:SetFormattedText("%d/%d", currentHealthPercent, maxHealthPercent)
  3. --Updates the status bar to new health
  4. local function update(self)
  5.   local unit = self.unit
  6.   --update health percentage text
  7.   local currentHealthPercent, maxHealthPercent = UnitHealth("player"), UnitHealthMax("player")
  8.   f.HealthPercentText:SetFormattedText("%d/%d", currentHealthPercent, maxHealthPercent)
  9.   --update health value text
  10.   local currentHealth, maxHealth = UnitHealth("player"), UnitHealthMax("player")
  11.   f.HealthText:SetFormattedText("%d/%d", currentHealth, maxHealth)
  12. end
  13. f:SetScript("OnEvent",update)
  14. f:RegisterUnitEvent("UNIT_HEALTH",f.unit)
  15. f:RegisterUnitEvent("UNIT_POWER",f.unit)
__________________
Tweets YouTube Website

Last edited by 10leej : 05-19-13 at 02:38 PM.
  Reply With Quote