mirror of
https://github.com/HybridDog/vector_extras.git
synced 2024-11-29 19:03:51 +01:00
Make vector.zero callable
This is needed to keep compatibility with new minetest builtin code
This commit is contained in:
parent
f8c12047d5
commit
ed6b514057
11
init.lua
11
init.lua
@ -334,7 +334,16 @@ function funcs.straightdelay(s, v, a)
|
|||||||
return (math.sqrt(v*v+2*a*s)-v)/a
|
return (math.sqrt(v*v+2*a*s)-v)/a
|
||||||
end
|
end
|
||||||
|
|
||||||
vector.zero = vector.new()
|
-- override vector.zero
|
||||||
|
-- builtin used not to have the vector.zero function. to keep compatibility,
|
||||||
|
-- vector.zero has to be a 0-vector and vector.zero() has to return a 0-vector
|
||||||
|
-- => we make a callable 0-vector table
|
||||||
|
if not vector.zero then
|
||||||
|
vector.zero = {x = 0, y = 0, z = 0}
|
||||||
|
else
|
||||||
|
local old_zero = vector.zero
|
||||||
|
vector.zero = setmetatable({x = 0, y = 0, z = 0}, {__call = old_zero})
|
||||||
|
end
|
||||||
|
|
||||||
function funcs.sun_dir(time)
|
function funcs.sun_dir(time)
|
||||||
if not time then
|
if not time then
|
||||||
|
Loading…
Reference in New Issue
Block a user