Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 04:38 PM |
It was censored, here's a link: http://pastebin.com/et877Bnp
I've attempted mathematics. Vince are you proud? x) It's just barely functioning. Where can it be trimmed? How could I show decimals?
|
|
|
| Report Abuse |
|
|
|
| 09 Aug 2016 04:40 PM |
why are you asking if vince is proud he's an absent minded fool about everything
Formerly xXTheRobotXx, add 13,349 posts |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 04:41 PM |
He's very friendly and helpful if you're willing to learn.
|
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 Aug 2016 04:43 PM |
| Nice little system you got there; however, once you're so high I would recommend showing more place values so people are like uhhhh how much do I have because they could say hey I got 3B! and they really have 3.8B. :P .8Bill is quite a bit off. :P |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 04:45 PM |
No, he's a good guy.
@eLunate This is the part where you slap me with your superior 3rd alternative to #tostring(num) that I don't know about.
@Vince Yeah I'm not sure how to incorporate decimals, that's one of the questions
|
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 09 Aug 2016 04:47 PM |
| It looks as efficient as it can be. I would suggest adding something to handle numbers with decimals to really flesh it all out. |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2016 04:48 PM |
"No, he's a good guy."
let's see here
flames people who ask for help frequently if they don't do exactly what he says
someone says his method doesn't work, they get flamed massively
argues that inefficient methods are better
example:
someone asked how to lerp a color, he made a complicated function that didn't work, jarod provided Color1:Lerp(Color2,alpha) and he said that it was a bad way of doing it
flames other scripters for trying to provide alternative methods
like i was telling someone they could use starter scripts for ease of use and he said it was bad
and then when they use starter scripts he just rambles about how it's inefficient when it's not
and then he's just bad at coding
his game has zombie script ais
he's a fraud "Dev"
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 09 Aug 2016 04:51 PM |
Round = function(i,d) return math.floor(i*(10^(d or 0))+0.5)/(10^(d or 0)) end
print(Round(3.456213123,2))
3.46
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 04:54 PM |
I'm not rounding a decimal though, this system is geared for integers. Sorry to be misleading.
The hard part for "decimals" is that I don't know how many "steps" to track back in the number, because it's possible that the stringR result is (for example) 2b, 46k, or 768m, which means I don't know whether to stirnb.sub 3 2 or 1 until I'm at the point where I could break it into a decimal (i.e 2.87b opposed to 2b)
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 04:56 PM |
*string.sub 3 or 2 or 1
Anyone know what I mean? XD
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 09 Aug 2016 04:58 PM |
num = 3,826,123,587
--reduce length
if key == 'b' then round(num,1) end
3.8b
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 09 Aug 2016 04:59 PM |
obv that won't work but thats the basic concept
|
|
|
| Report Abuse |
|
|
kools
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 1659 |
|
|
| 09 Aug 2016 05:03 PM |
Here is how I would include the decimals in pseudo-code (everybodies favorite!)
1) Determine the place of the digits (like you have done). 2) Use string.match to capture the first three digits of the number. Replace them with zero if they are nil (using the or keyword). 3) Using the place variable figure out what numbers to put before a decimal, and then what numbers to put after the decimal (use sub for this). |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 05:04 PM |
Unfortunately for #3 the place variable is just used to determine which "bracket" it's in. I don't know the mathematical term for it, if there is one. ex: 152,642,123,632 It would = 4 because it breaks into four chunks.
|
|
|
| Report Abuse |
|
|
|
| 09 Aug 2016 05:04 PM |
dev is gonna be post and be like
xD Narwhal I see your(notice this) still butthurt
xD take this butthurt cream |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 Aug 2016 05:17 PM |
--Not the best but it'll do what you're looking for. symbols = {'k','m','b','t','q','Q','s','S','o','n','d'} function reduceLength(num) num = tostring(num) local place, dec, new = math.ceil(#num/3), num:sub(2,2), nil if #num < 4 then return num end return (tonumber(dec)>1 and num:sub(1, 1)..'.'..num:sub(2,2) or num:sub(1, 1))..symbols[(place-1)] end print(reduceLength(3826)) print(reduceLength(3026)) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 Aug 2016 05:23 PM |
--Here is a edit that's a little better and runs less code when there isn't a reason to: symbols = {'k','m','b','t','q','Q','s','S','o','n','d'} function reduceLength(num) if #num < 4 then return num end num = tostring(num) return (tonumber(num:sub(2,2))>1 and num:sub(1, 1)..'.'..num:sub(2,2) or num:sub(1, 1))..symbols[(math.ceil(#num/3)-1)] end
print(reduceLength(3826)) print(reduceLength(3026)) |
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 Aug 2016 05:25 PM |
--derp
symbols = {'k','m','b','t','q','Q','s','S','o','n','d'} function reduceLength(num) num = tostring(num) if #num < 4 then return num end return (tonumber(num:sub(2,2))>1 and num:sub(1, 1)..'.'..num:sub(2,2) or num:sub(1, 1))..symbols[(math.ceil(#num/3)-1)] end
print(reduceLength(3826)) print(reduceLength(3026)) |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 09 Aug 2016 05:27 PM |
Sounds great I'll give it a shot.
|
|
|
| Report Abuse |
|
|
DevVince
|
  |
| Joined: 08 Nov 2008 |
| Total Posts: 9245 |
|
|
| 09 Aug 2016 05:32 PM |
| That's some great advice for you narwhal. ;) |
|
|
| Report Abuse |
|
|
|
| 09 Aug 2016 05:36 PM |
@Dev
here's some great advice for you
http://wiki.roblox.com/index.php?title=Intro_to_Scripting
Formerly xXTheRobotXx, add 13,349 posts |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 09 Aug 2016 05:37 PM |
Ouch am I allowed to hide when people say using :Lerp is bad? Because otherwise I may be held accountable for murder.
|
|
|
| Report Abuse |
|
|
|
| 09 Aug 2016 05:41 PM |
local symbols = {"", "k", "m", "b", ...}
local exponent = math.floor(math.log(math.abs(num))) local symbol = symbols[math.floor(exponent / 3) + 1]
ta-da |
|
|
| Report Abuse |
|
|