Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
Add hud tint to show team membership
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Oct 12, 2017
1 parent 4abfda0 commit 6dd85f8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 14 deletions.
39 changes: 26 additions & 13 deletions ctf_colors/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions ctf_colors/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Binary file added ctf_colors/textures/ctf_colors_hotbar_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ctf_colors/textures/ctf_colors_hotbar_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion ctf_flag/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6dd85f8

Please sign in to comment.