From 26bf53109646074c0d12ed12d27bd3afd222ad43 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Thu, 13 Aug 2020 19:58:26 +0100 Subject: [PATCH] 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 :) --- mods/default/functions.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 3dd7a008..ef02d8b7 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -666,10 +666,18 @@ function default.can_interact_with_node(player, pos) return false end + local player_name = player:get_player_name() 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 end