Thread Tools Display Modes
01-14-09, 12:09 PM   #481
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
you also need to register an event for the tag like this
Code:
oUF.Tags["[customtag]"] = function(unit)
  local m, n = UnitHealthMax(unit), UnitHealth(unit)
  return m == 0 and 0 or n ~= m and string.format("-%s|r", (m - n)) or m == n and m
end

oUF.TagEvents["[customtag]"] = "UNIT_HEALTH UNIT_MAXHEALTH"
and to use it something like this
Code:
	local hp = CreateFrame"StatusBar"
	hp:SetHeight(20)
	hp:SetStatusBarTexture(texture)
	hp:SetPoint(top)

	local hpp = hp:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
	hpp:SetPoint("RIGHT", -2, 0)
	hpp:SetTextColor(1, 1, 1)
	self:Tag(hpp, "[customtag]")
	
	hp.bg = hpbg
	self.Health = hp
 
01-14-09, 04:50 PM   #482
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Originally Posted by Bruners View Post
you also need to register an event for the tag like this
Code:
oUF.Tags["[customtag]"] = function(unit)
  local m, n = UnitHealthMax(unit), UnitHealth(unit)
  return m == 0 and 0 or n ~= m and string.format("-%s|r", (m - n)) or m == n and m
end

oUF.TagEvents["[customtag]"] = "UNIT_HEALTH UNIT_MAXHEALTH"
and to use it something like this
Code:
	local hp = CreateFrame"StatusBar"
	hp:SetHeight(20)
	hp:SetStatusBarTexture(texture)
	hp:SetPoint(top)

	local hpp = hp:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
	hpp:SetPoint("RIGHT", -2, 0)
	hpp:SetTextColor(1, 1, 1)
	self:Tag(hpp, "[customtag]")
	
	hp.bg = hpbg
	self.Health = hp
Again Bruners u are a life saver workin great atm cept i keep getting some error with tags in oUF_131 but i think thats a tag problem in my code.. its a unitisdead something lol
__________________
 
01-14-09, 05:27 PM   #483
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Nother question ...
When i right click on my frames and do set focus it comes up with a blizzard only function is there away around this something in the menu drop down that needs to be put in there or fixed?
__________________
 
01-14-09, 05:32 PM   #484
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Alkar View Post
Nother question ...
When i right click on my frames and do set focus it comes up with a blizzard only function is there away around this something in the menu drop down that needs to be put in there or fixed?
Only way to fix that would be to implement a secure menu from scratch.
 
01-14-09, 08:26 PM   #485
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Tag error?

Code:
[2009/01/14 19:25:54-896-x1]: oUF-1.3.1\elements\tags.lua:55: Usage: UnitIsDead("unit")
oUF-1.3.1\elements\tags.lua:55: in function `func'
oUF-1.3.1\elements\tags.lua:193: in function `UpdateTag'
oUF-1.3.1\elements\tags.lua:105: in function <Interface\AddOns\oUF\elements\tags.lua:100>
__________________
 
01-14-09, 08:38 PM   #486
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
Tag error?

Code:
[2009/01/14 19:25:54-896-x1]: oUF-1.3.1\elements\tags.lua:55: Usage: UnitIsDead("unit")
oUF-1.3.1\elements\tags.lua:55: in function `func'
oUF-1.3.1\elements\tags.lua:193: in function `UpdateTag'
oUF-1.3.1\elements\tags.lua:105: in function <Interface\AddOns\oUF\elements\tags.lua:100>
try with a if(not unit) then return end in your tag(s)
 
01-14-09, 08:58 PM   #487
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Alkar View Post
Tag error?

Code:
[2009/01/14 19:25:54-896-x1]: oUF-1.3.1\elements\tags.lua:55: Usage: UnitIsDead("unit")
oUF-1.3.1\elements\tags.lua:55: in function `func'
oUF-1.3.1\elements\tags.lua:193: in function `UpdateTag'
oUF-1.3.1\elements\tags.lua:105: in function <Interface\AddOns\oUF\elements\tags.lua:100>
Explaining where and when and how is always useful .
 
01-14-09, 11:00 PM   #488
Alkar
A Chromatic Dragonspawn
 
Alkar's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 195
Originally Posted by haste View Post
Explaining where and when and how is always useful .
ROFLMAo i figured it out had an extra tag that didnt lead to anything :P
__________________
 
01-15-09, 07:56 AM   #489
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
This commit fixes your issue.
 
01-15-09, 10:13 AM   #490
showbiz
A Kobold Labourer
Join Date: Jan 2009
Posts: 1
Is there a better way to ensure party frames never show up, while in party or raid, than just:
oUF:Spawn('header', 'oUF_Party'):Hide()


Even without the Hide() call the frames don't show up, but I get the feeling there's more that can be done. I notice in ouf.lua that HandleUnit it goes about unregistering events on the party members' frames.. wasn't sure if that would need to be replicated as well.

The end goal is just to use Grid for all party/raid frames, while using say oUF_P3lim for player, target, etc.
 
01-15-09, 10:26 AM   #491
Banur
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 7
Hi there I just started creating an ouf layout because I'm new to lua I started ripping apart a working one (sorry zork/roth its your orb layout).

http://i40.tinypic.com/3ekaq.jpg

As you can see the portrait is to big and not well placed so I'm asking if the pic can be scaled.

Code:
if(unit == 'player' or unit == 'target') then
		self.Portrait = CreateFrame('PlayerModel', nil, self)
		self.Portrait:SetFrameStrata("BACKGROUND")
		self.Portrait:SetPoint('TOPLEFT', 000, 000)
		self.Portrait:SetPoint('BOTTOMRIGHT', 000, 000)
		self.Portrait:SetScale(0.5)
I tried SetScale(0.5) and SetModelScale(0.5) but all it does is mashing the portrait (but I guess I'm using it in the wrong way).
 
01-15-09, 10:31 AM   #492
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Banur View Post
Hi there I just started creating an ouf layout because I'm new to lua I started ripping apart a working one (sorry zork/roth its your orb layout).

http://i40.tinypic.com/3ekaq.jpg

As you can see the portrait is to big and not well placed so I'm asking if the pic can be scaled.

Code:
if(unit == 'player' or unit == 'target') then
		self.Portrait = CreateFrame('PlayerModel', nil, self)
		self.Portrait:SetFrameStrata("BACKGROUND")
		self.Portrait:SetPoint('TOPLEFT', 000, 000)
		self.Portrait:SetPoint('BOTTOMRIGHT', 000, 000)
		self.Portrait:SetScale(0.5)
I tried SetScale(0.5) and SetModelScale(0.5) but all it does is mashing the portrait (but I guess I'm using it in the wrong way).

When you anchor it to two points the points decides its size
 
01-15-09, 10:44 AM   #493
Banur
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 7
Ah of course! That explains the stretching of the pic as I played with the coords. Thanks a lot.
 
01-15-09, 12:54 PM   #494
Waterdark
A Defias Bandit
Join Date: Jan 2009
Posts: 3
hi there, just started messing around with LUA and oUF layouts.

Using Lyn's layout as a base (as it's very nicely splitted into sections), I'm trying to modify it to suit my needs, and I'm currently wondering about castbar coloring.

In a more general way, how can I check if the targeted unit is hostile or friendly? I'd like to have the target's castbar colored blue for friends casting, and red for enemies. Tried something like

Code:
-- check if the target is friendly for a blue bar or hostile for a red one
if (UnitIsFriend("target", "player")) then
	self.Castbar:SetStatusBarColor(0,0,1) --blue
else 
	self.Castbar:SetStatusBarColor(1,0,0)	--red
end
but it always turns out red, even if I target myself.

Any info appreciated, thanks
 
01-15-09, 12:59 PM   #495
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Waterdark View Post
hi there, just started messing around with LUA and oUF layouts.

Using Lyn's layout as a base (as it's very nicely splitted into sections), I'm trying to modify it to suit my needs, and I'm currently wondering about castbar coloring.

In a more general way, how can I check if the targeted unit is hostile or friendly? I'd like to have the target's castbar colored blue for friends casting, and red for enemies. Tried something like

Code:
-- check if the target is friendly for a blue bar or hostile for a red one
if (UnitIsFriend("target", "player")) then
	self.Castbar:SetStatusBarColor(0,0,1) --blue
else 
	self.Castbar:SetStatusBarColor(1,0,0)	--red
end
but it always turns out red, even if I target myself.

Any info appreciated, thanks
UnitIsEnemy(unit, 'player')
 
01-15-09, 10:15 PM   #496
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Im using a XML template to spawn my party targets and pets, but for some reason i cant select or "click" the party pet frame. Party target works fine. Anyone run into this issue?
 
01-15-09, 10:36 PM   #497
Philr
A Defias Bandit
Join Date: Dec 2008
Posts: 3
Originally Posted by Freebaser View Post
Im using a XML template to spawn my party targets and pets, but for some reason i cant select or "click" the party pet frame. Party target works fine. Anyone run into this issue?
Yes. Did you blindly copy the partytarget frame xml and replace 'target' with 'pet' like I did? :-)

This attribute:

Code:
<Attribute name="type1" type="string" value="target"/>
is the action to perform on left-click. 'target' means target the unit. 'pet' means perform a pet action on the unit. Change it back to 'target'. :-)
 
01-15-09, 10:43 PM   #498
Philr
A Defias Bandit
Join Date: Dec 2008
Posts: 3
I'm also using an XML template to spawn partytarget and partypet frames. I'm using range fading on every frame. It seems that the partytarget and partypet frames inherit their alpha value from their parent party frame. Either the range check isn't being called for these frames or the alpha set by it is just overridden. Any way to change this behaviour so I can see when pets are in range independent of their master?
 
01-15-09, 10:43 PM   #499
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Originally Posted by Philr View Post

This attribute:

Code:
<Attribute name="type1" type="string" value="target"/>
is the action to perform on left-click. 'target' means target the unit. 'pet' means perform a pet action on the unit. Change it back to 'target'. :-)
Ah, I see now. Thanks, that was the issue

Last edited by Freebaser : 01-15-09 at 10:54 PM.
 
01-16-09, 07:49 AM   #500
Waterdark
A Defias Bandit
Join Date: Jan 2009
Posts: 3
Originally Posted by p3lim View Post
UnitIsEnemy(unit, 'player')
Thank you for the suggestion, but I tried this, too, without success

Code:
-- check if the target is friendly for a blue bar or hostile for a red one
if (UnitIsEnemy('target', 'player')) then
	self.Castbar:SetStatusBarColor(0.80, 0.01, 0)
else 
	self.Castbar:SetStatusBarColor(0, 0.01, 0.80)			
end

--	original line in Lyn's layout code			
--	self.Castbar:SetStatusBarColor(0.80, 0.01, 0)
I tried various stuff like UnitIsEnemy(unit, 'player'), ('target', 'player') and the like, all to no avail. The "else" branch is always chosen and the bar is colored blue.

I'm feeling quite stumped at this, and I can't see any other parts of the code that may alter this behaviour.

edit: tried on the same mob:
/script if (UnitIsEnemy("target","player")) then SendChatMessage("%t is evil!","SAY"); end;
and the chat message is correctly spammed (but still, cast bar is coloured wrong).

edit 2: tried with if (false) then <set color1> else <set color2> end, and it always chooses color2; if (true) always chooses color1, so I'm quite assured that nothing else is interfering in the colouring process itself. It seems the problem rests in the condition itself. Tried UnitIsPlayer(unit) with no avail, it always goes down the "false" branch even when I'm targeting myself.

Last edited by Waterdark : 01-16-09 at 09:40 AM.
 

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