areas/interact.lua
alexerate 6cad881b6f update player location
update player location when protected
2018-02-05 18:17:53 +01:00

23 lines
599 B
Lua

local old_is_protected = minetest.is_protected
function minetest.is_protected(pos, name)
local player = minetest.get_player_by_name(name)
local playerpos = player:getpos()
if not areas:canInteract(pos, name) then
player:setpos(playerpos)
return true
end
return old_is_protected(pos, name)
end
minetest.register_on_protection_violation(function(pos, name)
if not areas:canInteract(pos, name) then
local owners = areas:getNodeOwners(pos)
minetest.chat_send_player(name,
("%s is protected by %s."):format(
minetest.pos_to_string(pos),
table.concat(owners, ", ")))
end
end)