]> git.lizzy.rs Git - crafter_client.git/commitdiff
Fix bug 10 in crafter
authoroilboi <47129783+oilboi@users.noreply.github.com>
Thu, 25 Jun 2020 02:40:54 +0000 (22:40 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Thu, 25 Jun 2020 02:40:54 +0000 (22:40 -0400)
version_send.lua
weather_handling.lua

index 90cdf5204ee1c9bf65fe59478489f6a5ba9e9960..e12a3dc5190d63a6e118fc11f7ba063950fc91a1 100644 (file)
@@ -1,5 +1,5 @@
 local minetest,name = minetest,minetest.localplayer:get_name()
 local version_channel = minetest.mod_channel_join(name..":client_version_channel")
 minetest.after(2,function() -- this needs a few seconds for the mod channel to open up
-    version_channel:send_all("0.05009")
+    version_channel:send_all("0.05010")
 end)
\ No newline at end of file
index 0c318c74d60d2a38aa4eed3da2fb7b303baaaecf..20a4a5adc1e267ff392f9aac859e5a476e0d2d3f 100644 (file)
@@ -16,6 +16,14 @@ local id_table = {}
 
 local rain_sound_handle = nil
 
+local liquids = {
+       ["main:water"] = true,
+       ["main:waterflow"] = true,
+       ["main:lava"] = true,
+       ["main:lavaflow"] = true,
+       ["nether:lava"] = true,
+       ["nether:lavaflow"] = true,
+}
 
 
 local y
@@ -31,6 +39,7 @@ local lightlevel
 local null
 local curr_light
 local distance = vector.distance
+local current_node 
 local weather_effects = function(player,defined_type)
        pos = vector.round(player:get_pos())
        area = vector.new(10,10,10)
@@ -49,15 +58,17 @@ local weather_effects = function(player,defined_type)
        end
 
        if defined_type == "rain" then
-       curr_light = minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z},0.5)
+       curr_light = minetest.get_node_light(minetest.camera:get_pos(),0.5)
        --rain sound effect
        if curr_light then
-               if curr_light >= 15 then
+               current_node = minetest.get_node_or_nil(minetest.camera:get_pos())
+
+               if curr_light >= 15 and current_node and not liquids[current_node.name] then
                        if not rain_sound_handle then
                                rain_sound_handle = minetest.sound_play("rain", {loop=true,gain=0})
                        end
                        minetest.sound_fade(rain_sound_handle, 0.5, 1)
-               elseif curr_light < 15 and rain_sound_handle then
+               elseif rain_sound_handle then
                        minetest.sound_fade(rain_sound_handle, -0.5, 0)
                        rain_sound_handle = nil
                end
@@ -141,33 +152,42 @@ end
 
 
 
+
 --client runs through spawning weather particles
 local player_pos
+local current_node
 local function update_weather()
        player_pos = minetest.localplayer:get_pos()
        if do_effects then
                if snow or rain then
-                       --do normal weather
-                       if player_pos.y > -10033 then
-                               if snow == true then
-                                       weather_effects(minetest.localplayer, "snow")
-                               elseif rain == true then
-                                       weather_effects(minetest.localplayer, "rain")
-                               end
-                       --rain blood upwards in the nether
-                       else
-                               if snow == true or rain == true then
-                                       weather_effects(minetest.localplayer, "ichor")
-                               end
-                       
-                               --stop the rain sound effect
-                               if rain_sound_handle then
-                                       minetest.sound_fade(rain_sound_handle, -0.5, 0)
-                                       rain_sound_handle = nil
+                       current_node = minetest.get_node_or_nil(minetest.camera:get_pos())
+                       if current_node and not liquids[current_node.name] then
+                               --do normal weather
+                               if player_pos.y > -10033 then
+                                       if snow == true then
+                                               weather_effects(minetest.localplayer, "snow")
+                                       elseif rain == true then
+                                               weather_effects(minetest.localplayer, "rain")
+                                       end
+                               --rain blood upwards in the nether
+                               else
+                                       if snow == true or rain == true then
+                                               weather_effects(minetest.localplayer, "ichor")
+                                       end
+                               
+                                       --stop the rain sound effect
+                                       if rain_sound_handle then
+                                               minetest.sound_fade(rain_sound_handle, -0.5, 0)
+                                               rain_sound_handle = nil
+                                       end
                                end
+                       elseif rain_sound_handle then
+                               minetest.sound_fade(rain_sound_handle, -0.5, 0)
+                               rain_sound_handle = nil
                        end
                end
        end
+
        if not rain and rain_sound_handle then
                minetest.sound_fade(rain_sound_handle, -0.5, 0)
                rain_sound_handle = nil