From a8cacee8cc53a0f16583be1b116cbb022f6ee87d Mon Sep 17 00:00:00 2001 From: Crabman77 Date: Sat, 9 Jul 2022 02:49:12 +0200 Subject: [PATCH] Fixed a minor bug introduced when I created openfarming, which skips the faction test if an area is openfarming. And not return false if not a player(ie:mobs api) or unknown node, continue iterate on others areas(minor bug, generaly if 1 area it's protected). --- api.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/api.lua b/api.lua index cf85686..641b4ea 100644 --- a/api.lua +++ b/api.lua @@ -110,25 +110,27 @@ function areas:canInteract(pos, name) for _, area in pairs(self:getAreasAtPos(pos)) do if area.owner == name or area.open then return true - elseif area.openfarming then + end + if area.openfarming then -- if area is openfarming - local node = minetest.get_node(pos).name - if not minetest.registered_nodes[node] then return false end local player = minetest.get_player_by_name(name) - if not player then return false end - local wstack = player:get_wielded_item():get_name() - if wstack == "" then wstack = "hand" end + local node = minetest.get_node(pos).name + if player and minetest.registered_nodes[node] then + local wstack = player:get_wielded_item():get_name() + if wstack == "" then wstack = "hand" end - --on_dig - if minetest.get_item_group(node, "plant") == 1 and (wstack == "hand" or minetest.registered_tools[wstack]) then - return true - end + --on_dig + if minetest.get_item_group(node, "plant") == 1 and (wstack == "hand" or minetest.registered_tools[wstack]) then + return true + end - --on_place - if plants[wstack] ~= nil and plants[wstack] == node then - return true + --on_place + if plants[wstack] ~= nil and plants[wstack] == node then + return true + end end - elseif areas.factions_available and area.faction_open then + end + if areas.factions_available and area.faction_open then if (factions.version or 0) < 2 then local faction_name = factions.get_player_faction(name) if faction_name then