1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-03 17:10:27 +01:00
server-nalc/mods/hud/builtin.lua
LeMagnesium b6e44b4047 Manually applied hunger_split update
- Updated hud/hunger splitting while keeping our configuration and solving
  issues
2015-04-08 23:30:51 +02:00

102 lines
2.2 KiB
Lua

HUD_SB_SIZE = {x = 24, y = 24}
HUD_HEALTH_POS = {x = 0.5,y = 1}
HUD_HEALTH_OFFSET = {x = -262, y = -87}
HUD_AIR_POS = {x = 0.5, y = 1}
HUD_AIR_OFFSET = {x = 15, y = -87}
HUD_HUNGER_POS = {x = 0.5, y = 1}
HUD_HUNGER_OFFSET = {x = 15, y = -110}
HUD_ARMOR_POS = {x = 0.5, y = 1}
HUD_ARMOR_OFFSET = {x = -262, y = -110}
-- read hud.conf settings
hud.read_conf()
local damage_enabled = minetest.setting_getbool("enable_damage")
hud.show_hunger = minetest.get_modpath("hunger") ~= nil
hud.show_armor = minetest.get_modpath("3d_armor") ~= nil
-- check if some settings are invalid
local enable_hunger = minetest.setting_getbool("hud_hunger_enable")
if (enable_hunger == true or HUD_ENABLE_HUNGER == true) and not hud.show_hunger then
hud.notify_hunger(5)
end
if damage_enabled then
hud.register("health", {
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
size = HUD_SB_SIZE,
text = "hud_heart_fg.png",
number = 20,
alignment = {x=-1,y=-1},
offset = HUD_HEALTH_OFFSET,
background = "hud_heart_bg.png",
events = {
{
type = "damage",
func = function(player)
hud.change_item(player, "health", {number = player:get_hp()})
end
}
},
})
hud.register("air", {
hud_elem_type = "statbar",
position = HUD_AIR_POS,
size = HUD_SB_SIZE,
text = "hud_air_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_AIR_OFFSET,
background = nil,
events = {
{
type = "breath",
func = function(player)
local air = player:get_breath()
if air > 10 then
air = 0
end
hud.change_item(player, "air", {number = air * 2})
end
}
},
})
hud.register("armor", {
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
size = HUD_SB_SIZE,
text = "hud_armor_fg.png",
number = 0,
alignment = {x=-1,y=-1},
offset = HUD_ARMOR_OFFSET,
background = "hud_armor_bg.png",
autohide_bg = true,
max = 20,
})
local start_value = 0
if show_hunger then
start_value = 20
end
hud.register("hunger", {
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
size = HUD_SB_SIZE,
text = "hud_hunger_fg.png",
number = start_value,
alignment = {x=-1,y=-1},
offset = HUD_HUNGER_OFFSET,
background = "hud_hunger_bg.png",
--autohide_bg = true,
max = 0,
})
else
hud.show_armor = false
end