Go to Page... |
Thread Tools | Display Modes |
05-23-17, 06:26 AM | #1 |
Efficient way to change text color based on duration of aura
Hi all,
I am using CooldownFrameTemplate for my aura tracker addon to show the remaining duration and trying to alter text color when the duration goes below certain amount for better visibility. I've considered using OnUpdate as shown below, but when I checked a CPU usage, it was inefficient. Lua Code:
I should have considered of putting outer 'if' statement, one that you limit updates based on time elapsed, but pretty sure there will be slight inaccuracy of time where it alters text color. However, imagining over 10 different frames doing the same thing also makes my head dizzy Last edited by Layback_ : 05-23-17 at 06:44 AM. |
|
05-23-17, 07:23 AM | #2 |
Counting elapsed is standard to throttle OnUpdates. Put the following line right below the "OnUpdate",function line:
Code:
self.e=self.e and self.e+elapsed or 0 if self.e<0.5 then return else self.e=0 end This throttles the OnUpdate to every half a second. Change the 0.5 to whatever you want your throttle, in seconds.
__________________
Last edited by Kanegasi : 05-23-17 at 07:26 AM. |
|
05-23-17, 07:41 AM | #3 |
Heres my code for CooldownFrameTemplate and i guess this the best way to to do it.
Lua Code:
|
|
05-23-17, 07:46 AM | #4 |
And heres an "minimal" version of tullaCC aka OmniCC if it's something you wanna use, because i used the CooldownFrameTemplate but it doesn't work exactly everything unfortune
Lua Code:
Last edited by Aftermathhqt : 05-23-17 at 07:50 AM. |
|
05-23-17, 08:13 AM | #5 |
In the snippet provided there are a few things you could improve upon, you will find them below. I have included many notes of which I have found to work while working on JamPlates Auras in the early stages of development(On a computer so old that CPU and RAM were precious resources.).
Lua Code:
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison |
|
05-23-17, 11:12 PM | #6 | |
I've also considered counting elapsed, but the problem is that there's slight inaccuracy on altering text color because of that 0.x second which kinda annoys me Last edited by Layback_ : 05-23-17 at 11:33 PM. |
||
05-23-17, 11:13 PM | #7 | ||
Whoa! That's pretty long haha!! I'll definitely have a look at it Thank you |
|||
05-23-17, 11:23 PM | #8 | |
Made all modifications based on your advice! Thank you for detailed explanation |
||
WoWInterface » Developer Discussions » Lua/XML Help » Efficient way to change text color based on duration of aura |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|