sacr1ficez Posted June 7, 2019 Posted June 7, 2019 (edited) Hey, any idea how to make this simpler? math.floor(math.round(player_blood/90/(90000/90/90), 2)).."L" -- this thing -- function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor)/factor else return tonumber(("%."..decimals.."f"):format(number)) end end Edited June 7, 2019 by majqq
DNL291 Posted June 8, 2019 Posted June 8, 2019 It would be useful if you explain what this code is supposed to do. What do you want to do besides simplify the calculation?
sacr1ficez Posted June 8, 2019 Author Posted June 8, 2019 11 hours ago, salh said: in 1 what the player_blood Integer. 7 hours ago, DNL291 said: It would be useful if you explain what this code is supposed to do. What do you want to do besides simplify the calculation? Convert integer. For example: 12000 > 12 11000 > 11 5000 > 5 1000 > 1 less or equal to 999 > 0
savour Posted June 8, 2019 Posted June 8, 2019 are you talking about the amount of code or the process itself?
sacr1ficez Posted June 8, 2019 Author Posted June 8, 2019 3 minutes ago, savour said: are you talking about the amount of code or the process itself? I would like to make it simpler, instead of using math.floor + math.round, if possible. I use this with onClientRender.
savour Posted June 8, 2019 Posted June 8, 2019 1 hour ago, majqq said: Convert integer. For example: 12000 > 12 11000 > 11 5000 > 5 1000 > 1 less or equal to 999 > 0 well, from what i see here you don't really need the round method math.floor(12345/1000) = 12 math.floor(19999/1000) = 19 math.floor(999/1000) = 0 also for more optimization, avoid using the OOP on render events, since it uses double the resources (from my experience) also you can make some value setters outside the render events (that changes the value after something is happened) and use the final results only on rendering 1
sacr1ficez Posted June 8, 2019 Author Posted June 8, 2019 43 minutes ago, savour said: well, from what i see here you don't really need the round method math.floor(12345/1000) = 12 math.floor(19999/1000) = 19 math.floor(999/1000) = 0 also for more optimization, avoid using the OOP on render events, since it uses double the resources (from my experience) also you can make some value setters outside the render events (that changes the value after something is happened) and use the final results only on rendering Thank you
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now