mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-11 18:40:25 +01:00
added hudbars custom position
possibility to define position("health" in left or "sprint" in right, etc) in .conf refactor code position, load config before registrer default hudbars(health,breath)
This commit is contained in:
parent
0ba98ba2f6
commit
af4ff618bb
10
mods/hudbars/hudbars.conf
Executable file
10
mods/hudbars/hudbars.conf
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
-- if custom==true, use custom position
|
||||||
|
-- X 0=left, 1=right
|
||||||
|
--Y 0,1,2 = down--> up
|
||||||
|
hb.settings.custom.custom = true
|
||||||
|
hb.settings.custom.health = { x = 0, y = 0 }
|
||||||
|
hb.settings.custom.satiation = { x = 1, y = 0 }
|
||||||
|
hb.settings.custom.sprint = { x = 0, y = 1 }
|
||||||
|
hb.settings.custom.mana = { x = 1, y = 1 }
|
||||||
|
hb.settings.custom.armor = { x = 0, y = 2 }
|
||||||
|
hb.settings.custom.breath = { x = 1, y = 2 }
|
@ -6,7 +6,7 @@ hb.hudtables = {}
|
|||||||
hb.hudbars_count = 0
|
hb.hudbars_count = 0
|
||||||
|
|
||||||
hb.settings = {}
|
hb.settings = {}
|
||||||
|
hb.settings.custom = {} --MFF (crabman|19/06/15) add custom pos
|
||||||
-- default settings
|
-- default settings
|
||||||
hb.settings.max_bar_length = 160
|
hb.settings.max_bar_length = 160
|
||||||
|
|
||||||
@ -37,7 +37,24 @@ end
|
|||||||
function hb.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, default_start_hidden, format_string)
|
function hb.register_hudbar(identifier, text_color, label, textures, default_start_value, default_start_max, default_start_hidden, format_string)
|
||||||
local hudtable = {}
|
local hudtable = {}
|
||||||
local pos, offset
|
local pos, offset
|
||||||
if hb.hudbars_count % 2 == 0 then
|
|
||||||
|
--MFF (crabman|19/06/15)|DEBUT add custom pos
|
||||||
|
if hb.settings.custom.custom and hb.settings.custom[identifier] ~= nil then
|
||||||
|
if hb.settings.custom[identifier].x == 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 * math.floor(hb.settings.custom[identifier].y)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pos = hb.settings.pos_right
|
||||||
|
offset = {
|
||||||
|
x = hb.settings.start_offset_right.x,
|
||||||
|
y = hb.settings.start_offset_right.y - hb.settings.vmargin * math.floor(hb.settings.custom[identifier].y)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
--MFF (crabman|19/06/15) /FIN
|
||||||
|
elseif hb.hudbars_count % 2 == 0 then
|
||||||
pos = hb.settings.pos_left
|
pos = hb.settings.pos_left
|
||||||
offset = {
|
offset = {
|
||||||
x = hb.settings.start_offset_left.x,
|
x = hb.settings.start_offset_left.x,
|
||||||
@ -263,12 +280,6 @@ function hb.get_hudbar_state(player, identifier)
|
|||||||
return copy
|
return copy
|
||||||
end
|
end
|
||||||
|
|
||||||
--register built-in HUD bars
|
|
||||||
if minetest.setting_getbool("enable_damage") then
|
|
||||||
hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false)
|
|
||||||
hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
--load custom settings
|
--load custom settings
|
||||||
local set = io.open(minetest.get_modpath("hudbars").."/hudbars.conf", "r")
|
local set = io.open(minetest.get_modpath("hudbars").."/hudbars.conf", "r")
|
||||||
if set then
|
if set then
|
||||||
@ -276,6 +287,12 @@ if set then
|
|||||||
set:close()
|
set:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--register built-in HUD bars
|
||||||
|
if minetest.setting_getbool("enable_damage") then
|
||||||
|
hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false)
|
||||||
|
hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true)
|
||||||
|
end
|
||||||
|
|
||||||
local function hide_builtin(player)
|
local function hide_builtin(player)
|
||||||
local flags = player:hud_get_flags()
|
local flags = player:hud_get_flags()
|
||||||
flags.healthbar = false
|
flags.healthbar = false
|
||||||
|
Loading…
Reference in New Issue
Block a user