mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-25 00:33:50 +01:00
add disband hook support
This commit is contained in:
parent
7c2398b541
commit
4caea5e17e
15
init.lua
15
init.lua
@ -25,6 +25,18 @@ minetest.register_on_mods_loaded(function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- Hooks
|
||||||
|
local disband_hooks = {}
|
||||||
|
-- When a faction is disbanded, these callbacks are called
|
||||||
|
-- hook(faction_name)
|
||||||
|
function factions.register_disband_hook(hook)
|
||||||
|
if 'function' ~= hook then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
table.insert(disband_hooks, hook)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-- Data
|
-- Data
|
||||||
local facts = {}
|
local facts = {}
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
@ -160,6 +172,9 @@ function factions.disband_faction(faction_name)
|
|||||||
end
|
end
|
||||||
facts[faction_name] = nil
|
facts[faction_name] = nil
|
||||||
save_factions()
|
save_factions()
|
||||||
|
for _, hook in ipairs(disband_hooks) do
|
||||||
|
hook(faction_name)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user