add functions api + documentation (#23)

This commit is contained in:
wsor4035
2024-05-26 12:31:52 -04:00
committed by GitHub
parent 5b4b19a184
commit 788217bb8e
5 changed files with 36 additions and 1 deletions

19
src/functions.lua Normal file
View File

@ -0,0 +1,19 @@
local functions = {}
function functions.can_interact_with_node(player, pos)
--if we have default, use it
if default then return default.can_interact_with_node(player, pos) end
local owner = minetest.get_meta(pos):get_string("owner") or ""
--check that we have a valid player
if not player or not player:is_player() then return false end
--check there privs for compat with areas
if minetest.check_player_privs(player, "protection_bypass") then return true end
--if a normal player, check if they are the owner
if owner == "" or owner == player:get_player_name() then return true end
return false
end
return functions