From 56e35f6b4bd03bc71c93eec1c35930b828c70cb9 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Fri, 19 Jun 2020 16:01:01 -0400 Subject: [PATCH] Fix crashing if area is unloaded --- weather_handling.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/weather_handling.lua b/weather_handling.lua index 65fc95f..bd09531 100644 --- a/weather_handling.lua +++ b/weather_handling.lua @@ -47,13 +47,15 @@ local weather_effects = function(player,defined_type) if defined_type == "rain" then curr_light = minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z},0.5) --rain sound effect - if curr_light >= 15 then - if not rain_sound_handle then - rain_sound_handle = minetest.sound_play("rain", {loop=true,gain=0}) + if curr_light then + if curr_light >= 15 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 + minetest.sound_fade(rain_sound_handle, -0.5, 0) end - minetest.sound_fade(rain_sound_handle, 0.5, 1) - elseif curr_light < 15 and rain_sound_handle then - minetest.sound_fade(rain_sound_handle, -0.5, 0) end particle_table = { -- 2.44.0