mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Allow bossbars to be grouped
This commit is contained in:
parent
3449b3eb7c
commit
f282cd0c4d
1 changed files with 15 additions and 1 deletions
|
@ -37,9 +37,23 @@ local last_id = 0
|
||||||
|
|
||||||
function mcl_bossbars.add_bar(player, def)
|
function mcl_bossbars.add_bar(player, def)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local bars = mcl_bossbars.bars[name]
|
||||||
local bar = {text = def.text}
|
local bar = {text = def.text}
|
||||||
bar.color, bar.image = get_color_info(def.color, def.percentage)
|
bar.color, bar.image = get_color_info(def.color, def.percentage)
|
||||||
table.insert(mcl_bossbars.bars[name], bar)
|
if def.dynamic then
|
||||||
|
for _, other in pairs(bars) do
|
||||||
|
if not other.id and other.color == bar.color and (other.original_text or other.text) == bar.text and other.image == bar.image then
|
||||||
|
if not other.count then
|
||||||
|
other.count = 1
|
||||||
|
other.original_text = other.text
|
||||||
|
end
|
||||||
|
other.count = other.count + 1
|
||||||
|
other.text = other.original_text .. " x" .. other.count
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(bars, bar)
|
||||||
if not def.dynamic then
|
if not def.dynamic then
|
||||||
bar.raw_color = def.color
|
bar.raw_color = def.color
|
||||||
bar.id = last_id + 1
|
bar.id = last_id + 1
|
||||||
|
|
Loading…
Reference in a new issue