mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 08:05:18 +02:00
Add math.round
and fix vector.round
(#10803)
This commit is contained in:
@@ -244,6 +244,15 @@ function math.factorial(x)
|
||||
return v
|
||||
end
|
||||
|
||||
|
||||
function math.round(x)
|
||||
if x >= 0 then
|
||||
return math.floor(x + 0.5)
|
||||
end
|
||||
return math.ceil(x - 0.5)
|
||||
end
|
||||
|
||||
|
||||
function core.formspec_escape(text)
|
||||
if text ~= nil then
|
||||
text = string.gsub(text,"\\","\\\\")
|
||||
|
@@ -41,9 +41,9 @@ end
|
||||
|
||||
function vector.round(v)
|
||||
return {
|
||||
x = math.floor(v.x + 0.5),
|
||||
y = math.floor(v.y + 0.5),
|
||||
z = math.floor(v.z + 0.5)
|
||||
x = math.round(v.x),
|
||||
y = math.round(v.y),
|
||||
z = math.round(v.z)
|
||||
}
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user