WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Cooldown animation on buttons. (https://www.wowinterface.com/forums/showthread.php?t=2520)

Vayder 11-29-05 06:47 AM

Cooldown animation on buttons.
 
ive been searching for an example of how to do this all night but cannot seem to find anything. ive been working on a addon created by another person but they stopped updating it and i really like using it so im doing my best to make it work properly/better. its the mage recovery bar

http://www.wowinterface.com/download...fo.php?id=4368

Id like to be able to add the cooldown animation to the buttons on this addon but i have VERY limited coding knowledge. ive been trying to learn as i go. i used to be really good at mIRC scripting lol but this stuff looks alot more complicated. im sure this is possible. ive looked through the code of other action bar mods to see how/where this is done and i think ive found it in some but i dont understand how it works or how to impliment it. also the buttons on this mod change to different items depending on if your in combat or not so im guessing i would need seperate functions or somthing to properly display the cooldown animation on each item depending on your combat state.

any help would be greatly appericiated.

Gello 11-29-05 09:31 AM

It takes some getting used to but the cooldown spinner is just an animated model you can start at will and leave alone and it will handle spinning once and hiding itself when the cooldown is done. When you want to show the cooldown again you start another spin.

First off you need the buttons to inherit ActionButtonTemplate, or at least include the cooldown model in your frames. We'll use MultiBarBottomLeftButton12 as an example. This button is in the "bottom left" extra bar in the default UI. The cooldown model (under the <Frames> section of the template) is MultiBarBottomLeftButton12Cooldown.

You start the timer with CooldownFrame_SetTimer which takes at four arguments: frame of the cooldown model, start time, duration, enable. The latter three are exactly the results of every GetsomethingCooldown function:

frame: MultiBarBottomLeftButton12Cooldown <- change to whatever your cooldown model is
start: if there is a cooldown, this is the current GetTime(), 0 if none
duration: time (in seconds) to spin, 0 if none
enable: just needs to be over 0 to get a spinner going. Not sure why this is necessary.

So you can type this in manually:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, GetTime(), 10, 1)

and it will start a spinner starting now for 10 seconds. Or:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, GetTime()-5, 10, 1)

will show a spinner that started 5 seconds ago with a duration of 10 seconds, so it will start halfway done. Or:

/script CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, 0, 0, 0)

which will show a finished cooldown. If you want to reflect the cooldown of an item in bags, you can get the 3 arguments with GetContainerItemCooldown:

/script local start, duration, enable = GetContainerItemCooldown(0,1) CooldownFrame_SetTimer( MultiBarBottomLeftButton12Cooldown, start, duration, enable)

It's important to note that the cooldown won't automatically start the next time the button is used. You need to get the cooldown and start the spinner every time the item is used.

Ulti 12-05-05 10:40 AM

Great, I was also partly looking for this, although I had gotten a fair idea of how to use the CooldownFrame_SetTimer() function earlier this was good information. My biggest issue now though is to find out what the name of the button linked to the spell/addon is.

Since I intend to implement it in an addon I'm writing, the button (a macro calling my addon to perform certain checks and thereafter maybe casting a spell) may be placed in all sorts of places, on different actionbars/flexbar/other bar addons and so forth.

Anyone have any good tips on how to fetch the button name in order to set the cooldown?


All times are GMT -6. The time now is 12:49 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI