generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Free Thousand Seperator Code

Previous Thread :: Next Thread 
ProCoder is not online. ProCoder
Joined: 17 Oct 2013
Total Posts: 16
02 Feb 2015 03:31 PM
Hello, a lot of games use big numbers in general e.g(1000000).
This can be very annoying and hard to read.
I have developed A free function that fixes this.

function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end

The result:
comma_value(1000)
returns "1,000"
Report Abuse
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
02 Feb 2015 03:33 PM
interesting

Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
02 Feb 2015 03:34 PM
...

if i wanted comma-ed numbers i would have made my own function for it
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
02 Feb 2015 03:36 PM
Can be smaller eg:

function comma_value(amount)
local formatted = amount
while k ~= 0 do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
end
return formatted
end
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
02 Feb 2015 03:42 PM
@Leg
Why did you not make k local?


Also
http://www.roblox.com/--item?id=53225998
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
02 Feb 2015 03:51 PM
I never read over it but I just noticed there was a unneeded if that was there
but this is as short as it can be

function comma_value(amount)
while k ~= 0 do amount, k = string.gsub(amount, "^(-?%d+)(%d%d%d)", '%1,%2') end
return amount
end

or

comma_value = function(amount)while k ~= 0 do amount, k = string.gsub(amount, "^(-?%d+)(%d%d%d)", '%1,%2') end return amount end

but being short does not really matter that much
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
02 Feb 2015 03:54 PM
hmmm that look awfully familiar to his orignal code...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image