Originally Posted by Duugu
Come on. It happens once if the addon loads. And it is easy to maintain.
|
"It only runs once" isn't really a valid excuse for writing unnecessarily inefficient and overly verbose code. There absolutely no benefit to writing it that way, and even if
you want to write your own code that way "just because", posting it on forums as an example of working code just means that other people are likely to copy and paste and use it in their own addon without understanding that's pointlessly overcomplicated.
Originally Posted by Rainrider
You also don't have a local reference to MAX_COMBO_POINTS. You don't check for vehicle combo points either (there was a daily rep quest back in WotLK that used that, maybe there are others too). You could also set MAX_POWER to 4 for warlocks as long you are not using this for demonology and spare a function call in that case.
|
The lack of upvalues for constants was intentional, but if you wanted to go that route, you could just set MAX_POWER for every class (registering additional events for those that require them) and never call UnitPowerMax in the main code path at all.
Also, if you wanted to support vehicles, you could just include them in the event registration:
Code:
caelUI.powersound:RegisterUnitEvent("UNIT_COMBO_POINTS", "player", "vehicle")
caelUI.powersound:RegisterUnitEvent("UNIT_POWER", "player")