From 092be70b6f4ab490cb1b44678ab13fb3a2955973 Mon Sep 17 00:00:00 2001 From: Coder12a <38924418+Coder12a@users.noreply.github.com> Date: Fri, 28 Jun 2019 09:46:15 -0500 Subject: [PATCH] Allow: player db to store more data --- factions.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/factions.lua b/factions.lua index 67a8e4b..a4bdaca 100644 --- a/factions.lua +++ b/factions.lua @@ -176,7 +176,9 @@ function factions.set_name(oldname, name) end for playername in pairs(faction.players) do - factions.players.set(playername, name) + local data = factions.players.get(playername) or {} + data.faction = name + factions.players.set(playername, data) end for playername in pairs(factions.onlineplayers[oldname]) do @@ -228,7 +230,11 @@ function factions.add_player(name, player, rank) end faction.players[player] = rank or faction.default_rank - factions.players.set(player, name) + + local data = factions.players.get(player) or {} + data.faction = name + factions.players.set(player, data) + faction.invited_players[player] = nil local pdata = minetest.get_player_by_name(player) if pdata then @@ -473,9 +479,9 @@ function factions.get_parcel_pos(pos) end function factions.get_player_faction(playername) - local facname = factions.players.get(playername) - if facname then - local faction = factions.factions.get(facname) + local data = factions.players.get(playername) + if data then + local faction = factions.factions.get(faction.faction) return faction, facname end return nil