]> git.lizzy.rs Git - signs_lib.git/commitdiff
fix corner case
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>
Thu, 19 Sep 2019 00:22:30 +0000 (20:22 -0400)
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>
Thu, 19 Sep 2019 00:25:41 +0000 (20:25 -0400)
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.

api.lua

diff --git a/api.lua b/api.lua
index ca389912724ae34b5fa5cab8d9b73142d4b211de..e0676971e31f48f6a826d44ffa238cd6f8fd922f 100644 (file)
--- a/api.lua
+++ b/api.lua
@@ -739,8 +739,18 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
        local pdef = minetest.registered_items[pnode.name]
 
        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)
-               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
                local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
                local node = minetest.get_node(pos)