Fix some mcl_weather crashes
This commit is contained in:
parent
4ad7147123
commit
b7518bcbcc
|
@ -1,4 +1,12 @@
|
||||||
local modpath = minetest.get_modpath("mcl_weather");
|
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.."/weather_core.lua")
|
||||||
dofile(modpath.."/snow.lua")
|
dofile(modpath.."/snow.lua")
|
||||||
dofile(modpath.."/rain.lua")
|
dofile(modpath.."/rain.lua")
|
||||||
|
@ -6,8 +14,3 @@ dofile(modpath.."/rain.lua")
|
||||||
if minetest.get_modpath("lightning") ~= nil then
|
if minetest.get_modpath("lightning") ~= nil then
|
||||||
dofile(modpath.."/thunder.lua")
|
dofile(modpath.."/thunder.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If not located then embeded skycolor mod version will be loaded.
|
|
||||||
if minetest.get_modpath("skycolor") == nil then
|
|
||||||
dofile(modpath.."/skycolor.lua")
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
mcl_weather = {
|
-- weather states, 'none' is default, other states depends from active mods
|
||||||
-- weather states, 'none' is default, other states depends from active mods
|
mcl_weather.state = "none"
|
||||||
state = "none",
|
|
||||||
|
|
||||||
-- player list for saving player meta info
|
-- player list for saving player meta info
|
||||||
players = {},
|
mcl_weather.players = {}
|
||||||
|
|
||||||
-- default weather recalculation interval
|
-- default weather recalculation interval
|
||||||
check_interval = 300,
|
mcl_weather.check_interval = 300
|
||||||
|
|
||||||
-- weather min duration
|
-- weather min duration
|
||||||
min_duration = 600,
|
mcl_weather.min_duration = 600
|
||||||
|
|
||||||
-- weather max duration
|
-- weather max duration
|
||||||
max_duration = 9000,
|
mcl_weather.max_duration = 9000
|
||||||
|
|
||||||
-- weather calculated end time
|
|
||||||
end_time = nil,
|
|
||||||
|
|
||||||
-- registered weathers
|
|
||||||
reg_weathers = {},
|
|
||||||
|
|
||||||
-- automaticly calculates intervals and swap weathers
|
-- weather calculated end time
|
||||||
auto_mode = true,
|
mcl_weather.end_time = nil
|
||||||
|
|
||||||
-- global flag to disable/enable ABM logic.
|
-- registered weathers
|
||||||
allow_abm = true,
|
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"] = {
|
mcl_weather.reg_weathers["none"] = {
|
||||||
min_duration = mcl_weather.min_duration,
|
min_duration = mcl_weather.min_duration,
|
||||||
|
@ -240,9 +238,9 @@ end
|
||||||
local load_weather = function()
|
local load_weather = function()
|
||||||
local weather = storage:get_string("mcl_weather_state")
|
local weather = storage:get_string("mcl_weather_state")
|
||||||
if weather and weather ~= "" then
|
if weather and weather ~= "" then
|
||||||
mcl_weather.change_weather(weather, mcl_weather.end_time)
|
|
||||||
mcl_weather.state = weather
|
mcl_weather.state = weather
|
||||||
mcl_weather.end_time = storage:get_int("mcl_weather_end_time")
|
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
|
if type(mcl_weather.end_time) ~= "number" then
|
||||||
-- Fallback in case of corrupted end time
|
-- Fallback in case of corrupted end time
|
||||||
mcl_weather.end_time = mcl_weather.min_duration
|
mcl_weather.end_time = mcl_weather.min_duration
|
||||||
|
|
Loading…
Reference in New Issue