1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-12 16:15:20 +02:00

core: Add dir_to_yaw and yaw_to_dir helpers

These are needed to go from things like entity yaw to a vector
and vice versa.
This commit is contained in:
Auke Kok
2017-01-12 11:56:41 -08:00
committed by paramat
parent 2d7a6f2cc0
commit 7fc6719968
2 changed files with 12 additions and 0 deletions

View File

@@ -147,6 +147,14 @@ function core.wallmounted_to_dir(wallmounted)
return wallmounted_to_dir[wallmounted]
end
function core.dir_to_yaw(dir)
return -math.atan2(dir.x, dir.z)
end
function core.yaw_to_dir(yaw)
return {x = -math.sin(yaw), y = 0, z = math.cos(yaw)}
end
function core.get_node_drops(nodename, toolname)
local drop = ItemStack({name=nodename}):get_definition().drop
if drop == nil then