yes, a resource that needs to be readable, you even wanted it to be “readable”
even if its not a tutorial, its an resource, it still needs to be readable
yes, a resource that needs to be readable, you even wanted it to be “readable”
even if its not a tutorial, its an resource, it still needs to be readable
Me using many math.floor and math.log10 does not make it a better code. Also it is very easy to read. It’s a short sentence
… wait so your entire code is bad? did you realize you used math.floor and math.log10 just in variables?
if you want to continue, dm me instead
really? its basically reading a long story saying its a short sentence
wow, how short!
i can read this!
if (X - X + X * 2 % 5 * 7) and (2 * 7 ^ 3 % 4 * 5 * 2 % 4) and (2 * 7 % 3 * 2 % 7 * 2 ^ 6) then
return true
end
If you have any suggestions on how I could shorten it feel free to say so
what’s the use of this?There are already millions of things like this out there. What’s the difference with this and the other ones?
well, actually you could simplify this ALOT, take a look at this, its not mine but its actually fast and too simplified, other than this method
now this is more readable
I suggest you try his code which doesn’t even work for high numbers and doesn’t let you customly choose the amount of decimals
If you want to change the numbers of decimals you can just do %0.01. Just because you added 1 little feature to yours doesn’t make it better than the others.
Mynumber = abbreviation from other module
Mynumber = Mynumber - Mynumber % 0.01
Add more 0s after the decimals to see more/ less of those decimals
try to recreate this code but make it more “customizable” as you said, it would be readable
as in change the Abbreviations, floor and log10 variable to A, f and l10?
Edit: I mean to make it easier to read?
im not saying you must, its your choice
Thanks. I’ll see if I can apply this to my code.
I’ve got to agree with @regexman that the math.floor variable and math.log10 variable make it soooo much more confusing. It might not be to you as you wrote it therefore you know what every part does but to a person trying to implement this into their game it is very confusing and almost impossible to read. I would also recommend adding comments on each line explaining what it does because of all the math it’s doing, just to help out the beginner developers using this.
I don’t understand? what is the confusing part. What math.floor and math.log10 do?
Also it’s a community resource and not a tutorial.
Caching library functions in variables is not confusing or impossible to understand. I do this all the time to make my code more readable when necessary. Stop harassing the creator of this resource for a style choice they made. If you don’t like it then change it to your liking.
You want it to be readable, code isn’t just about making something that works, you need to be able to fix it easily.
Take this for example.
do function test() while thing do function2() end end test() end
if something was to go wrong there (let’s say function2
, tracking it would be very hard as it’s all on one line), compared to this:
do
function test()
while thing do
function2()
end
end
end
The code doesn’t need to be super short to run fast either, it still will take roughly the same time.
I’ve also made a NumberAbbreviator module, this seems a lot more readable than your functions.
local Abbreviator = {
Suffixes = {"","K","M","B","T","Q","QN","S","SP","O","N","D","UD","DD"},
Precision = 3
}
local Floor = math.floor
local Log10 = math.log10
function Abbreviator:ShortenNumber(number, precision)
self.Precision = precision or 3
local suffixes = self.Suffixes
local index = Floor(Log10(number))
index = index - (index % 3)
local suffix = suffixes[(index / 3) + 1]
local nearestMultiple = 10 ^ index
local precisionMultiple = 10 ^ self.Precision
local result = Floor((number / nearestMultiple) * precisionMultiple) / precisionMultiple .. suffix
return result
end
-- ...
return Abbreviator
VS:
function Module.AbbreviateN(N: number, D) -- N = Number. D = Decimals.
return f(((N < 1 and N) or f(N) / 10 ^ (l10(N) - l10(N) % 3)) * 10 ^ (D or 3)) / 10 ^ (D or 3)..(A[f(l10(N) / 3)] or "")
end
We aren’t doing that, all we’re saying is that the code should be set out neater if it’s a community resource, because at the end of the day we might want to change some of it aswell. I will say @luisgamercooI231fan you might want to tone down how you write some comments, but that’s it.
It’s a free resource, the creator isn’t obligated to do anything for anyone; they just shared it. Instead of telling the creator how they should have made it, make your own resource.
We aren’t forcing the creator to change how their code works, all we’re suggesting is that you should probably make the code a bit neater for people to read.
We’re only suggesting changes that could be made, at the end of the day, it’s their decision whether they want to do it
Nice thanks! I’ll be using this for an upcoming game!
Damn, everyone so hot headed nowadays, while you guys keep there fighting over readability and some different things, I’ll just say thanks for the contribution, although it’s a bit confusing to read and see how it works because of the name of the variable itself, what matters for me in the end is that it just works.