diff options
Diffstat (limited to 'interact.lua')
-rw-r--r-- | interact.lua | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/interact.lua b/interact.lua index f6a7cb1..feba9e5 100644 --- a/interact.lua +++ b/interact.lua @@ -10,30 +10,33 @@ if minetest.can_interact then old_can_interact = minetest.can_interact function minetest.can_interact(pos, name) if not areas:canInteract(pos, name) then - printWarning(name, pos) return false end return old_can_interact(pos, name) end -else - local old_node_place = minetest.item_place_node - function minetest.item_place_node(itemstack, placer, pointed_thing) - -- XXX: buildable_to nodes can mess this up - local pos = pointed_thing.above - if not areas:canInteract(pos, placer:get_player_name()) then - printWarning(placer:get_player_name(), pos) - return itemstack -- Abort place. - end - return old_node_place(itemstack, placer, pointed_thing) +end + +local old_node_place = minetest.item_place_node +function minetest.item_place_node(itemstack, placer, pointed_thing) + local pos = pointed_thing.above + local ndef = minetest.registered_nodes[pointed_thing.under] + if ndef and ndef.buildable_to then + pos = pointed_thing.under end - local old_node_dig = minetest.node_dig - function minetest.node_dig(pos, node, digger) - if not areas:canInteract(pos, digger:get_player_name()) then - printWarning(digger:get_player_name(), pos) - return -- Abort dig. - end - return old_node_dig(pos, node, digger) + if not areas:canInteract(pos, placer:get_player_name()) then + printWarning(placer:get_player_name(), pos) + return itemstack -- Abort place. + end + return old_node_place(itemstack, placer, pointed_thing) +end + +local old_node_dig = minetest.node_dig +function minetest.node_dig(pos, node, digger) + if not areas:canInteract(pos, digger:get_player_name()) then + printWarning(digger:get_player_name(), pos) + return -- Abort dig. end + return old_node_dig(pos, node, digger) end |