fix corner case

Placing a "wallmounted" sign onto a streets lamp would cause a
weird rotation if you're pointing downward too far.  Now it
enforces NESW direction according to your yaw.

Also fixes bad orientation when you're really close to a post.
This commit is contained in:
Vanessa Dannenberg 2019-09-18 20:22:30 -04:00
parent 4eeaf90ae3
commit f0bc18154e

12
api.lua
View File

@ -739,8 +739,18 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
local pdef = minetest.registered_items[pnode.name] local pdef = minetest.registered_items[pnode.name]
if (def.allow_onpole ~= false) and signs_lib.check_for_pole(pos, pointed_thing) then if (def.allow_onpole ~= false) and signs_lib.check_for_pole(pos, pointed_thing) then
print("allow onpole")
print(def.paramtype2)
local newparam2
local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
if def.paramtype2 == "wallmounted" then
newparam2 = minetest.dir_to_wallmounted(lookdir)
else
newparam2 = minetest.dir_to_facedir(lookdir)
end
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = itemstack:get_name().."_onpole", param2 = node.param2}) print(node.param2, newparam2)
minetest.swap_node(pos, {name = itemstack:get_name().."_onpole", param2 = newparam2})
elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) then elseif def.allow_hanging and signs_lib.check_for_ceiling(pointed_thing) then
local newparam2 = minetest.dir_to_facedir(placer:get_look_dir()) local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
local node = minetest.get_node(pos) local node = minetest.get_node(pos)