Add hud tint to show team membership

master
rubenwardy 2017-10-12 15:24:56 +01:00
parent 4abfda056f
commit 6dd85f8c91
7 changed files with 35 additions and 14 deletions

View File

@ -32,6 +32,17 @@ function ctf_colors.update(player, name, tplayer)
color = ctf_colors.get_nametag_color(name, tplayer, tcolor_text, tcolor_hex) })
end
if ctf.setting("colors.hudtint") then
if tcolor_text == "red" or tcolor_text == "blue" then
print("tinting hud! " .. tcolor_hex)
local tint_color = "#" .. string.sub(tcolor_hex, 3)
player:hud_set_hotbar_image("ctf_colors_hotbar_" .. tcolor_text .. ".png")
player:hud_set_hotbar_selected_image("ctf_colors_hotbar_selected_" .. tcolor_text .. ".png")
else
ctf.error("ctfcolors", "Hint color not supported for " .. tcolor_text)
end
end
if ctf.setting("colors.skins") and tcolor_text and tcolor_hex then
if minetest.global_exists("armor") then
-- TODO: how should support for skin mods be done?
@ -44,19 +55,21 @@ function ctf_colors.update(player, name, tplayer)
end
end
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 = "Team " .. tplayer.team,
number = tcolor_hex,
offset = {x = -20, y = 20},
alignment = {x = -1, y = 0}
})
else
ctf.hud:change(player, "ctf:hud_team", "text", "Team " .. tplayer.team)
ctf.hud:change(player, "ctf:hud_team", "number", tcolor_hex)
if ctf.setting("hud.teamname") then
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 = "Team " .. tplayer.team,
number = tcolor_hex,
offset = {x = -20, y = 20},
alignment = {x = -1, y = 0}
})
else
ctf.hud:change(player, "ctf:hud_team", "text", "Team " .. tplayer.team)
ctf.hud:change(player, "ctf:hud_team", "number", tcolor_hex)
end
end
end

View File

@ -21,6 +21,8 @@ ctf.register_on_init(function()
ctf._set("colors.skins", false)
ctf._set("colors.nametag", true)
ctf._set("colors.nametag.tcolor", false)
ctf._set("colors.hudtint", true)
ctf._set("hud.teamname", false)
end)
dofile(minetest.get_modpath("ctf_colors") .. "/hud.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -57,13 +57,19 @@ ctf.hud.register_part(function(player, name, tplayer)
ctf.hud:change(player, "ctf:hud_team_alert", "text", alert)
ctf.hud:change(player, "ctf:hud_team_alert", "number", color)
else
local y
if ctf.setting("hud.teamname") then
y = 50
else
y = 20
end
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 = color,
offset = {x = -10, y = 50},
offset = {x = -10, y = y},
alignment = {x = -1, y = 0}
})
end