From 06f337b23e7004d561ad771d017d1d410e80b6a5 Mon Sep 17 00:00:00 2001 From: Till Affeldt Date: Sun, 17 May 2020 22:13:09 +0200 Subject: [PATCH] Fix crash when trying to apply weather to dead players --- lib/trigger.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/trigger.lua b/lib/trigger.lua index 5fd8a6a..e575b42 100644 --- a/lib/trigger.lua +++ b/lib/trigger.lua @@ -90,20 +90,22 @@ function trigger.get_active_effects() for _, player in ipairs(minetest.get_connected_players()) do local pname = player:get_player_name() local env = environments[pname] - if is_weather_active(player, wname, env) then - if type(climate_mod.current_weather[pname]) == "nil" then - climate_mod.current_weather[pname] = {} - end - table.insert(climate_mod.current_weather[pname], wname) - local player_effects = get_weather_effects(player, wconfig, env) - for effect, value in pairs(player_effects) do - if type(effects[effect]) == "nil" then - effects[effect] = {} + if env ~= nil then + if is_weather_active(player, wname, env) then + if type(climate_mod.current_weather[pname]) == "nil" then + climate_mod.current_weather[pname] = {} end - if type(effects[effect][pname]) == "nil" then - effects[effect][pname] = {} + table.insert(climate_mod.current_weather[pname], wname) + local player_effects = get_weather_effects(player, wconfig, env) + for effect, value in pairs(player_effects) do + if type(effects[effect]) == "nil" then + effects[effect] = {} + end + if type(effects[effect][pname]) == "nil" then + effects[effect][pname] = {} + end + effects[effect][pname][wname] = value end - effects[effect][pname][wname] = value end end end