Update can_interact_with_node function

This change has the can_interact_with_node function check for both owner and protector, this way nodes like doors and chests could be protected as well and opened by many defined players instead of using keys (which still work too :)
This commit is contained in:
tenplus1 2020-08-13 19:58:26 +01:00 committed by GitHub
parent 0a96bac46d
commit 26bf531096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -666,10 +666,18 @@ function default.can_interact_with_node(player, pos)
return false return false
end end
local player_name = player:get_player_name()
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner") local owner = meta:get_string("owner") or ""
local prot = meta:get_string("protector") or ""
if not owner or owner == "" or owner == player:get_player_name() then -- Interaction with protected node
if prot ~= "" and owner == "" and not minetest.is_protected(pos, player_name) then
return true
end
-- Interaction with owned node
if prot = "" and (owner == "" or owner == player_name) then
return true return true
end end