Support optionally specifying map name in /ctf_next
This commit is contained in:
parent
67cb9b255d
commit
a98d759b35
1 changed files with 33 additions and 10 deletions
|
@ -66,21 +66,44 @@ function ctf_map.get_idx_and_map(param)
|
||||||
end
|
end
|
||||||
|
|
||||||
local next_idx
|
local next_idx
|
||||||
minetest.register_chatcommand("set_next", {
|
local function set_next_by_param(name, param)
|
||||||
privs = { ctf_admin = true },
|
|
||||||
func = function(name, param)
|
|
||||||
local idx, map = ctf_map.get_idx_and_map(param)
|
local idx, map = ctf_map.get_idx_and_map(param)
|
||||||
if idx then
|
if idx then
|
||||||
next_idx = idx
|
next_idx = idx
|
||||||
minetest.log("action", name .. " selected '" .. map.name .. "' as next map")
|
|
||||||
return true, "Selected " .. map.name
|
return true, "Selected " .. map.name
|
||||||
else
|
else
|
||||||
return false, "Couldn't find any matches"
|
return false, "Couldn't find any matching map!"
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
|
|
||||||
|
minetest.register_chatcommand("set_next", {
|
||||||
|
privs = { ctf_admin = true },
|
||||||
|
func = set_next_by_param
|
||||||
})
|
})
|
||||||
|
|
||||||
|
do
|
||||||
|
-- Override /ctf_next to support an optional map name as param
|
||||||
|
local old_func = minetest.registered_chatcommands["ctf_next"].func
|
||||||
|
minetest.override_chatcommand("ctf_next", {
|
||||||
|
params = "[map]",
|
||||||
|
description = "Start the next match. The map name can be optionally specified as param.",
|
||||||
|
func = function(name, param)
|
||||||
|
if param and param ~= "" then
|
||||||
|
local success, msg = set_next_by_param(name, param)
|
||||||
|
if not success then
|
||||||
|
return false, msg
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return old_func(name)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local function load_map_meta(idx, dirname, meta)
|
local function load_map_meta(idx, dirname, meta)
|
||||||
|
minetest.log("info", "load_map_meta: Loading map meta from '" .. dirname .. "/map.conf'")
|
||||||
if not meta:get("r") then
|
if not meta:get("r") then
|
||||||
error("Map was not properly configured: " .. dirname .. "/map.conf")
|
error("Map was not properly configured: " .. dirname .. "/map.conf")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue