This commit is contained in:
Mircea Kitsune 2015-01-16 23:41:37 +00:00
commit e1ab90a82a
12 changed files with 93 additions and 0 deletions

View file

@ -189,3 +189,17 @@ Mito551 (sounds) (CC BY-SA):
default_dirt_footstep.1.ogg
default_dirt_footstep.2.ogg
default_glass_footstep.ogg
earthcalling (sounds) (CC0):
default_flow_water.ogg
default_flow_lava.ogg
LeonMire (sounds) (CC0):
default_use_chest.ogg
Stephan (sounds) (CC0):
default_use_furnace.ogg
default_eat.ogg
Thore (sounds) (CC0):
default_use_workbench.ogg

View file

@ -83,6 +83,78 @@ function default.node_sound_glass_defaults(table)
return table
end
--
-- Fluid flow sounds
--
local flow_sounds = {}
local function flow_sound_start(pos, file)
local pos_hash = minetest.hash_node_position(pos)
local sound = flow_sounds[pos_hash]
if not sound then
-- Abort if this touches another liquid source, or lakes can cause heavy sound spam
local positions = {}
table.insert(positions, {x = pos.x - 1, y = pos.y, z = pos.z})
table.insert(positions, {x = pos.x + 1, y = pos.y, z = pos.z})
table.insert(positions, {x = pos.x, y = pos.y - 1, z = pos.z})
table.insert(positions, {x = pos.x, y = pos.y + 1, z = pos.z})
table.insert(positions, {x = pos.x, y = pos.y, z = pos.z - 1})
table.insert(positions, {x = pos.x, y = pos.y, z = pos.z + 1})
for i, entry in ipairs(positions) do
local pos_here = { x = entry.x, y = entry.y, z = entry.z }
local node_here = minetest.get_node(pos_here)
local nodedef_here = minetest.registered_nodes[node_here.name]
if(nodedef_here.drawtype == "liquid") then
return
end
end
flow_sounds[pos_hash] = {
handle = minetest.sound_play(file, {pos = pos, gain = 0.5, loop = true}),
}
end
end
local function flow_sound_stop(pos)
local pos_hash = minetest.hash_node_position(pos)
local sound = flow_sounds[pos_hash]
if sound then
minetest.sound_stop(sound.handle)
flow_sounds[pos_hash] = nil
end
end
minetest.register_on_placenode(function(pos, _, _, _, _)
flow_sound_stop(pos)
end)
minetest.register_on_dignode(function(pos, _, _)
flow_sound_stop(pos)
end)
minetest.register_abm({
nodenames = {"default:water_source"},
neighbors = {"default:water_flowing"},
interval = 0.5,
chance = 1,
action = function(pos, node, _, _)
flow_sound_start(pos, "default_flow_water")
end,
})
minetest.register_abm({
nodenames = {"default:lava_source"},
neighbors = {"default:lava_flowing"},
interval = 0.5,
chance = 1,
action = function(pos, node, _, _)
flow_sound_start(pos, "default_flow_lava")
end,
})
--
-- Legacy
--

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -35,6 +35,13 @@ following Textures created by PenguinDad (CC BY-SA 4.0):
door_glass.png
door_obsidian_glass.png
Door sounds created by Slanesh (CC-BY 3.0):
doors_door_open.ogg
doors_door_close.ogg
Gate sound created by j1987 (CC0):
doors_gate_open_close.ogg
All other textures (created by PilzAdam): WTFPL

Binary file not shown.

Binary file not shown.

Binary file not shown.