refactor: moved weather files to separate dir

This commit is contained in:
Arturas Norkus 2019-07-14 13:11:14 +03:00
parent 5e4a9a46cb
commit 9bb9a6cecb
9 changed files with 30 additions and 25 deletions

View File

@ -2,26 +2,26 @@ local modpath = minetest.get_modpath("weather_pack");
-- If skylayer mod not located then embeded version will be loaded.
if minetest.get_modpath("skylayer") == nil then
dofile(modpath.."/embedded_sky_layer_api.lua")
dofile(modpath.."/lib_sky_layer_api.lua")
end
-- If happy_weather_api mod not located then embeded version will be loaded.
if minetest.get_modpath("happy_weather_api") == nil then
dofile(modpath.."/embedded_happy_weather_api.lua")
dofile(modpath.."/lib_happy_weather_api.lua")
dofile(modpath.."/commands.lua")
end
-- Happy Weather utilities
dofile(modpath.."/utils.lua")
dofile(modpath.."/light_rain.lua")
dofile(modpath.."/rain.lua")
dofile(modpath.."/heavy_rain.lua")
dofile(modpath.."/snow.lua")
dofile(modpath.."/snowstorm.lua")
dofile(modpath.."/weathers/light_rain.lua")
dofile(modpath.."/weathers/rain.lua")
dofile(modpath.."/weathers/heavy_rain.lua")
dofile(modpath.."/weathers/snow.lua")
dofile(modpath.."/weathers/snowstorm.lua")
if minetest.get_modpath("lightning") ~= nil then
dofile(modpath.."/thunder.lua")
dofile(modpath.."/weathers/thunder.lua")
-- Turn off lightning mod 'auto mode'
lightning.auto = false

View File

@ -10,9 +10,9 @@ local snowstorm = {}
-- Weather identification code
snowstorm.code = "snowstorm"
snow.last_check = 0
snow.check_interval = 400
snow.chance = 0.04
snowstorm.last_check = 0
snowstorm.check_interval = 5
snowstorm.chance = 1
-- Keeps sound handler references
local sound_handlers = {}
@ -41,6 +41,13 @@ local remove_weather_sound = function(player)
end
snowstorm.is_starting = function(dtime, position)
if snowstorm.last_check + snowstorm.check_interval < os.time() then
snowstorm.last_check = os.time()
if math.random() < snowstorm.chance then
return true
end
end
if manual_trigger_start then
manual_trigger_start = false
return true
@ -65,26 +72,24 @@ local set_sky_box = function(player_name)
sl.sky_data = {
gradient_colors = {
{r=0, g=0, b=0},
{r=70, g=70, b=85},
{r=120, g=120, b=125},
{r=70, g=70, b=85},
{r=231, g=234, b=239},
{r=0, g=0, b=0}
}
}
sl.clouds_data = {
gradient_colors = {
{r=10, g=10, b=10},
{r=65, g=66, b=78},
{r=112, g=110, b=119},
{r=65, g=66, b=78},
{r=10, g=10, b=10}
},
speed = {z = 30, y = -80},
density = 0.6
}
skylayer.add_layer(player_name, sl)
end
snowstorm.in_area = function(position)
if hw_utils.is_biome_frozen(position) == false then
return false
end
if position.y > 30 and position.y < 140 then
return true
end
return false
end
snowstorm.add_player = function(player)
sound_handlers[player:get_player_name()] = set_weather_sound(player)
set_sky_box(player:get_player_name())