ctf_stats: Add map name to match summary (#495)
This commit is contained in:
parent
64793ea22c
commit
4de074dc17
3 changed files with 23 additions and 1 deletions
|
@ -285,6 +285,11 @@ local function place_map(map)
|
||||||
end, nil)
|
end, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ctf_map.registered_on_map_loaded = {}
|
||||||
|
function ctf_map.register_on_map_loaded(func)
|
||||||
|
ctf_map.registered_on_map_loaded[#ctf_map.registered_on_map_loaded + 1] = func
|
||||||
|
end
|
||||||
|
|
||||||
ctf_match.register_on_new_match(function()
|
ctf_match.register_on_new_match(function()
|
||||||
minetest.clear_objects({ mode = "quick" })
|
minetest.clear_objects({ mode = "quick" })
|
||||||
|
|
||||||
|
@ -366,6 +371,11 @@ ctf_match.register_on_new_match(function()
|
||||||
|
|
||||||
-- Update players' skyboxes last
|
-- Update players' skyboxes last
|
||||||
ctf_map.set_skybox_all()
|
ctf_map.set_skybox_all()
|
||||||
|
|
||||||
|
-- Run on_map_loaded callbacks
|
||||||
|
for i = 1, #ctf_map.registered_on_map_loaded do
|
||||||
|
ctf_map.registered_on_map_loaded[i](ctf_map.map)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function ctf_match.create_teams()
|
function ctf_match.create_teams()
|
||||||
|
|
|
@ -62,6 +62,7 @@ function ctf_stats.get_formspec_match_summary(stats, winner_team, winner_player,
|
||||||
|
|
||||||
local ret = ctf_stats.get_formspec("Match Summary", players, 1)
|
local ret = ctf_stats.get_formspec("Match Summary", players, 1)
|
||||||
|
|
||||||
|
-- Winning team and flag capturer name
|
||||||
if stats[winner_team] then
|
if stats[winner_team] then
|
||||||
local winner_color = ctf.flag_colors[winner_team]:gsub("0x", "#")
|
local winner_color = ctf.flag_colors[winner_team]:gsub("0x", "#")
|
||||||
ret = ret .. "item_image[0,0;1,1;ctf_flag:flag_top_"..winner_team.."]"
|
ret = ret .. "item_image[0,0;1,1;ctf_flag:flag_top_"..winner_team.."]"
|
||||||
|
@ -73,6 +74,9 @@ function ctf_stats.get_formspec_match_summary(stats, winner_team, winner_player,
|
||||||
ret = ret .. "label[1,0;NO WINNER]"
|
ret = ret .. "label[1,0;NO WINNER]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Map name
|
||||||
|
ret = ret .. "label[1,7.6;Map: " .. minetest.colorize("#EEEE00", stats.map) .. "]"
|
||||||
|
|
||||||
ret = ret .. "label[6.5,0;Kills]"
|
ret = ret .. "label[6.5,0;Kills]"
|
||||||
ret = ret .. "label[8,0;" .. render_team_stats(red, blue, "kills") .. "]"
|
ret = ret .. "label[8,0;" .. render_team_stats(red, blue, "kills") .. "]"
|
||||||
ret = ret .. "label[6.5,0.5;Attempts]"
|
ret = ret .. "label[6.5,0.5;Attempts]"
|
||||||
|
@ -81,7 +85,7 @@ function ctf_stats.get_formspec_match_summary(stats, winner_team, winner_player,
|
||||||
ret = ret .. "label[12,0;" .. match_length .. "]"
|
ret = ret .. "label[12,0;" .. match_length .. "]"
|
||||||
ret = ret .. "label[10.5,0.5;Total score]"
|
ret = ret .. "label[10.5,0.5;Total score]"
|
||||||
ret = ret .. "label[12,0.5;" .. render_team_stats(red, blue, "score", true) .. "]"
|
ret = ret .. "label[12,0.5;" .. render_team_stats(red, blue, "score", true) .. "]"
|
||||||
ret = ret .. "label[2,7.75;Tip: type /rankings for league tables]"
|
ret = ret .. "label[8,7.2;Tip: type /rankings for league tables]"
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
|
@ -217,6 +217,14 @@ ctf_match.register_on_new_match(function()
|
||||||
_needs_save = true
|
_needs_save = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- ctf_map can't be added as a dependency, as that'd result
|
||||||
|
-- in cyclic dependencies between ctf_map and ctf_stats
|
||||||
|
minetest.after(0, function()
|
||||||
|
ctf_map.register_on_map_loaded(function(map)
|
||||||
|
ctf_stats.current.map = map.name
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
ctf_flag.register_on_pick_up(function(name, flag)
|
ctf_flag.register_on_pick_up(function(name, flag)
|
||||||
local main, match = ctf_stats.player(name)
|
local main, match = ctf_stats.player(name)
|
||||||
if main and match then
|
if main and match then
|
||||||
|
|
Loading…
Reference in a new issue