Add simple_protection support

This commit is contained in:
Jordan Irwin
2021-07-20 14:31:30 -07:00
parent c8757c94a0
commit 8ab2107d37
4 changed files with 18 additions and 4 deletions

View File

@@ -164,8 +164,21 @@ local function add_drop(drops, item)
end
end
local function is_protected(pos, name) return core.is_protected(pos, name) end
if core.global_exists("s_protect") then
is_protected = function(pos, name)
local s_protect_name = name
-- simple_protection ignores names with empty strings
if s_protect_name == "" then
s_protect_name = " "
end
return core.is_protected(pos, name) or not s_protect.can_access(pos, s_protect_name)
end
end
local function destroy(drops, pos, cid)
if core.is_protected(pos, "") then
if is_protected(pos, "") then
return
end
local def = cid_data[cid]