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

View File

@ -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
else
stop_sprint(player)
sprinting = false
end end
sprinting = true
else else
stop_sprint(player) 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