]> git.lizzy.rs Git - crafter_client.git/commitdiff
Make bunnyhopping hold until you land
authoroilboi <47129783+oilboi@users.noreply.github.com>
Thu, 9 Apr 2020 20:36:13 +0000 (16:36 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Thu, 9 Apr 2020 20:36:13 +0000 (16:36 -0400)
init.lua

index 2c07ade0a94c6513371ba9c46a80c0d8ce31ceb7..9093c704f234858799a9a3559c3769d60ae73413 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -48,7 +48,7 @@ local run_discharge_timer = 0
 local old_up = false
 local sneak = false
 local old_sneak = false
-bunny_hop_timer = 0
+bunny_hop = false
 
 --attempt to tell the server to allow us to run
 local send_server_movement_state = function(state)
@@ -80,20 +80,16 @@ minetest.register_globalstep(function(dtime)
                sneak = true
        end
        
-       --count down bunny hop state
-       if bunny_hop_timer > 0 then
-               bunny_hop_timer = bunny_hop_timer - dtime
-               if bunny_hop_timer <= 0 then
-                       bunny_hop_timer = 0
-               end
+       --stop bunnyhopping on land
+       if bunny_hop == true and vel == 0 and oldvel < 0 then
+               bunny_hop = false
        end
        
        --check if need to tell server to bunnyhop
-       if running == true and vel > 0 and bunny_hop_timer == 0 then
+       if running == true and vel > 0 and input.jump == true and bunny_hop == false then
                send_server_movement_state("2")
-               bunny_hop_timer = 0.3
-       elseif bunny_hop_timer == 0 then
-               bunny_hopping = false
+               bunny_hop = true
+       elseif bunny_hop == false then
                if running == true then
                        send_server_movement_state("1")
                        bunny_hop = false