Thread Tools Display Modes
10-14-14, 12:40 PM   #1
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
easy to read numbers

Short question
How do I make that instead of 10000 or 100000, how do i make the numbers display like 10 000 or 100 000
  Reply With Quote
10-14-14, 01:37 PM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Which numbers do you want to change? (i.e. Which part of the UI?)
  Reply With Quote
10-14-14, 01:57 PM   #3
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
Originally Posted by Choonstertwo View Post
Which numbers do you want to change? (i.e. Which part of the UI?)
not a part of a ui, this is for use either in xpbar, unitframe

Lua Code:
  1. --number format func
  2. local SVal = function(val)
  3.     if val > 1E10 then
  4.       return (floor(val/1E9)).."b"
  5.     elseif val > 1E9 then
  6.       return (floor((val/1E9)*10)/10).."b"
  7.     elseif val > 1E7 then
  8.       return (floor(val/1E6)).."m"
  9.     elseif val > 1E6 then
  10.       return (floor((val/1E6)*10)/10).."m"
  11.     elseif val > 1E4 then
  12.       return (floor(val/1E3)).."k"
  13.     else
  14.       return val
  15.     end
  16.   end
I have this for shortening numbers, so I was wondering if there was a code to make the numbers with spaces atleast everything below 100k
  Reply With Quote
10-14-14, 02:19 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
return BreakUpLargeNumbers(val)

It will add commas.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-14-14, 02:25 PM   #5
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
If you want spaces rather than commas and don't want to rely on the breakUpLargeNumbers CVar being enabled, you can try this:
lua Code:
  1. local SVal = function(val)
  2.     if val > 1E10 then
  3.         return (floor(val/1E9)).."b"
  4.     elseif val > 1E9 then
  5.         return (floor((val/1E9)*10)/10).."b"
  6.     elseif val > 1E7 then
  7.         return (floor(val/1E6)).."m"
  8.     elseif val > 1E6 then
  9.         return (floor((val/1E6)*10)/10).."m"
  10.     elseif val > 1E5 then
  11.         return (floor(val/1E3)).."k"
  12.     elseif val >= 1E3 then
  13.         return (floor(val/1E3)) .. (" %03d"):format(val % 1E3)
  14.     else
  15.         return val
  16.     end
  17. end

This probably belongs in General Authoring Discussion or Lua/XML Help since you're looking for help with your own code rather than someone else's AddOn.
  Reply With Quote
10-14-14, 03:27 PM   #6
saxitoxin
A Theradrim Guardian
 
saxitoxin's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 60
Yes, you are right, sorry. can someone please move this?

And the code worked, Thank you so much
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » easy to read numbers


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