Quantcast WoWInterface - View Single Post - Dividing hundreds and thousands by a comma
View Single Post
12-18-12, 02:42 PM   #4
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,732
Unfortunately, BreakUpLargeNumbers() only works on number values, not strings such as one returned by GetCoinTextureString(). The following code will try to reformat an already formatted string. Note, don't try to use this on strings that contain numbers with a decimal component.

Lua Code:
  1. function ReformatNumberString(str)
  2.     local repstr="%1"..LARGE_NUMBER_SEPERATOR.."%2";
  4. --  Initial replacement of a number group at the end of the string
  5.     str=str:gsub("(%d)(%d%d%d)$",repstr));
  7. --  Note repeat checks post-loop, unlike while that checks pre-loop
  8. --  This not only guarantees the loop code to run at least once before the condition is checked, but allows use of locals inside the loop for the condition
  9.     repeat
  10. --      Writing to an upvalue actually uses one additional opcode from just reregistering a local inside a loop
  11.         local numrep;
  13. --      Looping replacement of a number group followed by a non-number
  14.         str,numrep=str:gsub("(%d)(%d%d%d%D)",repstr));
  15.     until numrep<=0
  16. end
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-18-12 at 02:52 PM.
  Reply With Quote