diff --git a/signs_lib/init.lua b/signs_lib/init.lua index a93fba6..ce3e37a 100644 --- a/signs_lib/init.lua +++ b/signs_lib/init.lua @@ -858,21 +858,21 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname) fences_with_sign[fencename] = fencewithsignname def_sign.on_place = function(itemstack, placer, pointed_thing, ...) - local node_above = minetest.get_node(pointed_thing.above) - local node_under = minetest.get_node(pointed_thing.under) - local def_above = minetest.registered_nodes[node_above.name] - local def_under = minetest.registered_nodes[node_under.name] + local node_above = minetest.get_node_or_nil(pointed_thing.above) + local node_under = minetest.get_node_or_nil(pointed_thing.under) + local def_above = node_above and minetest.registered_nodes[node_above.name] + local def_under = node_under and minetest.registered_nodes[node_under.name] local fdir = minetest.dir_to_facedir(placer:get_look_dir()) local playername = placer:get_player_name() if minetest.is_protected(pointed_thing.under, playername) then minetest.record_protection_violation(pointed_thing.under, playername) - return + return itemstack end if minetest.is_protected(pointed_thing.above, playername) then minetest.record_protection_violation(pointed_thing.above, playername) - return + return itemstack end if def_under and def_under.on_rightclick then @@ -883,15 +883,14 @@ function signs_lib.register_fence_with_sign(fencename, fencewithsignname) itemstack:take_item() end placer:set_wielded_item(itemstack) - return itemstack - elseif not def_above or def_above.buildable_to then + elseif def_above and def_above.buildable_to then minetest.add_node(pointed_thing.above, {name = fencename, param2 = fdir}) if not signs_lib.expect_infinite_stacks then itemstack:take_item() end placer:set_wielded_item(itemstack) - return itemstack end + return itemstack end def_sign.on_construct = function(pos, ...) signs_lib.construct_sign(pos)