2013-03-24 14:40:18 +01:00
|
|
|
-- Snow
|
2015-04-16 16:56:32 +02:00
|
|
|
local spawnerdef = {
|
|
|
|
amount = 8,
|
|
|
|
time = 0.5,
|
|
|
|
minexptime = 3,
|
|
|
|
maxexptime = 15,
|
|
|
|
minsize = 0.8,
|
|
|
|
maxsize = 1.2,
|
|
|
|
collisiondetection = true,
|
|
|
|
}
|
2013-03-24 14:40:18 +01:00
|
|
|
minetest.register_globalstep(function(dtime)
|
2015-04-16 16:56:32 +02:00
|
|
|
if weather ~= "snow" then
|
|
|
|
return
|
|
|
|
end
|
2013-03-24 14:40:18 +01:00
|
|
|
for _, player in ipairs(minetest.get_connected_players()) do
|
|
|
|
local ppos = player:getpos()
|
|
|
|
|
|
|
|
-- Make sure player is not in a cave/house...
|
2015-04-16 16:56:32 +02:00
|
|
|
--if minetest.get_node_light(ppos, 0.5) ~= 15 then return end
|
2013-03-24 14:40:18 +01:00
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
spawnerdef.minpos = addvectors(ppos, {x=-9, y=7, z=-9})
|
|
|
|
spawnerdef.maxpos = addvectors(ppos, {x= 9, y=7, z= 9})
|
2013-03-24 14:40:18 +01:00
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
spawnerdef.minvel = {x=0, y= -1, z=0}
|
|
|
|
spawnerdef.maxvel = spawnerdef.minvel
|
|
|
|
spawnerdef.minacc = {x=0, y= 0, z=0}
|
|
|
|
spawnerdef.maxacc = spawnerdef.minacc
|
2013-03-24 14:40:18 +01:00
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
spawnerdef.playername = player:get_player_name()
|
2013-03-24 14:40:18 +01:00
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
for _,i in ipairs({"", "2"}) do
|
|
|
|
spawnerdef.texture = "weather_snow"..i..".png"
|
|
|
|
minetest.add_particlespawner(spawnerdef)
|
|
|
|
end
|
2013-03-24 14:40:18 +01:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
--[[local snow_box =
|
2013-03-24 14:40:18 +01:00
|
|
|
{
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Snow cover
|
|
|
|
minetest.register_node("weather:snow_cover", {
|
|
|
|
tiles = {"weather_snow_cover.png"},
|
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
node_box = snow_box,
|
|
|
|
selection_box = snow_box,
|
|
|
|
groups = {not_in_creative_inventory = 1, crumbly = 3, attached_node = 1},
|
|
|
|
drop = {}
|
|
|
|
})
|
|
|
|
|
2015-04-16 16:56:32 +02:00
|
|
|
--[ Enable this section if you have a very fast PC
|
2013-03-24 14:40:18 +01:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:crumbly", "group:snappy", "group:cracky", "group:choppy"},
|
|
|
|
neighbors = {"default:air"},
|
2015-05-29 12:08:49 +02:00
|
|
|
interval = 10.0,
|
2013-03-24 14:40:18 +01:00
|
|
|
chance = 80,
|
|
|
|
action = function (pos, node, active_object_count, active_object_count_wider)
|
|
|
|
if weather == "snow" then
|
|
|
|
if minetest.registered_nodes[node.name].drawtype == "normal"
|
|
|
|
or minetest.registered_nodes[node.name].drawtype == "allfaces_optional" then
|
|
|
|
local np = addvectors(pos, {x=0, y=1, z=0})
|
2013-04-21 01:00:08 +02:00
|
|
|
if minetest.env:get_node_light(np, 0.5) == 15
|
|
|
|
and minetest.env:get_node(np).name == "air" then
|
2013-03-24 14:40:18 +01:00
|
|
|
minetest.env:add_node(np, {name="weather:snow_cover"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
]]
|