WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   PvP Icon (https://www.wowinterface.com/forums/showthread.php?t=27256)

Icerat 09-12-09 01:21 AM

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?

nailertn 09-12-09 05:02 AM

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.

haste 09-12-09 09:02 AM

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.

Icerat 09-15-09 11:26 AM

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

haste 09-16-09 07:36 AM

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 09-16-09 11:12 AM

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.



Quote:

Originally Posted by haste (Post 159051)
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 09-17-09 04:22 AM

Quote:

Originally Posted by Icerat (Post 159069)
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


Dawn 09-17-09 08:24 AM

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?

haste 09-17-09 04:48 PM

Quote:

Originally Posted by Dawn (Post 159171)
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.

Dawn 09-17-09 05:33 PM

Thank you. :)

Icerat 09-27-09 04:25 PM

Quote:

Originally Posted by haste (Post 159051)
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


All times are GMT -6. The time now is 03:27 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI