Stop sprinting immediately when running out of stamina or food

This commit is contained in:
tacotexmex 2017-08-07 22:38:44 +02:00
parent b76fe25725
commit 647f431653
1 changed files with 5 additions and 2 deletions

View File

@ -166,6 +166,7 @@ minetest.register_globalstep(function(dtime)
end
if player_stamina > 0 and hunger > 9 and walkable then
start_sprint(player)
sprinting = true
if stamina then drain_stamina(player) end
if starve then drain_hunger(player, hunger, name) end
if breath then
@ -175,15 +176,17 @@ minetest.register_globalstep(function(dtime)
end
end
if particles then create_particles(player, name, pos, ground) end
else
stop_sprint(player)
sprinting = false
end
sprinting = true
else
stop_sprint(player)
sprinting = false
if stamina_timer >= replenish then
if stamina then replenish_stamina(player) end
stamina_timer = 0
end
sprinting = false
end
end
sprint_timer = 0