1
0
mirror of https://github.com/Splizard/minetest-mod-snow.git synced 2025-06-30 15:20:20 +02:00

Replace falling_snow with paramat's functional snowdrift mechanics.

This commit is contained in:
Quentin Quaadgras
2018-04-23 22:28:21 +12:00
parent a624a6fabe
commit ee3b12c07d
15 changed files with 230 additions and 284 deletions

View File

@ -75,7 +75,7 @@ dofile(srcpath.."falling_snow.lua")
local is_uneven
--This function places snow checking at the same time for snow level and increasing as needed.
--This also takes into account sourrounding snow and makes snow even.
function snow.place(pos)
function snow.place(pos, disablesound)
local node = minetest.get_node_or_nil(pos)
--Oops, maybe there is no node?
@ -89,17 +89,23 @@ function snow.place(pos)
if level < 63 then
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name, "leafdecay") == 0
and not is_uneven(pos) then
if not disablesound then
minetest.sound_play("default_snow_footstep", {pos=pos})
end
minetest.add_node_level(pos, 7)
end
elseif level == 63 then
local p = minetest.find_node_near(pos, 10, "default:dirt_with_grass")
if p
and minetest.get_node_light(p, 0.5) == 15 then
if not disablesound then
minetest.sound_play("default_grass_footstep", {pos=pos})
end
minetest.place_node({x=pos.x, y=pos.y+1, z=pos.z}, {name="default:snow"})
else
if not disablesound then
minetest.sound_play("default_snow_footstep", {pos=pos})
end
minetest.add_node(pos, {name="default:snowblock"})
end
end
@ -111,7 +117,7 @@ function snow.place(pos)
or drawtype == "allfaces_optional" then
pos.y = pos.y+1
local sound = data.sounds
if sound then
if sound and not disablesound then
sound = sound.footstep
if sound then
minetest.sound_play(sound.name, {pos=pos, gain=sound.gain})