Adapt to the new version of playerfactions (#48)

Enable to open an area to many factions
    Update to adapt to the new version of playerfactions mod, with its new multi-faction mode
This commit is contained in:
Kalio_42
2020-09-05 18:49:17 +02:00
committed by GitHub
parent a9c05f0e38
commit c167b30ebf
9 changed files with 91 additions and 21 deletions

27
hud.lua
View File

@ -20,13 +20,32 @@ minetest.register_globalstep(function(dtime)
local areaStrings = {}
for id, area in pairs(areas:getAreasAtPos(pos)) do
local faction_info = area.faction_open and areas.factions_available and
factions.get_player_faction(area.owner)
area.faction_open = faction_info
local faction_info
if area.faction_open and areas.factions_available then
-- Gather and clean up disbanded factions
local changed = false
for i, fac_name in ipairs(area.faction_open) do
if not factions.get_owner(fac_name) then
table.remove(area.faction_open, i)
changed = true
end
end
if #area.faction_open == 0 then
-- Prevent DB clutter, remove value
area.faction_open = nil
else
faction_info = table.concat(area.faction_open, ", ")
end
if changed then
areas:save()
end
end
table.insert(areaStrings, ("%s [%u] (%s%s%s)")
:format(area.name, id, area.owner,
area.open and S(":open") or "",
faction_info and ":"..faction_info or ""))
faction_info and ": "..faction_info or ""))
end
for i, area in pairs(areas:getExternalHudEntries(pos)) do