RegisterUnitEvent ... UNIT_AURA
Hi,
I'm trying to mess with unit auras and code below does nothing for me. I'm talking classic wow. Can i do that somehow? I tried with hooksecurefunc but that works on target and player... not on pet... at least I couldn't find anything. Question is: can I track pet auras as an event? Thank you Code:
local Pet() |
Are you sure this code is running at all? It has some obvious syntax errors...
Have you enabled your error messages? Code:
/console scriptErrors 1 I think your Code:
local Pet() Code:
local function Pet() Furthermore, you are creating your frame as f, but use the variable name frame afterwards. This should throw an error, too. Then you are using frame:SetScript() for "OnEvent" twice. The second script assignment will override the first. |
Sometimes when tired you make the most embarrassing errors... like declaring f and using frame afterward :confused: :confused: :confused:
Thank you tho. |
A single frame can monitor multiple events or in this case, the same event for more than one unit.
Lua Code:
You can only register a maximum of two units with RegisterUnitEvent but if you need more, you could just use RegisterEvent and extend the unit checking in the event function. |
Thank you. That was helpful.
Could you be so kind and tell me just one more thing... is there an easy way to know when some frame is opened (like CharcterFrame or TalentFrame)? Some of them have events like MERCHANT_SHOW, BANKFRAME_OPENED... |
If there is no event that fires when a frame is shown, you can try hooking that frame's OnShow script (if it has one).
|
For CharcterFrame you can simply do:
Code:
hooksecurefunc(CharcterFrame, "Show", function() print("Showing CharcterFrame") end) But for PlayerTalentFrame (and others like ArchaeologyFrame, InspectFrame, AuctionHouseFrame, ClassTrainerFrame) it is a bit more complicated, because these frames do not exist yet after login. You have to wait with your hook until after they are created, and that is what these events you are mentioning can be helpful for. So for PlayerTalentFrame you could do: Code:
local playerTalentFrameHooked = false |
Oh yeah.. thank you so much .. and for fast answers as well...
|
I would usually hook the frame's OnShow/OnHide handlers. (As Seerah mentioned before)
Lua Code:
|
What are the cases where you would feel the difference between these two?
Code:
frame:HookScript("OnShow",function(self) Code:
hooksecurefunc(frame, "Show", function(self) |
Sometimes a frame's Show widget, or at least the pointer you can hook, isn't used to show the frame. The OnShow handler is guaranteed to fire every time the frame shows.
|
Cool thanks!
|
All times are GMT -6. The time now is 06:02 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI