Thread Tools Display Modes
10-04-10, 05:16 PM   #1
Elendhriel
A Deviate Faerie Dragon
Join Date: Jan 2010
Posts: 13
HolyPower Code

Hi, could anyone share the code to show the HolyPower as numbers 1-2-3 next to the player frame for example. Thanks.
  Reply With Quote
10-04-10, 05:54 PM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
The easiest way to do this would be with a custom tag.

The event you want to update the tag is 'UNIT_POWER'.

The API call to retrieve the holy power value is UnitPower. You can check the usage of the API from the HolyPower element.
  Reply With Quote
10-05-10, 01:02 AM   #3
Elendhriel
A Deviate Faerie Dragon
Join Date: Jan 2010
Posts: 13
Thanks, thing is I only just started 2 days ago playing with oUF and would really like some working piece of code to see and learn from it and change it to my needs
  Reply With Quote
10-05-10, 05:27 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Check http://www.wowinterface.com/download...ettoPower.html it has it all. Meaning all the events and such you need for your custom tags.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
10-10-10, 02:24 AM   #5
Karudon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 15
Code:
_, myclass = UnitClass("player") 

if (myclass == "WARLOCK" or myclass == "PALADIN") then
	
				local bars = CreateFrame("Frame", nil, self)
				bars:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, Scale(5))
				if lowversion then
					bars:SetWidth(Scale(186))
				else
					bars:SetWidth(Scale(fWidth))
				end
				bars:SetHeight(Scale(8))
                

				for i = 1, 3 do					
					bars[i]=CreateFrame("StatusBar", self:GetName().."_Shard"..i, self)
					bars[i]:SetHeight(Scale(5))					
					bars[i]:SetStatusBarTexture(normTex)
					bars[i]:GetStatusBarTexture():SetHorizTile(false)

					bars[i].bg = bars[i]:CreateTexture(nil, 'BORDER')
                    

                    
					if myclass == "WARLOCK" then
						bars[i]:SetStatusBarColor(255/255,101/255,101/255)
						bars[i].bg:SetTexture(255/255,101/255,101/255)
					elseif myclass == "PALADIN" then
						bars[i]:SetStatusBarColor(228/255,225/255,16/255)
						bars[i].bg:SetTexture(228/255,225/255,16/255)
					end
					
					if i == 1 then
						bars[i]:SetPoint("LEFT", bars)
						if lowversion then
							bars[i]:SetWidth(Scale(fWidth/3 - 4.8))
						else
							bars[i]:SetWidth(Scale(fWidth/3 - 4.8)) -- setting SetWidth here just to fit fit 250 perfectly
						end
						bars[i].bg:SetAllPoints(bars[i])
					else
						bars[i]:SetPoint("LEFT", bars[i-1], "RIGHT", Scale(7), 0)
						if lowversion then
							bars[i]:SetWidth(Scale(fWidth/3 - 4.8))
						else
							bars[i]:SetWidth(Scale(fWidth/3 - 4.8)) -- setting SetWidth here just to fit fit 250 perfectly
						end
						bars[i].bg:SetAllPoints(bars[i])
					end
					
					bars[i].bg:SetTexture(normTex)					
				end
				
				if myclass == "WARLOCK" then
					bars.Override = UpdateShards				
					self.SoulShards = bars
				elseif myclass == "PALADIN" then
					bars.Override = UpdateHoly
					self.HolyPower = bars
				end
			end
tukui code, just remove scale() and change width and heigh
  Reply With Quote
10-26-10, 10:30 AM   #6
Aerials
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 92
Don't forget drooders!!! O.o their powertype is #8
  Reply With Quote
10-26-10, 11:37 AM   #7
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Druid-Eclipse-bar is not the candidate to be displayed as text, is it?

I would guess most oUF-authors will create a bar for this^^
__________________
  Reply With Quote
10-26-10, 11:57 AM   #8
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Mischback View Post
Druid-Eclipse-bar is not the candidate to be displayed as text, is it?

I would guess most oUF-authors will create a bar for this^^
I want that too, i dont like a that bar!

but i have text for shards/holypower i chould share


Code:
-- Thanks Neverg For HolyPower/Shards.
oUF.Tags["Aftermathh:HolyPower"] = function(unit)
	
	local hp = UnitPower('player', SPELL_POWER_HOLY_POWER)
	local str
		
	if hp == 1 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 2 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 3 then
		str = string.format("|c50f58cba%d|r",hp)
	else
		str = ""
	end
		
	return str
end
oUF.TagEvents["Aftermathh:HolyPower"] = "UNIT_POWER"
Code:
		if(class == "PALADIN") then
			local HolyPower = self:CreateFontString(nil, 'OVERLAY')
			HolyPower:SetPoint('CENTER', self, 'RIGHT', 17, -2)
			HolyPower:SetFont(font, 24, "OUTLINE")
			HolyPower:SetShadowOffset(1, -1)
			HolyPower:SetJustifyH('CENTER')
			self:Tag(HolyPower, '[Aftermathh:HolyPower]')
		end

Last edited by Aftermathhqt : 10-26-10 at 12:05 PM.
  Reply With Quote
10-26-10, 01:03 PM   #9
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Originally Posted by Game92 View Post
I want that too, i dont like a that bar!
There is a default tag for the eclipse value, try using it. If you don't like the default tag, write a custom tag based upon it.

Originally Posted by Game92 View Post
but i have text for shards/holypower i chould share


Code:
-- Thanks Neverg For HolyPower/Shards.
oUF.Tags["Aftermathh:HolyPower"] = function(unit)
	
	local hp = UnitPower('player', SPELL_POWER_HOLY_POWER)
	local str
		
	if hp == 1 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 2 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 3 then
		str = string.format("|c50f58cba%d|r",hp)
	else
		str = ""
	end
		
	return str
end
oUF.TagEvents["Aftermathh:HolyPower"] = "UNIT_POWER"
bad tag is bad.

Code:
oUF.Tags["Aftermathh:HolyPower"] = function(unit)

	local hp = UnitPower('player', SPELL_POWER_HOLY_POWER)

	if hp > 0 then
		return string.format("|c50f58cba%d|r", hp)
	end
end
oUF.TagEvents["Aftermathh:HolyPower"] = "UNIT_POWER"
  Reply With Quote
10-26-10, 03:19 PM   #10
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Could one of the oUF-devs please aid me with a tip... It's totally off-topic, but should I consider working with tags instead of PostUpdate-functions and what would be the benefit?

Currently, I'm handling HP- / Power-texts in PostUpdate-hooks, since I really like the total control of what is displayed.
Would it be faster (in terms of addon performance) to use tags instead? Or is it merely a more "editable"-way of doing stuff?
__________________
  Reply With Quote
10-26-10, 03:43 PM   #11
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Handling text updates yourself will be the quickest method, in terms of CPU usage (especially if you do all you related updates together, e.g. health bar and health text). The problem is that this method will mean that any code you produce has added maintenance complexity.

The tags element is there to simplify the updating of text on your unit frames, but in doing so there is some processing overhead. This overhead should not be enough to affect your in-game experience, so it is recommended to uses tags for code maintainability and readability reasons.
  Reply With Quote
10-26-10, 03:47 PM   #12
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Thank you, yj589794!

In terms of complexity, I'm perfectly able to handle my hooks, since I tried (and until now succeeded) in commenting everything - enough.

I'll stick to this method until I encounter problems!
__________________
  Reply With Quote
10-26-10, 04:37 PM   #13
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Originally Posted by Game92 View Post

Code:
-- Thanks Neverg For HolyPower/Shards.
oUF.Tags["Aftermathh:HolyPower"] = function(unit)
	
	local hp = UnitPower('player', SPELL_POWER_HOLY_POWER)
	local str
		
	if hp == 1 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 2 then
		str = string.format("|c50f58cba%d|r",hp)
	elseif hp == 3 then
		str = string.format("|c50f58cba%d|r",hp)
	else
		str = ""
	end
		
	return str
end
oUF.TagEvents["Aftermathh:HolyPower"] = "UNIT_POWER"
Like vj pointed out, you don't need your tag like that. First remove the str="" at the end, it's not doing anything. Then you don't need conditionals if you are always outputing the same formating. Use what he gave you.
__________________
My oUF Layout: oUF Lumen
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » HolyPower Code


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