Thread Tools Display Modes
10-08-15, 04:49 PM   #1
veldgarr
A Defias Bandit
Join Date: Oct 2015
Posts: 3
KGpanels loading when I have a target

So basically what the title says.
I want to make my KGpanel load only when I have a target.
I typed /fstack and found out its called "ElvUF_Target", but Im still lost =/
  Reply With Quote
10-08-15, 05:19 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
What do you mean by "load"? You should be able to show a frame (panel) when you aquire a target. The ElvUF_Target would be from the ElvUI addon, not KgPanels.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-08-15, 05:29 PM   #3
veldgarr
A Defias Bandit
Join Date: Oct 2015
Posts: 3
What I have so far is the following:

OnLoad

self:RegisterEvent("UNIT_TARGET")
self:Hide()
OnEvent

if UnitExists("ElvUF_Target") == nil then
self:Hide()
return
end
local cl = UnitClassification("ElvUF_Target")
if (cl == "elite") or (cl == "worldboss") or (cl == "rareeleite") then
self:SetBackdropColor(0.1, 0.1, 0.1, 0.1)
self:Show()
else
self:SetBackdropColor(1, 1, 1, 1)
self:Show()
end
It appears the Art Panel appears when I target something, but when I untarget something it stays up, and I dont want that.
  Reply With Quote
10-08-15, 05:49 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
You probably just want "target" everywhere that you currently have "ElvUF_Target".

You should also never compare anything directly to nil unless you're sure it's going to return nil. UnitExists returns true or false, so you need something like "if not UnitExists('target') then" for it to actually hide the frame.

Last edited by semlar : 10-08-15 at 05:56 PM.
  Reply With Quote
10-09-15, 12:50 PM   #5
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Try just parenting your panel to the ElvUI targets frame. That should make the panel show / hide with the target frame.
__________________
Ahhhh, the vagueries of the aging mind. Wait.... What was I saying?


Carbonite <----- GitHub main module (Maps ONLY) download link. The other modules are also available on GitHub.
Carbonite-CLASSIC<----- GitHub link to Carbonite Classic. Thanks to ircdirk for this!
  Reply With Quote
10-10-15, 12:46 AM   #6
veldgarr
A Defias Bandit
Join Date: Oct 2015
Posts: 3
Well i got the target one to work, but now I am having another problem with my pet bar/unit frame.
Want the KGpanel to appear when I have a pet bar/uniteframe and disappear when i dont.

OnLoad
self:RegisterEvent("pet")
OnEvent
if get("pet") then
self:Show()
else
self:Hide()
return
end
Also may someone point me in a good direction to where to learn scripts, so I don't have to keep asking?
  Reply With Quote
10-10-15, 01:58 AM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
I'm not sure if it's appropriate or not but Discrod Art contains lots of basic conditionals (control options) that might suit your needs as a starting point.

DART and KGP both do the same job but take slightly different aproaches.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-10-15 at 02:06 AM.
  Reply With Quote
10-10-15, 02:05 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by veldgarr View Post
Want the KGpanel to appear when I have a pet bar/uniteframe and disappear when i dont.
If your goal is "show my panel when <this frame> is visible, hide my panel when <this frame> is hidden" you don't need to figure out the conditions under which <this frame> is shown or hidden and reproduce them using scripts on your panel. Just enter <this frame> as the parent for your frame in the kgPanels options.

If you really want to use scripts, "pet" is a unit token (like "player" or "target") and not an event name, and "get" is not a function at all (if it is, it's a very badly named one, and it's defined by an addon, not by WoW itself).

The function to determine whether a given unit currently exists is "UnitExists". The event that fires when something about a pet changes is "UNIT_PET", and the first argument passed with the event is a unit token telling you whose pet changed. In this case, you only care about the player's pet, so you can filter on that in one of two ways:

The best way:
lua Code:
  1. -- OnLoad
  2. self:RegisterUnitEvent("UNIT_PET", "player")
  3. -- OnEvent
  4. if UnitExists("pet") then
  5.    self:Show()
  6. else
  7.    self:Hide()
  8. end

Another way (you'll still see this a lot in existing code, because it used to be the only way, before RegisterUnitEvent was added, but it's less efficient, so there's no reason to use it in new code):
lua Code:
  1. -- OnLoad
  2. self:RegisterEvent("UNIT_PET")
  3. -- OnEvent
  4. if arg1 == "player" then
  5.    if UnitExists("pet") then
  6.       self:Show()
  7.    else
  8.       self:Hide()
  9.    end
  10. end

Originally Posted by veldgarr View Post
Also may someone point me in a good direction to where to learn scripts, so I don't have to keep asking?
http://www.wowinterface.com/forums/s...100#post258100
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KGpanels loading when I have a target


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