]> git.lizzy.rs Git - crafter_client.git/commitdiff
Fix crashing and make water splash pleasant
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 11 Apr 2020 06:02:39 +0000 (02:02 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 11 Apr 2020 06:02:39 +0000 (02:02 -0400)
init.lua
player_input.lua

index 5491c5d8dc12a5fc9c73e932dd04919608e55bc9..263784097edb263990146b7f4a9662244c06a20c 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -15,16 +15,20 @@ local old_node
 local in_water = false
 local old_in_water = false
 minetest.register_globalstep(function(dtime)
+       if not minetest.localplayer then
+               return
+       end
+       
+       local vel = minetest.localplayer:get_velocity().y
        local pos = minetest.localplayer:get_pos()
-       pos.y = pos.y - 0.1
+       
        local node = minetest.get_node_or_nil(pos)
        if node then
                local name = node.name
                if name == "main:water" or name == "main:water_flowing" then
                        in_water = true
-                       
-                       if in_water == true and old_in_water == false then
-                               minetest.sound_play("splash", {gain = 0.4, pitch = math.random(80,100)/100})
+                       if in_water == true and old_in_water == false and vel < 0 then
+                               minetest.sound_play("splash", {gain = 0.4, pitch = math.random(80,100)/100, gain = 0.05})
                        end
                else
                        in_water = false
index cb2f3c5c7c09185057cc8b89db866014d29614d2..56932b4a662e7085677bb121d87d655e972fce6c 100644 (file)
@@ -36,7 +36,7 @@ local run_discharge_timer = 0
 local old_up = false
 local sneak = false
 local old_sneak = false
-bunny_hop = false
+local bunny_hop = false
 
 --attempt to tell the server to allow us to run
 local send_server_movement_state = function(state)
@@ -55,6 +55,7 @@ minetest.register_globalstep(function(dtime)
        if not minetest.localplayer then
                return
        end
+       
        local input = minetest.get_control_bits(minetest.localplayer)
        local vel = minetest.localplayer:get_velocity().y
        local oldvel = minetest.localplayer:get_last_velocity().y