Help on calling a switch function
Hi all,
I have posted an help / search request in the addons forum looking for addons that can disable the tooltip from the actionbars. As usual, my question was kindly answered fast and correctly. Here was the post: http://www.wowinterface.com/forums/s...ad.php?t=52130 I have tried to go further and create a minimal addon that can automagically swap tooltip state combat base but I really have to understand that I have some limit in understand lua principles and basis :/ Here is the code: Lua Code:
The code is very ugly but it works even if half way, and it is a a good thing for now (at least it has no error :-) 1ST Problem: - When it starts, it starts with tooltips disabled because I have not yet called the GameTooltip:ToggleAction(). Then it works as expected toggling enter/leaving from combat. So first question is: Is possible to call the GameTooltip:ToggleAction() only from inside the unit in combat event ? I was not able to code in this way (but I have not yet fully understood the code by munkdev so :-) And the choice of the event ACTIONBAR_UPDATE_STATE is the correct one or it is fired too many times ? 2ND Problem: I am not so confident that the IF statement on the enter combat condition and exit condition are always true and so the conditions are always correctly evaluated. Can you suggest a better practice to manage such conditions ? Thanks very much for any help or attention. |
For complete information I have tried also a more minimalist approach.
The relevant part of the code is this one: Lua Code:
but it correctly remove tooltips when I enter in combat but never put them back :-) when I exit from it :-) Thanks again :-) |
I don't see any references or registering the events PLAYER_REGEN_ENABLED (out of combat) and PLAYER_REGEN_DISABLED (in combat).
|
Hi myrroddin,
Thanks very much for your kind reply. I have tried to implement your suggestion and to rewrite the code in this way: Lua Code:
It HIDE the tooltips when I go in combat but it doesn't show again when I exit from it . Mah. I am investigating a little bit more. EDIT: It continues to print a sequence of DEBUG: Hide DEBUG: Show DEBUG: Hide DEBUG: Show Like the 2 events fire each others one by one very fast after exiting from combat. |
When you repeatedly call hooksecurefunc you will hook the function alot of times, it doesn't overwrite the earlier hooks. I'm not sure what order they're called in but it isn't a good way to do it anyways. I'd do something like:
Lua Code:
|
Thanks very much sticklord !!
It works like a charm. Lua Code:
I have added an option to temporary reenable them if sometime you need to read tooltip again. Here is the full code. Thanks really very much ! |
You're welcome =)
|
All times are GMT -6. The time now is 02:26 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI