mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Fix breath_bar scaling; delay breath_bar hiding by one second (#8271)
PLAYER_MAX_BREATH_DEFAULT was earlier set to 11, so that 10 bubbles are shown before the breath bar disappears. Now, PLAYER_MAX_BREATH_DEFAULT is set to 10, and the breath_bar scaling code in builtin has been tweaked to show all 10 bubbles before hiding the breath_bar
This commit is contained in:
parent
a368e7e793
commit
a36c9c3e93
@ -24,7 +24,7 @@ core.MAP_BLOCKSIZE = 16
|
|||||||
-- Default maximal HP of a player
|
-- Default maximal HP of a player
|
||||||
core.PLAYER_MAX_HP_DEFAULT = 20
|
core.PLAYER_MAX_HP_DEFAULT = 20
|
||||||
-- Default maximal breath of a player
|
-- Default maximal breath of a player
|
||||||
core.PLAYER_MAX_BREATH_DEFAULT = 11
|
core.PLAYER_MAX_BREATH_DEFAULT = 10
|
||||||
|
|
||||||
-- light.h
|
-- light.h
|
||||||
-- Maximum value for node 'light_source' parameter
|
-- Maximum value for node 'light_source' parameter
|
||||||
|
@ -49,6 +49,7 @@ local function update_builtin_statbars(player)
|
|||||||
local hud = hud_ids[name]
|
local hud = hud_ids[name]
|
||||||
|
|
||||||
local immortal = player:get_armor_groups().immortal == 1
|
local immortal = player:get_armor_groups().immortal == 1
|
||||||
|
|
||||||
if flags.healthbar and enable_damage and not immortal then
|
if flags.healthbar and enable_damage and not immortal then
|
||||||
local number = scaleToDefault(player, "hp")
|
local number = scaleToDefault(player, "hp")
|
||||||
if hud.id_healthbar == nil then
|
if hud.id_healthbar == nil then
|
||||||
@ -63,19 +64,28 @@ local function update_builtin_statbars(player)
|
|||||||
hud.id_healthbar = nil
|
hud.id_healthbar = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local show_breathbar = flags.breathbar and enable_damage and not immortal
|
||||||
|
|
||||||
|
local breath = player:get_breath()
|
||||||
local breath_max = player:get_properties().breath_max
|
local breath_max = player:get_properties().breath_max
|
||||||
if flags.breathbar and enable_damage and not immortal and
|
if show_breathbar and breath <= breath_max then
|
||||||
player:get_breath() < breath_max then
|
|
||||||
local number = 2 * scaleToDefault(player, "breath")
|
local number = 2 * scaleToDefault(player, "breath")
|
||||||
if hud.id_breathbar == nil then
|
if not hud.id_breathbar and breath < breath_max then
|
||||||
local hud_def = table.copy(breath_bar_definition)
|
local hud_def = table.copy(breath_bar_definition)
|
||||||
hud_def.number = number
|
hud_def.number = number
|
||||||
hud.id_breathbar = player:hud_add(hud_def)
|
hud.id_breathbar = player:hud_add(hud_def)
|
||||||
else
|
elseif hud.id_breathbar then
|
||||||
player:hud_change(hud.id_breathbar, "number", number)
|
player:hud_change(hud.id_breathbar, "number", number)
|
||||||
end
|
end
|
||||||
elseif hud.id_breathbar then
|
end
|
||||||
player:hud_remove(hud.id_breathbar)
|
|
||||||
|
if hud.id_breathbar and (not show_breathbar or breath == breath_max) then
|
||||||
|
minetest.after(1, function(player_name, breath_bar)
|
||||||
|
local player = minetest.get_player_by_name(player_name)
|
||||||
|
if player then
|
||||||
|
player:hud_remove(breath_bar)
|
||||||
|
end
|
||||||
|
end, name, hud.id_breathbar)
|
||||||
hud.id_breathbar = nil
|
hud.id_breathbar = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,7 +93,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define PLAYER_MAX_HP_DEFAULT 20
|
#define PLAYER_MAX_HP_DEFAULT 20
|
||||||
|
|
||||||
// Default maximal breath of a player
|
// Default maximal breath of a player
|
||||||
#define PLAYER_MAX_BREATH_DEFAULT 11
|
#define PLAYER_MAX_BREATH_DEFAULT 10
|
||||||
|
|
||||||
// Number of different files to try to save a player to if the first fails
|
// Number of different files to try to save a player to if the first fails
|
||||||
// (because of a case-insensitive filesystem)
|
// (because of a case-insensitive filesystem)
|
||||||
|
Loading…
Reference in New Issue
Block a user