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
 

Re: Shorthand help

Previous Thread :: Next Thread 
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
10 Aug 2016 04:22 PM
so Im trying to make a script display this:

1234567891234

as

1,234,567,891,234

but instead I keep getting this:

12,345,678,912,34

so how would I move the comma over to the left by 1? My brain is dead today.
------------------------------------------------------------------------------
local number = 1234567891234
local newNumber = ""
local toString = tostring(number)

for i = 0,string.len(toString),1 do
if i % 3 == 0 and i~= 0 then
newNumber = newNumber..","..string.sub(toString,i,i)
else
newNumber = newNumber..string.sub(toString,i,i)
end
end

print(newNumber)
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
10 Aug 2016 04:26 PM
bump
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
10 Aug 2016 04:33 PM
nvm, I figured it out:

local number = 1234567891234
local newNumber = ""
local toString = tostring(number)

for i = 0,string.len(toString),1 do
if (i + 1) % 3 == 0 and i + 1~= 0 then
newNumber = newNumber..","..string.sub(toString,i,i)
else
newNumber = newNumber..string.sub(toString,i,i)
end
end

print(newNumber)
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
10 Aug 2016 04:45 PM
Im talking to my self arent I....

Anyways, For a number from 10000 to 99999, it displays it like this:

1,000,0 or 9,999,9, but any number above 100k and below 9k works fine
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
10 Aug 2016 04:52 PM
Oh goodie post filtered!

http://hastebin.com/raw/qufifofava
Report Abuse
XtremeTemper is not online. XtremeTemper
Joined: 02 Mar 2012
Total Posts: 1774
10 Aug 2016 04:54 PM
oh, that works flawlessly, thanks!
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