Thread Tools Display Modes
07-31-07, 06:35 AM   #1
Zombic
A Defias Bandit
Join Date: Jul 2007
Posts: 3
parent= usage

Hey Guys,

I'm trying to write a simple addon which will display the amount of time left on my summoned Water Elemental (as a mage).

I think I'm pretty close, I just can't quite figure out the showing/hiding the frame when the pet is present/not present.

It seems the best way to do this would be to somehow attach my frame to the pet action bar frame - so when the pet action bar is shown (meaning the pet is present) it shows my frame which counts down the petTimeRemaining(). When the pet action bar is hidden, it hides my frame too.

Is this done with parent="PetActionBarFrame" or similar? I don't quite understand how the parent command works exactly. I've tried the above instead of parent="UIParent" but it just never shows my frame...

How do I show/hide my frame at the same time the pet action bar is shown/hidden?

Thanks!

Z
  Reply With Quote
07-31-07, 09:32 AM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You must have the event that fires when you summon your water elemental (to know when to start the counter). You just also attach showing your frame to when that event fires.
__________________
"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
07-31-07, 04:14 PM   #3
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
I would use the hooksecurefunc function ( http://www.wowwiki.com/API_hooksecurefunc ) with, as the 1st argument, the elemental's HP bar's frame, as a second element, "OnShow" (respectively "OnHide"), and as a third element, function() MyHpText:Show() end (respectively function() MyHpText:Hide() end).

This 1-line answer might be hard to read, just ask if there's anything that wowwiki doesn't explain well enough (beside the lack of substance of the rest of my post ^^)
  Reply With Quote
08-01-07, 02:32 AM   #4
Zombic
A Defias Bandit
Join Date: Jul 2007
Posts: 3
Thanks heaps for the responses guys,

I *think* I understand what you're getting at Layrajha, it's looking quite a bit more complex than I was expecting.

Basically it seems you're suggesting my onUpdate (onEvent?) in the lua has a show/hide command based on information gained from hooksecurefunc? So the code checks to see if the HP Frame of the Water Elemental is being shown/hidden and fires a show/hide for my frame correspondingly?

eg: hooksecurefunc(HP Frame, "OnShow", showTimerBar) where showTimerBar is my own function created to show the xml frame... ?

Or have I misunderstood completely (very possible)?

Thanks!
  Reply With Quote
08-01-07, 09:29 AM   #5
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
hooksecurefunction is a function that modifies an existing function. The existing function you want to change is the function that shows your pet's frame: you want it to show you own frame too, now.
This function is "MyPetFrame:Show()" (i don't know the exact name of the pet frame actually). The "OnShow" and "OnHide" I wrote are mistakes (I mixed things up, there ), you just want to change the "Show()" and "Hide()" methods so that they show and hide your frame too.
  Reply With Quote
08-02-07, 03:20 AM   #6
Zombic
A Defias Bandit
Join Date: Jul 2007
Posts: 3
Ahh, I think I get it now. Thanks for explaining it again. I'll get to work and see what I can come up with...

Many thanks,

Z
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » parent= usage


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