allow reversing the order of the name parts
This commit is contained in:
parent
09cbb1abc5
commit
8953062ed5
26
init.lua
26
init.lua
|
@ -3,18 +3,18 @@ local modpath = minetest.get_modpath(modname)
|
|||
local S = minetest.get_translator(modname)
|
||||
|
||||
name_monoid = {
|
||||
version = os.time({year = 2022, month = 5, day = 22}),
|
||||
version = os.time({year = 2022, month = 5, day = 22}),
|
||||
fork = "fluxionary",
|
||||
|
||||
modname = modname,
|
||||
modpath = modpath,
|
||||
modname = modname,
|
||||
modpath = modpath,
|
||||
|
||||
S = S,
|
||||
|
||||
log = function(level, message_fmt, ...)
|
||||
local message = message_fmt:format(...)
|
||||
minetest.log(level, ("[%s] %s"):format(modname, message))
|
||||
end,
|
||||
log = function(level, message_fmt, ...)
|
||||
local message = message_fmt:format(...)
|
||||
minetest.log(level, ("[%s] %s"):format(modname, message))
|
||||
end,
|
||||
|
||||
dofile = function(...)
|
||||
dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua")
|
||||
|
@ -24,8 +24,10 @@ name_monoid = {
|
|||
name_monoid.dofile("settings")
|
||||
name_monoid.dofile("monoid")
|
||||
|
||||
if name_monoid.settings.show_name then
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
name_monoid.monoid:add_change(player, {text = player:get_player_name()}, "name_monoid")
|
||||
end)
|
||||
end
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if name_monoid.settings.show_name then
|
||||
name_monoid.monoid:add_change(player, {text = player:get_player_name()}, "name_monoid")
|
||||
else
|
||||
name_monoid.monoid:add_change(player, {text = "", text_separator = ""}, "name_monoid")
|
||||
end
|
||||
end)
|
||||
|
|
69
monoid.lua
69
monoid.lua
|
@ -17,27 +17,43 @@ name_monoid.monoid_def = {
|
|||
combine = function(nametag_attributes1, nametag_attributes2)
|
||||
if nametag_attributes1.hide_all or nametag_attributes2.hide_all then
|
||||
return {
|
||||
text = "",
|
||||
color = {a = 0, r = 255, g = 255, b = 255},
|
||||
bgcolor = {a = 0, r = 255, g = 255, b = 255},
|
||||
hide_all = true,
|
||||
}
|
||||
else
|
||||
local bgcolor
|
||||
if nametag_attributes2.bgcolor == nil then
|
||||
bgcolor = nametag_attributes1.bgcolor
|
||||
else
|
||||
bgcolor = nametag_attributes2.bgcolor
|
||||
end
|
||||
if name_monoid.settings.invert_composition then
|
||||
local bgcolor
|
||||
if nametag_attributes1.bgcolor == nil then
|
||||
bgcolor = nametag_attributes2.bgcolor
|
||||
else
|
||||
bgcolor = nametag_attributes1.bgcolor
|
||||
end
|
||||
|
||||
return {
|
||||
text = table.concat(
|
||||
remove_empty({nametag_attributes1.text, nametag_attributes2.text}),
|
||||
nametag_attributes2.text_separator or name_monoid.settings.text_separator
|
||||
),
|
||||
color = nametag_attributes1.color or nametag_attributes2.color,
|
||||
bgcolor = bgcolor,
|
||||
}
|
||||
return {
|
||||
text = table.concat(
|
||||
remove_empty({nametag_attributes2.text, nametag_attributes1.text}),
|
||||
nametag_attributes2.text_separator or name_monoid.settings.text_separator
|
||||
),
|
||||
color = nametag_attributes1.color or nametag_attributes2.color,
|
||||
bgcolor = bgcolor,
|
||||
}
|
||||
|
||||
else
|
||||
local bgcolor
|
||||
if nametag_attributes2.bgcolor == nil then
|
||||
bgcolor = nametag_attributes1.bgcolor
|
||||
else
|
||||
bgcolor = nametag_attributes2.bgcolor
|
||||
end
|
||||
|
||||
return {
|
||||
text = table.concat(
|
||||
remove_empty({nametag_attributes1.text, nametag_attributes2.text}),
|
||||
nametag_attributes2.text_separator or name_monoid.settings.text_separator
|
||||
),
|
||||
color = nametag_attributes2.color or nametag_attributes1.color,
|
||||
bgcolor = bgcolor,
|
||||
}
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -50,11 +66,20 @@ name_monoid.monoid_def = {
|
|||
end,
|
||||
|
||||
apply = function(nametag_attributes, player)
|
||||
player:set_nametag_attributes({
|
||||
text = nametag_attributes.text,
|
||||
color = nametag_attributes.color,
|
||||
bgcolor = nametag_attributes.bgcolor or false,
|
||||
})
|
||||
if nametag_attributes.hide_all 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 = nametag_attributes.text,
|
||||
color = nametag_attributes.color,
|
||||
bgcolor = nametag_attributes.bgcolor or false,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,6 @@ local s = minetest.settings
|
|||
|
||||
name_monoid.settings = {
|
||||
tag_separator = s:get("name_monoid.tag_separator") or " ",
|
||||
show_name = s:get_bool("name_monoid.show_name", true)
|
||||
show_name = s:get_bool("name_monoid.show_name", true),
|
||||
invert_composition = s:get_bool("name_monoid.invert_composition", false),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue