master
LinusHsao 2016-07-16 23:05:57 +00:00
parent 9d4dd5bb9b
commit 7eb18a92f5
38 changed files with 1995 additions and 0 deletions

55
mods/mymonths/README Normal file
View File

@ -0,0 +1,55 @@
Mod is by Don and Nathan
Mymonths is licenced as DWYWPL
Fall leaf textures are modified from original default textures by Cisoun (WTFPL) and Paramat. (CC BY-SA 3.0)
The rain and snow code comes from the weather mod
from topic - https://forum.minetest.net/viewtopic.php?t=5245
by Jeija
- Code: LGPL
- Textures:
- Snow cover: WTFPL
- Rain / Snow: CC-BY-SA 3.0, credit goes to TeddyDesTodes, from his weather branch at https://github.com/TeddyDesTodes/minetest/tree/weather
- Sound Effects:
- mymonths_rain & mymonths_rain1: CC0 by Q.K.
This mod adds months, weeks and days to Minetest.
A Minetest year has 12 months with 2 weeks per month. Each week has 7 days.
The weather is depended on the time of year. If it is winter then it will snow spring has rain etc.
Leaves turn color in the fall and the the tree will have no leaves or apples through the winter.
The leaves grow back in the spring and the apples later in the year.
Acacia trees will bloom in January
The desert and savannah biomes do not get rain or snow but do have sand storms.
The snow biomes do not get rain.
The trees in these biomes do not loose their leaves.
Each morning at 6am a chat message will say the date. If the day is a holiday it will show in chat with the morning date.
If you are caught in a storm you will need to seek shelter. Rain or snow does nothingbut if you are in a storm, snowstorm,
sandstorm or hail you will recieve damage. You need to cover yourself so you do not recieve damage.
Chat Commands
You need the priv mymonths to set mymonth things. You do not need it to check the weather.
/setweather rain,storm,snow,snowstorm,sandstorm,hail
/setmonth - can be either 1-12,January-December,january-december or jan-dec
/setday 1-14
No priv needed for these commands
/weather - tell you what the weather is
/date - tells you what the time and date is
/holidays - gives a list of holidays. These are Minetest holidays made up by me. I will not add real holidays.
Holidays were added to give players a bit of fun.

201
mods/mymonths/abms.lua Normal file
View File

@ -0,0 +1,201 @@
--Places Snow on ground
if mymonths.snow_on_ground == true then
minetest.register_abm({
nodenames = {"default:leaves", "default:dirt", "default:dirt_with_grass"},
neighbors = {"air"},
interval = 8,
chance = 20,
action = function (pos, node)
local biome_jungle = minetest.find_node_near(pos, 5, "default:jungletree", "default:junglegrass")
pos.y = pos.y + 1 -- check above node
local na = minetest.get_node(pos)
if (mymonths.weather == "snow" or mymonths.weather == "snowstorm")
and biome_jungle == nil then
if minetest.get_node_light(pos, 0.5) == 15
and na.name == "air" then
minetest.set_node(pos, {name = "mymonths:snow_cover_1"})
end
end
end
})
--Replace grass and flowers with snow
minetest.register_abm({
nodenames = {"group:flora", "mymonths:puddle"},
neighbors = {"air"},
interval = 8,
chance = 20,
action = function (pos, node)
local biome_jungle = minetest.find_node_near(pos, 5, "default:jungletree","default:junglegrass")
if mymonths.weather == "snow"
and biome_jungle == nil then
if minetest.get_node_light({
x = pos.x,
y = pos.y + 1,
z = pos.z}, 0.5) == 15 then
minetest.set_node(pos, {name="mymonths:snow_cover_1"})
end
end
end
})
-- Changes snow to larger snow
minetest.register_abm({
nodenames = {"mymonths:snow_cover_1", "mymonths:snow_cover_2", "mymonths:snow_cover_3", "mymonths:snow_cover_4"},
neighbors = {"default:dirt", "default:dirt_with_grass"},
interval = 20,
chance = 40,
action = function (pos, node)
if mymonths.weather2 == "snow"
or mymonths.weather2 == "snowstorm" then
if mymonths.weather2 == "snow"
and math.random(1, 4) ~= 1 then
return
end
if node.name == "mymonths:snow_cover_1" then
minetest.set_node(pos, {name = "mymonths:snow_cover_2"})
elseif node.name == "mymonths:snow_cover_2" then
minetest.set_node(pos, {name = "mymonths:snow_cover_3"})
elseif node.name == "mymonths:snow_cover_3" then
minetest.set_node(pos, {name = "mymonths:snow_cover_4"})
elseif node.name == "mymonths:snow_cover_4" then
minetest.set_node(pos, {name = "mymonths:snow_cover_5"})
end
end
end
})
-- Snow Melting
minetest.register_abm({
nodenames = {"mymonths:snow_cover_1", "mymonths:snow_cover_2", "mymonths:snow_cover_3", "mymonths:snow_cover_4", "mymonths:snow_cover_5"},
interval = 10,
chance = 1,
action = function (pos, node)
if mymonths.month_counter == 12
or mymonths.month_counter == 1
or mymonths.month_counter == 2 then
return
end
-- remove snow if month is april
if mymonths.month_counter == 4 then
minetest.remove_node(pos)
return
end
if math.random(1, 100) == 1 then
if node.name == "mymonths:snow_cover_2" then
minetest.set_node(pos, {name = "mymonths:snow_cover_1"})
elseif node.name == "mymonths:snow_cover_3" then
minetest.set_node(pos, {name = "mymonths:snow_cover_2"})
elseif node.name == "mymonths:snow_cover_4" then
minetest.set_node(pos, {name = "mymonths:snow_cover_3"})
elseif node.name == "mymonths:snow_cover_5" then
minetest.set_node(pos, {name = "mymonths:snow_cover_4"})
elseif node.name == "mymonths:snow_cover_1" then
local nu = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
if nu.name == "default:dirt_with_grass"
or nu.name == "default:dirt" then
minetest.set_node(pos, {name = "mymonths:puddle"})
else
minetest.remove_node(pos)
end
end
end
end
})
end -- END IF
if mymonths.use_puddles == true then
-- Makes Puddles when raining
minetest.register_abm({
nodenames = {"default:dirt", "default:dirt_with_grass"},
neighbors = {"default:air"},
interval = 10,
chance = 50,
action = function (pos, node)
if mymonths.weather == "rain" then
-- return if puddle found nearby
if minetest.find_node_near(pos, 20, "mymonths:puddle") then
return
end
pos.y = pos.y + 1
-- otherwise place puddle in empty space
if minetest.get_node_light(pos, 0.5) == 15
and minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name = "mymonths:puddle"})
end
end
end
})
-- Makes puddles dry up when not raining
minetest.register_abm({
nodenames = {"mymonths:puddle"},
neighbors = {"air"},
interval = 5,
chance = 5,
action = function (pos, node)
if mymonths.weather == "clear" then
minetest.remove_node(pos)
elseif mymonths.weather == "snow"
or mymonths.weather == "snowstorm" then
minetest.set_node(pos, {name = "mymonths:snow_cover_1"})
end
end
})
end -- END IF

266
mods/mymonths/command.lua Normal file
View File

@ -0,0 +1,266 @@
--Sets the privs for changing settings
minetest.register_privilege("mymonths", {
description = "Change the weather and date",
give_to_singleplayer = false
})
-- Set weather
if mymonths.use_weather == true then
minetest.register_chatcommand("setweather", {
params = "<mymonths>",
description = "Set weather to rain, snow, wind or clear",
privs = {mymonths = true},
func = function(name, param)
if param == "rain"
or param == "storm"
or param == "snow"
or param == "snowstorm"
or param == "sandstorm"
or param == "hail"
or param == "clear" then
mymonths.weather = param
mymonths.save_table()
else
minetest.chat_send_player(name,
"invalid input - use rain, storm, snow, snowstorm, sandstorm, hail or clear.")
return
end
end
})
end -- END IF
--Set month
minetest.register_chatcommand("setmonth", {
params = "",
description = "Set the month. Use the number 1-12 or the name",
privs = {mymonths = true},
func = function(name, param)
if param == "1"
or param == "January"
or param == "january"
or param == "jan" then
mymonths.month = "January"
mymonths.month_counter = 1
minetest.chat_send_player(name," Month has been changed to January")
elseif param == "2"
or param == "February"
or param == "february"
or param == "feb" then
mymonths.month = "Febuary"
mymonths.month_counter = 2
minetest.chat_send_player(name, "Month has been changed to Febuary")
elseif param == "3"
or param == "March"
or param == "march"
or param == "mar" then
mymonths.month = "March"
mymonths.month_counter = 3
minetest.chat_send_player(name, "Month has been changed to March")
elseif param == "4"
or param == "April"
or param == "april"
or param == "apr" then
mymonths.month = "April"
mymonths.month_counter = 4
minetest.chat_send_player(name, "Month has been changed to April")
elseif param == "5"
or param == "May"
or param == "may" then
mymonths.month = "May"
mymonths.month_counter = 5
minetest.chat_send_player(name, "Month has been changed to May")
elseif param == "6"
or param == "June"
or param == "june"
or param == "jun" then
mymonths.month = "June"
mymonths.month_counter = 6
minetest.chat_send_player(name, "Month has been changed to June")
elseif param == "7"
or param == "July"
or param == "july"
or param == "jul" then
mymonths.month = "July"
mymonths.month_counter = 7
minetest.chat_send_player(name, "Month has been changed to July")
elseif param == "8"
or param == "August"
or param == "august"
or param == "aug" then
mymonths.month = "Augest"
mymonths.month_counter = 8
minetest.chat_send_player(name, "Month has been changed to August")
elseif param == "9"
or param == "September"
or param == "september"
or param == "sep" then
mymonths.month = "September"
mymonths.month_counter = 9
minetest.chat_send_player(name, "Month has been changed to September")
elseif param == "10"
or param == "October"
or param == "october"
or param == "oct" then
mymonths.month = "October"
mymonths.month_counter = 10
minetest.chat_send_player(name, "Month has been changed to October")
elseif param == "11"
or param == "November"
or param == "november"
or param == "nov" then
mymonths.month = "November"
mymonths.month_counter = 11
minetest.chat_send_player(name, "Month has been changed to November")
elseif param == "12"
or param == "December"
or param == "december"
or param == "dec"then
mymonths.month = "December"
mymonths.month_counter = 12
minetest.chat_send_player(name, "Month has been changed to December")
else
minetest.chat_send_player(name, "invalid input")
return
end
mymonths.save_table()
end
})
--Set Days
minetest.register_chatcommand("setday", {
params = "",
description = "Set the day of the month",
privs = {mymonths = true},
func = function(name, param)
local d = tonumber(param)
if d then
for day = 1, 14 do
if tonumber(param) >= 15 then
return
end
if tonumber(param) == day then
mymonths.day_counter = tonumber(day)
end
end
end
end
})
--Weather
if mymonths.use_weather == true then
minetest.register_chatcommand("weather", {
params = "",
description = "Tells player the weather",
func = function(name, param)
minetest.chat_send_player(name,"The weather is " .. mymonths.weather2)
end
})
end -- END IF
--Time and Date
minetest.register_chatcommand("date", {
params = "",
description = "Say the date in chat",
func = function(name, param)
local t = tostring(minetest.get_timeofday() * 2400)
local tt = string.find(t, "%p",1)
tt = tt or "0" -- if nil then force value
local th = string.sub(t, tt-4,tt-3)
local tm = string.sub(t, tt-2,tt-1)
local m = (tm/100)*60
local mx = m+1000
local my = ".00"
local mz = mx..my
local mf = string.find(mz, "%p",1)
local mi = string.sub(mx,mf-2,mf-1)
local ampm = "am"
th = th or 0 -- if nil then force value
if tonumber(th..tm) >= 1201
and tonumber(th) <= 2400 then
ampm = "pm"
th = th - 12
if th == 0 then
th = 12
end
else
ampm = "am"
if th == 0
or th == "" then
th = 12
end
end
minetest.chat_send_player(name, "The time is " ..th.. ":"
.. mi .. " " .. ampm .. " on " .. mymonths.day_name
.. " " .. mymonths.month .. " " .. mymonths.day_counter)
end
})
--Gives list of holidays
minetest.register_chatcommand("holidays", {
params = "",
description = "Say the date in chat",
func = function(name, param)
minetest.chat_send_player(name, "New Years Day - January 1")
minetest.chat_send_player(name, "Friendship Day - March 12")
minetest.chat_send_player(name, "Miners Day - April 10")
minetest.chat_send_player(name, "Minetest Day - June 5")
minetest.chat_send_player(name, "Builders Day - Augest 12")
minetest.chat_send_player(name, "Harvest Day - October 8")
minetest.chat_send_player(name, "New Years Eve - December 14")
end
})

View File

@ -0,0 +1,3 @@
default
thirsty?
lightning?

View File

@ -0,0 +1 @@
Adds days of the week and months. Also weather, including rain and snow.

74
mods/mymonths/flowers.lua Normal file
View File

@ -0,0 +1,74 @@
-- Flowers die in late fall
minetest.register_abm({
-- nodenames = {'group:flower'},
nodenames = {'group:flower','group:farming'},
interval = 10,
chance = 10,
action = function (pos)
if mymonths.month_counter == 10
or mymonths.month_counter == 11 then
minetest.set_node(pos, {name = 'default:dry_grass_1'})
end
end
})
-- Flowers grow in spring, flower spread ABM is in flower mod, this just gives
-- initial population as that ABM won't grow flowers where there are none.
minetest.register_abm({
nodenames = {'group:soil'},
interval = 240,
chance = 100,
action = function (pos)
-- return if not march or april
if mymonths.month ~= 3
or mymonths.month ~= 4 then
return
end
local pos0 = {x = pos.x - 4, y = pos.y - 4, z = pos.z - 4}
local pos1 = {x = pos.x + 4, y = pos.y + 4, z = pos.z + 4}
local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flower")
if #flowers > 2 then
return
end
pos.y = pos.y + 1
if minetest.get_node(pos).name == 'air' then
local key = math.random(1, 6)
if key == 1 then
minetest.set_node(pos, {name = 'flowers:dandelion_white'})
elseif key == 2 then
minetest.set_node(pos, {name = "flowers:dandelion_yellow"})
elseif key == 3 then
minetest.set_node(pos, {name = "flowers:geranium"})
elseif key == 4 then
minetest.set_node(pos, {name = "flowers:rose"})
elseif key == 5 then
minetest.set_node(pos, {name = "flowers:tulip"})
elseif key == 6 then
minetest.set_node(pos, {name = "flowers:viola"})
end
end
end
})

View File

@ -0,0 +1,58 @@
-- Save table to file
function mymonths.save_table()
local data = mymonths
local f, err = io.open(minetest.get_worldpath() .. "/mymonths_data", "w")
if err then
return err
end
f:write(minetest.serialize(data))
f:close()
end
-- Reads saved file
function mymonths.read_mymonths()
local f, err = io.open(minetest.get_worldpath() .. "/mymonths_data", "r")
local data = minetest.deserialize(f:read("*a"))
f:close()
return data
end
-- Saves the table every 10 seconds
local tmr = 0
minetest.register_globalstep(function(dtime)
tmr = tmr + dtime
if tmr >= 10 then
tmr = 0
mymonths.save_table()
end
end)
-- Check to see if file exists and if not sets default values.
local f, err = io.open(minetest.get_worldpath().."/mymonths_data", "r")
if f == nil then
mymonths.day_counter = 1
mymonths.month_counter = 6
mymonths.month = "June"
mymonths.weather = "clear"
mymonths.day_name = "Monday"
else
mymonths.day_counter = mymonths.read_mymonths().day_counter
mymonths.month_counter = mymonths.read_mymonths().month_counter
mymonths.month = mymonths.read_mymonths().month
mymonths.weather = mymonths.read_mymonths().weather
mymonths.day_name = mymonths.read_mymonths().day_name
end

94
mods/mymonths/init.lua Normal file
View File

@ -0,0 +1,94 @@
--Settings
mymonths = {}
--Turn damage on or off. This will make storms and hail cause damage
mymonths.damage = false
--You can turn weather off
mymonths.use_weather = false
--Leaves change color in the fall.
mymonths.leaves = true
--Have snow accumulate on the ground
mymonths.snow_on_ground = true
--Puddles appear when raining
mymonths.use_puddles = true
--Flowers die in winter, grown in spring
mymonths.flowers_die = true
if minetest.get_modpath("lightning") then
lightning.auto = false
end
local modpath = minetest.get_modpath("mymonths")
local input = io.open(modpath.."/settings.txt", "r")
if input then
dofile(modpath.."/settings.txt")
input:close()
input = nil
--else
-- mymonths.damage = false
-- mymonths.use_weather = true
-- mymonths.leaves = true
-- mymonths.snow_on_ground = true
-- mymonths.use_puddles = true
end
dofile(minetest.get_modpath("mymonths") .. "/functions.lua")
dofile(minetest.get_modpath("mymonths") .. "/abms.lua")
dofile(minetest.get_modpath("mymonths") .. "/command.lua")
dofile(minetest.get_modpath("mymonths") .. "/months.lua")
if mymonths.use_weather == true then
dofile(minetest.get_modpath("mymonths").."/weather.lua")
end
if mymonths.use_weather == false then
minetest.register_alias("mymonths:puddle", "air")
minetest.register_alias("mymonths:snow_cover_1", "air")
minetest.register_alias("mymonths:snow_cover_2", "air")
minetest.register_alias("mymonths:snow_cover_3", "air")
minetest.register_alias("mymonths:snow_cover_4", "air")
minetest.register_alias("mymonths:snow_cover_5", "air")
end
if mymonths.snow_on_ground == false then
minetest.register_alias("mymonths:snow_cover_1", "air")
minetest.register_alias("mymonths:snow_cover_2", "air")
minetest.register_alias("mymonths:snow_cover_3", "air")
minetest.register_alias("mymonths:snow_cover_4", "air")
minetest.register_alias("mymonths:snow_cover_5", "air")
end
--[[
if mymonths.use_puddles == false then
minetest.register_alias("mymonths:puddle", "air")
end
--]]
if mymonths.leaves == true then
dofile(minetest.get_modpath("mymonths") .. "/leaves.lua")
end
if mymonths.leaves == false then
minetest.register_alias("mymonths:leaves_pale_green", "default:leaves")
minetest.register_alias("mymonths:leaves_orange", "default:leaves")
minetest.register_alias("mymonths:leaves_red", "default:leaves")
minetest.register_alias("mymonths:sticks_default", "default:leaves")
minetest.register_alias("mymonths:sticks_aspen", "default:aspen_leaves")
end
if mymonths.flowers_die == true then
dofile(minetest.get_modpath("mymonths") .. "/flowers.lua")
end
if minetest.get_modpath("thirsty") then
thirst = true
end

390
mods/mymonths/leaves.lua Normal file
View File

@ -0,0 +1,390 @@
--Nodes #################
local leaves_table = {
'pale_green', 'orange', 'red', 'blooms', 'acacia_blooms',
'orange_aspen', 'red_aspen', 'aspen_blooms', 'yellow_aspen','sticks'}
local sticks_table = {'default', 'aspen'}
for i, name in pairs(leaves_table) do
minetest.register_node('mymonths:leaves_' .. name, {
description = name .. ' leaves',
drawtype = 'allfaces_optional',
waving = 1,
visual_scale = 1.3,
tiles = {'mymonths_leaves_' .. name .. '.png'},
paramtype = 'light',
is_ground_content = false,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
end
for i, name in pairs(sticks_table) do
minetest.register_node('mymonths:sticks_' .. name, {
description = 'Sticks',
drawtype = 'allfaces_optional',
waving = 1,
visual_scale = 1.3,
tiles = {'mymonths_sticks.png'},
paramtype = 'light',
is_ground_content = false,
drop = 'mymonths:leaves_sticks 2',
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
})
end
minetest.register_craft({
output = "default:stick 2",
recipe = {
{"mymonths:leaves_sticks","mymonths:leaves_sticks","mymonths:leaves_sticks" },
{"mymonths:leaves_sticks","mymonths:leaves_sticks","mymonths:leaves_sticks"},
{"mymonths:leaves_sticks","mymonths:leaves_sticks","mymonths:leaves_sticks"},
}
})
--ABMs ##################
--leaves changing in September and October.
minetest.register_abm({
nodenames = {'group:leaves'},
interval = 60,
chance = 40,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 9
or mymonths.month_counter == 10 then
if node.name == 'default:leaves' then
minetest.set_node(pos, {name = 'mymonths:leaves_pale_green'})
elseif node.name == 'mymonths:leaves_pale_green' then
minetest.set_node(pos, {name = 'mymonths:leaves_orange'})
elseif node.name == 'mymonths:leaves_orange' then
minetest.set_node(pos, {name = 'mymonths:leaves_red'})
elseif node.name == 'mymonths:leaves_red' then
minetest.set_node(pos, {name = 'mymonths:sticks_default'})
elseif node.name == 'default:aspen_leaves' then
minetest.set_node(pos, {name = 'mymonths:leaves_yellow_aspen'})
elseif node.name == 'mymonths:leaves_yellow_aspen' then
minetest.set_node(pos, {name = 'mymonths:leaves_orange_aspen'})
elseif node.name == 'mymonths:leaves_orange_aspen' then
minetest.set_node(pos, {name = 'mymonths:leaves_red_aspen'})
end
end
end
})
--All leaves should be pale green by mid September
minetest.register_abm({
nodenames = {'default:leaves'},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 9
and mymonths.day_counter >= 8 then
minetest.set_node(pos, {name = 'mymonths:leaves_pale_green'})
end
end
})
--All leaves should be orange by October
minetest.register_abm({
nodenames = {'default:leaves', 'mymonths:leaves_pale_green'},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 10
and tonumber(mymonths.day_counter) >= 1
and tonumber(mymonths.day_counter) <= 7 then
minetest.set_node(pos, {name = 'mymonths:leaves_orange'})
end
end
})
--All leaves should be red by mid October
minetest.register_abm({
nodenames = {'default:leaves', 'mymonths:leaves_pale_green','mymonths:leaves_orange'},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 10
and mymonths.day_counter >= 8 then
minetest.set_node(pos, {name = 'mymonths:leaves_red'})
end
end
})
--leaves 'falling/dying' in October
minetest.register_abm({
nodenames = {'mymonths:leaves_red', 'mymonths:leaves_red_aspen'},
interval = 60,
chance = 40,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 10 then
if node.name == 'mymonths:leaves_red' then
minetest.set_node(pos, {name = 'mymonths:sticks_default'})
elseif node.name == 'mymonths:leaves_red_aspen' then
minetest.set_node(pos, {name = 'mymonths:sticks_aspen'})
end
end
end
})
--All default leaves should be sticks in November and December
minetest.register_abm({
nodenames = {'default:leaves', 'mymonths:leaves_pale_green', 'mymonths:leaves_orange', 'mymonths:leaves_red'},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 11
or mymonths.month_counter == 12
or mymonths.month_counter == 1
or mymonths.month_counter == 2 then
minetest.set_node(pos, {name = 'mymonths:sticks_default'})
end
end
})
--All aspen leaves should be sticks in November and December
minetest.register_abm({
nodenames = {'default:aspen_leaves', 'mymonths:leaves_orange_aspen', 'mymonths:leaves_red_aspen',},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 11
or mymonths.month_counter == 12
or mymonths.month_counter == 1
or mymonths.month_counter == 2 then
minetest.set_node(pos, {name = 'mymonths:sticks_aspen'})
end
end
})
--New growth in spring
minetest.register_abm({
nodenames = {'mymonths:sticks_default', 'mymonths:leaves_blooms', 'mymonths:sticks_aspen', 'mymonths:leaves_aspen_blooms'},
interval = 60,
chance = 40,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 3
or mymonths.month_counter == 4 then
if node.name == 'mymonths:sticks_default' then
minetest.set_node(pos, {name = 'mymonths:leaves_blooms'})
elseif node.name == 'mymonths:leaves_blooms' then
minetest.set_node(pos, {name = 'default:leaves'})
elseif node.name == 'mymonths:sticks_aspen' then
minetest.set_node(pos, {name = 'mymonths:leaves_aspen_blooms'})
elseif node.name == 'mymonths:leaves_aspen_blooms' then
minetest.set_node(pos, {name = 'default:aspen_leaves'})
end
end
end
})
--By April all trees should be back to normal
minetest.register_abm({
nodenames = {'mymonths:sticks_default','mymonths:leaves_sticks', 'mymonths:leaves_blooms', 'mymonths:sticks_aspen', 'mymonths:leaves_aspen_blooms'},
interval = 5,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 5 then
if node.name == 'mymonths:sticks_default'
or node.name == 'mymonths:leaves_sticks'
or node.name == 'mymonths:leaves_blooms' then
minetest.set_node(pos, {name = 'default:leaves'})
elseif node.name =='mymonths:sticks_aspen'
or node.name == 'mymonths:leaves_aspen_blooms' then
minetest.set_node(pos, {name = 'default:aspen_leaves'})
end
end
end
})
--apples die in November
minetest.register_abm({
nodenames = {'default:apple'},
interval = 15,
chance = 10,
action = function (pos, node, active_object_count, active_object_count_wider)
local nodeu1 = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
local nodeu2 = minetest.get_node({x = pos.x, y = pos.y - 2, z = pos.z})
local nodeu3 = minetest.get_node({x = pos.x, y = pos.y - 3, z = pos.z})
local nodeu4 = minetest.get_node({x = pos.x, y = pos.y - 4, z = pos.z})
if mymonths.month_counter == 11 then
if nodeu1.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 1,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu2.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 2,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu3.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 3,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif nodeu4.name == "air" then
minetest.spawn_item({
x = pos.x,
y = pos.y - 4,
z = pos.z}, 'default:apple')
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
else
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
end
end
end
})
--apples grow in fall
minetest.register_abm({
nodenames = {'default:leaves'},
interval = 60,
chance = 15,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 7
or mymonths.month_counter == 8
or mymonths.month_counter == 9 then
local a = minetest.find_node_near(pos, 3, 'default:apple')
if a == nil then
minetest.set_node(pos,{name = 'default:apple'})
end
end
end
})
--apples change to leaves or sticks is not in season
minetest.register_abm({
nodenames = {'default:apple'},
interval = 1,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 12
or mymonths.month_counter == 1
or mymonths.month_counter == 2 then
minetest.set_node(pos,{name = 'mymonths:sticks_default'})
elseif mymonths.month_counter == 3
or mymonths.month_counter == 4 then
minetest.set_node(pos,{name = 'mymonths:leaves_blooms'})
elseif mymonths.month_counter == 5
or mymonths.month_counter == 6 then
minetest.set_node(pos,{name = 'default:leaves'})
end
end
})
--Acacia blooming
minetest.register_abm ({
nodenames = {'default:acacia_leaves'},
interval = 60,
chance = 15,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 1 then
minetest.set_node(pos,{name = 'mymonths:leaves_acacia_blooms'})
end
end
})
--Acacia blooming
minetest.register_abm ({
nodenames = {'mymonths:leaves_acacia_blooms'},
interval = 15,
chance = 1,
action = function (pos, node, active_object_count, active_object_count_wider)
if mymonths.month_counter == 2 then
minetest.set_node(pos,{name = 'default:acacia_leaves'})
end
end
})

13
mods/mymonths/licence.txt Normal file
View File

@ -0,0 +1,13 @@
DO WHAT YOU WANT TO PUBLIC LICENSE
or abbreviated DWYWPL
December 2nd 2015
License Copyright (C) 2015 Michael Tomaino (PlatinumArts@gmail.com)
www.sandboxgamemaker.com/DWYWPL/
DO WHAT YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
1. You are allowed to do whatever you want to with what content is using this license.
2. This content is provided 'as-is', without any express or implied warranty. In no event
will the authors be held liable for any damages arising from the use of this content.

1
mods/mymonths/mod.conf Normal file
View File

@ -0,0 +1 @@
name = mymonths

163
mods/mymonths/months.lua Normal file
View File

@ -0,0 +1,163 @@
local timechange = 0
local gm = 0
local gn = 0
-- Set holidays
local hol = {
{"12", 14, "It is New Years Eve!"},
{"1", 1, "It is New Years Day!"},
{"3", 12, "It is Friendship Day!"},
{"6", 5, "It is Minetest Day!"},
{"4", 10, "It is Miners Day!"},
{"8", 12, "It is Builders Day!"},
{"10", 8, "It is Harvest Day!"},
}
-- Set days
local days = {
{1, 8, "Monday"},
{2, 9, "Tuesday"},
{3, 10, "Wednesday"},
{4, 11, "Thursday"},
{5, 12, "Friday"},
{6, 13, "Saturday"},
{7, 14, "Sunday"},
}
-- this stops undeclared variable errors
local t1, t2, t3, t4, t5 = 0, 0, 0, 0, 0
-- Set months
local mon = {
{1, "January", t5, t1, .9},
{2, "February", t5, t1, .9},
{3, "March", t4, t2, 1},
{4, "April", t4, t2, 1},
{5, "May", t3, t3, 1},
{6, "June", t3, t3, 1.1},
{7, "July", t1, t5, 1.2},
{8, "Augest", t1, t5, 1.5},
{9, "September",t3, t3, 1},
{10, "October", t3, t3, 1},
{11, "November", t4, t2, .9},
{12, "December", t4, t2, .9},
}
-- Sets Month and length of day
local timer = 0
minetest.register_globalstep(function(dtime)
-- Checks every X seconds
timer = timer + dtime
--do not change because it will effect other values
if timer < 3 then
return
end
timer = 0
--Day Night Speeds (Thanks to sofar for this)
local dc = tonumber(mymonths.day_counter)
local mc = tonumber(mymonths.month_counter)
local x = ((mc-1)*14)+dc
local ratio = ((math.cos((x / 168) * 2 * math.pi) * 0.8) / 2.0) + 0.5
local nightratio = math.floor(72*(ratio+0.5))
local dayratio = math.floor(72/(ratio+0.5))
--Checks for morning
local time_in_seconds = minetest.get_timeofday() * 24000
if time_in_seconds >= 12001
and timechange == 0 then
timechange = 1
gm = 1
end
if time_in_seconds <= 12000
and timechange == 1 then
timechange = 0
mymonths.day_counter = mymonths.day_counter + 1
end
if mymonths.day_counter >= 15 then
mymonths.month_counter = mymonths.month_counter + 1
mymonths.day_counter = 1
end
if tonumber(mymonths.month_counter) == nil then
mymonths.monthcounter = 6
elseif tonumber(mymonths.month_counter) >= 13 then
mymonths.month_counter = 1
mymonths.day_counter = 1
end
-- Sets time speed in the morning
if time_in_seconds >= 6000
and time_in_seconds <= 12000
and gm == 1 then
minetest.setting_set("time_speed", dayratio)
minetest.chat_send_all("Good Morning! It is "..mymonths.day_name.." "..mymonths.month.." "..mymonths.day_counter)
--minetest.chat_send_all("Time speed is "..dayratio.." and "..nightratio)
---Holidays
for i in ipairs(hol) do
local h1 = hol[i][1]
local h2 = hol[i][2]
local h3 = hol[i][3]
if mymonths.month_counter == h1
and mymonths.day_counter == h2 then
minetest.chat_send_all(h3)
end
end
gm = 0
gn = 1
end
--Months
for i in ipairs(mon) do
local m1 = mon[i][1]
local m2 = mon[i][2]
local m3 = mon[i][3]
local m4 = mon[i][4]
local m5 = mon[i][5]
if mymonths.month_counter == m1 then
mymonths.month = m2
mymonths.day_speed = m3
mymonths.night_speed = m4
end
end
if time_in_seconds >= 22000
and time_in_seconds <= 24000
and gn == 1 then
minetest.setting_set("time_speed", nightratio)
gn = 0
end
-- Set the name of the day
for i in ipairs(days) do
local w1 = days[i][1]
local w2 = days[i][2]
local dy = days[i][3]
if mymonths.day_counter == w1
or mymonths.day_counter == w2 then
mymonths.day_name = dy
end
end
end)

35
mods/mymonths/roadmap.txt Normal file
View File

@ -0,0 +1,35 @@
Add more blocks that snow will land on
Add more items that change with the seasons
- dirt with grass - grass turns brown in the fall
- jungle trees have moss during the wet season (spring)
- acorns on pine trees in the fall
- flowers die in the fall and re grow in the spring
Add support for moretrees and plantlife.
- make deciduous trees leaves change
-
Add support for mobs
- Animals that hibernate would not spawn in the winter
- More rabbits in the late spring
Weather
- Make better weather textures
- Find a way to make weather work better/less lag
- make sky change when raining/snowing
- raindrops in water
- lightning
- better/more sounds
Months/Days
- make it so mods can register holidays
- make an easy api for other mods to use this
Farming
- making farming a seasonal thing
- crops only grow from april to oct
- make a greenhouse mod so crops can be grown year round
- make crops full maturity at the right time of year
- make crops yeild more since they will take longer to grow
- add support for other farming mods (farming redo, farmingplus, crops etc)

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

View File

@ -0,0 +1,23 @@
--Turn damage on or off. This will make storms and hail cause damage
mymonths.damage = false
------------------------------------------------------------------------
--You can turn weather off
mymonths.use_weather = true
------------------------------------------------------------------------
--Leaves change color in the fall.
mymonths.leaves = true
------------------------------------------------------------------------
--Have snow accumulate on the ground
mymonths.snow_on_ground = true
------------------------------------------------------------------------
--Puddles appear when raining
mymonths.use_puddles = true

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 B

618
mods/mymonths/weather.lua Normal file
View File

@ -0,0 +1,618 @@
--Sets the weather types for each month
local t = 0
minetest.register_globalstep(function(dtime)
local month = mymonths.month_counter
t = t + dtime
if t < 5 then
return
end
t = 0
if minetest.get_modpath("lightning") then
if mymonths.weather == "storm" then
lightning.strike()
end
end
if mymonths.weather ~= "clear" then
if math.random(1, 100) == 1 then
mymonths.weather = "clear"
minetest.chat_send_all("Clear skys!")
end
else
-- January
if tonumber(month) == 1 then
if math.random(1, 2) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- February
elseif tonumber(month) == 2 then
if math.random(1, 1000) == 1 then
mymonths.weather = "snow"
minetest.chat_send_all("It is Snowing")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "snowstorm"
minetest.chat_send_all("It's a Snow storm")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "hail"
minetest.chat_send_all("It is Hailing")
end
-- March
elseif tonumber(month) == 3 then
if math.random(1, 1000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 2500) == 2 then
mymonths.weather = "snow"
minetest.chat_send_all("It is Snowing")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "hail"
minetest.chat_send_all("It is Hailing")
end
-- April
elseif tonumber(month) == 4 then
if math.random(1, 1000) == 1 then
mymonths.weather = "rain"
end
-- May
elseif tonumber(month) == 5 then
if math.random(1, 1500) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- June
elseif tonumber(month) == 6 then
if math.random(1, 5000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- July
elseif tonumber(month) == 7 then
if math.random(1, 5000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- August
elseif tonumber(month) == 8 then
if math.random(1, 5000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- September
elseif tonumber(month) == 9 then
if math.random(1, 1500) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 2500) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- October
elseif tonumber(month) == 10 then
if math.random(1, 1000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 2500) == 1 then
mymonths.weather = "storm"
minetest.chat_send_all("It's a Storm")
end
-- November
elseif tonumber(month) == 11 then
if math.random(1, 1000) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 2000) == 2 then
mymonths.weather = "snow"
minetest.chat_send_all("It is Snowing")
end
-- December
elseif tonumber(month) == 12 then
if math.random(1, 2500) == 1 then
mymonths.weather = "rain"
minetest.chat_send_all("It is Raining")
elseif math.random(1, 1000) == 1 then
mymonths.weather = "snow"
minetest.chat_send_all("It is Snowing")
elseif math.random(1, 5000) == 1 then
mymonths.weather = "hail"
minetest.chat_send_all("It is Hailing")
end
end
end
end)
-- Weather vectors and some particles are from jeija's weather mod
addvectors = function (v1, v2)
return {x = v1.x + v2.x, y = v1.y + v2.y, z = v1.z + v2.z}
end
hp_t = 0
minetest.register_globalstep(function(dtime)
hp_t = hp_t + dtime
if hp_t <= 0.2 then
return
end
mymonths.weather2 = mymonths.weather
for _, player in ipairs(minetest.get_connected_players()) do
local ppos = player:getpos()
local hp = player:get_hp()
local name = player:get_player_name()
local nodein = minetest.get_node(ppos)
local nodeu = minetest.get_node({x = ppos.x, y = ppos.y - 1, z = ppos.z})
local biome_jungle = minetest.find_node_near(ppos, 5, "default:jungletree", "default:junglegrass")
local biome_desert = minetest.find_node_near(ppos, 5, "default:desert_sand", "default:desert_stone")
local biome_snow = minetest.find_node_near(ppos, 5, "default:snow", "default:snowblock", "default:dirt_with_snow", "default:ice")
local minp = addvectors(ppos, {x = -10, y = 7, z = -10})
local maxp = addvectors(ppos, {x = 10, y = 7, z = 10})
local minps = addvectors(ppos, {x =-15, y = 0, z = -10})
local maxps = addvectors(ppos, {x = 5, y = 3, z = 10})
local minp_deep = addvectors(ppos, {x = -10, y = 3.2, z = -10})
local maxp_deep = addvectors(ppos, {x = 10, y = 2.6, z = 10})
local vel_rain = {x = 0, y = -4, z = 0}
local acc_rain = {x = 0, y = -9.81, z = 0}
local vel_snow = {x = 0, y = -0.4, z = 0}
local acc_snow = {x = 0, y = -0.5, z = 0}
local vel_sand = {x = 1, y = -0.1, z = 0}
local acc_sand = {x = 2, y = 0, z = 0}
-- slows players walk in snow
if nodein.name == "mymonths:snow_cover_1" then
player:set_physics_override(0.95, 1, 1, true, false)
elseif nodein.name == "mymonths:snow_cover_2" then
player:set_physics_override(0.8, 1, 1, true, false)
elseif nodein.name == "mymonths:snow_cover_3" then
player:set_physics_override(0.65, 1, 1, true, false)
elseif nodein.name == "mymonths:snow_cover_4" then
player:set_physics_override(0.5, 1, 1, true, false)
elseif nodein.name == "mymonths:snow_cover_5" then
player:set_physics_override(0.35, 1, 1, true, false)
else
player:set_physics_override(1, 1, 1, true, false)
end
-- check light to make sure player is outside
if minetest.get_node_light({
x = ppos.x,
y = ppos.y + 1,
z = ppos.z}, 0.5) ~= 15 then
return
end
-- checks if there is any weather
if mymonths.weather2 == "none" then
return
end
-- changes weather based on biome
-- Jungle
if biome_jungle ~= nil then
if mymonths.weather == "snow" then
mymonths.weather2 = "rain"
elseif mymonths.weather == "snowstorm"
or mymonths.weather == "hail" then
mymonths.weather2 = "storm"
end
-- Desert
elseif biome_desert ~= nil then
if mymonths.weather == "snow"
or mymonths.weather == "rain" then
mymonths.weather2 = "clear"
elseif mymonths.weather == "snowstorm"
or mymonths.weather == "hail"
or mymonths.weather == "storm" then
mymonths.weather2 = "sandstorm"
end
-- Snow
elseif biome_snow ~= nil then
if mymonths.weather == "rain" then
mymonths.weather2 = "snow"
elseif mymonths.weather == "storm" then
mymonths.weather2 = "snowstorm"
end
else
mymonths.weather2 = mymonths.weather
end
if mymonths.weather2 == "storm" then
minetest.add_particlespawner({
amount = 40,
time = 0.5,
minpos = minp,
maxpos = maxp,
minvel = vel_rain,
maxvel = vel_rain,
minacc = acc_rain,
maxacc = acc_rain,
minexptime = 0.8,
maxexptime = 0.8,
minsize = 25,
maxsize = 40,
collisiondetection = false,
vertical = true,
texture = "weather_rain_dark.png",
playername = name
})
if minetest.get_node_light({
x = ppos.x,
y = ppos.y + 1,
z = ppos.z}, 0.5) == 15
and mymonths.damage == true then
if hp_t >= 15 then
player:set_hp(hp - 1)
hp_t = 0
end
end
if math.random(1, 200) == 1 then
minetest.sound_play("mymonths_thunder", {
pos = ppos,
max_hear_distance = 10,
gain = 10.0,
})
end
elseif mymonths.weather2 == "rain" then
minetest.add_particlespawner({
amount = 15,
time = 0.5,
minpos = minp,
maxpos = maxp,
minvel = vel_rain,
maxvel = vel_rain,
minacc = acc_rain,
maxacc = acc_rain,
minexptime = 0.6,
maxexptime = 0.8,
minsize = 25,
maxsize = 25,
collisiondetection = false,
vertical = true,
texture = "weather_rain.png",
playername = name
})
elseif mymonths.weather2 == "snow" then
minetest.add_particlespawner({
amount = 4,
time = 0.5,
minpos = minp,
maxpos = maxp,
minvel = vel_snow,
maxvel = vel_snow,
minacc = acc_snow,
maxacc = acc_snow,
minexptime = 4,
maxexptime = 8,
minsize = 15,
maxsize = 25,
collisiondetection = false,
vertical = true,
texture = "weather_snow.png",
playername = name
})
minetest.add_particlespawner({
amount = 4,
time = 0.5,
minpos = minp_deep,
maxpos = maxp_deep,
minvel = vel_snow,
maxvel = vel_snow,
minacc = acc_snow,
maxacc = acc_snow,
minexptime = 4,
maxexptime = 6,
minesize = 15,
maxsize = 25,
collisiondetection = false,
vertical = true,
texture = "weather_snow.png",
playername = name
})
elseif mymonths.weather2 == "snowstorm" then
minetest.add_particlespawner({
amount = 25,
time = 0.5,
minpos = minp,
maxpos = maxp,
minvel = vel_snow,
maxvel = vel_snow,
minacc = acc_snow,
maxacc = acc_snow,
minexptime = 4,
maxexptime = 6,
minesize = 15,
maxsize = 35,
collisiondetection = false,
vertical = true,
texture = "weather_snow.png",
playername = name
})
minetest.add_particlespawner({
amount = 25,
time = 0.5,
minpos = minp_deep,
maxpos = maxp_deep,
minvel = vel_snow,
maxvel = vel_snow,
minacc = acc_snow,
maxacc = acc_snow,
minexptime = 4,
maxexptime = 6,
minesize = 15,
maxsize = 25,
collisiondetection = false,
vertical = true,
texture = "weather_snow.png",
playername = name
})
if minetest.get_node_light({
x = ppos.x,
y = ppos.y + 1,
z =ppos.z}, 0.5) == 15
and mymonths.damage == true then
if hp_t >= 15 then
player:set_hp(hp - 1)
hp_t = 0
end
end
elseif mymonths.weather2 == "sandstorm" then
minetest.add_particlespawner({
amount = 35,
time = 0.5,
minpos = minps,
maxpos = maxps,
minvel = vel_sand,
maxvel = vel_sand,
minacc = acc_sand,
maxacc = acc_sand,
minexptime = 4,
maxexptime = 4,
minesize = 5,
maxsize = 10,
collisiondetection = false,
vertical = true,
texture = "weather_sand.png",
playername = name
})
if minetest.get_node_light({
x = ppos.x,
y = ppos.y + 1,
z = ppos.z}, 0.5) == 15
and mymonths.damage == true then
if hp_t >= 15 then
player:set_hp(hp - 1)
hp_t = 0
end
end
elseif mymonths.weather2 == "hail" then
minetest.add_particlespawner({
amount = 35,
time = 0.5,
minpos = minp,
maxpos = maxp,
minvel = vel_rain,
maxvel = vel_rain,
minacc = acc_rain,
maxacc = acc_rain,
minexptime = 1,
maxexptime = 1,
minesize = 5,
maxsize = 10,
collisiondetection = true,
vertical = true,
texture = "weather_hail.png",
playername = name
})
if minetest.get_node_light({
x = ppos.x,
y = ppos.y + 1,
z = ppos.z}, 0.5) == 15
and mymonths.damage == true then
if hp_t >= 15 then
player:set_hp(hp - 1)
hp_t = 0
end
end
end
biome_jungle = nil
biome_snow = nil
biome_desert = nil
end
end)
local t2 = 0
minetest.register_globalstep(function(dtime)
for _, player in ipairs(minetest.get_connected_players()) do
local ppos = player:getpos()
t2 = t2 + dtime
if t2 < 1 then
return
end
t2 = 0
if mymonths.weather2 == "rain"
or mymonths.weather2 == "storm" then
minetest.sound_play("mymonths_rain1", {
pos = ppos,
max_hear_distance = 10,
gain = 2.0,
})
end
end
end)
--Puddle node
local puddle_box = {
type = "fixed",
fixed = {
{-0.1875, -0.5, -0.375, 0.125, -0.4875, 0.3125},
{-0.25, -0.5, -0.3125, 0.3125, -0.4925, 0.25},
{-0.3125, -0.5, -0.1875, 0.375, -0.4975, 0.1875},
}
}
minetest.register_node("mymonths:puddle", {
tiles = {"weather_puddle.png"},
drawtype = "nodebox",
paramtype = "light",
pointable = false,
buildable_to = true,
alpha = 50,
node_box = puddle_box,
selection_box = puddle_box,
groups = {not_in_creative_inventory = 1, crumbly = 3, attached_node = 0, falling_node = 1},
drop = "",
})
--Snow Nodes
local snow = {
{"mymonths:snow_cover_1","1", -0.4},
{"mymonths:snow_cover_2","2", -0.2},
{"mymonths:snow_cover_3","3", 0},
{"mymonths:snow_cover_4","4", 0.2},
{"mymonths:snow_cover_5","5", 0.5},
}
for i in ipairs(snow) do
local itm = snow[i][1]
local num = snow[i][2]
local box = snow[i][3]
minetest.register_node(itm, {
tiles = {"weather_snow_cover.png"},
drawtype = "nodebox",
paramtype = "light",
buildable_to = true,
walkable = false,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, box, 0.5}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, box, 0.5}
},
groups = {not_in_creative_inventory = 0, crumbly = 3, attached_node = 0, falling_node = 1},
drop = "default:snow " .. num,
})
end