Hi everyone! Just looking for some advice with coding :) My addon, ShamanBuffBars, tracks shaman weapon buffs and shows a rebuff bar once it expires. I am wanting to add in a feature which shows the bar x mins before the buffs expire (user specified.) I know how to retrieve time remaining, but not sure as to what event I would hook it to, since I believe it needs to be triggered by an event.
I could find an event that gets fired every second or so (I could add it into the update function for the bar), but wouldn't that type of thing cause a lot of lag and/or memory consumption if I was running something every second?
Basically, I'm looking for the most efficient way to implement such a feature. Any help would be greatly appreciated. :)
That is in fact your only solution: Use an OnUpdate function that runs every frame and check if you need to do anything. You may use a library to do this for you like AceTimer-3.0, you tell it how many seconds later you want your function to start running, and after that amount of time, your function will be called. But internally, it is still checking the time every frame in an OnUpdate.
Register something like PLAYER_AURAS_CHANGED event
Detect when you gain the buff you want to warn about
Start some form of OnUpdate timer that triggers some logic (warn you about the buff expiring) x seconds later.
Ahh alright thanks. I'm actually using Ace2 libraries at the moment. Is it much work to upgrade to Ace3? I was fiddling around a few weeks ago with the Ace3 framework but it kept spitting out errors and I couldn't get it to work :(