From 7d93f60b74309d1e759b4a31aa5b0e664d52836d Mon Sep 17 00:00:00 2001 From: addi Date: Wed, 7 Sep 2016 16:47:21 +0200 Subject: [PATCH] Using Screwdriver rotates the signs clockwise. Fix issue #2 --- init.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ shared_locked.lua | 6 +++--- steel.lua | 5 +++-- wood.lua | 5 +++-- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index 5fd0690..759663b 100644 --- a/init.lua +++ b/init.lua @@ -94,6 +94,50 @@ arrow_signs.on_place = function(itemstack, placer, pointed_thing) return minetest.item_place_node(itemstack, placer, pointed_thing, param2) end +local matrix = { + -- Mounted on Ground (-Y) + [10]=19, + [19]=4, + [4]=13, + [13]=10, + + -- Mounted on Top (+Y) + [8]=17, + [17]=6, + [6]=15, + [15]=8, + + -- Mounted at South (-Z) + [2]=18, -- down + [18]=22, -- left + [22]=14, -- up + [14]=2, -- right + + -- Mounted at North (+Z) + [0]=12, -- down + [12]=20, -- left + [20]=16, -- up + [16]=0, -- right + + -- Mounted at West (-X) + [3]=7, -- down + [7]=21, -- left + [21]=11, -- up + [11]=3, -- right + + -- Mounted at East (+X) + [1]=9, -- down + [9]=23, -- left + [23]=5, -- up + [5]=1, -- right +} + +arrow_signs.on_rotate = function(pos, node, player, mode, new_param2) + node.param2 = matrix[node.param2] or 0 --in case of error + minetest.swap_node(pos,node) + return true +end + arrow_signs.savetext = function(pos, formname, fields, sender) if fields.text then local playername = sender:get_player_name() or "" diff --git a/shared_locked.lua b/shared_locked.lua index fb70fa3..cc9e746 100644 --- a/shared_locked.lua +++ b/shared_locked.lua @@ -1,7 +1,7 @@ --[[ - Shared Locked Arrow sign + Shared Locked Arrow sign - This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. ]] minetest.register_node("arrow_signs:shared_locked", { @@ -24,7 +24,7 @@ minetest.register_node("arrow_signs:shared_locked", { locks:lock_set_owner( pointed_thing.above, placer, "Shared locked sign"); return itemstack end, - + on_rotate = arrow_signs.on_rotate, on_construct = function(pos) local meta = minetest.get_meta(pos) -- prepare the lock of the sign diff --git a/steel.lua b/steel.lua index 9e3c7a2..c1e1510 100644 --- a/steel.lua +++ b/steel.lua @@ -1,7 +1,7 @@ --[[ - Steel Arrow Sign + Steel Arrow Sign - This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. ]] @@ -20,6 +20,7 @@ minetest.register_node("arrow_signs:steel", { groups = {cracky = 2}, sounds = default.node_sound_defaults(), on_place = arrow_signs.on_place, + on_rotate = arrow_signs.on_rotate, on_construct = function(pos) local meta = minetest.get_meta(pos) meta:set_string("formspec", arrow_signs.formspec) diff --git a/wood.lua b/wood.lua index 11f4223..88ad5e2 100644 --- a/wood.lua +++ b/wood.lua @@ -1,7 +1,7 @@ --[[ - Wooden Arrow sign + Wooden Arrow sign - This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. ]] @@ -20,6 +20,7 @@ minetest.register_node("arrow_signs:wall", { groups = {choppy = 2, flammable = 2, oddly_breakable_by_hand = 3}, sounds = default.node_sound_defaults(), on_place = arrow_signs.on_place, + on_rotate = arrow_signs.on_rotate, on_construct = function(pos) --local n = minetest.get_node(pos) local meta = minetest.get_meta(pos)