]> git.lizzy.rs Git - crafter_client.git/commitdiff
Add rain sound effect and better rain particles
authoroilboi <47129783+oilboi@users.noreply.github.com>
Fri, 17 Apr 2020 07:36:37 +0000 (03:36 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Fri, 17 Apr 2020 07:36:37 +0000 (03:36 -0400)
weather_handling.lua

index d93ee57a1514882506d62f5cde7d5c9db3db0a52..1aca8e4fcca685870b792cf8338663f64f57e102 100644 (file)
@@ -5,6 +5,8 @@ local rain = false
 local weather_update_timer = 0
 local id_table = {}
 
+local rain_sound_handle = nil
+
 local spawn_snow = function(player)
        local pos = player:get_pos()
        local radius = 10
@@ -91,12 +93,12 @@ local spawn_rain = function(player)
                                local lightlevel = minetest.get_node_light(pos, 0.5)
                                if lightlevel >= 14 then
                                        minetest.add_particlespawner({
-                                               amount = 1,
+                                               amount = 3,
                                                time = 0.5,
                                                minpos = vector.new(x-0.5,y,z-0.5),
                                                maxpos = vector.new(x+0.5,y+20,z+0.5),
-                                               minvel = {x=0, y=-9.81, z=0},
-                                               maxvel = {x=0, y=-9.81, z=0},
+                                               minvel = {x=0, y=-20, z=0},
+                                               maxvel = {x=0, y=-20, z=0},
                                                minacc = {x=0, y=0, z=0},
                                                maxacc = {x=0, y=0, z=0},
                                                minexptime = 1,
@@ -152,4 +154,11 @@ minetest.register_on_modchannel_message(function(channel_name, sender, message)
                        snow = false
                end
        end
+       if not rain_sound_handle and rain == true then
+               rain_sound_handle = minetest.sound_play("rain", {loop=true,gain=0})
+               minetest.sound_fade(rain_sound_handle, 0.5, 0.5)
+       elseif rain_sound_handle and rain == false then
+               minetest.sound_fade(rain_sound_handle, -0.5, 0)
+               rain_sound_handle = nil
+       end
 end)