diff options
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 45 |
1 files changed, 39 insertions, 6 deletions
@@ -22,6 +22,25 @@ hb.settings.start_offset_right = { x = 15, y = -86 } hb.settings.vmargin = 24 hb.settings.tick = 0.1 +--[[ +- hudbars_display_mode: This setting changes the way the HUD bars are ordered on the display. You can choose + between a zig-zag pattern or a vertically stacked pattern. + The following values are allowed: + zigzag: Starting from the left bottom, the next is right from the first, + the next is above the first, the next is right of the third, etc. + This is the default. + stack_up: The HUD bars are stacked vertically, going upwards. + stack_down: The HUD bars are stacked vertically. going downwards. +]] +hb.settings.display_mode = "zigzag" +local display_mode = minetest.setting_getbool("hudbars_display_mode") +if display_mode ~= nil then + hb.settings.display_mode = display_mode + if display_mode ~= "zigzag" and display_mode ~= "stack_up" and display_mode ~= "stack_down" then + minetest.log("error", "[hudbars] Invalid value for hudbars_display_mode! Using default (zigzag).") + end +end + hb.settings.autohide_breath = true local autohide_breath = minetest.setting_getbool("hudbars_autohide_breath") if autohide_breath ~= nil then @@ -75,18 +94,32 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta local pos, offset local index = math.floor(hb.get_hudbar_position_index(identifier)) hb.registered_slots[index] = true - if index % 2 == 0 then + if hb.settings.display_mode == "stack_up" then pos = hb.settings.pos_left offset = { x = hb.settings.start_offset_left.x, - y = hb.settings.start_offset_left.y - hb.settings.vmargin * (index/2) + y = hb.settings.start_offset_left.y - hb.settings.vmargin * index } - else - pos = hb.settings.pos_right + elseif hb.settings.display_mode == "stack_down" then + pos = hb.settings.pos_left offset = { - x = hb.settings.start_offset_right.x, - y = hb.settings.start_offset_right.y - hb.settings.vmargin * ((index-1)/2) + x = hb.settings.start_offset_left.x, + y = hb.settings.start_offset_left.y + hb.settings.vmargin * index } + else + if index % 2 == 0 then + pos = hb.settings.pos_left + offset = { + x = hb.settings.start_offset_left.x, + y = hb.settings.start_offset_left.y - hb.settings.vmargin * (index/2) + } + else + pos = hb.settings.pos_right + offset = { + x = hb.settings.start_offset_right.x, + y = hb.settings.start_offset_right.y - hb.settings.vmargin * ((index-1)/2) + } + end end if format_string == nil then format_string = "%s: %d/%d" |