parent
dae08c5b30
commit
de61711bb9
28
abms.lua
28
abms.lua
|
@ -5,7 +5,7 @@ minetest.register_abm({
|
|||
interval = 10.0,
|
||||
chance = 80,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather == "snow" then
|
||||
if mymonths.weather2 == "snow" then
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
if minetest.get_node_light({x=pos.x,y=pos.y+1,z=pos.z}, 0.5) == 15
|
||||
and na.name == "air" then
|
||||
|
@ -17,11 +17,11 @@ minetest.register_abm({
|
|||
-- 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 = {"group:crumbly", "group:snappy", "group:cracky", "group:choppy"},
|
||||
neighbors = {"default:dirt","default:dirt_with_grass"},
|
||||
interval = 10.0,
|
||||
chance = 80,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather == "snow" then
|
||||
if mymonths.weather2 == "snow" then
|
||||
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
|
||||
|
@ -29,15 +29,14 @@ minetest.register_abm({
|
|||
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 = "default:snowblock"})
|
||||
minetest.set_node(pos,{name = "mymonths:snow_cover_5"})
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
--Snow Melting
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:snowblock","mymonths:snow_cover_1","mymonths:snow_cover_2","mymonths:snow_cover_3","mymonths:snow_cover_4"},
|
||||
--neighbors = {"group:crumbly", "group:snappy", "group:cracky", "group:choppy"},
|
||||
nodenames = {"mymonths:snow_cover_1","mymonths:snow_cover_2","mymonths:snow_cover_3","mymonths:snow_cover_4","mymonths:snow_cover_5"},
|
||||
interval = 10.0,
|
||||
chance = 80,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
|
@ -50,7 +49,7 @@ minetest.register_abm({
|
|||
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 == "default:snowblock" then
|
||||
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})
|
||||
|
@ -70,7 +69,7 @@ minetest.register_abm({
|
|||
interval = 10.0,
|
||||
chance = 5000,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather == "rain" then
|
||||
if mymonths.weather2 == "rain" then
|
||||
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
local nn = minetest.find_node_near(pos, 20, "mymonths:puddle")
|
||||
if nn == nil then
|
||||
|
@ -91,18 +90,9 @@ minetest.register_abm({
|
|||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather == "none" then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
--Makes puddles turn into snow if weather is snow
|
||||
minetest.register_abm({
|
||||
nodenames = {"mymonths:puddle"},
|
||||
neighbors = {},
|
||||
interval = 10.0,
|
||||
chance = 5,
|
||||
action = function (pos, node, active_object_count, active_object_count_wider)
|
||||
if mymonths.weather == "snow" then
|
||||
elseif mymonths.weather2 == "snow" then
|
||||
minetest.set_node(pos,{name = "mymonths:snow_cover_1"})
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
|
10
command.lua
10
command.lua
|
@ -51,11 +51,19 @@ minetest.register_chatcommand("setmonth", {
|
|||
save_table()
|
||||
end
|
||||
})
|
||||
--Weather
|
||||
-- Set weather
|
||||
minetest.register_chatcommand("weather", {
|
||||
params = "",
|
||||
description = "Set weather to rain, snow, wind or none",
|
||||
func = function(name, param)
|
||||
minetest.chat_send_player(name,"The weather is "..mymonths.weather)
|
||||
end
|
||||
})
|
||||
--Time and Date
|
||||
minetest.register_chatcommand("date", {
|
||||
params = "",
|
||||
description = "Say the date in chat",
|
||||
--privs = {mymonths = true},
|
||||
func = function(name, param)
|
||||
local t = tostring(minetest.get_timeofday() * 2400)
|
||||
local tt = string.find(t, "%p",1)
|
||||
|
|
36
init.lua
36
init.lua
|
@ -37,6 +37,7 @@ mymonths.day_counter = 1
|
|||
mymonths.month_counter = 6
|
||||
mymonths.month = "June"
|
||||
mymonths.weather = "none"
|
||||
mymonths.weather2 = "none"
|
||||
else
|
||||
mymonths.day_speed = read_mymonths().day_speed
|
||||
mymonths.night_speed = read_mymonths().night_speed
|
||||
|
@ -44,11 +45,10 @@ mymonths.day_counter = read_mymonths().day_counter
|
|||
mymonths.month_counter = read_mymonths().month_counter
|
||||
mymonths.month = read_mymonths().month
|
||||
mymonths.weather = read_mymonths().weather
|
||||
mymonths.weather2 = "none"
|
||||
end
|
||||
|
||||
addvectors = function (v1, v2)
|
||||
return {x=v1.x+v2.x, y=v1.y+v2.y, z=v1.z+v2.z}
|
||||
end
|
||||
|
||||
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
@ -162,84 +162,92 @@ minetest.register_globalstep(function(dtime)
|
|||
if mymonths.month_counter == 1 then--January
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 2 then--Febuary
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 3 then --March
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
--save_table()
|
||||
--end
|
||||
--elseif mymonths.month_counter == 3 then --March
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 25000) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 4 then --April
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 5 then --May
|
||||
if math.random(1, 15000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 6 then --June
|
||||
if math.random(1, 20000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 7 then --July
|
||||
if math.random(1, 50000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 8 then --Augest
|
||||
if math.random(1, 50000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 9 then --September
|
||||
if math.random(1, 15000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 10 then --October
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 11 then --November
|
||||
if math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
--save_table()
|
||||
--end
|
||||
--elseif mymonths.month_counter == 11 then --November
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 20000) == 2 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
elseif mymonths.month_counter == 12 then --December
|
||||
if math.random(1, 25000) == 1 then
|
||||
mymonths.weather = "rain"
|
||||
--save_table()
|
||||
--end
|
||||
--elseif mymonths.month_counter == 12 then --December
|
||||
minetest.chat_send_all("Might be a rainy day")
|
||||
save_table()
|
||||
elseif math.random(1, 10000) == 1 then
|
||||
mymonths.weather = "snow"
|
||||
minetest.chat_send_all("Looks like snow is on it's way")
|
||||
save_table()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
dofile(minetest.get_modpath("mymonths").."/rain.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/snow.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/weather.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/abms.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/leaves.lua")
|
||||
dofile(minetest.get_modpath("mymonths").."/command.lua")
|
||||
|
|
42
rain.lua
42
rain.lua
|
@ -1,42 +0,0 @@
|
|||
-- Rain partical
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if mymonths.weather ~= "rain" then return end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local ppos = player:getpos()
|
||||
-- Make sure player is not in a cave/house...
|
||||
if minetest.env:get_node_light(ppos, 0.5) ~= 15 then return end
|
||||
local minp = addvectors(ppos, {x=-9, y=7, z=-9})
|
||||
local maxp = addvectors(ppos, {x= 9, y=7, z= 9})
|
||||
local vel = {x=0, y= -4, z=0}
|
||||
local acc = {x=0, y=-9.81, z=0}
|
||||
minetest.add_particlespawner({amount=25, time=0.5,
|
||||
minpos=minp, maxpos=maxp,
|
||||
minvel=vel, maxvel=vel,
|
||||
minacc=acc, maxacc=acc,
|
||||
minexptime=0.8, maxexptime=0.8,
|
||||
minsize=25, maxsize=25,
|
||||
collisiondetection=false, vertical=true, texture="weather_rain.png", player=player:get_player_name()})
|
||||
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 = {""}
|
||||
})
|
52
snow.lua
52
snow.lua
|
@ -1,52 +0,0 @@
|
|||
-- Snow partical
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if mymonths.weather ~= "snow" then return end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local ppos = player:getpos()
|
||||
-- Make sure player is not in a cave/house...
|
||||
if minetest.env:get_node_light(ppos, 0.5) ~= 15 then return end
|
||||
local minp = addvectors(ppos, {x=-9, y=7, z=-9})
|
||||
local maxp = addvectors(ppos, {x= 9, y=7, z= 9})
|
||||
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 = {x=0, y= -0.5, z=0}
|
||||
local acc = {x=0, y= -0.5, z=0}
|
||||
minetest.add_particlespawner(5, 0.5,
|
||||
minp, maxp,
|
||||
vel, vel,
|
||||
acc, acc,
|
||||
5, 5,
|
||||
25, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
minetest.add_particlespawner(4, 0.5,
|
||||
minp_deep, maxp_deep,
|
||||
vel, vel,
|
||||
acc, acc,
|
||||
4, 4,
|
||||
25, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
end
|
||||
end)
|
||||
--Snow Nodes
|
||||
local snow_box ={type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}}
|
||||
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},
|
||||
}
|
||||
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,
|
||||
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 = 1},
|
||||
drop = "default:snow "..num
|
||||
})
|
||||
end
|
|
@ -0,0 +1,137 @@
|
|||
addvectors = function (v1, v2)
|
||||
return {x=v1.x+v2.x, y=v1.y+v2.y, z=v1.z+v2.z}
|
||||
end
|
||||
|
||||
local t = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
t = t + dtime
|
||||
if t >= 1 then
|
||||
|
||||
mymonths.weather2 = mymonths.weather
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local ppos = player:getpos()
|
||||
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, 10, "default:snow","default:snowblock","default:dirt_with_snow","default:ice")
|
||||
|
||||
|
||||
local minp = addvectors(ppos, {x=-7, y=7, z=-7})
|
||||
local maxp = addvectors(ppos, {x= 7, y=7, z= 7})
|
||||
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}
|
||||
|
||||
if minetest.get_node_light(ppos, 0.5) ~= 15 then return end
|
||||
|
||||
if mymonths.weather2 == "none" then return end
|
||||
|
||||
if biome_jungle ~= nil and
|
||||
mymonths.weather == "snow" then
|
||||
mymonths.weather2 = "rain"
|
||||
end
|
||||
|
||||
if biome_desert ~= nil and
|
||||
mymonths.weather == "snow" or
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "none"
|
||||
end
|
||||
|
||||
if biome_snow ~= nil and
|
||||
mymonths.weather == "rain" then
|
||||
mymonths.weather2 = "snow"
|
||||
end
|
||||
|
||||
if 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", player:get_player_name()})
|
||||
|
||||
elseif mymonths.weather2 == "snow" then
|
||||
minetest.add_particlespawner(4, 0.5,
|
||||
minp, maxp,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
minetest.add_particlespawner(4, 0.5,
|
||||
minp_deep, maxp_deep,
|
||||
vel_snow, vel_snow,
|
||||
acc_snow, acc_snow,
|
||||
4, 6,
|
||||
15, 25,
|
||||
false, "weather_snow.png", player:get_player_name())
|
||||
end
|
||||
|
||||
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_box ={type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}}
|
||||
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,
|
||||
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 = 1},
|
||||
drop = "default:snow "..num
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue