Thread Tools Display Modes
01-17-13, 02:54 AM   #1
MiRai
A Warpwood Thunder Caller
Join Date: Jul 2011
Posts: 96
Smooth Power Values (Digits)

I wasn't quite sure how to put what I wanted to ask into words, so I made a quick and dirty mock up video. I will recommend that you watch it at a higher resolution than the default 360p embedded resolution:

Video

Is it possible to make the power value digits count 'up' and 'down' like in the video? If so, what would it take to accomplish that? Is this going to be a boatload of work?

To be completely honest, I'm not entirely sure that I'd like this change, but if at all possible, I would like to see it in action on my screen while playing before I can truly make that call. As always, any help is appreciated.

Thanks!

EDIT: Apologies... the layout is oUF_Fail and here is the link.
  Reply With Quote
01-17-13, 05:50 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Set a OnValueChanged script handler on the power bar and update the text based on the value it receives.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
01-18-13, 07:31 AM   #3
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Originally Posted by haste View Post
Set a OnValueChanged script handler on the power bar and update the text based on the value it receives.
Thanks Haste this gave me the starting point I needed to get this working. Really appreciate all the help
  Reply With Quote
01-23-13, 06:13 AM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I really like that. Especially, because I currently use "numbers only" unit frames that work fine but could need some ooomph. Please share the solution.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
01-23-13, 06:55 PM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'd imagine something like this:
Code:
self.Power:HookScript("OnValueChanged", function(bar, value)
     bar.value:SetText(value)
end)
__________________
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
01-24-13, 03:29 PM   #6
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Phanx's way is probably better but...

Code:
	local text = lib.gen_fontstring(f.Health, cfg.font, 18, "OUTLINE")
	text:SetPoint("RIGHT", s.arrow, "LEFT", 6, -8)
	s:SetScript("OnValueChanged", function(self, value)
	text:SetFormattedText("%d", value, 0)
	text:SetJustifyH("RIGHT")
	end)
  Reply With Quote
01-24-13, 03:37 PM   #7
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
I can't figure out how to color the text to match the bar. Any ideas would be appreciated.
  Reply With Quote
01-24-13, 05:06 PM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Sauerkraut View Post
I can't figure out how to color the text to match the bar. Any ideas would be appreciated.
Something along the lines like this should work

Code:
local r, g, b = yourstatusbar:GetStatusBarColor()
and

Code:
yourtext:SetTextColor(r, g, b)
Btw, I'd use HookScript, instead of SetScript.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 01-24-13 at 05:09 PM.
  Reply With Quote
01-24-13, 08:44 PM   #9
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Thanks Dawn, unfortunately all that did was change the color from white to yellow but I think it is a step in the right direction.
  Reply With Quote
01-24-13, 09:35 PM   #10
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I don't know where you put it and how you color said statusbar. I suppose it's class coloured?
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
01-24-13, 09:53 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
self.Power:HookScript("OnValueChanged", function(bar, value)
     bar.value:SetText(value)
     local r, g, b = bar:GetStatusBarColor()
     bar.value:SetTextColor(r, g, b)
end)
?
__________________
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
01-25-13, 05:43 AM   #12
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Thanks Phanx I'll try that when I get home from work.
  Reply With Quote
01-25-13, 05:47 AM   #13
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Originally Posted by Dawn View Post
I don't know where you put it and how you color said statusbar. I suppose it's class coloured?
Oops didn't see this. Dawn, I tried the code in two places within my power bar setup. I can't paste the code atm because I'm at work. The bars are colored by power type, but the text stayed yellow regardless of what class I was playing. I'm sure it is something I have done. I'll try the solution Phanx posted and it it doesn't work I'll post the code. Thanks again I really appreciate the help.
  Reply With Quote
01-25-13, 04:51 PM   #14
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Awesome it works!!! Thank you all so much. There is no way I could have done it without you. I'm still such a noob when it comes to lua.
  Reply With Quote
01-25-13, 05:26 PM   #15
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Would it be possible to incorporate this in a tag?

I'm currently trying to get my head around it, but can't really get to it. Thing is I don't use any bars and therefore no hp or pp functions at all, just tags.

Code:
For instance, this is my health percent tag

oUF.Tags.Methods['GhostHPPerc'] = function(u)
	local m = UnitHealthMax(u)	
	local hp_perc = math.floor(UnitHealth(u)/m*100+.5)

	-- set text color and info
	if(UnitIsDead(u)) then
		return "|CFFB80D20".. "RIP" .."|r"
	elseif(UnitIsGhost(u)) then
		return "|CFFB80D20".. "GHO" .."|r"
	elseif(not UnitIsConnected(u)) then	
		return "|CFFFFFFFF".. "OFF" .."|r"
	elseif(UnitIsTapped(u) and not UnitIsTappedByPlayer(u)) then
		return "|CFF969696".. "TPD" .."|r"	
	elseif(hp_perc <= 60 and hp_perc > 35) then
		return format('|CFFF7F774 %d|r', hp_perc)			
	elseif(hp_perc <= 35 and hp_perc >= 25) then
		return format('|CFFFDEE50 %d|r', hp_perc)
	elseif(hp_perc < 25 and hp_perc >= 20) then
		return format('|CFFFA8200 %d|r', hp_perc)	
	elseif(hp_perc < 20) then
		return format('|CFFB80D20 %d|r', hp_perc)	
	else
		return format('|CFFFFFFFF %d|r', hp_perc)
	end	
	
end
oUF.Tags.Events['GhostHPPerc'] = "UNIT_HEALTH UNIT_MAXHEALTH UNIT_CONNECTION"
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 01-25-13 at 05:29 PM.
  Reply With Quote
01-29-13, 05:27 AM   #16
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Two options.

Try frequent events first.
http://wowprogramming.com/docs/event...EALTH_FREQUENT
http://wowprogramming.com/docs/event...POWER_FREQUENT

If that is not enough use the onUpdate function haste provides. It can be enabled via:
Lua Code:
  1. fontString.frequentUpdates = true

Hope that helps.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 01-29-13 at 05:29 AM.
  Reply With Quote
01-29-13, 05:13 PM   #17
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
My question is how to "incorporate" the "OnValueChanged" visual effect into a tag.

Since I only have self or a font string in my layout, no self.health or power to :HookScript.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
01-29-13, 05:44 PM   #18
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You don't. Your only option with the tag is to unconditionally update it many times per second.

Also, you could easily add a Power bar element to your frame, but give it no dimensions and/or points, thus making it invisible. The only way to run some code when a bar's value changes is to actually have a bar whose value is being changed.
__________________
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
01-29-13, 06:31 PM   #19
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Thanks, that's what I was thinking. I was just hoping that I missed something.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
01-30-13, 02:36 AM   #20
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Well you can create an invisible statusbar object and use the onValueChanged of that hidden element.
__________________
| 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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Smooth Power Values (Digits)

Thread Tools
Display Modes

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