From 4614d66cbe5b467b35001f0a90ae5a4286c645ea Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 11 Sep 2019 15:54:50 -0400 Subject: [PATCH] Fix broken/bad screwdriver rotation handling --- api.lua | 17 ++++++++++++++--- standard_signs.lua | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api.lua b/api.lua index 5a14a74..55aaa64 100644 --- a/api.lua +++ b/api.lua @@ -66,7 +66,11 @@ signs_lib.wall_fdir_to_back = { local ctexcache = {} signs_lib.wallmounted_rotate = function(pos, node, user, mode) - if mode ~= screwdriver.ROTATE_FACE then return false end + if not signs_lib.can_modify(pos, user) then return false end + + if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then + return false + end minetest.swap_node(pos, { name = node.name, param2 = wall_dir_change[node.param2 % 6] }) for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do local e = v:get_luaentity() @@ -79,8 +83,15 @@ signs_lib.wallmounted_rotate = function(pos, node, user, mode) end signs_lib.facedir_rotate = function(pos, node, user, mode) - if mode ~= screwdriver.ROTATE_FACE or not signs_lib.can_modify(pos, user) then return end - newparam2 = ((node.param2 % 6 ) == 0) and 1 or 0 + if not signs_lib.can_modify(pos, user) then return false end + + if mode ~= screwdriver.ROTATE_FACE or string.match(node.name, "_onpole") then + return false + end + + local newparam2 = node.param2 + 1 + if newparam2 > 3 then newparam2 = 0 end + minetest.swap_node(pos, { name = node.name, param2 = newparam2 }) for _, v in ipairs(minetest.get_objects_inside_radius(pos, 0.5)) do local e = v:get_luaentity() diff --git a/standard_signs.lua b/standard_signs.lua index 2cbe18d..d9ce07d 100644 --- a/standard_signs.lua +++ b/standard_signs.lua @@ -41,7 +41,7 @@ for _, onpole in ipairs({"", "_onpole"}) do on_destruct = signs_lib.destruct_sign, on_receive_fields = signs_lib.receive_fields, on_punch = signs_lib.update_sign, - on_rotate = on_rotate, + on_rotate = signs_lib.wallmounted_rotate, number_of_lines = signs_lib.standard_lines, horiz_scaling = signs_lib.standard_hscale, vert_scaling = signs_lib.standard_vscale, @@ -84,7 +84,7 @@ for _, onpole in ipairs({"", "_onpole"}) do on_receive_fields = signs_lib.receive_fields, on_punch = signs_lib.update_sign, can_dig = signs_lib.can_modify, - on_rotate = on_rotate, + on_rotate = signs_lib.wallmounted_rotate, number_of_lines = signs_lib.standard_lines, horiz_scaling = signs_lib.standard_hscale, vert_scaling = signs_lib.standard_vscale,