Thread Tools Display Modes
05-08-09, 01:13 AM   #1
kip
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 7
Tags and Events

hey,

I'm trying to make my first oUF Layout. I'm using P3Lim's Layout as basis, but I'm having some problems to understand the tag system.

Following P3lim's example, I created a custom tag to show the combo-points.
The code looks like this:

Code:
oUF.TagEvents['[customcpoints]'] = 'UNIT_TARGET UNIT_COMBO_POINTS'
oUF.Tags['[customcpoints]'] = function(unit)
   -- if (unit ~= 'player') then return end
   local cp = GetComboPoints('player', 'target')
   local sw = {
      [1] = '|cFFFFFFFF%s',
      [2] = '|cFFFFFFFF%s',
      [3] = '|cFFebee14%s',
      [4] = '|cFFf4aa0b%s',
      [5] = '|cFFf40b0b%s',
   }
   if (cp > 0) then return format(sw[cp], cp)
   else return end  
end
...

Code:
   if (unit == 'target') then
   
		local comp = self:CreateFontString(nil, 'OVERLAY')
		comp:SetFont(font, fsize, 'OUTLINE')
		comp:SetPoint('LEFT', self, 'RIGHT', 10, 0)
		self:Tag(comp, '[customcpoints]')
   
   end
But this doesn't really work. If I just attack my target it shows nothing. If I clear my target during combat and retarget the mob it shows "something" (most of the time a false value ... e.g. if I should have 1 CP it display 2 or 3 or something like that).
Can somebody tell me what I'm doing wrong?

thanks!

P.S.: I saw that p3lim uses another way to display the combopoints, but this is kind of an experiment to understand and get used to the tag-system.
  Reply With Quote
05-08-09, 06:35 AM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Those false values might be that you have talents or glyphs that might give you more than 1 combopoint per special attack.

Dont create the table inside the function, it uses more memory that way.
Also, end your colors by using '|r'

Code:
local sw = {
	[1] = '|cFFFFFFFF%s|r',
	[2] = '|cFFFFFFFF%s|r',
	[3] = '|cFFebee14%s|r',
	[4] = '|cFFf4aa0b%s|r',
	[5] = '|cFFf40b0b%s|r',
}

oUF.TagEvents['[customcp]'] = 'UNIT_TARGET UNIT_COMBO_POINTS'
oUF.Tags['[customcp]'] = function(unit)
	if(unit == 'player' or unit == 'vehicle') then -- you want this to work with both you and your vehicle
		local cp = GetComboPoints(unit, 'target')
		return cp > 0 and format(sw[cp], cp)
	end
end
This should work
  Reply With Quote
05-08-09, 08:33 AM   #3
kip
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 7
Thank you, you put me on the right track! I used the tag inside the "target" definition, that can't work

So, in addition to your improvements, I changed it from

Code:
   if (unit == 'target') then
   
		local comp = self:CreateFontString(nil, 'OVERLAY')
		comp:SetFont(font, fsize, 'OUTLINE')
		comp:SetPoint('LEFT', self, 'RIGHT', 10, 0)
		self:Tag(comp, '[customcpoints]')
   
   end
to

Code:
   if (unit == 'player') then
   
		local comp = self:CreateFontString(nil, 'OVERLAY')
		comp:SetFont(font, fsize, 'OUTLINE')
		comp:SetPoint('LEFT', self, 'RIGHT', 10, 0)
		self:Tag(comp, '[customcpoints]')
   
   end
that. Now it works great!

But I have a another, very simillar problem. I've created a custom tag to display the creature type. Here's the code:

Code:
local creatures = {
   Humanoid = 'Hu',
   Dragonkin = 'Dragon',
   Elemental = 'Ele',
   Undead = 'Ud',
   Critter = 'Crit',
   Mechanical = 'Mech',
   ["Not specified"] = 'N/A',
   ["Non-combat Pet"] = 'Pet',
   ["Gas Cloud"] = 'Gas',
}
oUF.TagEvents['[customcreature]'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION UNIT_CLASSIFICATION_CHANGED'
oUF.Tags['[customcreature]'] = function(unit)
   local ct = UnitCreatureType(unit)
   return (creatures[ct] or ct)
end
...

Code:
   if (unit ~= 'targettarget') then
   
      local ctype = self.Health:CreateFontString('nil', 'OVERLAY')
      ctype:SetFont(font, fsize-2, 'OUTLINE')
      ctype:SetPoint('RIGHT', self, 0, 30)
      self:Tag(ctype, '[customcreature]')
   
   end
It works well, but it doesn't update if the creature type changed. I'm making this layout mainly for my druid. If I switch into cat and reload UI, it say's "Beast". But when I switch from cat to caster (without reloading the UI), it still says "Beast" [Of cause if I'm in caster stance and reload UI it says "Hu", but it then doesn't change to "Beast" if I switch into cat]. Any idea why the tag isn't updated?

(This bug doesn't bother me too much, but since I make this layout to learn something about lua and oUF, I would be really happy to know what causes this behavior)

Last edited by kip : 05-08-09 at 08:37 AM.
  Reply With Quote
05-09-09, 06:32 AM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
You havent specified the whole list of possible creature types.

Anyways, add this event: 'UPDATE_SHAPESHIFT_FORM'
  Reply With Quote
05-09-09, 09:30 AM   #5
kip
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 7
Originally Posted by p3lim View Post
You havent specified the whole list of possible creature types.
Yeah I know, that's on purpose. I only specified the types I want to truncate. All others are passed through.


Originally Posted by p3lim View Post
Anyways, add this event: 'UPDATE_SHAPESHIFT_FORM'
Didn't help :<
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Tags and Events


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