Allow custom checks before allowing a player to protect new areas (#74)

This commit is contained in:
tour
2024-03-22 22:26:12 +01:00
committed by GitHub
parent c044d49d21
commit 0bad0ec0ae
3 changed files with 79 additions and 20 deletions

13
api.lua
View File

@ -1,9 +1,22 @@
local hudHandlers = {}
areas.registered_protection_conditions = {}
areas.registered_on_adds = {}
areas.registered_on_removes = {}
areas.registered_on_moves = {}
areas.callback_origins = {}
function areas:registerProtectionCondition(func)
table.insert(areas.registered_protection_conditions, func)
local debug_info = debug.getinfo(func, "S")
areas.callback_origins[func] = {
mod = core.get_current_modname() or "??",
source = debug_info.short_src or "??",
line = debug_info.linedefined or "??"
}
end
function areas:registerOnAdd(func)
table.insert(areas.registered_on_adds, func)
end