diff --git a/mods/HUD/vl_hudbars/init.lua b/mods/HUD/vl_hudbars/init.lua index 5a1fd4c3a..9f88c37f1 100644 --- a/mods/HUD/vl_hudbars/init.lua +++ b/mods/HUD/vl_hudbars/init.lua @@ -4,26 +4,26 @@ local modpath = minetest.get_modpath(modname) vl_hudbars = { hudbar_defs = {}, players = {}, - settings = {}, + settings = { + start_offset_left = {x = -16, y = -90}, + start_offset_right = {x = 16, y = -90}, + scale_x = 24, + hudbar_height_gap = 4, + bar_length = 20, + base_pos = {x=0.5, y=1}, + max_rendered_layers = 100, -- per part, to prevent lag due to too many layers rendered. Only applies to absolute hudbars + + -- Squish settings + min_layer_offset = 8, -- 'most squished possible' offset from layer below + max_unsquished_layers = 3, -- number of layers allowed before squishing kicks in + squish_duration = 12, -- number of layers to squish over before reaching max squish + + forceload_default_hudbars = true, + autohide_breath = true, + tick = 0.1, + }, } -vl_hudbars.settings.start_offset_left = {x = -16, y = -90} -vl_hudbars.settings.start_offset_right = {x = 16, y = -90} -vl_hudbars.settings.scale_x = 24 -vl_hudbars.settings.hudbar_height_gap = 4 -vl_hudbars.settings.bar_length = 20 -vl_hudbars.settings.base_pos = {x=0.5, y=1} -vl_hudbars.settings.max_rendered_layers = 100 -- per part, to prevent lag due to too many layers rendered. Only applies to absolute hudbars - --- Squish settings -vl_hudbars.settings.min_layer_offset = 8 -- 'most squished possible' offset from layer below -vl_hudbars.settings.max_unsquished_layers = 3 -- number of layers allowed before squishing kicks in -vl_hudbars.settings.squish_duration = 12 -- number of layers to squish over before reaching max squish - -vl_hudbars.settings.forceload_default_hudbars = true -vl_hudbars.settings.autohide_breath = true -vl_hudbars.settings.tick = 0.1 - if minetest.get_modpath("mcl_experience") and not minetest.is_creative_enabled("") then -- reserve some space for experience bar: vl_hudbars.settings.start_offset_left.y = vl_hudbars.settings.start_offset_left.y - 20 @@ -46,7 +46,9 @@ end local function get_squished_layer_gap(max_gap, texture_height_y, layers) local min_gap = vl_hudbars.settings.min_layer_offset - texture_height_y -- work out proportion to squish by - local squish_proportion = math.min(math.max((layers - vl_hudbars.settings.max_unsquished_layers)/vl_hudbars.settings.squish_duration, 0), 1) + local squish_proportion = (layers - vl_hudbars.settings.max_unsquished_layers)/vl_hudbars.settings.squish_duration + -- clamp between 0 and 1 so there is a maximum squish + squish_proportion = math.min(math.max(squish_proportion, 0), 1) -- linear interpolate squishage return max_gap - (max_gap - min_gap) * squish_proportion end