From fd33c77a78e693b7d7f98fc899527c1c43af2126 Mon Sep 17 00:00:00 2001 From: wsor <24964441+wsor4035@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:09:27 -0400 Subject: [PATCH] patch crash, adjust hud positions --- mods/fl_hunger/init.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mods/fl_hunger/init.lua b/mods/fl_hunger/init.lua index 3e8b221..56d0c8d 100644 --- a/mods/fl_hunger/init.lua +++ b/mods/fl_hunger/init.lua @@ -34,11 +34,25 @@ local breath_bar_def = { item = 20, direction = 0, size = {x = 24, y = 24}, - offset = {y=-88+-16*2, x=25}, + offset = {y=-88+-16*2, x=14}, } core.hud_replace_builtin("breath", breath_bar_def) +local health_bar_def = { + hud_elem_type = "statbar", + position = {x=0.5, y=1}, + text = "heart.png", + text2 = "heart_gone.png", + number = 20, + item = 20, + direction = 0, + size = {x = 24, y = 24}, + offset = {y=-88, x=-254}, +} +core.hud_replace_builtin("health", health_bar_def) + + --init data minetest.register_on_joinplayer(function(player, last_login) local hv = player:get_meta():get("hunger_value") or 20 @@ -53,7 +67,7 @@ minetest.register_on_joinplayer(function(player, last_login) item = 20, direction = 0, size = {x = 24, y = 24}, - offset = {y=-88, x=25}, + offset = {y=-88, x=14}, }) hunger_data[player:get_player_name()]["id"] = id end) @@ -78,7 +92,7 @@ minetest.after(600, write_data) local old_eat = minetest.do_item_eat function minetest.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed_thing) - if hunger_data[user:get_player_name()]["hunger_value"] < 20 then + if tonumber(hunger_data[user:get_player_name()]["hunger_value"]) < 20 then local hpchange = 0 local change = hunger_data[user:get_player_name()]["hunger_value"] + hp_change