forked from mtcontrib/minetest-mod-snow
Merge pull request #11 from HybridDog/particlespawnerfix
update particlespawner and use a random rotation and/or mirroring for the falling snow texture
This commit is contained in:
commit
a3b9a4453a
@ -103,6 +103,27 @@ if snow.enable_snowfall then
|
|||||||
return {x=x,y=y,z=z}
|
return {x=x,y=y,z=z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local default_snow_particle = {
|
||||||
|
amount = 3,
|
||||||
|
time = 0.5,
|
||||||
|
exptime = 5,
|
||||||
|
size = 50,
|
||||||
|
collisiondetection = false,
|
||||||
|
vertical = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function get_snow_particledef(data)
|
||||||
|
for n,i in pairs(default_snow_particle) do
|
||||||
|
data[n] = data[n] or i
|
||||||
|
end
|
||||||
|
for _,i in pairs({"vel", "acc", "exptime", "size"}) do
|
||||||
|
data["min"..i] = data[i]
|
||||||
|
data["max"..i] = data[i]
|
||||||
|
end
|
||||||
|
data.texture = "weather_snow.png^[transform"..math.random(0,7)
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
local snow_fall=function (pos, player, animate)
|
local snow_fall=function (pos, player, animate)
|
||||||
local ground_y = nil
|
local ground_y = nil
|
||||||
for y=pos.y+10,pos.y+20,1 do
|
for y=pos.y+10,pos.y+20,1 do
|
||||||
@ -129,13 +150,13 @@ if snow.enable_snowfall then
|
|||||||
local maxp = addvectors(spos, {x= 9, y=5, z= 9})
|
local maxp = addvectors(spos, {x= 9, y=5, z= 9})
|
||||||
local vel = {x=0, y= -1, z=-1}
|
local vel = {x=0, y= -1, z=-1}
|
||||||
local acc = {x=0, y= 0, z=0}
|
local acc = {x=0, y= 0, z=0}
|
||||||
minetest.add_particlespawner(3, 0.5,
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
minp, maxp,
|
minpos = minp,
|
||||||
vel, vel,
|
maxpos = maxp,
|
||||||
acc, acc,
|
vel = vel,
|
||||||
5, 5,
|
acc = acc,
|
||||||
50, 50,
|
playername = player:get_player_name()
|
||||||
false, "weather_snow.png", player:get_player_name())
|
}))
|
||||||
end
|
end
|
||||||
snow.place(pos, true)
|
snow.place(pos, true)
|
||||||
--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"}) -- LazyJ
|
--minetest.place_node({x=pos.x, y=pos.y+2, z=pos.z}, {name="default:snow"}) -- LazyJ
|
||||||
@ -163,21 +184,26 @@ if snow.enable_snowfall then
|
|||||||
local acc = {x=0, y= 0, z=0}
|
local acc = {x=0, y= 0, z=0}
|
||||||
|
|
||||||
if not snow.lighter_snowfall then
|
if not snow.lighter_snowfall then
|
||||||
minetest.add_particlespawner(5, 0.5,
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
minp, maxp,
|
amount = 5,
|
||||||
vel, vel,
|
minpos = minp,
|
||||||
acc, acc,
|
maxpos = maxp,
|
||||||
5, 5,
|
vel = vel,
|
||||||
25, 25,
|
acc = acc,
|
||||||
false, "weather_snow.png", player:get_player_name())
|
size = 25,
|
||||||
|
playername = player:get_player_name()
|
||||||
|
}))
|
||||||
|
|
||||||
minetest.add_particlespawner(4, 0.5,
|
minetest.add_particlespawner(get_snow_particledef({
|
||||||
minp_deep, maxp_deep,
|
amount = 4,
|
||||||
vel, vel,
|
minpos = minp_deep,
|
||||||
acc, acc,
|
maxpos = maxp_deep,
|
||||||
4, 4,
|
vel = vel,
|
||||||
25, 25,
|
acc = acc,
|
||||||
false, "weather_snow.png", player:get_player_name())
|
exptime = 4,
|
||||||
|
size = 25,
|
||||||
|
playername = player:get_player_name()
|
||||||
|
}))
|
||||||
|
|
||||||
if math.random(1,5) == 4 then
|
if math.random(1,5) == 4 then
|
||||||
snow_fall(randpos(sminp, smaxp), player)
|
snow_fall(randpos(sminp, smaxp), player)
|
||||||
|
Loading…
Reference in New Issue
Block a user