WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Problems with runes (https://www.wowinterface.com/forums/showthread.php?t=44192)

Ereki 09-06-12 07:35 PM

Problems with runes
 
Hi I made a thread about this like 2 years ago () but back then I decided to give up and just remove the problem area from the addon. And now I've decided to give it another shot but I'm not really getting any further than I did 2 years ago.

What I want to do is make a runes switch alpha depending on if they're on cooldown or not, it works well except for one thing, energize.. For those of you don't play DK a rune is energized when either Empower_Rune_Weapon, Runic_Empowerment or Blood_Tap is used. All three of those immediately refreshes a rune. To begin with here's the complete lua file of the addon http://pastebin.com/fb4G9JFV it's in a mess I know, I just can't be bothered since it works (except for this).

So the problem is that I can't get the runes to change alpha when they're energized, it works just fine every other time, I've done some digging and it appears the event RUNE_POWER_UPDATE is called twice when a rune is energized and it does some weird things.
This is when I use Blood Tap:

And this is when I use Empower Rune Weapon with every rune on CD:


The print is the following:
Code:

elseif event == "RUNE_POWER_UPDATE" and InCombatLockdown() and not UnitInVehicleControlSeat("player") then
local runeIndex, isEnergize = ...;
local runeButton = _G["RuneButtonIndividual"..runeIndex];
local start, duration, runeReady = GetRuneCooldown(runeIndex);
print(GetTime(),runeIndex,start,duration,runeReady,isEnergize)

As you can see the event is firing twice and does wierd things with isEnergize and runeReady. I've tried changing the code around (which is based on the code for energizing runes in FrameXML) right now I'm really tired and can't think straight so I figured someone here will know lua way better than me and might be able to help me.

Thanks in advance
Ereki

(And I might've done some spelling errors but it's 3:34AM here so gimmie a break :p)

Dridzt 09-06-12 08:57 PM

Nothing jumps out at me, but this block can be simplified
Code:

if not runeReady and isEnergize == nil then
        runeButton:SetAlpha(RHaoc)
else
        runeButton:SetAlpha(RHaic)
end

if isEnergize then
        runeButton:SetAlpha(RHaic)
end

to this
Code:

local alpha = (runeReady or isEnergize) and RHaic or RHaoc
runeButton:SetAlpha(alpha)

I'm not sure isEnergize means the rune is instantly ready, the default code starts a short (sub-second) energize animation, so maybe runeReady is only true at the end of that small period after energizing.

Barjack 09-07-12 12:21 AM

Just a question, but what's the significance of isEnergize in terms of functionality? I mean, why is it not sufficient to rely only on runeReady? It appears that the event with isEnergize being true is firing before a rune is technically ready (perhaps indicating that that rune is about to be "energized", for whatever reason).

But why not just treat that as a not-ready event, ignoring isEnergize, and wait until the energize is complete and the follow-up event happens a split second later, which has runeReady as true and will fix the alpha just like a normal ready event?

Ereki 09-07-12 07:39 AM

Quote:

Originally Posted by Barjack (Post 262666)
Just a question, but what's the significance of isEnergize in terms of functionality? I mean, why is it not sufficient to rely only on runeReady? It appears that the event with isEnergize being true is firing before a rune is technically ready (perhaps indicating that that rune is about to be "energized", for whatever reason).

But why not just treat that as a not-ready event, ignoring isEnergize, and wait until the energize is complete and the follow-up event happens a split second later, which has runeReady as true and will fix the alpha just like a normal ready event?

I thought of that too but I couldn't get it to work properly I tried just doing:
if not runeReady then
runeButton:SetAlpha(RHaoc)
else
runeButton:SetAlpha(RHaic)
end
But it gave pretty much the same results or completly broke the whole thing, can't really remember.. It didn't work at least


All times are GMT -6. The time now is 09:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI