forked from mtcontrib/weather_pack
refactor: moved weather files to separate dir
This commit is contained in:
parent
5e4a9a46cb
commit
9bb9a6cecb
16
init.lua
16
init.lua
@ -2,26 +2,26 @@ local modpath = minetest.get_modpath("weather_pack");
|
|||||||
|
|
||||||
-- If skylayer mod not located then embeded version will be loaded.
|
-- If skylayer mod not located then embeded version will be loaded.
|
||||||
if minetest.get_modpath("skylayer") == nil then
|
if minetest.get_modpath("skylayer") == nil then
|
||||||
dofile(modpath.."/embedded_sky_layer_api.lua")
|
dofile(modpath.."/lib_sky_layer_api.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If happy_weather_api mod not located then embeded version will be loaded.
|
-- If happy_weather_api mod not located then embeded version will be loaded.
|
||||||
if minetest.get_modpath("happy_weather_api") == nil then
|
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")
|
dofile(modpath.."/commands.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Happy Weather utilities
|
-- Happy Weather utilities
|
||||||
dofile(modpath.."/utils.lua")
|
dofile(modpath.."/utils.lua")
|
||||||
|
|
||||||
dofile(modpath.."/light_rain.lua")
|
dofile(modpath.."/weathers/light_rain.lua")
|
||||||
dofile(modpath.."/rain.lua")
|
dofile(modpath.."/weathers/rain.lua")
|
||||||
dofile(modpath.."/heavy_rain.lua")
|
dofile(modpath.."/weathers/heavy_rain.lua")
|
||||||
dofile(modpath.."/snow.lua")
|
dofile(modpath.."/weathers/snow.lua")
|
||||||
dofile(modpath.."/snowstorm.lua")
|
dofile(modpath.."/weathers/snowstorm.lua")
|
||||||
|
|
||||||
if minetest.get_modpath("lightning") ~= nil then
|
if minetest.get_modpath("lightning") ~= nil then
|
||||||
dofile(modpath.."/thunder.lua")
|
dofile(modpath.."/weathers/thunder.lua")
|
||||||
|
|
||||||
-- Turn off lightning mod 'auto mode'
|
-- Turn off lightning mod 'auto mode'
|
||||||
lightning.auto = false
|
lightning.auto = false
|
||||||
|
@ -10,9 +10,9 @@ local snowstorm = {}
|
|||||||
|
|
||||||
-- Weather identification code
|
-- Weather identification code
|
||||||
snowstorm.code = "snowstorm"
|
snowstorm.code = "snowstorm"
|
||||||
snow.last_check = 0
|
snowstorm.last_check = 0
|
||||||
snow.check_interval = 400
|
snowstorm.check_interval = 5
|
||||||
snow.chance = 0.04
|
snowstorm.chance = 1
|
||||||
|
|
||||||
-- Keeps sound handler references
|
-- Keeps sound handler references
|
||||||
local sound_handlers = {}
|
local sound_handlers = {}
|
||||||
@ -41,6 +41,13 @@ local remove_weather_sound = function(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
snowstorm.is_starting = function(dtime, position)
|
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
|
if manual_trigger_start then
|
||||||
manual_trigger_start = false
|
manual_trigger_start = false
|
||||||
return true
|
return true
|
||||||
@ -65,26 +72,24 @@ local set_sky_box = function(player_name)
|
|||||||
sl.sky_data = {
|
sl.sky_data = {
|
||||||
gradient_colors = {
|
gradient_colors = {
|
||||||
{r=0, g=0, b=0},
|
{r=0, g=0, b=0},
|
||||||
{r=70, g=70, b=85},
|
{r=231, g=234, b=239},
|
||||||
{r=120, g=120, b=125},
|
|
||||||
{r=70, g=70, b=85},
|
|
||||||
{r=0, g=0, b=0}
|
{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)
|
skylayer.add_layer(player_name, sl)
|
||||||
end
|
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)
|
snowstorm.add_player = function(player)
|
||||||
sound_handlers[player:get_player_name()] = set_weather_sound(player)
|
sound_handlers[player:get_player_name()] = set_weather_sound(player)
|
||||||
set_sky_box(player:get_player_name())
|
set_sky_box(player:get_player_name())
|
Loading…
Reference in New Issue
Block a user