Reply
Thread Tools Display Modes
Unread 09-12-09, 01:21 AM   #1
Icerat
A Fallenroot Satyr
Join Date: Sep 2006
Posts: 28
PvP Icon

I'm fairly new to lua and ouf but have worked out how to customize and get what i want out of an oUF_coree layout i been playing with.

At the moment im using
Code:
--	PVP Icon
	if (unit == "player" or unit == "target") then
		self.PvP = self.Health:CreateTexture(nil, "OVERLAY")
		local faction = PvPCheck
			if faction == "Horde" then
				self.PvP:SetTexCoord(0.08, 0.58, 0.045, 0.545)
			elseif faction == "Alliance" then
				self.PvP:SetTexCoord(0.07, 0.58, 0.06, 0.57)
			else
				self.PvP:SetTexCoord(0.05, 0.605, 0.015, 0.57)
			end
		self.PvP:SetHeight(18)
		self.PvP:SetWidth(18)
		self.PvP:SetPoint("BOTTOMLEFT", -13, -13)
	end
to generate a PvP ion on the bottom left edge my player frame.

My question is how do i alter this so it shows a small red square at the bottom left hand corner of my player frame?
Icerat is offline   Reply With Quote
Unread 09-12-09, 05:02 AM   #2
nailertn
An Aku'mai Servant
Join Date: Oct 2008
Posts: 33
Code:
if unit == "player" then
	self.PvP = self.Health:CreateTexture(nil, "OVERLAY")
	self.PvP:SetTexture("Interface\\Buttons\\WHITE8X8")
	self.PvP:SetVertexColor(1,0,0)
	self.PvP:SetHeight(18)
	self.PvP:SetWidth(18)
	self.PvP:SetPoint("BOTTOMLEFT", -13, -13)
end
If you want it on the target frame too leave the first line intact.
nailertn is offline   Reply With Quote
Unread 09-12-09, 09:02 AM   #3
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 983
Code:
	self.PvP = self.Health:CreateTexture(nil, "OVERLAY")
	self.PvP:SetTexture(1, 0, 0)
	self.PvP:SetHeight(18)
	self.PvP:SetWidth(18)
	self.PvP:SetPoint("BOTTOMLEFT", -13, -13)
Slightly simpler.
haste is offline   Reply With Quote
Unread 09-15-09, 11:26 AM   #4
Icerat
A Fallenroot Satyr
Join Date: Sep 2006
Posts: 28
Hi Guys many many thanks for the reply's.

I tried the suggestions but what I'm after is something like the indicators in grid, a clean simple red square.

I even tried:
Code:
 if (unit == "player" or unit == "target") then
	self.PvP = self.Health:CreateTexture(nil, "OVERLAY")
	self.PvP:SetTexture("Interface\AddOns\oUF_Harpz\media\\white16x16.tga")
	self.PvP:SetVertexColor(1,0,0)
	self.PvP:SetHeight(18)
	self.PvP:SetWidth(18)
	self.PvP:SetPoint("BOTTOMLEFT", -13, -13)
end
after copying the white16x16.tga from oUF_Rabbit http://wow.curse.com/downloads/wow-a...uf_rabbit.aspx and setting up a media dir and putting white16x16.tga in it.

What am i doing wrong?

The aim is to have a small green square top right of the frame showing when in resting state and to the left of that a red square to indicate pvp.

What i have at moment is a square like pvp icon, not very clean.





I look forward to any help given and thanks in advance

Last edited by Icerat : 09-15-09 at 12:11 PM.
Icerat is offline   Reply With Quote
Unread 09-16-09, 07:36 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 983
What you do:
Code:
-- This goes in the main scope of your layout:
local MyPvPUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end

	local pvp = self.MyPvP
	if(pvp) then
		local factionGroup = UnitFactionGroup(unit)
		-- FFA!
		if(UnitIsPVPFreeForAll(unit)) then
			pvp:SetTexture(0, 0, 1)
			pvp:Show()
		elseif(UnitIsPVP(unit) and factionGroup) then
			if(factionGroup == 'Horde') then
				pvp:SetTexture(1, 0, 0)
			else
				pvp:SetTexture(0, 1, 0)
			end

			pvp:Show()
		else
			pvp:Hide()
		end
	end
end


-- This goes in your layout style function:
	local pvp = self.Health:CreateTexture(nil, "OVERLAY")
	pvp:SetTexture(1, 0, 0)
	pvp:SetHeight(18)
	pvp:SetWidth(18)
	pvp:SetPoint("BOTTOMLEFT", -13, -13)
	self.MyPvP = pvp

	-- This makes oUF update the information.
	self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
	-- This makes oUF update the information on forced updates.
	table.insert(self.__elements, MyPvPUpdate)
haste is offline   Reply With Quote
Unread 09-16-09, 11:12 AM   #6
Icerat
A Fallenroot Satyr
Join Date: Sep 2006
Posts: 28
Wow many thanks Haste just what i was after, may i ask how it works so i can learn from it as i would like to do the same for the rested icon.



Originally Posted by haste View Post
What you do:
Code:
-- This goes in the main scope of your layout:
local MyPvPUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end

	local pvp = self.MyPvP
	if(pvp) then
		local factionGroup = UnitFactionGroup(unit)
		-- FFA!
		if(UnitIsPVPFreeForAll(unit)) then
			pvp:SetTexture(0, 0, 1)
			pvp:Show()
		elseif(UnitIsPVP(unit) and factionGroup) then
			if(factionGroup == 'Horde') then
				pvp:SetTexture(1, 0, 0)
			else
				pvp:SetTexture(0, 1, 0)
			end

			pvp:Show()
		else
			pvp:Hide()
		end
	end
end


-- This goes in your layout style function:
	local pvp = self.Health:CreateTexture(nil, "OVERLAY")
	pvp:SetTexture(1, 0, 0)
	pvp:SetHeight(18)
	pvp:SetWidth(18)
	pvp:SetPoint("BOTTOMLEFT", -13, -13)
	self.MyPvP = pvp

	-- This makes oUF update the information.
	self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
	-- This makes oUF update the information on forced updates.
	table.insert(self.__elements, MyPvPUpdate)
Icerat is offline   Reply With Quote
Unread 09-17-09, 04:22 AM   #7
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 983
Originally Posted by Icerat View Post
Wow many thanks Haste just what i was after, may i ask how it works so i can learn from it as i would like to do the same for the rested icon.
You don't need to apply the same logic mess to the Resting icon. If we compare the states the icons have we get this:
PvP: Show(FFA/Horde/Alliance)/Hide
Resting: Show/Hide

This means that we just have to set a texture with a static color on the Resting icon to make it work properly. The extra code on the PvP element is just to handle updating of it.

Due to this all you have to do is:
Code:
	local resting = self.Health:CreateTexture(nil, "OVERLAY")
	resting:SetTexture(1, 0, 0)
	resting:SetHeight(18)
	resting:SetWidth(18)
	resting:SetPoint("BOTTOMLEFT", -13, -13)
	self.Resting = resting
haste is offline   Reply With Quote
Unread 09-17-09, 08:24 AM   #8
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 907
While we are talking about the pvp icon... I tried to use a different texture than blizzard does for the horde and alliance PvP icon texture, some time ago. I couldn't make it to use the new texture, via
Code:
self.PvP:SetTexture(mytexture)
because it always took the default textures. Seems like the code in elements\pvp.lua was always "preferred" over the one from the layout. Do I have to do it in a whole different way or is this something oUF should handle?
Dawn is offline   Reply With Quote
Unread 09-17-09, 04:48 PM   #9
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 983
Originally Posted by Dawn View Post
While we are talking about the pvp icon... I tried to use a different texture than blizzard does for the horde and alliance PvP icon texture, some time ago. I couldn't make it to use the new texture, via
Code:
self.PvP:SetTexture(mytexture)
because it always took the default textures. Seems like the code in elements\pvp.lua was always "preferred" over the one from the layout. Do I have to do it in a whole different way or is this something oUF should handle?
You would have to handle the updating yourself as I gave an example of in my post above. The PvP element is pretty straight forward, so I've always encouraged people to just copy it and make their own if they want to do something uncommon. Most people just want the default behavior and nothing more after all.
haste is offline   Reply With Quote
Unread 09-17-09, 05:33 PM   #10
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 907
Thank you.
Dawn is offline   Reply With Quote
Unread 09-27-09, 04:25 PM   #11
Icerat
A Fallenroot Satyr
Join Date: Sep 2006
Posts: 28
Originally Posted by haste View Post
What you do:
Code:
-- This goes in the main scope of your layout:
local MyPvPUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end

	local pvp = self.MyPvP
	if(pvp) then
		local factionGroup = UnitFactionGroup(unit)
		-- FFA!
		if(UnitIsPVPFreeForAll(unit)) then
			pvp:SetTexture(0, 0, 1)
			pvp:Show()
		elseif(UnitIsPVP(unit) and factionGroup) then
			if(factionGroup == 'Horde') then
				pvp:SetTexture(1, 0, 0)
			else
				pvp:SetTexture(0, 1, 0)
			end

			pvp:Show()
		else
			pvp:Hide()
		end
	end
end


-- This goes in your layout style function:
	local pvp = self.Health:CreateTexture(nil, "OVERLAY")
	pvp:SetTexture(1, 0, 0)
	pvp:SetHeight(18)
	pvp:SetWidth(18)
	pvp:SetPoint("BOTTOMLEFT", -13, -13)
	self.MyPvP = pvp

	-- This makes oUF update the information.
	self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
	-- This makes oUF update the information on forced updates.
	table.insert(self.__elements, MyPvPUpdate)

Hi Back again

The above works great I'm just trying to tweak it a little to show a different color for my pvp square on a horde DK.

Code:
-- This goes in the main scope of your layout:
local MyPvPUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end
	local pvp = self.MyPvP
	if(pvp) then
		local factionGroup = UnitFactionGroup(unit)
		-- FFA!
		if(UnitIsPVPFreeForAll(unit)) then
			pvp:SetTexture(1, 1, 1)
			pvp:Show()
		elseif(UnitIsPVP(unit) and factionGroup) then
			if(factionGroup == 'Horde' and Class =="DEATHKNIGHT") then
				pvp:SetTexture(0.294118, 0, 0.509804) -- DK Horde Colour
			elseif(factionGroup == 'Horde') then
				pvp:SetTexture(0.545098, 0, 0) -- Horde Colour
			else
				pvp:SetTexture(0.25, 0.4, 0.9) -- Alliance Colour
			end

			pvp:Show()
		else
			pvp:Hide()
		end
	end
end
Am i doing this right? have i even put it in the right place? should i be making the changes in the function?

Sorry for all the stupid question, thanks in advance for helping a nub
Icerat is offline   Reply With Quote
Reply

Go BackWoWInterface » Featured Projects » oUF (Otravi Unit Frames) » PvP Icon

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