1
0
Fork 0

Add a bossbar limit setting

This commit is contained in:
Lizzy Fleckenstein 2021-04-07 17:02:03 +02:00
parent f282cd0c4d
commit 567f157541
2 changed files with 26 additions and 20 deletions

View File

@ -3,6 +3,7 @@ mcl_bossbars = {
huds = {}, huds = {},
static = {}, static = {},
colors = {"light_purple", "blue", "red", "green", "yellow", "dark_purple", "white"}, colors = {"light_purple", "blue", "red", "green", "yellow", "dark_purple", "white"},
max_bars = tonumber(minetest.settings:get("max_bossbars")) or 6
} }
function mcl_bossbars.recalculate_colors() function mcl_bossbars.recalculate_colors()
@ -127,27 +128,29 @@ minetest.register_globalstep(function()
end end
if bar and not hud then if bar and not hud then
hud = { if i < mcl_bossbars.max_bars then
color = bar.color, hud = {
image = bar.image, color = bar.color,
text = bar.text, image = bar.image,
text_id = player:hud_add({
hud_elem_type = "text",
text = bar.text, text = bar.text,
number = bar.color, text_id = player:hud_add({
position = {x = 0.5, y = 0}, hud_elem_type = "text",
alignment = {x = 0, y = 1}, text = bar.text,
offset = {x = 0, y = i * 40}, number = bar.color,
}), position = {x = 0.5, y = 0},
image_id = player:hud_add({ alignment = {x = 0, y = 1},
hud_elem_type = "image", offset = {x = 0, y = i * 40},
text = bar.image, }),
position = {x = 0.5, y = 0}, image_id = player:hud_add({
alignment = {x = 0, y = 1}, hud_elem_type = "image",
offset = {x = 0, y = i * 40 + 25}, text = bar.image,
scale = {x = 3, y = 3}, position = {x = 0.5, y = 0},
}), alignment = {x = 0, y = 1},
} offset = {x = 0, y = i * 40 + 25},
scale = {x = 3, y = 3},
}),
}
end
elseif hud and not bar then elseif hud and not bar then
player:hud_remove(hud.text_id) player:hud_remove(hud.text_id)
player:hud_remove(hud.image_id) player:hud_remove(hud.image_id)

View File

@ -97,6 +97,9 @@ animated_chests (Animated chests) bool true
# Whether to preview the player in inventory in 3D (requires Minetest 5.4) # Whether to preview the player in inventory in 3D (requires Minetest 5.4)
3d_player_preview (3D Player preview) bool true 3d_player_preview (3D Player preview) bool true
# The maximum number of boss bars to simultaniously display on the screen
max_bossbars (Maximum Boss bars) int 6
[Experimental] [Experimental]
# Whether ice is translucent. If disabled, ice is fully opaque. # Whether ice is translucent. If disabled, ice is fully opaque.
# #