mirror of
https://repo.or.cz/minetest_hudbars.git
synced 2024-11-30 19:03:49 +01:00
Add preliminary display mode setting
Intentionally not in README.txt yet, because the positions cannot be set in minetest.conf yet.
This commit is contained in:
parent
fc66c4f0a5
commit
b68af069a4
@ -58,6 +58,7 @@ This mod can be configured by editing minetest.conf. Currently, the following se
|
|||||||
breath=0, health=1
|
breath=0, health=1
|
||||||
This places the breath bar at the left side, and the health bar to the right side.
|
This places the breath bar at the left side, and the health bar to the right side.
|
||||||
|
|
||||||
|
|
||||||
API:
|
API:
|
||||||
----
|
----
|
||||||
The API is used to add your own custom HUD bars.
|
The API is used to add your own custom HUD bars.
|
||||||
|
33
init.lua
33
init.lua
@ -22,6 +22,25 @@ hb.settings.start_offset_right = { x = 15, y = -86 }
|
|||||||
hb.settings.vmargin = 24
|
hb.settings.vmargin = 24
|
||||||
hb.settings.tick = 0.1
|
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
|
hb.settings.autohide_breath = true
|
||||||
local autohide_breath = minetest.setting_getbool("hudbars_autohide_breath")
|
local autohide_breath = minetest.setting_getbool("hudbars_autohide_breath")
|
||||||
if autohide_breath ~= nil then
|
if autohide_breath ~= nil then
|
||||||
@ -75,6 +94,19 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
|||||||
local pos, offset
|
local pos, offset
|
||||||
local index = math.floor(hb.get_hudbar_position_index(identifier))
|
local index = math.floor(hb.get_hudbar_position_index(identifier))
|
||||||
hb.registered_slots[index] = true
|
hb.registered_slots[index] = true
|
||||||
|
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
|
||||||
|
}
|
||||||
|
elseif hb.settings.display_mode == "stack_down" 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
|
||||||
|
}
|
||||||
|
else
|
||||||
if index % 2 == 0 then
|
if index % 2 == 0 then
|
||||||
pos = hb.settings.pos_left
|
pos = hb.settings.pos_left
|
||||||
offset = {
|
offset = {
|
||||||
@ -88,6 +120,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta
|
|||||||
y = hb.settings.start_offset_right.y - hb.settings.vmargin * ((index-1)/2)
|
y = hb.settings.start_offset_right.y - hb.settings.vmargin * ((index-1)/2)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if format_string == nil then
|
if format_string == nil then
|
||||||
format_string = "%s: %d/%d"
|
format_string = "%s: %d/%d"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user