From 00accc22ec5843b310e3c920e926fea79ac69d5b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 23 Feb 2015 23:32:04 +0100 Subject: Use HUD bars mod to show player's saturation level --- depends.txt | 1 + init.lua | 28 +++++----------------------- textures/hud_hunger_fg.png | Bin 522 -> 0 bytes textures/hunger_bar.png | Bin 0 -> 80 bytes textures/hunger_icon.png | Bin 0 -> 522 bytes 5 files changed, 6 insertions(+), 23 deletions(-) delete mode 100644 textures/hud_hunger_fg.png create mode 100644 textures/hunger_bar.png create mode 100644 textures/hunger_icon.png diff --git a/depends.txt b/depends.txt index 3f49583..117f951 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ +hudbars default animalmaterials? bucket? diff --git a/init.lua b/init.lua index 2926c36..4389411 100644 --- a/init.lua +++ b/init.lua @@ -27,35 +27,17 @@ if set then end local function custom_hud(player) - local name = player:get_player_name() - if minetest.setting_getbool("enable_damage") then --hunger - player:hud_add({ - hud_elem_type = "statbar", - position = HUD_HUNGER_POS, - size = HUD_SIZE, - text = "hud_hunger_bg.png", - number = 20, - alignment = {x=-1,y=-1}, - offset = HUD_HUNGER_OFFSET, - }) - local h = hunger.hunger[name] - if h == nil or h > 20 then h = 20 end - hunger_hud[name] = player:hud_add({ - hud_elem_type = "statbar", - position = HUD_HUNGER_POS, - size = HUD_SIZE, - text = "hud_hunger_fg.png", - number = h, - alignment = {x=-1,y=-1}, - offset = HUD_HUNGER_OFFSET, - }) + hb.init_hudbar(player, "saturation") end end dofile(minetest.get_modpath("hunger").."/hunger.lua") +-- register saturation hudbar +hb.register_hudbar("saturation", 0xFFFFFF, "Saturation", { icon = "hunger_icon.png", bar = "hunger_bar.png" }, 20, 20, false) + -- update hud elemtens if value has changed local function update_hud(player) local name = player:get_player_name() @@ -66,7 +48,7 @@ local function update_hud(player) hunger.hunger_out[name] = h -- bar should not have more than 10 icons if h>20 then h=20 end - player:hud_change(hunger_hud[name], "number", h) + hb.change_hudbar(player, "saturation", h) end end diff --git a/textures/hud_hunger_fg.png b/textures/hud_hunger_fg.png deleted file mode 100644 index a5cc2a1..0000000 Binary files a/textures/hud_hunger_fg.png and /dev/null differ diff --git a/textures/hunger_bar.png b/textures/hunger_bar.png new file mode 100644 index 0000000..c94bf52 Binary files /dev/null and b/textures/hunger_bar.png differ diff --git a/textures/hunger_icon.png b/textures/hunger_icon.png new file mode 100644 index 0000000..a5cc2a1 Binary files /dev/null and b/textures/hunger_icon.png differ -- cgit v1.2.3