Add is_protected_action in Protection Block placing

master
MoNTE48 2019-09-10 19:49:08 +02:00
parent e5f6097714
commit a845b1adda
1 changed files with 18 additions and 15 deletions

View File

@ -37,23 +37,26 @@ minetest.register_node(":areasprotector:protector", {
local pos1 = vector.add(pos, vector.new(radius, radius, radius))
local pos2 = vector.add(pos, vector.new(-1 * radius, -1 * radius, -1 * radius))
local name = player:get_player_name()
local perm, err = areas:canPlayerAddArea(pos1, pos2, name)
if not perm then
minetest.chat_send_player(name, red("You are not allowed to protect that area: ") .. err)
if not minetest.is_protected_action(pos, name) then
local perm, err = areas:canPlayerAddArea(pos1, pos2, name)
if not perm then
minetest.chat_send_player(name, red("You are not allowed to protect that area: ") .. err)
return itemstack
end
local id = areas:add(name, "Protected by Protector Block", pos1, pos2)
areas:save()
local msg = string.format("The area from %s to %s has been protected as #%s", cyan(minetest.pos_to_string(pos1)), cyan(minetest.pos_to_string(pos2)), cyan(id))
minetest.chat_send_player(name, msg)
minetest.set_node(pos, {name = "areasprotector:protector"})
local meta = minetest.get_meta(pos)
local infotext = string.format("Protecting area %d owned by %s", id, name)
meta:set_string("infotext", infotext)
meta:set_int("area_id", id)
meta:set_string("owner", name)
itemstack:take_item()
return itemstack
end
local id = areas:add(name, "Protected by Protector Block", pos1, pos2)
areas:save()
local msg = string.format("The area from %s to %s has been protected as #%s", cyan(minetest.pos_to_string(pos1)), cyan(minetest.pos_to_string(pos2)), cyan(id))
minetest.chat_send_player(name, msg)
minetest.set_node(pos, {name = "areasprotector:protector"})
local meta = minetest.get_meta(pos)
local infotext = string.format("Protecting area %d owned by %s", id, name)
meta:set_string("infotext", infotext)
meta:set_int("area_id", id)
meta:set_string("owner", name)
itemstack:take_item()
return itemstack
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)