From b7518bcbcc45265d7851432258a43d2f0d6de2a6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 8 Dec 2017 17:06:21 +0100 Subject: [PATCH] Fix some mcl_weather crashes --- mods/ENVIRONMENT/mcl_weather/init.lua | 13 +++--- mods/ENVIRONMENT/mcl_weather/weather_core.lua | 44 +++++++++---------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/init.lua b/mods/ENVIRONMENT/mcl_weather/init.lua index 04f83f8caa..e31331f5e6 100644 --- a/mods/ENVIRONMENT/mcl_weather/init.lua +++ b/mods/ENVIRONMENT/mcl_weather/init.lua @@ -1,4 +1,12 @@ local modpath = minetest.get_modpath("mcl_weather"); + +mcl_weather = {} + +-- If not located then embeded skycolor mod version will be loaded. +if minetest.get_modpath("skycolor") == nil then + dofile(modpath.."/skycolor.lua") +end + dofile(modpath.."/weather_core.lua") dofile(modpath.."/snow.lua") dofile(modpath.."/rain.lua") @@ -6,8 +14,3 @@ dofile(modpath.."/rain.lua") if minetest.get_modpath("lightning") ~= nil then dofile(modpath.."/thunder.lua") end - --- If not located then embeded skycolor mod version will be loaded. -if minetest.get_modpath("skycolor") == nil then - dofile(modpath.."/skycolor.lua") -end diff --git a/mods/ENVIRONMENT/mcl_weather/weather_core.lua b/mods/ENVIRONMENT/mcl_weather/weather_core.lua index 042d2989b4..46592cce77 100644 --- a/mods/ENVIRONMENT/mcl_weather/weather_core.lua +++ b/mods/ENVIRONMENT/mcl_weather/weather_core.lua @@ -1,31 +1,29 @@ -mcl_weather = { - -- weather states, 'none' is default, other states depends from active mods - state = "none", +-- weather states, 'none' is default, other states depends from active mods +mcl_weather.state = "none" - -- player list for saving player meta info - players = {}, +-- player list for saving player meta info +mcl_weather.players = {} - -- default weather recalculation interval - check_interval = 300, +-- default weather recalculation interval +mcl_weather.check_interval = 300 - -- weather min duration - min_duration = 600, +-- weather min duration +mcl_weather.min_duration = 600 - -- weather max duration - max_duration = 9000, - - -- weather calculated end time - end_time = nil, - - -- registered weathers - reg_weathers = {}, +-- weather max duration +mcl_weather.max_duration = 9000 - -- automaticly calculates intervals and swap weathers - auto_mode = true, +-- weather calculated end time +mcl_weather.end_time = nil - -- global flag to disable/enable ABM logic. - allow_abm = true, -} +-- registered weathers +mcl_weather.reg_weathers = {} + +-- automaticly calculates intervals and swap weathers +mcl_weather.auto_mode = true + +-- global flag to disable/enable ABM logic. +mcl_weather.allow_abm = true mcl_weather.reg_weathers["none"] = { min_duration = mcl_weather.min_duration, @@ -240,9 +238,9 @@ end local load_weather = function() local weather = storage:get_string("mcl_weather_state") if weather and weather ~= "" then - mcl_weather.change_weather(weather, mcl_weather.end_time) mcl_weather.state = weather mcl_weather.end_time = storage:get_int("mcl_weather_end_time") + mcl_weather.change_weather(weather, mcl_weather.end_time) if type(mcl_weather.end_time) ~= "number" then -- Fallback in case of corrupted end time mcl_weather.end_time = mcl_weather.min_duration