Hide frame when pet leaves
So I know how to show/update a frame when the player's pet exists/enters, but how do I hide the frame when the pet leaves?
I figured I could call the same event for enter and leaves and run UnitExists("pet") but that did no good. source code |
You inherit from "SecureHandlerStateTemplate" in addition to whatever it is you're inheriting from now (didn't check code) and then
RegisterStateDriver(yourframe, "visibility", "[nopet]hide;show") |
Your if and elseif logic is exactly the same.
/edit: plus what Dridzt said ;) |
Quote:
|
Hmm, I took a look at your code.
You're over-complicating things :) There's no reason to have a frame to parent your unitframe to, that does nothing. You should just create your Button from 'SecureUnitButtonTemplate' as you've done, set your attributes and then use RegisterUnitWatch(yourframe) It will take care of showing / hiding of itself (look at how the default target frame is done for example) You don't need that 'w' frame you have at all. Here for an example: http://www.wowpedia.org/API_RegisterUnitWatch |
Also, since your button is created as a secure frame, you can't use :Show() and :Hide() on it while you're in combat. If you want a unit frame, create a secure unit button (as you're already doing) and use RegisterUnitWatch on it like Dridzt said; you don't even need to use a state driver to hide/show it, as the UI will do that automatically based on the existence of the unit it's registered to watch.
The example code on Wowpedia is really messy, so here is a cleaner one: Code:
local f = CreateFrame("Button", "MyPetButton", UIParent, "SecureUnitButtonTemplate") |
Awesome I was about to rage about how terrible that example code was, lmao.
Anyways seems to be working fine now, now to look into making target/focus huds, those work with just a copy paste of the pet code. Probably gonna have to call an even to get health/power update when targetted. (apparently people want an icehud really replacement or something I guess) Anyways this thread b resolved. |
All times are GMT -6. The time now is 12:34 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI