]> git.lizzy.rs Git - signs_lib.git/commitdiff
allow using "Sneak"/Shift to skip the on-pole/hanging/yard checks
authorVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>
Thu, 26 Sep 2019 05:10:28 +0000 (01:10 -0400)
committerVanessa Dannenberg <vanessa.e.dannenberg@gmail.com>
Thu, 26 Sep 2019 05:16:51 +0000 (01:16 -0400)
(makes it possible to directly place a sign flat on the ground or
ceiling, among other things.)

README.md
api.lua

index 8bf11f8331d218578f95390ee12046cb039e89ea..ee89213b84cdcde3912594a887f7132624588a6b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -38,6 +38,8 @@ That said, there are some basic text formatting options:
 
 * Pointing at an X or Z side of something that's detected as a pole/post will mount the sign onto that pole.  Note that the sign actually occupies the node space in front of the pole, since they're still separate nodes.  But, I figure, no one's going to want to use the space in front of the sign anyway, because doing so would of course obscure the sign, so it doesn't matter if the sign logically occupies that node space.
 
+* If you're holding "Sneak" (usually shift) while placing, the on-pole/hanging/yard checks are skipped, allowing you to just place a sign flat onto the ground, ceiling, or top/bottom of a pole/post, like they used to work before `signs_lib` was a thing.
+
 * If a sign is on the wall or flat on the ground, the screwdriver will spin it from one wall to the next, in clockwise order, whether there's a wall to attach to or not, followed by putting it flat on the ground, then flat against the ceiling, then back to wall orientation.
 
 * If a sign is hanging from the ceiling (not flat against it), the screwdriver will just rotate it around its Y axis.
diff --git a/api.lua b/api.lua
index 2a73977145629667fdf6e9f5cfd7427fd425fe53..5de10e5c69dc20a3d52a9872d700d09949dad131 100644 (file)
--- a/api.lua
+++ b/api.lua
@@ -815,6 +815,9 @@ end
 
 function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locked)
        local playername = placer:get_player_name()
+
+       local controls = placer:get_player_control()
+
        local signname = itemstack:get_name()
        local no_wall_name = string.gsub(signname, "_wall", "")
 
@@ -824,7 +827,7 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
        local pnode = minetest.get_node(ppos)
        local pdef = minetest.registered_items[pnode.name]
 
-       if def.allow_onpole and signs_lib.check_for_pole(pos, pointed_thing) then
+       if def.allow_onpole and signs_lib.check_for_pole(pos, pointed_thing) and not controls.sneak then
                local newparam2
                local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
                if def.paramtype2 == "wallmounted" then
@@ -834,7 +837,7 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
                end
                local node = minetest.get_node(pos)
                minetest.swap_node(pos, {name = no_wall_name.."_onpole", param2 = newparam2})
-       elseif def.allow_onpole_horizontal and signs_lib.check_for_horizontal_pole(pos, pointed_thing) then
+       elseif def.allow_onpole_horizontal and signs_lib.check_for_horizontal_pole(pos, pointed_thing) and not controls.sneak then
                local newparam2
                local lookdir = minetest.yaw_to_dir(placer:get_look_horizontal())
                if def.paramtype2 == "wallmounted" then
@@ -844,12 +847,12 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
                end
                local node = minetest.get_node(pos)
                minetest.swap_node(pos, {name = no_wall_name.."_onpole_horiz", 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) and not controls.sneak then
                local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
                local node = minetest.get_node(pos)
                minetest.swap_node(pos, {name = no_wall_name.."_hanging", param2 = newparam2})
-       elseif def.allow_yard and signs_lib.check_for_floor(pointed_thing) then
-               local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
+       elseif def.allow_yard and signs_lib.check_for_floor(pointed_thing) and not controls.sneak then
+               local newparam2 = minetest.dir_to_facedir(placer:get_look_dir())
                local node = minetest.get_node(pos)
                minetest.swap_node(pos, {name = no_wall_name.."_yard", param2 = newparam2})
        elseif def.paramtype2 == "facedir" and signs_lib.check_for_ceiling(pointed_thing) then
@@ -857,6 +860,7 @@ function signs_lib.after_place_node(pos, placer, itemstack, pointed_thing, locke
        elseif def.paramtype2 == "facedir" and signs_lib.check_for_floor(pointed_thing) then
                minetest.swap_node(pos, {name = signname, param2 = 4})
        end
+
        if locked then
                local meta = minetest.get_meta(pos)
                meta:set_string("owner", playername)