Enforce stricter type compliance for HUD elements (#602)
This commit is contained in:
parent
266fdd5a07
commit
8cf0a1648b
4 changed files with 14 additions and 14 deletions
|
@ -6,14 +6,14 @@ function ctf_colors.get_color(tplayer)
|
||||||
end
|
end
|
||||||
local tcolor_hex = ctf.flag_colors[tcolor_text]
|
local tcolor_hex = ctf.flag_colors[tcolor_text]
|
||||||
if not tcolor_hex then
|
if not tcolor_hex then
|
||||||
tcolor_hex = "0x000000"
|
tcolor_hex = 0x000000
|
||||||
end
|
end
|
||||||
|
|
||||||
local tcolor_css = "#" .. tcolor_hex:sub(3, 8)
|
local tcolor_css = "#" .. tostring(tcolor_hex):sub(3, 8)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text = tcolor_text,
|
text = tcolor_text,
|
||||||
hex = tcolor_hex,
|
hex = tonumber(tcolor_hex),
|
||||||
css = tcolor_css
|
css = tcolor_css
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,9 +5,9 @@ ctf.hud.register_part(function(player, name, tplayer)
|
||||||
for _, flag in pairs(team.flags) do
|
for _, flag in pairs(team.flags) do
|
||||||
local hud = "ctf:hud_" .. tname
|
local hud = "ctf:hud_" .. tname
|
||||||
local flag_name = flag.name or tname .. "'s base"
|
local flag_name = flag.name or tname .. "'s base"
|
||||||
local color = ctf.flag_colors[team.data.color]
|
local color = tonumber(ctf.flag_colors[team.data.color])
|
||||||
if not color then
|
if not color then
|
||||||
color = "0x000000"
|
color = 0x000000
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf.hud:exists(player, hud) then
|
if ctf.hud:exists(player, hud) then
|
||||||
|
@ -36,7 +36,7 @@ end)
|
||||||
ctf.hud.register_part(function(player, name, tplayer)
|
ctf.hud.register_part(function(player, name, tplayer)
|
||||||
-- Check all flags
|
-- Check all flags
|
||||||
local alert = nil
|
local alert = nil
|
||||||
local color = "0xFFFFFF"
|
local color = 0xFFFFFF
|
||||||
if ctf.setting("flag.alerts") then
|
if ctf.setting("flag.alerts") then
|
||||||
if ctf.setting("flag.alerts.neutral_alert") then
|
if ctf.setting("flag.alerts.neutral_alert") then
|
||||||
alert = "Punch the enemy flag! Protect your flag!"
|
alert = "Punch the enemy flag! Protect your flag!"
|
||||||
|
@ -55,22 +55,22 @@ ctf.hud.register_part(function(player, name, tplayer)
|
||||||
if teamHolder == name then
|
if teamHolder == name then
|
||||||
if enemyHolder then
|
if enemyHolder then
|
||||||
alert = "You can't capture the flag until " .. enemyHolder .. " is killed!"
|
alert = "You can't capture the flag until " .. enemyHolder .. " is killed!"
|
||||||
color = "0xFF0000"
|
color = 0xFF0000
|
||||||
else
|
else
|
||||||
alert = "You've got the flag! Run back and punch your flag!"
|
alert = "You've got the flag! Run back and punch your flag!"
|
||||||
color = "0xFF0000"
|
color = 0xFF0000
|
||||||
end
|
end
|
||||||
elseif teamHolder then
|
elseif teamHolder then
|
||||||
if enemyHolder then
|
if enemyHolder then
|
||||||
alert = "Kill " .. enemyHolder .. " to allow " .. teamHolder .. " to capture the flag!"
|
alert = "Kill " .. enemyHolder .. " to allow " .. teamHolder .. " to capture the flag!"
|
||||||
color = "0xFF0000"
|
color = 0xFF0000
|
||||||
else
|
else
|
||||||
alert = "Protect " .. teamHolder .. ", they've got the enemy flag!"
|
alert = "Protect " .. teamHolder .. ", they've got the enemy flag!"
|
||||||
color = "0xFF0000"
|
color = 0xFF0000
|
||||||
end
|
end
|
||||||
elseif enemyHolder then
|
elseif enemyHolder then
|
||||||
alert = "Kill " .. enemyHolder .. ", they've got your flag!"
|
alert = "Kill " .. enemyHolder .. ", they've got your flag!"
|
||||||
color = "0xFF0000"
|
color = 0xFF0000
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ local function add_marker(name, tname, pos, str)
|
||||||
teams[tname].players[pname] = tplayer:hud_add({
|
teams[tname].players[pname] = tplayer:hud_add({
|
||||||
hud_elem_type = "waypoint",
|
hud_elem_type = "waypoint",
|
||||||
name = str,
|
name = str,
|
||||||
number = ctf.flag_colors[team.data.color],
|
number = tonumber(ctf.flag_colors[team.data.color]),
|
||||||
world_pos = pos
|
world_pos = pos
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ local function update(name)
|
||||||
|
|
||||||
for i, def in ipairs(temp) do
|
for i, def in ipairs(temp) do
|
||||||
-- If not the top-most element, prefix with "+ "
|
-- If not the top-most element, prefix with "+ "
|
||||||
local text = def.value
|
local text = tostring(def.value)
|
||||||
if i > 1 then
|
if i > 1 then
|
||||||
text = "+ " .. text
|
text = "+ " .. text
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ local function update(name)
|
||||||
alignment = {x = 0, y = 0},
|
alignment = {x = 0, y = 0},
|
||||||
position = {x = 0.5, y = 0.6},
|
position = {x = 0.5, y = 0.6},
|
||||||
offset = {x = 0, y = i * 20},
|
offset = {x = 0, y = i * 20},
|
||||||
number = def.color,
|
number = tonumber(def.color),
|
||||||
text = text
|
text = text
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue