Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-24-13, 07:24 PM   #20
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Aanson View Post
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:
  1. myHealthBar:SetScript("OnValueChanged", function(self, health)
  2.     local _, maxHealth = self:GetMinMaxValues();
  3.     healthText:SetFormattedText("%d/%d", health, maxHealth);
  4.     -- update other things here too
  5. 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 ).
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » FontString for value and percent?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off