Add /summary command to show last match's stats

* Add /summary command

* Fix invalid method names
This commit is contained in:
Anand S 2018-07-02 13:48:25 +05:30 committed by rubenwardy
parent 460fd335ff
commit 2ffaed27af

View file

@ -1,3 +1,6 @@
local storage = minetest.get_mod_storage()
local prev_match_summary = storage:get("prev_match_summary")
local function render_per_team_stats(red, blue, stat, round)
local red_stat, blue_stat = red[stat], blue[stat]
if round then
@ -65,6 +68,11 @@ function ctf_stats.get_formspec_match_summary(stats, winner_team, winner_player,
ret = ret .. "label[10,0.5;" .. render_per_team_stats(red, blue, "score", true) .. "]"
ret = ret .. "label[3.5,7.2;Tip: type /rankings for league tables]"
-- Set prev_match_summary and write to mod_storage
prev_match_summary = ret
storage:set("prev_match_summary", ret)
return ret
end
@ -259,3 +267,13 @@ minetest.register_chatcommand("reset_rankings", {
return true, "Reset the stats and ranking of " .. reset_name
end
})
minetest.register_chatcommand("summary", {
func = function (name, param)
if not prev_match_summary then
return false, "Couldn't find the requested data."
end
minetest.show_formspec(name, "ctf_stats:prev_match_summary", prev_match_summary)
end
})