From e6bc7c62696b15a437ba18988340135548ab9ba5 Mon Sep 17 00:00:00 2001 From: Mrchiantos <51173452+Mrchiantos@users.noreply.github.com> Date: Sun, 21 Jul 2019 17:15:13 +0200 Subject: [PATCH] Update statbars.lua --- builtin/game/statbars.lua | 79 +-------------------------------------- 1 file changed, 1 insertion(+), 78 deletions(-) diff --git a/builtin/game/statbars.lua b/builtin/game/statbars.lua index db9d7e161..d5edd90c5 100644 --- a/builtin/game/statbars.lua +++ b/builtin/game/statbars.lua @@ -1,27 +1,6 @@ -- cache setting local enable_damage = core.settings:get_bool("enable_damage") -local health_bar_definition = { - hud_elem_type = "statbar", - position = {x = 0.5, y = 1}, - alignment = {x = -1, y = -1}, - offset = {x = -247, y = -108}, - size = {x = 24, y = 24}, - text = "heart.png", - background = "heart_bg.png", - number = 20 -} - -local breath_bar_definition = { - hud_elem_type = "statbar", - position = {x = 0.5, y = 1}, - alignment = {x = -1, y = -1}, - offset = {x = 8, y = -134}, - size = {x = 24, y = 24}, - text = "bubble.png", - number = 20 -} - local hud_ids = {} local function initialize_builtin_statbars(player) @@ -43,19 +22,7 @@ local function initialize_builtin_statbars(player) player:hud_set_flags(player:hud_get_flags()) end - if player:hud_get_flags().healthbar and enable_damage then - if hud_ids[name].id_healthbar == nil then - hud_ids[name].id_healthbar = hud.register("health", health_bar_definition) - minetest.after(0, function() - hud.change_item(player, "health", {number = player:get_hp()}) - end) - end - else - if hud_ids[name].id_healthbar ~= nil then - player:hud_remove(hud_ids[name].id_healthbar) - hud_ids[name].id_healthbar = nil - end - end + if (player:get_breath() < 11) then if player:hud_get_flags().breathbar and enable_damage then @@ -98,14 +65,7 @@ local function player_event_handler(player, eventname) return end - if eventname == "health_changed" then - initialize_builtin_statbars(player) - if hud_id[name.."_".."health"] ~= nil then - hud.change_item(player, "health", {number = player:get_hp()}) - return true - end - end if eventname == "breath_changed" then initialize_builtin_statbars(player) @@ -124,43 +84,6 @@ local function player_event_handler(player, eventname) return false end ---[[function core.hud_replace_builtin(name, definition) - - if definition == nil or - type(definition) ~= "table" or - definition.hud_elem_type ~= "statbar" then - return false - end - - if name == "health" then - health_bar_definition = definition - - for name,ids in pairs(hud_ids) do - local player = core.get_player_by_name(name) - if player and hud_ids[name].id_healthbar then - player:hud_remove(hud_ids[name].id_healthbar) - initialize_builtin_statbars(player) - end - end - return true - end - - if name == "breath" then - breath_bar_definition = definition - - for name,ids in pairs(hud_ids) do - local player = core.get_player_by_name(name) - if player and hud_ids[name].id_breathbar then - player:hud_remove(hud_ids[name].id_breathbar) - initialize_builtin_statbars(player) - end - end - return true - end - - return false -end]] - if enable_damage then core.register_on_joinplayer(initialize_builtin_statbars) core.register_on_leaveplayer(cleanup_builtin_statbars)