add lbm for better protector update

This commit is contained in:
tenplus1
2025-08-19 08:21:47 +01:00
parent 3e141f7080
commit 56b33bb50f
2 changed files with 20 additions and 10 deletions
+18 -8
View File
@@ -112,6 +112,24 @@ local function add_faction(meta, name)
set_faction_list(meta, list)
end
-- convert old faction tick-box to "*" for all owner factions
core.register_lbm({
label = "Protector update",
name = "protector:protector_update",
nodenames = {"protector:protect", "protector:protect2", "protector:protect_hidden"},
run_at_every_load = false,
action = function(pos, node, dtime_s)
local meta = core.get_meta(pos)
if meta:get_int("faction_members") == 1 then
meta:set_string("factions", "*")
meta:set_int("faction_members", 0)
end
end
})
-- check for member name
local function is_member(meta, name)
@@ -123,14 +141,6 @@ local function is_member(meta, name)
if factions_available then
-- migrate
if meta:get_int("faction_members") == 1 then
add_faction(meta, "*")
meta:set_int("faction_members", 0)
end
if factions.version == nil then
-- backward compatibility