forked from minetest-mods/hbsprint
Stop sprinting immediately when running out of stamina or food
This commit is contained in:
parent
b76fe25725
commit
647f431653
9
init.lua
9
init.lua
@ -166,6 +166,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
if player_stamina > 0 and hunger > 9 and walkable then
|
if player_stamina > 0 and hunger > 9 and walkable then
|
||||||
start_sprint(player)
|
start_sprint(player)
|
||||||
|
sprinting = true
|
||||||
if stamina then drain_stamina(player) end
|
if stamina then drain_stamina(player) end
|
||||||
if starve then drain_hunger(player, hunger, name) end
|
if starve then drain_hunger(player, hunger, name) end
|
||||||
if breath then
|
if breath then
|
||||||
@ -175,15 +176,17 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if particles then create_particles(player, name, pos, ground) end
|
if particles then create_particles(player, name, pos, ground) end
|
||||||
end
|
|
||||||
sprinting = true
|
|
||||||
else
|
else
|
||||||
stop_sprint(player)
|
stop_sprint(player)
|
||||||
|
sprinting = false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
stop_sprint(player)
|
||||||
|
sprinting = false
|
||||||
if stamina_timer >= replenish then
|
if stamina_timer >= replenish then
|
||||||
if stamina then replenish_stamina(player) end
|
if stamina then replenish_stamina(player) end
|
||||||
stamina_timer = 0
|
stamina_timer = 0
|
||||||
end
|
end
|
||||||
sprinting = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sprint_timer = 0
|
sprint_timer = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user