Thread Tools Display Modes
05-15-09, 02:10 AM   #1
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Druid Mana

Hi,

I have a druid mana bar working in my layout, the update is handled this way:

Code:
local function PreUpdatePower(self, event, unit)
	if (self ~= oUF_player) then return end
	local _,class = UnitClass('player')
	if (class ~= "DRUID") then return end

	local p = UnitPowerType('player')
	local min,max = UnitPower('player', SPELL_POWER_MANA), UnitPowerMax('player', SPELL_POWER_MANA)
	
	if (min ~= max) then
		self.DruidManaText:SetFormattedText("|cff8080ff%s|r", number(min))
		self.Power.value:SetPoint("LEFT", self.Health, "LEFT", 2, 5)
	else
		self.DruidManaText:SetText()
	end

	self.DruidMana:SetMinMaxValues(0, max)
	self.DruidMana:SetValue(min)
    
	self.DruidMana:SetAlpha((p ~= 0) and 1 or 0)
	self.DruidManaText:SetAlpha((p ~= 0) and 1 or 0)

	if (p==0) then
		self.Power.value:SetPoint("LEFT", self.Health, "LEFT", 2, 0)
	end
end
Now this is working great, but if the shapeshifted powertype of the druid stops updating (power full or rage empty), the druid mana is not updating anymore either.

So is there anything I can do about that?

so long,
luzzi.

**edit: It's working correctly if I disable frequentUpdates, but that is something I explicitly do not want.

Last edited by Luzzifus : 05-15-09 at 02:16 AM.
  Reply With Quote
05-15-09, 03:18 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Use PostUpdatePower instead of PreUpdatePower?!
__________________
| 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
05-15-09, 03:22 AM   #3
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Same result.
  Reply With Quote
05-15-09, 07:08 AM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
oUF stops updating if the health/power regenerating is stopped (only applies to the frequentUpdate option).
Here is the onupdate script that the power uses, I highlighted the argument check that stops your function from working.
Code:
OnPowerUpdate = function(self)
	if(self.disconnected) then return end
	local power = UnitMana(self.unit)

	if(power ~= self.min) then
		self.min = power

		self:GetParent():UNIT_MAXMANA("OnPowerUpdate", self.unit)
	end
end
Use your own events and handling instead, I would also recommend that you add UPDATE_SHAPESHIFT_FORM to that function.

Last edited by p3lim : 05-15-09 at 09:51 AM.
  Reply With Quote
05-15-09, 09:17 AM   #5
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
I tried to understand that code from oUF but I'm far from it. So I found this one:

Code:
	local power = self.Power
	if(power) then
		if(power.frequentUpdates and (unit == 'player' or unit == 'pet')) then
			power.disconnected = true
			power:SetScript("OnUpdate", OnPowerUpdate)
		else
                ...
Why is power.disconnected set to true if frequentUpdates is active for player and pet? Wouldn't that stop that OnPowerUpdate function from working entirely?

And to use my own handler I'd have to override that SetScript, right?
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Druid 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