From 567f157541973b3034e44ae1bbb730177b652539 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 7 Apr 2021 17:02:03 +0200 Subject: [PATCH] Add a bossbar limit setting --- mods/HUD/mcl_bossbars/init.lua | 43 ++++++++++++++++++---------------- settingtypes.txt | 3 +++ 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/mods/HUD/mcl_bossbars/init.lua b/mods/HUD/mcl_bossbars/init.lua index 504fc3aef..3ba0bd755 100644 --- a/mods/HUD/mcl_bossbars/init.lua +++ b/mods/HUD/mcl_bossbars/init.lua @@ -3,6 +3,7 @@ mcl_bossbars = { huds = {}, static = {}, 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() @@ -127,27 +128,29 @@ minetest.register_globalstep(function() end if bar and not hud then - hud = { - color = bar.color, - image = bar.image, - text = bar.text, - text_id = player:hud_add({ - hud_elem_type = "text", + if i < mcl_bossbars.max_bars then + hud = { + color = bar.color, + image = bar.image, text = bar.text, - number = bar.color, - position = {x = 0.5, y = 0}, - alignment = {x = 0, y = 1}, - offset = {x = 0, y = i * 40}, - }), - image_id = player:hud_add({ - hud_elem_type = "image", - text = bar.image, - position = {x = 0.5, y = 0}, - alignment = {x = 0, y = 1}, - offset = {x = 0, y = i * 40 + 25}, - scale = {x = 3, y = 3}, - }), - } + text_id = player:hud_add({ + hud_elem_type = "text", + text = bar.text, + number = bar.color, + position = {x = 0.5, y = 0}, + alignment = {x = 0, y = 1}, + offset = {x = 0, y = i * 40}, + }), + image_id = player:hud_add({ + hud_elem_type = "image", + text = bar.image, + 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 player:hud_remove(hud.text_id) player:hud_remove(hud.image_id) diff --git a/settingtypes.txt b/settingtypes.txt index 67e686d1e..4ba6034eb 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -97,6 +97,9 @@ animated_chests (Animated chests) bool true # Whether to preview the player in inventory in 3D (requires Minetest 5.4) 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] # Whether ice is translucent. If disabled, ice is fully opaque. #