I'll answer my own question with the code that does what I was looking to do. There's a bit of extra crap but you should get the picture.
Code:
function Gypsy_PlayerFrameOnLoad ()
-- Health and mana registrations
this:RegisterEvent("UNIT_HEALTH");
this:RegisterEvent("UNIT_MANA");
this:RegisterEvent("UNIT_RAGE");
this:RegisterEvent("UNIT_FOCUS");
this:RegisterEvent("UNIT_ENERGY");
-- If a druid shapeshifts, the bar changes from rage/mana/energy/etc
this:RegisterEvent("UPDATE_SHAPESHIFT_FORMS");
-- Experience registrations
this:RegisterEvent("PLAYER_XP_UPDATE");
this:RegisterEvent("UPDATE_EXHAUSTION");
this:RegisterEvent("PLAYER_LEVEL_UP");
-- Register for variable loading to run our configuration registrations
this:RegisterEvent("VARIABLES_LOADED");
-- Thank me for adding this.
this:RegisterEvent("PLAYER_ENTERING_WORLD");
-- Combat events for coloring the player name
this:RegisterEvent("PLAYER_ENTER_COMBAT");
this:RegisterEvent("PLAYER_LEAVE_COMBAT");
end
Code:
if( event == "UNIT_HEALTH" ) then
Gypsy_ShowPlayerHealth();
Gypsy_ShowPlayerHealthPercent();
return;
end
Code:
function Gypsy_ShowPlayerHealth()
-- This gets the whole status text "Health xxxx / yyyy" - we need to parse it to remove the "Health" part
local text = PlayerFrameHealthBarText:GetText();
if( text == nil ) then
Gypsy_PlayerHealthText:SetText("Failure #1");
else
-- It always says "Health " first, so just remove the first 7 characters off the string
local health = strsub(text, 7);
if(health == nil) then
Gypsy_PlayerHealthText:SetText("Failure #2");
else
Gypsy_PlayerHealthText:SetText(health);
end
end
end