hide name via alpha channel when empty; setting it to the empty string reverts it to the "default" value, the player's name.

This commit is contained in:
flux 2023-05-20 15:17:43 -07:00
parent 6e1ab86ffc
commit 3ce1d2828b
Signed by: flux
GPG Key ID: 9333B27816848A15
2 changed files with 29 additions and 12 deletions

View File

@ -10,6 +10,20 @@ repos:
- repo: local
hooks:
- id: detect_debug
name: detect debug
language: pygrep
entry: DEBUG
pass_filenames: true
exclude: .pre-commit-config.yaml
fail_fast: true
- id: stylua
name: stylua
language: system
entry: stylua
pass_filenames: true
types: [ file, lua ]
fail_fast: true
- id: luacheck
name: luacheck
language: system
@ -17,9 +31,4 @@ repos:
pass_filenames: true
types: [ file, lua ]
args: [ -q ]
- id: stylua
name: stylua
language: system
entry: stylua
pass_filenames: true
types: [ file, lua ]
fail_fast: true

View File

@ -96,7 +96,7 @@ name_monoid.monoid_def = {
apply = function(nametag_attributes, player)
if nametag_attributes.hide_all then
player:set_nametag_attributes({
text = "",
text = " ",
color = { a = 0, r = 0, g = 0, b = 0 },
bgcolor = { a = 0, r = 0, g = 0, b = 0 },
})
@ -143,11 +143,19 @@ name_monoid.monoid_def = {
text = nametag_attributes.text
end
player:set_nametag_attributes({
text = text,
color = nametag_attributes.color,
bgcolor = nametag_attributes.bgcolor or false,
})
if text == "" then
player:set_nametag_attributes({
text = " ",
color = { a = 0, r = 0, g = 0, b = 0 },
bgcolor = { a = 0, r = 0, g = 0, b = 0 },
})
else
player:set_nametag_attributes({
text = text,
color = nametag_attributes.color,
bgcolor = nametag_attributes.bgcolor or false,
})
end
end
end,
}