diff --git a/chatcommands.lua b/chatcommands.lua index 35315ac..c3392c3 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -330,10 +330,10 @@ factions.register_command("list", { infaction = false, global_privileges = def_global_privileges, on_success = function(player, faction, pos, parcelpos, args) - local list = factions.factions.iterate() + local list = factions.factions.to_array() local tosend = "Existing factions:" - for i,v in ipairs(list) do + for i, v in ipairs(list) do if i ~= #list then tosend = tosend .. " " .. v .. "," else @@ -1525,7 +1525,7 @@ factions.register_command("obliterate", { infaction = false, global_privileges = {"faction_admin"}, on_success = function(player, faction, pos, parcelpos, args) - for i, facname in factions.factions.iterate() do + for facname, i in factions.factions.iterate() do factions.disband(facname, "obliterated") end return true diff --git a/diplomacy_events.lua b/diplomacy_events.lua index 715981e..c720745 100644 --- a/diplomacy_events.lua +++ b/diplomacy_events.lua @@ -1,13 +1,13 @@ function factions.start_diplomacy(name, faction) for l, i in factions.factions.iterate() do - local fac = factions.factions.get(i) - if i ~= name and not (faction.neutral[i] or faction.allies[i] or faction.enemies[i]) then + local fac = factions.factions.get(l) + if l ~= name and not (faction.neutral[l] or faction.allies[l] or faction.enemies[l]) then if factions_config.faction_diplomacy == true then - factions.new_neutral(name, i) - factions.new_neutral(i, name) + factions.new_neutral(name, l) + factions.new_neutral(l, name) else - factions.new_enemy(name, i) - factions.new_enemy(i, name) + factions.new_enemy(name, l) + factions.new_enemy(l, name) end end end diff --git a/factions.lua b/factions.lua index a1e996a..67a8e4b 100644 --- a/factions.lua +++ b/factions.lua @@ -142,7 +142,7 @@ function factions.set_name(oldname, name) local faction = factions.factions.get(oldname) faction.name = name - for i, v in factions.factions.iterate() do + for v, i in factions.factions.iterate() do if v ~= oldname then local fac = factions.factions.get(v) @@ -301,7 +301,7 @@ function factions.disband(name, reason) local faction = factions.factions.get(name) if not faction.is_admin then - for i, v in factions.factions.iterate() do + for v, i in factions.factions.iterate() do local fac = factions.factions.get(v) if fac ~= nil and fac.name ~= name then if fac.enemies[name] then @@ -496,7 +496,7 @@ end function factions.faction_tick() local now = os.time() - for i, facname in factions.factions.iterate() do + for facname, i in factions.factions.iterate() do local faction = factions.factions.get(facname) if faction ~= nil then