Thread Tools Display Modes
08-19-14, 08:23 PM   #1
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
... how would I go around to fetch time remaning and aura name for two fontstrings?
Did some google-ing, could'nt find any real answer on how to fetch these strings
You'd get them from UnitAura. Assuming you wanted to show that info on the bars, you'd want to create the font strings in the PostCreateIcon function, something like:

Code:
	local time = bar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	time:SetPoint("RIGHT", -4, 0)
	bar.time = time

	local name = bar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
	name:SetPoint("LEFT", 4, 0)
	name:SetPoint("RIGHT", time, "LEFT", -2, 0)
	bar.name = name
Then in the PostUpdateAura function, use the values you're already getting from UnitAura. Set the name font string to display the name in the same place, and for auras with no duration, make sure you clear the time text. Then, update the time text in the OnUpdate function; it'll have a lot of digits after the decimal point, so you'll want to use SetFormattedText to restrict it to the number of decimal values you actually want to show.
__________________
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
08-20-14, 06:52 AM   #2
Kygo
A Theradrim Guardian
 
Kygo's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 64
Originally Posted by Phanx View Post
You'd get them from UnitAura. Assuming you wanted to show that info on the bars, you'd want to create the font strings in the PostCreateIcon function, ..
Added.
Did react to something (maybe it's supposed to happen?) when i wrote this
(Using Notepad++ with language set to LUA)
Code:
local time = bar:CreateFontString..
time:SetPoint..
time:SetTextcolor..
bar.time = time
Originally Posted by Phanx View Post
Then in the PostUpdateAura function, use the values you're already getting from UnitAura. Set the name font string to display the name in the same place.
Are you refering to "local function auras_PostUpdateIcon.."? If you're not, then I have missed that one.

Originally Posted by Phanx View Post
..use SetFormattedText ..
Alright. So something like this: "time:SetFormattedText(m:s)" ? (Havent gotten this far yet, still trying to figure half of this out )
  Reply With Quote
08-20-14, 08:49 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Kygo View Post
Did react to something (maybe it's supposed to happen?) when i wrote this
(Using Notepad++ with language set to LUA)
There is a global "time" function in Lua. Since you're not using it anywhere in your code, it doesn't matter, but if you prefer your editor not highlight it as a built-in global, just use another name.

Originally Posted by Kygo View Post
Are you refering to "local function auras_PostUpdateIcon.."?
Yes.

Originally Posted by Kygo View Post
So something like this: "time:SetFormattedText(m:s)" ?
fontstring:SetFormattedText(...) is the same as (but faster than) doing fontstring:SetText(string.format(...)) so just refer to the documentation for string.format to see what arguments you need to provide:

http://wowpedia.org/API_format
https://www.gnu.org/software/libc/ma...nt-Conversions

Or just look at other addons that display formatted time strings:

https://github.com/haste/oUF/blob/ma...stbar.lua#L371
__________________
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

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF_Kygo, a few tips wanted


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