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