Fix dir_to_rotation()

This commit is contained in:
kay27 2021-02-27 23:20:57 +04:00
parent 21e6c5ad1f
commit abc0bb9e8e

View File

@ -278,7 +278,7 @@ local function hut_placement_callback(p1, p2, size, orientation, pr)
end end
end end
mcl_structures.generate_witch_hut = function(pos, rotation) mcl_structures.generate_witch_hut = function(pos, rotation, pr)
local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts" local path = minetest.get_modpath("mcl_structures").."/schematics/mcl_structures_witch_hut.mts"
mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr) mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr)
end end
@ -517,21 +517,16 @@ mcl_structures.register_structures = function(structure_type, structures)
registered_structures[structure_type] = structures registered_structures[structure_type] = structures
end end
-- helper - finds the rotation value for a certain direction local function dir_to_rotation(dir)
-- https://forum.minetest.net/viewtopic.php?t=13280 local ax, az = math.abs(dir.x), math.abs(dir.z)
-- by Exilyth if ax > az then
local function dir_to_rotation(p_dir) if dir.x < 0 then
if p_dir.x == 0 and p_dir.z > 0 then return "270"
return "0" end
end
if p_dir.x == 0 and p_dir.z < 0 then
return "180"
end
if p_dir.x > 0 and p_dir.z == 0 then
return "90" return "90"
end end
if p_dir.x < 0 and p_dir.z == 0 then if dir.z < 0 then
return "270" return "180"
end end
return "0" return "0"
end end