Add hail effect and date functions
@ -6,3 +6,4 @@
|
|||||||
- Snow flake and rain drop textures CC BY-SA (3.0) by paramat, found in snowdrift mod at https://github.com/paramat/snowdrift
|
- Snow flake and rain drop textures CC BY-SA (3.0) by paramat, found in snowdrift mod at https://github.com/paramat/snowdrift
|
||||||
- Snow texture composited from individual snow flakes by paramat. CC-BY-SA (3.0)
|
- Snow texture composited from individual snow flakes by paramat. CC-BY-SA (3.0)
|
||||||
- Wind sound CC-BY (3.0) by InspectorJ from https://freesound.org/people/InspectorJ/sounds/376415/
|
- Wind sound CC-BY (3.0) by InspectorJ from https://freesound.org/people/InspectorJ/sounds/376415/
|
||||||
|
- Hail sound CC0 by ikayuka from https://freesound.org/people/ikayuka/sounds/240742/
|
1
init.lua
@ -52,3 +52,4 @@ dofile(weather_mod.modpath.."/weathers/snow.lua")
|
|||||||
dofile(weather_mod.modpath.."/weathers/snow_heavy.lua")
|
dofile(weather_mod.modpath.."/weathers/snow_heavy.lua")
|
||||||
dofile(weather_mod.modpath.."/weathers/storm.lua")
|
dofile(weather_mod.modpath.."/weathers/storm.lua")
|
||||||
dofile(weather_mod.modpath.."/weathers/sandstorm.lua")
|
dofile(weather_mod.modpath.."/weathers/sandstorm.lua")
|
||||||
|
dofile(weather_mod.modpath.."/weathers/hail.lua")
|
||||||
|
@ -14,5 +14,5 @@ function weather_mod.handle_time_progression()
|
|||||||
if time < weather_mod.state.time.last_check then
|
if time < weather_mod.state.time.last_check then
|
||||||
weather_mod.state.time.day = weather_mod.state.time.day + 1
|
weather_mod.state.time.day = weather_mod.state.time.day + 1
|
||||||
end
|
end
|
||||||
weather_mod.state.last_check = time
|
weather_mod.state.time.last_check = time
|
||||||
end
|
end
|
@ -1,4 +1,4 @@
|
|||||||
local days = {
|
weather_mod.weekdays = {
|
||||||
"Monday",
|
"Monday",
|
||||||
"Tuesday",
|
"Tuesday",
|
||||||
"Wednesday",
|
"Wednesday",
|
||||||
@ -8,7 +8,7 @@ local days = {
|
|||||||
"Sunday"
|
"Sunday"
|
||||||
}
|
}
|
||||||
|
|
||||||
local months = {
|
weather_mod.months = {
|
||||||
{ name = "January", days = 31 },
|
{ name = "January", days = 31 },
|
||||||
{ name = "February", days = 28 },
|
{ name = "February", days = 28 },
|
||||||
{ name = "March", days = 31 },
|
{ name = "March", days = 31 },
|
||||||
@ -22,3 +22,37 @@ local months = {
|
|||||||
{ name = "November", days = 30 },
|
{ name = "November", days = 30 },
|
||||||
{ name = "December", days = 31 }
|
{ name = "December", days = 31 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
weather_mod.seasons = {
|
||||||
|
{ name = "spring" },
|
||||||
|
{ name = "summer" },
|
||||||
|
{ name = "autumn" },
|
||||||
|
{ name = "winter" }
|
||||||
|
}
|
||||||
|
|
||||||
|
function weather_mod.get_weekday()
|
||||||
|
return (weather_mod.state.time.day - 1) % 7 + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function weather_mod.get_month()
|
||||||
|
local day = (weather_mod.state.time.day - 1) % 365 + 1
|
||||||
|
local sum = 0
|
||||||
|
for i, month in ipairs(weather_mod.months) do
|
||||||
|
sum = sum + month.days
|
||||||
|
if sum >= day then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function weather_mod.get_season()
|
||||||
|
local month = weather_mod.get_month()
|
||||||
|
return math.floor((month - 1) / 3 + 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function weather_mod.print_date()
|
||||||
|
local weekday = weather_mod.weekdays[weather_mod.get_weekday()]
|
||||||
|
local date = (weather_mod.state.time.day - 1) % 365 + 1
|
||||||
|
local month = weather_mod.months[weather_mod.get_month()].name
|
||||||
|
return weekday .. ", " .. date .. ". " .. month
|
||||||
|
end
|
@ -3,6 +3,13 @@ minetest.register_privilege("weather", {
|
|||||||
give_to_singleplayer = false
|
give_to_singleplayer = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("date", {
|
||||||
|
func = function(playername, param)
|
||||||
|
local date = weather_mod.print_date()
|
||||||
|
minetest.chat_send_player(playername, date)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
-- Force a weather effect to override environment
|
-- Force a weather effect to override environment
|
||||||
minetest.register_chatcommand("set_weather", {
|
minetest.register_chatcommand("set_weather", {
|
||||||
params = "<weather>",
|
params = "<weather>",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local GSCYCLE = 0.05
|
local GSCYCLE = 0.05
|
||||||
local RECALCCYCLE = 0
|
local RECALCCYCLE = 0.2
|
||||||
|
|
||||||
weather_mod.weathers = {}
|
weather_mod.weathers = {}
|
||||||
function weather_mod.register_effect(name, config, override)
|
function weather_mod.register_effect(name, config, override)
|
||||||
@ -117,6 +117,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
if timer >= RECALCCYCLE then
|
if timer >= RECALCCYCLE then
|
||||||
weather_mod.set_clouds(player)
|
weather_mod.set_clouds(player)
|
||||||
weather_mod.set_headwind(player)
|
weather_mod.set_headwind(player)
|
||||||
|
weather_mod.handle_time_progression()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
timer = 0
|
timer = 0
|
||||||
|
BIN
sounds/weather_hail.ogg
Normal file
Before Width: | Height: | Size: 2.8 KiB |
BIN
textures/weather_hail1.png
Normal file
After Width: | Height: | Size: 121 B |
BIN
textures/weather_hail2.png
Normal file
After Width: | Height: | Size: 134 B |
BIN
textures/weather_hail3.png
Normal file
After Width: | Height: | Size: 136 B |
BIN
textures/weather_hail4.png
Normal file
After Width: | Height: | Size: 204 B |
BIN
textures/weather_hail5.png
Normal file
After Width: | Height: | Size: 311 B |
Before Width: | Height: | Size: 5.6 KiB |
38
weathers/hail.lua
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
local name = weather_mod.modname .. ":hail"
|
||||||
|
|
||||||
|
local config = {}
|
||||||
|
|
||||||
|
config.environment = {
|
||||||
|
spawn_puddles = true,
|
||||||
|
lightning = true,
|
||||||
|
damage = true
|
||||||
|
}
|
||||||
|
|
||||||
|
config.sound = {
|
||||||
|
name = "weather_hail",
|
||||||
|
gain = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
config.particles = {
|
||||||
|
min_pos = {x=-9, y=7, z=-9},
|
||||||
|
max_pos = {x= 9, y=7, z= 9},
|
||||||
|
falling_speed=15,
|
||||||
|
amount=5,
|
||||||
|
exptime=0.8,
|
||||||
|
size=1,
|
||||||
|
textures = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i = 1,5,1 do
|
||||||
|
config.particles.textures[i] = "weather_hail" .. i .. ".png"
|
||||||
|
end
|
||||||
|
|
||||||
|
config.conditions = {
|
||||||
|
min_height = weather_mod.settings.min_height,
|
||||||
|
max_height = weather_mod.settings.max_height,
|
||||||
|
max_heat = 45,
|
||||||
|
min_humidity = 65,
|
||||||
|
min_windspeed = 2.5
|
||||||
|
}
|
||||||
|
|
||||||
|
weather_mod.register_effect(name, config)
|