diff --git a/README.md b/README.md index fc9ffc5..0c63654 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ - Rain texture CC-BY-SA 3.0 from TeddyDesTodes, taken from his weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather - 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) -- Wind sound CC-BY (3.0) by InspectorJ from https://freesound.org/people/InspectorJ/sounds/376415/ \ No newline at end of file +- 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/ \ No newline at end of file diff --git a/init.lua b/init.lua index 82c219f..8169301 100644 --- a/init.lua +++ b/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/storm.lua") dofile(weather_mod.modpath.."/weathers/sandstorm.lua") +dofile(weather_mod.modpath.."/weathers/hail.lua") diff --git a/lib/calendar.lua b/lib/calendar.lua index 6eefe07..8601cf8 100644 --- a/lib/calendar.lua +++ b/lib/calendar.lua @@ -14,5 +14,5 @@ function weather_mod.handle_time_progression() if time < weather_mod.state.time.last_check then weather_mod.state.time.day = weather_mod.state.time.day + 1 end - weather_mod.state.last_check = time + weather_mod.state.time.last_check = time end \ No newline at end of file diff --git a/lib/calendar_dictionary.lua b/lib/calendar_dictionary.lua index 69a4042..cf28ca7 100644 --- a/lib/calendar_dictionary.lua +++ b/lib/calendar_dictionary.lua @@ -1,4 +1,4 @@ -local days = { +weather_mod.weekdays = { "Monday", "Tuesday", "Wednesday", @@ -8,7 +8,7 @@ local days = { "Sunday" } -local months = { +weather_mod.months = { { name = "January", days = 31 }, { name = "February", days = 28 }, { name = "March", days = 31 }, @@ -21,4 +21,38 @@ local months = { { name = "October", days = 31 }, { name = "November", days = 30 }, { name = "December", days = 31 } -} \ No newline at end of file +} + +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 \ No newline at end of file diff --git a/lib/commands.lua b/lib/commands.lua index b0ce5b9..79a9d03 100644 --- a/lib/commands.lua +++ b/lib/commands.lua @@ -3,6 +3,13 @@ minetest.register_privilege("weather", { 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 minetest.register_chatcommand("set_weather", { params = "", diff --git a/lib/main.lua b/lib/main.lua index c29df50..231fd9e 100644 --- a/lib/main.lua +++ b/lib/main.lua @@ -1,5 +1,5 @@ local GSCYCLE = 0.05 -local RECALCCYCLE = 0 +local RECALCCYCLE = 0.2 weather_mod.weathers = {} function weather_mod.register_effect(name, config, override) @@ -117,6 +117,7 @@ minetest.register_globalstep(function(dtime) if timer >= RECALCCYCLE then weather_mod.set_clouds(player) weather_mod.set_headwind(player) + weather_mod.handle_time_progression() end end timer = 0 diff --git a/sounds/weather_hail.ogg b/sounds/weather_hail.ogg new file mode 100644 index 0000000..0206a9c Binary files /dev/null and b/sounds/weather_hail.ogg differ diff --git a/textures/weather_hail.png b/textures/weather_hail.png deleted file mode 100644 index 4fcfe70..0000000 Binary files a/textures/weather_hail.png and /dev/null differ diff --git a/textures/weather_hail1.png b/textures/weather_hail1.png new file mode 100644 index 0000000..c052410 Binary files /dev/null and b/textures/weather_hail1.png differ diff --git a/textures/weather_hail2.png b/textures/weather_hail2.png new file mode 100644 index 0000000..d5af6ed Binary files /dev/null and b/textures/weather_hail2.png differ diff --git a/textures/weather_hail3.png b/textures/weather_hail3.png new file mode 100644 index 0000000..00860d3 Binary files /dev/null and b/textures/weather_hail3.png differ diff --git a/textures/weather_hail4.png b/textures/weather_hail4.png new file mode 100644 index 0000000..b2bd4b3 Binary files /dev/null and b/textures/weather_hail4.png differ diff --git a/textures/weather_hail5.png b/textures/weather_hail5.png new file mode 100644 index 0000000..c7c19de Binary files /dev/null and b/textures/weather_hail5.png differ diff --git a/textures/weather_rain_dark.png b/textures/weather_rain_dark.png deleted file mode 100644 index 3829b36..0000000 Binary files a/textures/weather_rain_dark.png and /dev/null differ diff --git a/weathers/hail.lua b/weathers/hail.lua new file mode 100644 index 0000000..535ef33 --- /dev/null +++ b/weathers/hail.lua @@ -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)