From 12d7228ff0da38647b759e86e7b22e15aa4d8046 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 18 Apr 2018 23:00:15 +0100 Subject: [PATCH] Add bounty kills to stats --- mods/ctf_bounties/init.lua | 4 ++++ mods/ctf_stats/gui.lua | 5 +++-- mods/ctf_stats/init.lua | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mods/ctf_bounties/init.lua b/mods/ctf_bounties/init.lua index a6d34f2..f3c9702 100644 --- a/mods/ctf_bounties/init.lua +++ b/mods/ctf_bounties/init.lua @@ -88,6 +88,10 @@ ctf.register_on_killedplayer(function(victim, killer) local msg = killer .. " has killed " .. victim .. " and received the prize!" minetest.chat_send_all(msg) + + local pstats, mstats = ctf_stats.player(killer) + pstats.bounty_kills = pstats.bounty_kills + 1 + mstats.bounty_kills = mstats.bounty_kills + 1 end end) diff --git a/mods/ctf_stats/gui.lua b/mods/ctf_stats/gui.lua index 6c6f014..4b0020c 100644 --- a/mods/ctf_stats/gui.lua +++ b/mods/ctf_stats/gui.lua @@ -77,10 +77,10 @@ function ctf_stats.get_formspec(title, players, header) ret = ret .. "container[0,"..header.."]" ret = ret .. "vertlabel[0,0;" .. title .. "]" - ret = ret .. "tablecolumns[color;text;text;text;text;text;text;text;text]" + ret = ret .. "tablecolumns[color;text;text;text;text;text;text;text;text;text]" ret = ret .. "tableoptions[highlight=#00000000]" ret = ret .. "table[0.5,0;11.25,6;scores;" - ret = ret .. "#ffffff,,username,kills,deaths,K/D ratio,captures,attempts,score" + ret = ret .. "#ffffff,,Player,Kills,Deaths,K/D ratio,Bounty kills,Captures,Attempts,Score" for i = 1, #players do local pstat = players[i] @@ -96,6 +96,7 @@ function ctf_stats.get_formspec(title, players, header) "," .. pstat.kills .. "," .. pstat.deaths .. "," .. math.floor(kd*10)/10 .. + "," .. pstat.bounty_kills .. "," .. pstat.captures .. "," .. pstat.attempts .. "," .. math.floor(pstat.score*10)/10 diff --git a/mods/ctf_stats/init.lua b/mods/ctf_stats/init.lua index 1177608..bdcd441 100644 --- a/mods/ctf_stats/init.lua +++ b/mods/ctf_stats/init.lua @@ -118,6 +118,8 @@ function ctf_stats.player(name) ctf_stats.players[name] = player_stats end + player_stats.bounty_kills = player_stats.bounty_kills or 0 + local match_player_stats = ctf_stats.current.red[name] or ctf_stats.current.blue[name] @@ -132,6 +134,7 @@ ctf.register_on_join_team(function(name, tname) attempts = 0, captures = 0, score = 0, + bounty_kills = 0, } end)