Thread Tools Display Modes
02-05-11, 05:16 PM   #1
Oraknathal
A Flamescale Wyrmkin
 
Oraknathal's Avatar
Join Date: Sep 2010
Posts: 143
help with kgPanels

hey guys i need help with kgpanels,
I want to make a panel only show when I have a target and to hide when i dont.
How would I do this?.

P.S im sorry for posting here but for sum reason I cant post it anywhere else:S
Can sum 1 move it if they can and link me the new url?
  Reply With Quote
02-05-11, 06:05 PM   #2
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
create the panel the way you want then in the scripts tab go to onload and paste this
Code:
self:RegisterEvent("UNIT_TARGET")
self:Hide()
then go to onevent and paste this
Code:
if UnitExists("target") == nil then
   self:Hide()
else
  self:Show()
   return
end
that should make the panel only visable when you have a target. At least it works for me
__________________


  Reply With Quote
02-05-11, 07:33 PM   #3
strykerk
A Deviate Faerie Dragon
 
strykerk's Avatar
Join Date: Nov 2010
Posts: 19
You can also type /framestack. Then when you hover over your target it will give you the frame name.

Take that name and parent your KGPanel to it.

I might be wrong on the command, its been a while.
  Reply With Quote
02-05-11, 09:06 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Use PLAYER_TARGET_CHANGED rather than UNIT_TARGET. It will only fire for when your target changes, rather than everyone's.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-05-11, 09:43 PM   #5
Oraknathal
A Flamescale Wyrmkin
 
Oraknathal's Avatar
Join Date: Sep 2010
Posts: 143
I tried what othgar said it didnt work:S
I'm sorry Seerah i dont quite understand what u mean.
I'm not very good with scripts so sorry to ask but i need pretty much every step on this procedure.:S
  Reply With Quote
02-05-11, 09:45 PM   #6
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Originally Posted by Seerah View Post
Use PLAYER_TARGET_CHANGED rather than UNIT_TARGET. It will only fire for when your target changes, rather than everyone's.
I've never had a problem with it the other way that I've noticed. I'll have to change it and see if there's a difference.
__________________


  Reply With Quote
02-05-11, 09:57 PM   #7
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
What Seerah is suggesting would look like this in the OnLoad script

Code:
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:Hide()
At least I think so....right Seerah?

I double checked the scripts and they work fine on my rogues UI. I don't have my panels parented to anything though. The script would be different if you were trying to hide something that the panel is attatched to. I had one for hiding my minimap unless I was moving but it bugged the minimap in dungeons.

ALso don't forget to hit the Accept button after you paste the script. You have no idea how mny times I've lost a script I was writing just because I flaked out lol
__________________



Last edited by Othgar : 02-05-11 at 10:01 PM.
  Reply With Quote
02-06-11, 12:27 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Yep.

In the OnLoad section of the scripts for your panel:
Code:
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:Hide()
this registers for our events and then hides the panel (cause we won't have a target when logging in)

Then in the OnEvent section:
Code:
if UnitExists("target") then
     self:Show()
else
     self:Hide()
end
this checks to see if we have a target when the event fires (since losing your target counts as a change). If we have a target, show our panel. If not, hide it.


Using PLAYER_TARGET_CHANGED is better than using UNIT_TARGET because it will fire only when you need it - running your code only when you need to.


A MUCH easier way to do what you want though... Is to not use scripts at all. Go to the area of the config where you set up the size/colors/etc. of your panel. Scroll all the way down. Set the target frame as the parent of the panel. The panel will then inherit from the target frame things such as scale and visibility. If you are using the default unit frames, the name of the frame is simply TargetFrame. Otherwise, use the /framestack command and hover your mouse over it to find what name to put in the box.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-06-11, 07:12 AM   #9
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
Awesome tip Seerah! I was also scripting my panels, not realizing I can parent them to a frame that is there or not! Will make the rest of the frames I didn't script because i got lazy so much easier to fix.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
02-06-11, 07:50 AM   #10
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
huh that is a lot easier, probably a bit faster too. I did notice that my panels were about a half second behind my target frame. And it appeals to the lazy side of me
__________________


  Reply With Quote
02-06-11, 03:48 PM   #11
Oraknathal
A Flamescale Wyrmkin
 
Oraknathal's Avatar
Join Date: Sep 2010
Posts: 143
Im sorry if i sound stupid:S
but i still dont know how to use fstack what do I look for im using Stuf unit frames I want the panel to show on my target portrait when it shows.
  Reply With Quote
02-06-11, 05:16 PM   #12
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Type "/framestack" a dialog should open in the lower left corner of your screen. Select a target and mouse over the target portrait then look in the dialog for the name of the frame you are moused over. It should be something like STUF_TARGETFRAME or STUF_TARGET_FRAME, don't quote me on that but it should point you in the right direction when you look at fstack. Then you just parent your panel to that frame.

As far as having the panel showing on your target portrait I'm not sure if you can parent the panel directly to the portrait or not. I think I'm going to go give it a try just out of curiosity though. I'll post an update after I try it.
__________________


  Reply With Quote
02-06-11, 05:19 PM   #13
Kendian
A Molten Giant
 
Kendian's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 614
Stuf uses a deficit so is always Stuf.units.target or Stuf.units.targettarget
Stuf.units.player etc~


__________________
  Reply With Quote
02-06-11, 05:32 PM   #14
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
yup it was "Stuf.units.target" there's no seperate frame for the portrait so I'm not sure how you'd parent a panel to it. What are you trying to show on the targets portrait? There might be a better way than with kgpanels.

Also, Seerah, "PLAYER_TARGET_CHANGED" is faster than "UNIT_TARGET" ty ty ty lol Now everything appears at the same time.
__________________



Last edited by Othgar : 02-06-11 at 05:38 PM.
  Reply With Quote
02-06-11, 07:19 PM   #15
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
You should be able to parent the panel to the frame, then re-size it and offset it to the portrait.

i still dont know how to use fstack
Open your chat prompt, and type "/fstack" (without the quotes), hit enter and you should get a new window on your screen telling you everything that is under your cursor anywhere you place your cursor on screen. You would just hover an object and read what comes up in the window.

Type "/fstack" (without the quotes) in chat again to close the window.

Last edited by jeffy162 : 02-06-11 at 07:43 PM.
  Reply With Quote
02-06-11, 11:15 PM   #16
Oraknathal
A Flamescale Wyrmkin
 
Oraknathal's Avatar
Join Date: Sep 2010
Posts: 143
Originally Posted by Kendian View Post
Stuf uses a deficit so is always Stuf.units.target or Stuf.units.targettarget
Stuf.units.player etc~


When I try this the frame completely dissapears and I cant retrieve it in anyway unless i copy another frame:S
  Reply With Quote
02-07-11, 10:34 AM   #17
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Is it completely disappearing, or is it resizing/moving to match its parent? You need to change it back to how you want it after setting the Parent, iirc.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-07-11, 11:30 AM   #18
jeffy162
A Pyroguard Emberseer
 
jeffy162's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 2,364
Originally Posted by Oraknathal View Post
When I try this the frame completely dissapears and I cant retrieve it in anyway unless i copy another frame:S
Yep! I have the same problem, but I've figured out that if you set the "Anchor Frame" first, it works OK. Dunno why, but it does (at least for me).
  Reply With Quote
02-09-11, 08:04 PM   #19
Oraknathal
A Flamescale Wyrmkin
 
Oraknathal's Avatar
Join Date: Sep 2010
Posts: 143
Okay tried everything this is what happens.
I make the anchor frame Stuf.Units.Focus.and it moves sum where and i can no longer see it I try change its width and height to max ( like 5000) to see if I can see it nothing happens.
Then i add the parent frame stil nothing .
overall i really cant see anything
I dont know y.
  Reply With Quote
02-09-11, 08:09 PM   #20
Othgar
"That" Guy
 
Othgar's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 228
Dumb question, but I've done this too...do you have a target/focus selcted when you parent the frame? I fought with a panel for action bars once for 2 days before I realized I kept parenting to the bar when it was hidden and I wasn't showing it so my frame would hide with it lol
__________________


  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » help with kgPanels


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