I want to use math.round in my project, but errors are thrown.
I tested this problem in a new 1 line project with the math module enabled in the config.
Because math.round doesn't exist. It's a convenience function provided in some frameworks (I think it exists in gmod, for example), but it's not part of the Lua standard library and LÖVE devs don't want to interfere with that. You can easily define it as such:
-- math.floor rounds to negative infinity
-- math.ceil rounds to positive infinity
math.trunc = function(n) return n >= 0.0 and n-n% 1 or n-n%-1 end -- rounds towards zero from both infinities
math.round = function(n) return n >= 0.0 and n-n%-1 or n-n% 1 end -- rounds away from zero, towards both infinities
Not to mention the fact that these definitions provide all of the "big 4" rounding functions, though none of them handle the .5 thing specially.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.