View Single Post
05-18-13, 09:43 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not really sure what you're looking for. The code you posted should work, though you probably want to give it a more useful name so you can access it later:

Code:
f.HealthText = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
f.HealthText:SetPoint("BOTTOM")
Then whenever you want to make it show some other text, just set its text:

Code:
f.HealthText:SetText("15%")
If your text involves any string.format or concatenation, use :SetFormattedText instead of :SetText to move the formatting C-side:

Code:
local currentHealth, maxHealth = UnitHealth("player"), UnitHealthMax("player")
f.HealthText:SetFormattedText("%d/%d", currentHealth, maxHealth)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote