Colorize "flag regarding" messages (#715)

* Colorize "flag regarding" messages

* edit flag_func.lua

* edit api.lua

* edit matches.lua

* fix small bug in flag_func.lua

* fix another small bug in flag_func.lua
This commit is contained in:
-sniper- 2020-12-13 17:44:31 +01:00 committed by GitHub
parent 0345c4e284
commit a51d7cd347
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 7 deletions

View file

@ -80,7 +80,17 @@ function ctf_flag.player_drop_flag(name)
ctf.hud.updateAll() ctf.hud.updateAll()
ctf.action("flag", name .. " dropped " .. flag_name) ctf.action("flag", name .. " dropped " .. flag_name)
minetest.chat_send_all(flag_name.." has returned.")
local flag_return_color = "#ffffff"
if flag_name == "red's flag" then
flag_return_color = ctf_colors.colors["red"]
end
if flag_name == "blue's flag" then
flag_return_color = ctf_colors.colors["blue"]
end
flag_return_color = "#" .. tostring(flag_return_color):sub(3, 8)
minetest.chat_send_all(minetest.colorize(flag_return_color, (flag_name.." has returned.")))
for j = 1, #ctf_flag.registered_on_drop do for j = 1, #ctf_flag.registered_on_drop do
ctf_flag.registered_on_drop[j](name, flag) ctf_flag.registered_on_drop[j](name, flag)

View file

@ -16,8 +16,22 @@ local function do_capture(attname, flag, returned)
end end
end end
minetest.chat_send_all(flag_name.." has been picked up by ".. local team_has_flag_color = "#ffffff"
attname.." (team "..attacker.team..")") local team_lose_flag_color = "#ffffff"
if attacker.team == "red" then
team_has_flag_color = ctf_colors.colors["red"]
team_lose_flag_color = ctf_colors.colors["blue"]
end
if attacker.team == "blue" then
team_has_flag_color = ctf_colors.colors["blue"]
team_lose_flag_color = ctf_colors.colors["red"]
end
team_has_flag_color = "#" .. tostring(team_has_flag_color):sub(3, 8)
team_lose_flag_color = "#" .. tostring(team_lose_flag_color):sub(3, 8)
minetest.chat_send_all((minetest.colorize(team_lose_flag_color, flag_name)).." has been picked up by "..
(minetest.colorize(team_has_flag_color, (attname.." (team "..attacker.team..")"))))
ctf.action("flag", attname .. " picked up " .. flag_name) ctf.action("flag", attname .. " picked up " .. flag_name)
@ -41,8 +55,22 @@ local function do_capture(attname, flag, returned)
end end
end end
minetest.chat_send_all(flag_name.." has been captured ".. local team_win_color = "#ffffff"
" by "..attname.." (team "..attacker.team..")") local team_lose_color = "#ffffff"
if attacker.team == "red" then
team_win_color = ctf_colors.colors["red"]
team_lose_color = ctf_colors.colors["blue"]
end
if attacker.team == "blue" then
team_win_color = ctf_colors.colors["blue"]
team_lose_color = ctf_colors.colors["red"]
end
team_win_color = "#" .. tostring(team_win_color):sub(3, 8)
team_lose_color = "#" .. tostring(team_lose_color):sub(3, 8)
minetest.chat_send_all((minetest.colorize(team_lose_color, flag_name)).." has been captured "..
"by "..(minetest.colorize(team_win_color, (attname.." (team "..attacker.team..")"))))
ctf.action("flag", attname .. " captured " .. flag_name) ctf.action("flag", attname .. " captured " .. flag_name)

View file

@ -62,7 +62,18 @@ function ctf_match.check_for_winner()
if not game_won then if not game_won then
game_won = true game_won = true
ctf.action("match", winner .. " won!") ctf.action("match", winner .. " won!")
minetest.chat_send_all(minetest.colorize("#028704", ("Team " .. winner .. " won!")))
local winner_color = "#ffffff"
if winner == "red" then
winner_color = ctf_colors.colors["red"]
end
if winner == "blue" then
winner_color = ctf_colors.colors["blue"]
end
winner_color = "#" .. tostring(winner_color):sub(3, 8)
minetest.chat_send_all(minetest.colorize(winner_color, ("Team " .. winner .. " won!")))
for i = 1, #ctf_match.registered_on_winner do for i = 1, #ctf_match.registered_on_winner do
ctf_match.registered_on_winner[i](winner) ctf_match.registered_on_winner[i](winner)
end end
@ -99,7 +110,7 @@ ctf_flag.register_on_capture(function(attname, flag)
if fl_team and #fl_team.flags == 0 then if fl_team and #fl_team.flags == 0 then
ctf.action("match", flag.team .. " was defeated.") ctf.action("match", flag.team .. " was defeated.")
ctf.remove_team(flag.team) ctf.remove_team(flag.team)
minetest.chat_send_all(minetest.colorize("#028704", (flag.team .. " has been defeated!"))) minetest.chat_send_all(minetest.colorize("#808080", (flag.team .. " has been defeated!")))
end end
ctf_match.check_for_winner() ctf_match.check_for_winner()