From 647f4316537d2db734b72f64e4f1f36ba0d9e4a8 Mon Sep 17 00:00:00 2001 From: tacotexmex Date: Mon, 7 Aug 2017 22:38:44 +0200 Subject: [PATCH] Stop sprinting immediately when running out of stamina or food --- init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 3a5149c..74be89b 100644 --- a/init.lua +++ b/init.lua @@ -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