Add check for is_protected when placing door

This commit is contained in:
CloudyProton 2017-12-10 14:33:42 -05:00 committed by GitHub
parent 2f420ef71a
commit 0458df996e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
-- xDoors² mod by xyz
-- xDoors² mod by xyz
-- modified by Sokomine to allow locked doors that can only be opened/closed/dig up by the player who placed them
-- a little bit modified by addi to allow someone with the priv "opendoors" to open/close/dig all locked doors.
-- Sokomine: modified again so that it uses the new locks-mod
@ -139,7 +139,10 @@ minetest.register_node("locks:door", {
stack_max = 1,
on_place = function(itemstack, placer, pointed_thing)
local above = pointed_thing.above
if minetest.is_protected(above, placer:get_player_name()) then
minetest.chat_send_player(placer:get_player_name(), "This area is protected!")
return itemstack
else
-- there should be 2 empty nodes
if minetest.env:get_node({x = above.x, y = above.y + 1, z = above.z}).name ~= "air" then
return itemstack
@ -172,6 +175,7 @@ minetest.register_node("locks:door", {
return ItemStack("")
end
end
})