areas/interact.lua

29 lines
693 B
Lua
Raw Normal View History

2020-03-08 22:15:00 +01:00
local S = minetest.get_translator("areas")
2013-09-03 01:16:14 +02:00
2013-12-18 02:31:11 +01:00
local old_is_protected = minetest.is_protected
2013-12-15 23:47:56 +01:00
function minetest.is_protected(pos, name)
if not areas:canInteract(pos, name) then
return true
end
2013-12-15 23:47:56 +01:00
return old_is_protected(pos, name)
end
2013-12-15 23:47:56 +01:00
minetest.register_on_protection_violation(function(pos, name)
if areas:canInteract(pos, name) then
return
end
local owners = areas:getNodeOwners(pos)
if #owners == 0 then
-- When require_protection=true
2013-12-15 23:47:56 +01:00
minetest.chat_send_player(name,
S("@1 may not be accessed.",
minetest.pos_to_string(pos)))
return
2013-09-03 01:16:14 +02:00
end
minetest.chat_send_player(name,
S("@1 is protected by @2.",
minetest.pos_to_string(pos),
table.concat(owners, ", ")))
2013-12-15 23:47:56 +01:00
end)