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: How would you go about

Previous Thread :: Next Thread 
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 08:57 AM
converting a number (like 1537) to 1.5k
I can think of a way to do this but it would be highly inefficient and a waste of time, all I need to see is how it would be done in the thousands
thanks
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 08:58 AM
(I'm going to manipulate numbers other than a thousand so don't just make it divide the number by 1k)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
12 Jan 2016 09:37 AM
[Post blocked] http://codepad.org/H27p1Bl3

I hope I don't get banned for trying to post code.


Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 10:25 AM
Thanks a lot, do you mind messaging me how this works?

Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:05 PM
bump (script that was given rounds the number up instead of giving real value)

Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:46 PM
does anyone know how to do this?

Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
12 Jan 2016 02:49 PM
Still lost, what are you exactly trying to do? Just change a number like 4567 to 4.567k or what?
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:54 PM
similar to how other tycoons do it, I want to know how you can compress any number down to only 3 digits;
4,567 = 4.56k
9,223,372 = 9.22m
107,888,103 = 107m
and so on...do you know how that's possible?

Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:55 PM
and while obviously leaving numbers < 1,000 unmanipulated

Report Abuse
LongKillKreations is not online. LongKillKreations
Joined: 14 Feb 2014
Total Posts: 4502
12 Jan 2016 02:55 PM
It's simple string manipulation. Here's an example:

string.format("%.1fK", n / 1000.0)
where 'n' would be your number.

http://www.lua.org/pil/20.html
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:56 PM
^ not what I'm asking. thx anyway though

Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
12 Jan 2016 02:58 PM
This is kinda inefficient but meh.

local NUMBER = 1300

local Mess = tostring(NUMBER)

print(Mess:sub(1,1).."."..Mess:sub(2,3).."k")
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 02:59 PM
^ again, not what I'm asking for :/

Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
12 Jan 2016 03:00 PM
'similar to how other tycoons do it, I want to know how you can compress any number down to only 3 digits;
4,567 = 4.56k
9,223,372 = 9.22m
107,888,103 = 107m
and so on...do you know how that's possible?'
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 03:01 PM
lol why did you quote me? if you read through that you would know that yours only supports numbers under 1m

Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 03:02 PM
under 10k*

Report Abuse
62GB is not online. 62GB
Joined: 03 Oct 2011
Total Posts: 4157
12 Jan 2016 03:05 PM
Then do something like.. I'm sure there's a better way but it's alright.


local cash = 1000

if cash >= 10000000 then --1b

elseif cash >= 1000000 then --1m

elseif cash >= 100000 then

elseif cash >= 10000 then

end
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 03:06 PM
yeah that's what I was thinking of when I put "inefficient and waste of time" in the OP
that'll be my last resort lol

Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 03:28 PM
b

Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
12 Jan 2016 03:36 PM
Replace num with your input. This is just a rough version but is something like this what you are after? Always 3 significant figures and adds the letter automatically?

num = 1356807340
mag = 0
compressed = num

while string.len(tostring(compressed)) > 3 do
compressed = math.floor(compressed / 1000)
mag = mag + 1
end

output = tostring(compressed)
if string.len(output) < 3 then
output = string.sub(tostring(num / 1000 ^ mag), 1, 4)
end

letters = { "K+", "M+", "B+", "Q+", "Qn+" }
if mag > 0 then
output = output .. letters[mag]
end
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
12 Jan 2016 03:37 PM
Paste into a script in studio and put print(output) at the end to see the result
Report Abuse
MahouReikon is not online. MahouReikon
Joined: 15 Feb 2014
Total Posts: 1359
12 Jan 2016 03:38 PM
3 Sig Figs*


#code 'The Legend of Heroes Sen no Kiseki'
Report Abuse
NecroBumpism is not online. NecroBumpism
Joined: 25 Nov 2015
Total Posts: 534
12 Jan 2016 03:39 PM
dude, that's perfect. thank you so much :^)

Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
12 Jan 2016 03:40 PM
You're welcome, I'd neaten it up if I had more time but I'm sure you can edit it for your needs :)
Report Abuse
koen523 is not online. koen523
Joined: 23 Feb 2011
Total Posts: 4026
12 Jan 2016 03:45 PM
NecroBumpism you're clever ^^
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