Reply
 
Thread Tools Display Modes
Old 01-17-13, 01:54 AM   #1
MiRai
A Theradrim Guardian
Join Date: Jul 2011
Posts: 66
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:



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.
MiRai is offline   Reply With Quote
Old 01-17-13, 04:50 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 978
Set a OnValueChanged script handler on the power bar and update the text based on the value it receives.
__________________
「貴方は1人じゃないよ」
haste is offline   Reply With Quote
Old 01-18-13, 06:31 AM   #3
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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
Sauerkraut is offline   Reply With Quote
Old 01-23-13, 05:13 AM   #4
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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..."

Dawn is offline   Reply With Quote
Old 01-23-13, 05:55 PM   #5
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,671
I'd imagine something like this:
Code:
self.Power:HookScript("OnValueChanged", function(bar, value)
     bar.value:SetText(value)
end)
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 01-24-13, 02:29 PM   #6
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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)
Sauerkraut is offline   Reply With Quote
Old 01-24-13, 02:37 PM   #7
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
I can't figure out how to color the text to match the bar. Any ideas would be appreciated.
Sauerkraut is offline   Reply With Quote
Old 01-24-13, 04:06 PM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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 04:09 PM.
Dawn is offline   Reply With Quote
Old 01-24-13, 07:44 PM   #9
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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.
Sauerkraut is offline   Reply With Quote
Old 01-24-13, 08:35 PM   #10
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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..."

Dawn is offline   Reply With Quote
Old 01-24-13, 08:53 PM   #11
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,671
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)
?
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 01-25-13, 04:43 AM   #12
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
Thanks Phanx I'll try that when I get home from work.
Sauerkraut is offline   Reply With Quote
Old 01-25-13, 04:47 AM   #13
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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.
Sauerkraut is offline   Reply With Quote
Old 01-25-13, 03:51 PM   #14
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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.
Sauerkraut is offline   Reply With Quote
Old 01-25-13, 04:26 PM   #15
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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 04:29 PM.
Dawn is offline   Reply With Quote
Old 01-29-13, 04:27 AM   #16
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,289
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.
| Blog | Roth UI | Roth UI FAQ | GoogleCode | Zork | Guild | zorker.de

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

Last edited by zork : 01-29-13 at 04:29 AM.
zork is offline   Reply With Quote
Old 01-29-13, 04:13 PM   #17
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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..."

Dawn is offline   Reply With Quote
Old 01-29-13, 04:44 PM   #18
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,671
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.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 01-29-13, 05:31 PM   #19
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 903
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..."

Dawn is offline   Reply With Quote
Old 01-30-13, 01:36 AM   #20
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,289
Well you can create an invisible statusbar object and use the onValueChanged of that hidden element.
__________________
| Simple is beautiful.
| Blog | Roth UI | Roth UI FAQ | GoogleCode | Zork | Guild | zorker.de

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
zork is offline   Reply With Quote
Reply

Go BackWoWInterface » 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