Thread Tools Display Modes
09-28-05, 11:48 AM   #1
ILikeVoltron
A Murloc Raider
 
ILikeVoltron's Avatar
Join Date: Sep 2005
Posts: 4
Get the players HP/Mana?

I'm looking to modify the PlayerFrame to always show HP/MANA numbers, and then eventually either fix the old Gypsy Mod Player Frame .90 Standalone - to work with the 1.0 beta, or write my own unit/player frame mod.

Anyway, how do I show HP/Mana, I'm currently looking at the FrameXML\PlayerFrame.lua and don't see any relevant information.
  Reply With Quote
10-01-05, 02:31 AM   #2
ILikeVoltron
A Murloc Raider
 
ILikeVoltron's Avatar
Join Date: Sep 2005
Posts: 4
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
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Get the players HP/Mana?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off