Aaron Suen 3a4bfdb258 One last refactor to ambient sounds.
Make tree sounds managed by the mod that defines the nodes in
question using register_ambient, consistent with other things like
fluids.

nc_envsounds is now responsible for just the air moving and
cave dripping sounds made by air itself.

Common windiness logic moved into api layer.
2019-09-02 11:34:14 -04:00

21 lines
612 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
nodecore.register_ambiance({
label = "Tree Leaves Ambiance",
nodenames = {"nc_tree:leaves"},
neigbors = {"air"},
interval = 1,
chance = 100,
sound_name = "nc_tree_breeze",
check = function(pos)
pos.y = pos.y + 1
if pos.y <= 0 then return end
return minetest.get_node(pos).name == "air"
and minetest.get_node_light(pos, 0.5) == 15
and { gain = nodecore.windiness(pos.y) / 20 }
end
})