]> git.lizzy.rs Git - Crafter.git/blob - mods/season/init.lua
Added Seasons
[Crafter.git] / mods / season / init.lua
1 season = {}
2
3 season.which = minetest.settings:get("season") or "reallife"
4
5 if season.which == "reallife" then
6         local dayofyear = os.date("*t").yday
7         if dayofyear >= 79 and dayofyear < 172 then
8                 season.which = "spring"
9         elseif dayofyear < 266 then
10                 season.which = "summer"
11         elseif dayofyear < 355 then
12                 season.which = "autumn"
13         else
14                 season.which = "winter"
15         end
16 end
17
18 function season.pick(spring, summer, autumn, winter)
19         local t =  {
20                 spring = spring,
21                 summer = summer,
22                 autumn = autumn,
23                 winter = winter
24         }
25         return t[season.which]
26 end