You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
862 B
25 lines
862 B
local setmetatable, minetest, vector |
|
= setmetatable, minetest, vector |
|
|
|
-- Creates a vector using `get_position_from_hash` from the specified `hash`. |
|
function vector.from_hash(hash) |
|
return setmetatable(minetest.get_position_from_hash(hash), vector.metatable) |
|
end |
|
|
|
-- Returns the integer hash of this vector using `hash_node_position`. |
|
function vector:hash() |
|
return minetest.hash_node_position(self) |
|
end |
|
|
|
-- Returns vector components from the specified arguments. |
|
-- * `(x, y, z)` returns `x, y, z`. |
|
-- * `(number)` returns `n, n, n`. |
|
-- * `(table)` returns `t.x, t.y, t.z`. |
|
-- * `(array)` returns `t[1], t[2], t[3]`. |
|
-- * Unexpected input returns undefined output. |
|
function vector.get(x, y, z) |
|
if z then return x, y, z end |
|
if type(x) == "number" then return x, x, x end |
|
if x.z then return x.x, x.y, x.z end |
|
return x[1], x[2], x[3] |
|
end
|
|
|