Thread Tools Display Modes
01-31-09, 12:12 PM   #601
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Doesn't self.Buffs.onlyShowPlayer = true do the trick?
 
01-31-09, 12:15 PM   #602
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by MoonWitch View Post
Perhaps I am being thick for once ...

self.Buffs.filter = "PLAYER"

Can someone be nice and explain those filters... I just wanna see those *I* placed on the people, or is this no longer possible? (It helps me in knowing who's about to fall without a certain buff). If it's not possible, I guess I'll be working with the tag system
This parameter can be any of "HELPFUL", "HARMFUL", "PLAYER", "RAID", "CANCELABLE", "NOT_CANCELABLE". You can also specify several filters separated by a space or | character to chain multiple filters together (e.g. "HELPFUL|RAID" == helpful buffs that you can cast on your raid). By default UnitAura has "HELPFUL" as an implicit filter - you cannot get back BOTH helpful and harmful at the same time. Neither "HELPFUL" or "HARMFUL" have meaning for UnitBuff/UnitDebuff, and will be ignored.

Quoted from WoWWiki: http://www.wowwiki.com/API_UnitAura
 
01-31-09, 12:22 PM   #603
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by haste View Post
Doesn't self.Buffs.onlyShowPlayer = true do the trick?
Tried it, I still saw all buffs. I'll give it another try.

Originally Posted by p3lim View Post
This parameter can be any of "HELPFUL", "HARMFUL", "PLAYER", "RAID", "CANCELABLE", "NOT_CANCELABLE". You can also specify several filters separated by a space or | character to chain multiple filters together (e.g. "HELPFUL|RAID" == helpful buffs that you can cast on your raid). By default UnitAura has "HELPFUL" as an implicit filter - you cannot get back BOTH helpful and harmful at the same time. Neither "HELPFUL" or "HARMFUL" have meaning for UnitBuff/UnitDebuff, and will be ignored.

Quoted from WoWWiki: http://www.wowwiki.com/API_UnitAura
Yeah I know. I know which filters are possible, I just didn't see a difference when using "PLAYER", "RAID" or anything else, so figured I was doing something wrong.
 
01-31-09, 12:26 PM   #604
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by MoonWitch View Post
Tried it, I still saw all buffs. I'll give it another try.
Then that's a bug. I'll see if I can poke anyone to look into it for me.
 
01-31-09, 05:51 PM   #605
MoonWitch
A Firelord
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 455
Originally Posted by haste View Post
Then that's a bug. I'll see if I can poke anyone to look into it for me.
It's ok - it does work. I hadn't commented out a previous filter :P Sorry.
 
01-31-09, 10:47 PM   #606
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Originally Posted by Alkar View Post
Tried that .. first thing i thought of but for some reason it does nothing turns the border back to black no class color at all. wonder if im having a conflict somewhere :P
try with

Code:
local updateHealth = function(self, event, unit, bar, min, max)
	local r, g, b
	local class = select(2, UnitClass(unit))
	r = RAID_CLASS_COLORS[class].r
	g = RAID_CLASS_COLORS[class].g
	b = RAID_CLASS_COLORS[class].b
	if class then
		self:SetBackdropColor(r, g, b)
	else 
		self:SetBackdropColor(0, 0, 0)
	end
end
and then call it with self.PostUpdateHealth = updateHealth in your style func
obviously you would have to have a self:SetBackdrop() somewhere
 
02-01-09, 02:22 AM   #607
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Using local _, class = UnitClass(unit) is about twice as fast as local class = select(2, UnitClass(unit)) in that situation. You'll probably also want to move the if check above the table indexing.
 
02-01-09, 03:45 AM   #608
grimman
A Fallenroot Satyr
 
grimman's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 28
I'm really miffed by this. I see lots of people using select() to do various stuff, lua.org has a bunch of examples using select() and Slouken shows up more than once on google giving examples... but I just can't use it.
Code:
function dummyfunction()
print(select(2, UnitClass("player")))
end
That code throws an error (something to do with select, I don't remember the exact wording).
Using it with /script print(select(1, UnitClass("player"))) just gives me "Paladin PALADIN", which isn't even the expected output (though the class is obviously right). wth am I doing wrong?

I only tried this stuff because I was curious about your statement, haste. For the record, I can do local _,class=UnitClass("player") ~1m times per second. Even if select() was twice as slow/fast/whatever (and worked!) it wouldn't be likely to impact anything unless the coder is an outright idiot.
 
02-01-09, 04:26 AM   #609
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by grimman View Post
I'm really miffed by this. I see lots of people using select() to do various stuff, lua.org has a bunch of examples using select() and Slouken shows up more than once on google giving examples... but I just can't use it.
Code:
function dummyfunction()
print(select(2, UnitClass("player")))
end
That code throws an error (something to do with select, I don't remember the exact wording).
That doesn't throw an error.
Originally Posted by grimman View Post
Using it with /script print(select(1, UnitClass("player"))) just gives me "Paladin PALADIN", which isn't even the expected output (though the class is obviously right). wth am I doing wrong?
And that's not the expected behavior. It behaves correctly, you select the first return and all after.
Originally Posted by grimman View Post
I only tried this stuff because I was curious about your statement, haste. For the record, I can do local _,class=UnitClass("player") ~1m times per second. Even if select() was twice as slow/fast/whatever (and worked!) it wouldn't be likely to impact anything unless the coder is an outright idiot.
Many small steps make a leap. It was really just meant as a minor tips on what you should avoid doing.

Then again using select() can avoid some odd cases like local _ b = UnitClass'player' and such.
 
02-01-09, 02:53 PM   #610
grimman
A Fallenroot Satyr
 
grimman's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 28
Originally Posted by haste View Post
That doesn't throw an error.

Many small steps make a leap. It was really just meant as a minor tips on what you should avoid doing.
Here's something everyone should know: Don't code right before going to bed. :P
K, so as it turns out I was being a right idiot. My test function had (iterations, select) and a bunch of other variables, so naturally they overrode the select function like that.
As for the test data, what I reported was also wrong.
local _,class=UnitClass("player") -> ~4m times per second (off by a factor of 4! :P)
local class=select(2,UnitClass("player")) -> ~2.6m times per second

So yes, your data was pretty much right. Also, I absolutely think optimizing where possible is a good idea, and in this case it's not really much of a hassle either. MY point was that the difference is minimal for select, at least for a small amount of operations.
 
02-02-09, 11:27 AM   #611
jadakren
A Flamescale Wyrmkin
 
jadakren's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 103
Theory, Treat TemporaryEnchants as buff auras.

practice:

Code:
local function PreUpdateAura(self, event, unit)
	if(unit == 'player')then
		local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = GetWeaponEnchantInfo();
		TemporaryEnchantFrameWidth = ( (hasMainHandEnchant and 1 or 0) + (hasOffHandEnchant and 1 or 0) )*self.Buffs.size
		TemporaryEnchantFrame:SetWidth((TemporaryEnchantFrameWidth > 0) and TemporaryEnchantFrameWidth or 1)
		
	end
end
Somewhere in style func both can be found :

Code:
self.PreUpdateAura = PreUpdateAura
Code:
if unit == "player" then
		TemporaryEnchantFrame:ClearAllPoints()
		TemporaryEnchantFrame:SetPoint("RIGHT",self,"LEFT",-5,0)
		TemporaryEnchantFrame:Show()
		
		TempEnchant2Duration:ClearAllPoints()
		TempEnchant2Duration:SetPoint("CENTER",TempEnchant2,"CENTER",0,0)
		TempEnchant2Border:Hide()
		
		TempEnchant1Duration:ClearAllPoints()
		TempEnchant1Duration:SetPoint("CENTER",TempEnchant1,"CENTER",0,0)
		TempEnchant1Border:Hide()
		
		self.Buffs:SetPoint(self.Buffs.anchorFrom, TemporaryEnchantFrame, self.Buffs.anchorTo,self.Buffs.anchorX,self.Buffs.anchorY)

		TempEnchant1:SetHeight(self.Buffs.size)
		TempEnchant1:SetWidth(self.Buffs.size)
		TempEnchant2:SetHeight(self.Buffs.size)
		TempEnchant2:SetWidth(self.Buffs.size)
		
		TemporaryEnchantFrame:SetHeight(self.Buffs.size)
end
These are variables used in m createBuffFrame function i repeat throughout my layout.

Code:
self.Buffs.anchorFrom, self.Buffs.anchorTo, self.Buffs.anchorX,self.Buffs.anchorY

Idea is to have the TemporaryEnchantFrame inline with my buffs and only visible when there are weapon buffs.

I also had some other code to remove various fluff on the TemporaryEnchantFrame but the above code should give you an idea of what i was trying to achieve without modifying any of hastes aura.lua


I also wanted cooldown/time-remaining timers on debuffs/buffs without running another mod, unfortunatly unless I modified the aura.lua the time remaining would be incorrect when i recalled UnitAura withingh the update function in my layout :

+ have the count fontString created on the cooldown texture
Code:
local count = cd:CreateFontString(nil, "OVERLAY")
+ create three additional variables on each icon within aura.lua:update():

Code:
	icon.isPlayer = isPlayer
	icon.duration = duration
	icon.timeLeft = timeLeft
and then use a function similar to :

Code:
local DAY, HOUR, MINUTE, SHORT = 86400, 3600, 60, 5 --values for time

local UsingMMSS = false
local useCooldownTimers = true
local useEnlargedFonts = true
local cooldownTimerStyle = {

	short = {r = 1, g = 0, b = 0, s = 1.025}, -- <= 5 seconds

	secs = {r = 1, g = 1, b = 0.4, s = 1}, -- < 1 minute

	mins = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 minute

	hrs = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 hr

	days = {r = 0.8, g = 0.8, b = 0.9, s = 1}, -- >= 1 day

}


local function GetFormattedTime(s)

	if s >= DAY then

		return format('%dd', floor(s/DAY + 0.5)), s % DAY

	elseif s >= HOUR then

		return format('%dh', floor(s/HOUR + 0.5)), s % HOUR

	elseif s >= MINUTE then

		if s <= MINUTE*3 and UsingMMSS then

			return format('%d:%02d', floor(s/60), s % MINUTE), s - floor(s)

		end

		return format('%dm', floor(s/MINUTE + 0.5)), s % MINUTE

	elseif s > 2 then
		return floor(s + 0.5), s - floor(s)
	end
	return format("%0.1f", s), 0.1
end
local function GetFormattedFont(s)
	local style = cooldownTimerStyle

	if s > DAY then
 
		style = style.days

	elseif s > HOUR then

		style = style.hrs

	elseif s > MINUTE then

		style = style.mins

	elseif s > SHORT then

		style = style.secs

	else

		style = style.short

	end

	return style.s, style.r, style.g, style.b

end
local function PostCreateAuraIcon(self, button, icons, index, debuff)
	button.cd:SetReverse()
	button.overlay:SetTexture(border)
	button.overlay:SetTexCoord(0, 1, 0, 1)
	button.overlay.Hide = function(self) self:SetVertexColor(0.25, 0.25, 0.25) end

	if(button.isPlayer)then
		button:SetWidth((button.debuff and self.Debuffs.mySize or self.Buffs.mySize))
	end
	
	button.count:SetFont(font, '10', "OUTLINE")
	button.count:SetPoint("CENTER",button,"BOTTOM",0,-2)
	if (not debuff) then
		button:SetScript('OnMouseUp', function(self, mouseButton)
			if mouseButton == 'RightButton' then
				CancelUnitBuff('player', index)
			end
		end)
	end

	if(useCooldownTimers)then
		local remaining = button.cd:CreateFontString(nil, "OVERLAY")
			  remaining:SetFont(font, '10', "OUTLINE")
			  remaining:SetPoint("CENTER", button, 4, 4)
			  remaining:SetJustifyH("CENTER")
			  remaining:SetText('')
		button.remaining = remaining
		
		button:SetScript('OnUpdate', function(self,event)
			if(self.duration > 0 or self.timeLeft > 0) then	
				local timeLeft = self.timeLeft - GetTime()
				local _,fontSize,_ = remaining:GetFont()
				local size, r, g, b = GetFormattedFont(timeLeft)
				remaining:SetText(GetFormattedTime(timeLeft)) 
				remaining:SetFont(font, (useEnlargedFonts and fontSize * size or fontSize), 'outline')
				remaining:SetTextColor(r,g,b)
			end			
		end)
	end
end
haste :
If you are aware of a way that i can retrieve the info for those three variables i created inside 'aura.lua:updateIcon()' without having to call UnitAura a second time, i would be greatful.

I found that my temporaryEnchant hack didn't update when weapon buffs were present or not due to them not firing the unit_aura event, any suggestions on this ?

Last edited by jadakren : 02-02-09 at 12:05 PM.
 
02-02-09, 12:05 PM   #612
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by jadakren View Post
Theory, Treat TemporaryEnchants as buff auras.
haste :
If you are aware of a way that i can retrieve the info for those three variables i created inside 'aura.lua:updateIcon()' without having to call UnitAura a second time, i would be greatful.

I found that my temporaryEnchant hack didn't update when weapon buffs were present or not due to them not firing the unit_aura event, any suggestions on this ?
1. You could proxy :SetCooldown() for two of the variables. isPlayer can be added however.
2. Two possible solutions: a) watch the combat log b) on update polling.
 
02-03-09, 04:09 PM   #613
coree
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 28
I am trying to filter out some debuffs (i.e "Exhaustion" and "Recently Bandaged").

That's what i have:

Code:
local dblacklist = {
[1] = 57723, --Exhaustion
[2] = 11196, -- Recently Bandaged
}

local function PostUpdateAuraIcon(self, icons, unit, icon, index, offset, filter, debuff)
  if(debuff) then		
    for index, value in ipairs(dblacklist) do
      local name, _, _, _, _, _, _, _, _ = GetSpellInfo(value)
      for i=1, 40, 1 do
        local dname, _, _, _, _, _, _, _, _ = UnitAura("player", i, filter);
        if dname == name then
            icon:Hide()
        end
      end
    end
  end
end
But, now all debuffs will be hidden. So i need some help to hide the debuffs from the blacklist only. Any idea ? thanks in advance
 
02-03-09, 05:31 PM   #614
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
:PostUpdateAuraIcon() is called for every aura icon oUF shows. Your running your check on every single icon, thus hiding it.
 
02-03-09, 08:45 PM   #615
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Is there away to shorten target names? like say the mob name yousuckatthisto
can be cut down to yousuck lol i have names that are to long for my frames just wondering if i can condence them
__________________
 
02-03-09, 10:10 PM   #616
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Originally Posted by Alkar View Post
Is there away to shorten target names? like say the mob name yousuckatthisto
can be cut down to yousuck lol i have names that are to long for my frames just wondering if i can condence them
Code:
oUF.Tags["[shortname]"] = function(unit)
	return string.sub(UnitName(unit), 0, 12) or ""
end
 
02-04-09, 04:37 AM   #617
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
As of 1.3.2 tags should return nil (ie. nothing) when they fail. oUF uses this to determine if the tag should have a prefix/affix. It also adds the "" if not.

Another note is that string.sub is byte based, and not character. This has discussed numerous times before however.
 
02-04-09, 09:40 AM   #618
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Originally Posted by Bruners View Post
Code:
oUF.Tags["[shortname]"] = function(unit)
	return string.sub(UnitName(unit), 0, 12) or ""
end
Originally Posted by haste View Post
As of 1.3.2 tags should return nil (ie. nothing) when they fail. oUF uses this to determine if the tag should have a prefix/affix. It also adds the "" if not.

Another note is that string.sub is byte based, and not character. This has discussed numerous times before however.
So what you are saying is that it should be like this?
Code:
oUF.Tags["[shortname]"] = function(unit)
	if(not unit) then return end
	return string.sub(UnitName(unit), 0, 12)
end
or just return the output?

Last edited by Bruners : 02-04-09 at 09:45 AM.
 
02-04-09, 10:16 AM   #619
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Again that works perfect thank ya haste and bruners man i just dont know what to say you guys have been a on of help for me
__________________
 
02-04-09, 10:33 AM   #620
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Alkar View Post
Is there away to shorten target names? like say the mob name yousuckatthisto
can be cut down to yousuck lol i have names that are to long for my frames just wondering if i can condence them
If you restrict the size of your fontstring then it will automatically shorten the string. You can do this by setting the width using :SetWidth() or by anchoring the right hand side of the fontstring using :SetPoint().
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - Layout discussion


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