Alerts via HUD who has a flag
This commit is contained in:
parent
60e4e0600e
commit
43e4d7fa75
15
ctf/hud.lua
15
ctf/hud.lua
@ -26,21 +26,6 @@ function ctf.hud.update(player)
|
||||
end
|
||||
end
|
||||
|
||||
ctf.hud.register_part(function(player, name, tplayer)
|
||||
if not ctf.hud:exists(player, "ctf:hud_team") then
|
||||
ctf.hud:add(player, "ctf:hud_team", {
|
||||
hud_elem_type = "text",
|
||||
position = {x = 1, y = 0},
|
||||
scale = {x = 100, y = 100},
|
||||
text = tplayer.team,
|
||||
number = "0x000000",
|
||||
offset = {x=-100, y = 20}
|
||||
})
|
||||
else
|
||||
ctf.hud:change(player, "ctf:hud_team", "text", tplayer.team)
|
||||
end
|
||||
end)
|
||||
|
||||
function ctf.hud.updateAll()
|
||||
if not ctf.setting("hud") then
|
||||
return
|
||||
|
@ -43,7 +43,8 @@ ctf.hud.register_part(function(player, name, tplayer)
|
||||
scale = {x = 100, y = 100},
|
||||
text = tplayer.team,
|
||||
number = color,
|
||||
offset = {x=-100, y = 20}
|
||||
offset = {x = -20, y = 20},
|
||||
alignment = {x = -1, y = 0}
|
||||
})
|
||||
else
|
||||
ctf.hud:change(player, "ctf:hud_team", "number", color)
|
||||
|
@ -31,6 +31,8 @@ local function do_capture(attname, flag, returned)
|
||||
player = attname
|
||||
}
|
||||
|
||||
ctf.hud.updateAll()
|
||||
|
||||
ctf_flag.update(flag)
|
||||
|
||||
for i = 1, #ctf_flag.registered_on_pick_up do
|
||||
|
@ -79,6 +79,35 @@ ctf.hud.register_part(function(player, name, tplayer)
|
||||
end
|
||||
end)
|
||||
|
||||
ctf.hud.register_part(function(player, name, tplayer)
|
||||
local alert = nil
|
||||
local team = ctf.team(tplayer.team)
|
||||
for _, flag in pairs(team.flags) do
|
||||
if flag.claimed then
|
||||
alert = "Kill " .. flag.claimed.player .. ", they have your flag!"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if alert then
|
||||
if ctf.hud:exists(player, "ctf:hud_team_alert") then
|
||||
ctf.hud:change(player, "ctf:hud_team_alert", "text", alert)
|
||||
else
|
||||
ctf.hud:add(player, "ctf:hud_team_alert", {
|
||||
hud_elem_type = "text",
|
||||
position = {x = 1, y = 0},
|
||||
scale = {x = 100, y = 100},
|
||||
text = alert,
|
||||
number = "0xFF0000",
|
||||
offset = {x = -10, y = 50},
|
||||
alignment = {x = -1, y = 0}
|
||||
})
|
||||
end
|
||||
else
|
||||
ctf.hud:remove(player, "ctf:hud_team_alert")
|
||||
end
|
||||
end)
|
||||
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
||||
|
||||
@ -127,6 +156,8 @@ function ctf_flag.player_drop_flag(name)
|
||||
end
|
||||
flag_name = flag.team .. "'s " .. flag_name .. "flag"
|
||||
|
||||
ctf.hud.updateAll()
|
||||
|
||||
ctf.action("flag", name .. " dropped " .. flag_name)
|
||||
minetest.chat_send_all(flag_name.." has returned.")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user