Reply
Thread Tools Display Modes
Unread 03-09-11, 02:19 PM   #1
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
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

Last edited by Lily.Petal : 04-30-11 at 05:16 PM.
Lily.Petal is offline   Reply With Quote
Unread 03-09-11, 02:29 PM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
Featured
Join Date: Jan 2010
Posts: 1,505
Originally Posted by Lily.Petal View Post
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.

Last edited by Nibelheim : 03-09-11 at 02:35 PM.
Nibelheim is offline   Reply With Quote
Unread 03-09-11, 02:42 PM   #3
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
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~
Lily.Petal is offline   Reply With Quote
Unread 03-09-11, 02:45 PM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
Featured
Join Date: Jan 2010
Posts: 1,505
Originally Posted by Lily.Petal View Post
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 is offline   Reply With Quote
Unread 03-09-11, 02:50 PM   #5
Nibelheim
local roygbi-
 
Nibelheim's Avatar
Featured
Join Date: Jan 2010
Posts: 1,505
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)

Last edited by Nibelheim : 03-09-11 at 02:52 PM.
Nibelheim is offline   Reply With Quote
Unread 03-09-11, 05:38 PM   #6
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
Originally Posted by Nibelheim View Post
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
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	676
Size:	98.4 KB
ID:	5835  Click image for larger version

Name:	Untitled2.png
Views:	629
Size:	65.7 KB
ID:	5836  Click image for larger version

Name:	Untitled3.png
Views:	609
Size:	26.1 KB
ID:	5837  

Last edited by Lily.Petal : 03-09-11 at 05:57 PM.
Lily.Petal is offline   Reply With Quote
Unread 03-09-11, 05:52 PM   #7
Nibelheim
local roygbi-
 
Nibelheim's Avatar
Featured
Join Date: Jan 2010
Posts: 1,505
Originally Posted by Lily.Petal View Post
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.

Last edited by Nibelheim : 03-09-11 at 05:56 PM.
Nibelheim is offline   Reply With Quote
Unread 03-09-11, 06:03 PM   #8
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
-- 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

Last edited by Lily.Petal : 03-09-11 at 06:07 PM.
Lily.Petal is offline   Reply With Quote
Unread 03-10-11, 04:49 AM   #9
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
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
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
Lily.Petal is offline   Reply With Quote
Unread 03-10-11, 07:11 AM   #10
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,201
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.
__________________
RDX manager
Sigg
sigg is offline   Reply With Quote
Unread 03-10-11, 07:24 AM   #11
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 537
Originally Posted by sigg View Post
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 ><
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
Lily.Petal is offline   Reply With Quote
Unread 03-10-11, 08:01 AM   #12
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,201
I understand. You are afraid to lost all what you have done.

Please take 2 minutes to watch this video :


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

Cheers
Sigg
__________________
RDX manager
Sigg
sigg is offline   Reply With Quote
Reply

Go BackWoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KG Panels + Coloring

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