Optimize openfarming check

This commit is contained in:
bri cassa 2025-03-20 00:08:37 +01:00
parent b129fb9494
commit 7f277db7ac

View File

@ -132,7 +132,7 @@ function areas:getSmallestAreaAtPos(pos)
return smallest_area, smallest_id
end
-- Checks if the area is unprotected, open, owned by player
-- Checks if the area is unprotected, open[farming], owned by player
-- or player is part of faction of [smallest] area at position.
function areas:canInteract(pos, name)
if minetest.check_player_privs(name, self.adminPrivs) then
@ -146,13 +146,13 @@ function areas:canInteract(pos, name)
areas_list = self:getAreasAtPos(pos)
end
local owned = false
local player = minetest.get_player_by_name(name)
local node = minetest.get_node(pos).name
for _, area in pairs(areas_list) do
-- Player owns the area or area is open
if area.owner == name or area.open then
return true
elseif area.openfarming then -- If area is openfarming
local player = minetest.get_player_by_name(name)
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