forked from minetest-mods/hbsprint
Fix hbsprint behaviour with max value greater than 20
This commit is contained in:
parent
b3773c0470
commit
dc766c1336
13
init.lua
13
init.lua
@ -84,25 +84,28 @@ local function drain_stamina(player)
|
||||
player:get_meta():set_float("hbsprint:stamina", player_stamina)
|
||||
end
|
||||
if mod_hudbars then
|
||||
if autohide and player_stamina < 20 then hb.unhide_hudbar(player, "stamina") end
|
||||
if autohide and
|
||||
player_stamina < hb.get_hudtable("stamina").hudstate[player:get_player_name()].max
|
||||
then hb.unhide_hudbar(player, "stamina") end
|
||||
hb.change_hudbar(player, "stamina", player_stamina)
|
||||
end
|
||||
end
|
||||
|
||||
local function replenish_stamina(player)
|
||||
local player_stamina = player:get_meta():get_float("hbsprint:stamina")
|
||||
local max_stamina = hb.get_hudtable("stamina").hudstate[player:get_player_name()].max
|
||||
local ctrl = player:get_player_control()
|
||||
if player_stamina < 20 and not ctrl.jump then
|
||||
if player_stamina < max_stamina and not ctrl.jump then
|
||||
if not ctrl.right and not ctrl.left and not ctrl.down and not ctrl.up and not ctrl.LMB and not ctrl.RMB then
|
||||
player_stamina = math.min(20, player_stamina + standing)
|
||||
player_stamina = math.min(max_stamina, player_stamina + standing)
|
||||
else
|
||||
player_stamina = math.min(20, player_stamina + stamina_heal)
|
||||
player_stamina = math.min(max_stamina, player_stamina + stamina_heal)
|
||||
end
|
||||
player:get_meta():set_float("hbsprint:stamina", player_stamina)
|
||||
end
|
||||
if mod_hudbars then
|
||||
hb.change_hudbar(player, "stamina", player_stamina)
|
||||
if autohide and player_stamina >= 20 then hb.hide_hudbar(player, "stamina") end
|
||||
if autohide and player_stamina >= max_stamina then hb.hide_hudbar(player, "stamina") end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user