add lbm for better protector update
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -31,7 +31,6 @@ core.register_craftitem("protector:tool", {
|
||||
-- get members on protector
|
||||
local meta = core.get_meta(pos)
|
||||
local members = meta:get_string("members") or ""
|
||||
local faction_members = meta:get_int("faction_members")
|
||||
local factions = meta:get_string("factions") or ""
|
||||
|
||||
-- get direction player is facing
|
||||
@@ -139,12 +138,13 @@ core.register_craftitem("protector:tool", {
|
||||
-- copy members across if holding sneak when using tool
|
||||
if user:get_player_control().sneak then
|
||||
meta:set_string("members", members)
|
||||
meta:set_int("faction_members", faction_members)
|
||||
meta:set_string("factions", factions)
|
||||
else
|
||||
meta:set_string("members", "")
|
||||
end
|
||||
|
||||
core.add_entity(pos, "protector:display")
|
||||
|
||||
core.chat_send_player(name,
|
||||
S("Protector placed at @1", core.pos_to_string(pos)))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user