WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (http://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   KG Panels + Coloring (http://www.wowinterface.com/forums/showthread.php?t=39213)

Lily.Petal 03-09-11 02:19 PM

KG Panels + Coloring
 
Posted from Below and from PM's
(Big thanks to Nib!)

Normal Threat:

-- OnLoad
Code:

self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
-- OnEvent
Code:

-- Replace unit with "party1" to "party4" for party members. Or ("target", "targettarget") for seeing threat on your target.
local status = UnitThreatSituation(unit)
local color = status and {GetThreatStatusColor(status)} or {0,0,0}
self:SetBackdropBorderColor(unpack(color))

--------------------------------

Personal Colors: (also with extra quirks that doesn't show threat unless you're in group/have pet and won't show in BGs)

-- OnLoad
Code:

self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("UNIT_PET")
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")

-- On Event
Code:

--- {R, G, B, A}  - Set A to 0 to hide the panel.
local ThreatStatusColors = {
        [0] = {0, 0, 0, 0},                -- not tanking, lower threat than tank.
        [1] = {0, 0, 0, 1},                -- not tanking, higher threat than tank.
        [2] = {0, 0, 0, 1},                -- insecurely tanking, another unit have higher threat but not tanking.
        [3] = {0, 0, 0, 1},                -- securely tanking, highest threat
}

local color
local status = UnitThreatSituation(unit)
local _, InstType = IsInInstance()
if ( (status ~= nil) and (UnitExists("pet") or (GetRealNumPartyMembers() > 0) or (GetRealNumRaidMembers() > 1)) and not (InstType == "pvp" or InstType == "arena") ) then
        color = ThreatStatusColors[status]
else
        color = {0,0,0,0}        -- Hide
end
self:SetBackdropBorderColor(unpack(color))

---------------------------
Same as above, but default ThreatColors:

-- OnLoad
Code:

self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("UNIT_PET")
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")

-- OnEvent
Code:

local color, status
local _, InstType = IsInInstance()
if ( (UnitExists("pet") or (GetRealNumPartyMembers() > 0) or (GetRealNumRaidMembers() > 1)) and not (InstType == "pvp" or InstType == "arena") ) then
        status = UnitThreatSituation(unit)
        color = status and {GetThreatStatusColor(status)} or {0,0,0,0}        -- Threat colors
else
        color = {0,0,0,0}        -- Hide
end


Nibelheim 03-09-11 02:29 PM

Quote:

Originally Posted by Lily.Petal (Post 231381)
Is there anyway I can change the background color of a frame to show if that party member has aggro or not?

I can't seem to find any leads :<

-- OnLoad
Code:

self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
or

-- OnEvent
Code:

-- Replace unit with "party1" to "party4" for party members. Or ("target", "targettarget") for seeing threat on your target.
local status = UnitThreatSituation(unit, "target")
local r, g, b = GetThreatStatusColor(status)
self.bg:SetVertexColor(r, g, b)

UnitThreatSituation API

Hmm, may need a "UNIT_TARGET" event registered in OnLoad.

Lily.Petal 03-09-11 02:42 PM

The code works.. but the only problem is that I want the border to change colors, not the BG >< Any fix you may think up?

And thank you very much for the previous code~

Nibelheim 03-09-11 02:45 PM

Quote:

Originally Posted by Lily.Petal (Post 231384)
The code works.. but the only problem is that I want the border to change colors, not the BG >< Any fix you may think up?

And thank you very much for the previous code~

self:SetBackdropBorderColor(r,g,b) should work.

Nibelheim 03-09-11 02:50 PM

Come to think of it, are you wanting to see the threat of party members on your target, or just whether or not they have agro?

If it's the latter, just remove the second argument from the UnitThreatSituation line. So like this:

Code:

local status = UnitThreatSituation(unit)

Lily.Petal 03-09-11 05:38 PM

3 Attachment(s)
Quote:

Originally Posted by Nibelheim (Post 231386)
Come to think of it, are you wanting to see the threat of party members on your target, or just whether or not they have agro?

If it's the latter, just remove the second argument from the UnitThreatSituation line. So like this:

Code:

local status = UnitThreatSituation(unit)

Works great, only one problem now, it changes my border after combat to white, instead of back to black ><

1st : Before combat and script change
2nd : In combat after script change
3rd : After combat with script

Nibelheim 03-09-11 05:52 PM

Quote:

Originally Posted by Lily.Petal (Post 231392)
Works great, only one problem now, it changes my background after combat to white, instead of back to black ><


Try changing the color lines to:

Code:

local color = status and {GetThreatStatusColor(status)} or {0,0,0}
self:SetBackdropBorderColor(unpack(color))

The {0,0,0} is what you want the default color to be.

Lily.Petal 03-09-11 06:03 PM

-- OnLoad
Code:

self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE")
-- OnEvent
Code:

-- Replace unit with "party1" to "party4" for party members. Or ("target", "targettarget") for seeing threat on your target.
local status = UnitThreatSituation(unit)
local color = status and {GetThreatStatusColor(status)} or {0,0,0}
self:SetBackdropBorderColor(unpack(color))

Is that correct?

EDIT:
Awesome! That worked great, Thank you very much for your time and patients :) <3
I also like how if I am in combat with more then 1 enemy, my Border doesn't go back to black until everything is dead. ^^ Though in group combat that might be a lil odd to see it go to white instead of to black again @@ oh wells, I like it how it is

Lily.Petal 03-10-11 04:49 AM

Hmm is there anyway I can make 1 KGPanel for say raid unit 1, and the border goes around every one of my raid members by chance? O.o

sigg 03-10-11 07:11 AM

You could move to RDX.

You don't need to learn lua anymore. You use the development tool that will generate the code and execute it for you.

http://www.wowrdx.com/tutorials-basi...-and-backdrops

What you are looking for is exaclty the business of RDX.

Lily.Petal 03-10-11 07:24 AM

Quote:

Originally Posted by sigg (Post 231418)
You could move to RDX.

You don't need to learn lua anymore. You use the development tool that will generate the code and execute it for you.

http://www.wowrdx.com/tutorials-basi...-and-backdrops

What you are looking for is exaclty the business of RDX.

I would have no Idea how to duplicate my own UI, though I might DL it to my laptop and see what I can do with it on there. I just don't want to start from scratch with a program I have no prior experience or knowledge of ><

sigg 03-10-11 08:01 AM

I understand. You are afraid to lost all what you have done.

Please take 2 minutes to watch this video :
http://www.youtube.com/watch?v=8WNdlNBw03I

This is the user interface manager that let you save and load many UIs with RDX.

Cheers
Sigg


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

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC