From da8d1cfc73b0a80e5cd33095b78d169b6e828912 Mon Sep 17 00:00:00 2001 From: s20 <129506166+src4026@users.noreply.github.com> Date: Sat, 28 Oct 2023 21:05:13 +0530 Subject: [PATCH 1/2] Adding warning to inform map is being played in unsupported mode --- mods/ctf/ctf_map/map_functions.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mods/ctf/ctf_map/map_functions.lua b/mods/ctf/ctf_map/map_functions.lua index 7914fda57c..bb060bd6f4 100644 --- a/mods/ctf/ctf_map/map_functions.lua +++ b/mods/ctf/ctf_map/map_functions.lua @@ -47,6 +47,16 @@ function ctf_map.place_map(mapmeta, callback) ctf_map.current_map = mapmeta callback() + + local current_map = ctf_map.current_map + local current_mode = ctf_modebase.current_mode + if table.indexof(current_map.game_modes, current_mode) == -1 then + local concat = "The current mode is not in the list of modes supported by the current map." + local cmd_text = string.format("/ctf_next -f [mode:technical modename] %s", current_map.dirname) + minetest.chat_send_all(minetest.colorize( + "red", string.format("%s\nSupported mode(s): %s. To switch to a mode set for the map, do %s", + concat, table.concat(current_map.game_modes, ", "), cmd_text))) + end end) end From 721894a58e760fa2d9c23b59f46f39a9d3d574ce Mon Sep 17 00:00:00 2001 From: s20 <129506166+src4026@users.noreply.github.com> Date: Sat, 28 Oct 2023 21:17:49 +0530 Subject: [PATCH 2/2] Move code to match.lua --- mods/ctf/ctf_map/map_functions.lua | 10 ---------- mods/ctf/ctf_modebase/match.lua | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mods/ctf/ctf_map/map_functions.lua b/mods/ctf/ctf_map/map_functions.lua index bb060bd6f4..7914fda57c 100644 --- a/mods/ctf/ctf_map/map_functions.lua +++ b/mods/ctf/ctf_map/map_functions.lua @@ -47,16 +47,6 @@ function ctf_map.place_map(mapmeta, callback) ctf_map.current_map = mapmeta callback() - - local current_map = ctf_map.current_map - local current_mode = ctf_modebase.current_mode - if table.indexof(current_map.game_modes, current_mode) == -1 then - local concat = "The current mode is not in the list of modes supported by the current map." - local cmd_text = string.format("/ctf_next -f [mode:technical modename] %s", current_map.dirname) - minetest.chat_send_all(minetest.colorize( - "red", string.format("%s\nSupported mode(s): %s. To switch to a mode set for the map, do %s", - concat, table.concat(current_map.game_modes, ", "), cmd_text))) - end end) end diff --git a/mods/ctf/ctf_modebase/match.lua b/mods/ctf/ctf_modebase/match.lua index fa9285961e..5e7fd065cc 100644 --- a/mods/ctf/ctf_modebase/match.lua +++ b/mods/ctf/ctf_modebase/match.lua @@ -40,6 +40,17 @@ function ctf_modebase.start_match_after_vote() ctf_teams.allocate_teams(ctf_map.current_map.teams) ctf_modebase.current_mode_matches_played = ctf_modebase.current_mode_matches_played + 1 + + local current_map = ctf_map.current_map + local current_mode = ctf_modebase.current_mode + + if table.indexof(current_map.game_modes, current_mode) == -1 then + local concat = "The current mode is not in the list of modes supported by the current map." + local cmd_text = string.format("/ctf_next -f [mode:technical modename] %s", current_map.dirname) + minetest.chat_send_all(minetest.colorize( + "red", string.format("%s\nSupported mode(s): %s. To switch to a mode set for the map, do %s", + concat, table.concat(current_map.game_modes, ", "), cmd_text))) + end end) end