Originally Posted by Aanson
Yeah true, you could always contain the data in local UpValues.
It makes little difference though because you'd still need to be constantly updating the value of your UpValues anyway.
Hooking to OnValueChanged just seems like the cleanest way to me. ie.
Lua Code:
myHealthBar:SetScript("OnValueChanged", function(self, health) local _, maxHealth = self:GetMinMaxValues(); healthText:SetFormattedText("%d/%d", health, maxHealth); -- update other things here too end);
|
This is still more expensive. You're calling the functions in OnUpdate regardless. It's better to save the values to apply them to whatever requires the data than using more function calls (and you're creating variables anyhow in that snippet
).