Sounds: move them into sounds mod, add electric humm for mech.

Most of the active mech nodes now make the humming sound, which
is very low key but still audible.
This commit is contained in:
Auke Kok 2017-03-28 21:35:24 -07:00
parent d5e8df72ec
commit 003cc38c21
12 changed files with 173 additions and 130 deletions

View File

@ -176,7 +176,7 @@ minetest.register_node("mech:button_down", {
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
groups = {node = 1, unbreakable = 1},
groups = {node = 1, unbreakable = 1, mech = 1},
sounds = sounds.metal,
collision_box = {
type = "fixed",
@ -238,7 +238,7 @@ minetest.register_node("mech:switch_on", {
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
groups = {node = 1, unbreakable = 1},
groups = {node = 1, unbreakable = 1, mech = 1},
sounds = sounds.metal,
collision_box = {
type = "fixed",
@ -296,7 +296,7 @@ minetest.register_node("mech:pressure_plate_down", {
fixed = {{-7/16, -1/2, -7/16, 7/16, -1/2 + 0.001, 7/16}},
},
paramtype = "light",
groups = {node = 1, unbreakable = 1},
groups = {node = 1, unbreakable = 1, mech = 1},
sounds = sounds.metal,
after_dig_node = mech.after_dig,
walkable = false,
@ -391,7 +391,7 @@ minetest.register_node("mech:piston_base_extended", {
{-1/8, 1/4, -1/8, 1/8, 1/2, 1/8}, -- rod
}
},
groups = {node = 1, unbreakable = 1},
groups = {node = 1, unbreakable = 1, mech = 1},
sounds = sounds.wood,
after_dig_node = mech.after_dig,
on_trigger = function(pos) end,
@ -569,7 +569,7 @@ minetest.register_node(":boxes:pedestal", {
},
},
connects_to = {"boxes:nexus"},
groups = {node = 1},
groups = {node = 1, mech = 1},
sounds = sounds.stone,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
if itemstack:get_name() ~= "boxes:nexus" then

View File

@ -999,122 +999,6 @@ minetest.register_node("nodes:fire", {
})
frame.register("nodes:fire")
--
-- fire sounds
--
local fire_sound_tbl = {}
minetest.register_abm({
label = "fire_sounds",
nodenames = {"nodes:fire"},
neighbors = {"air"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(fire_sound_tbl) do
if k < slice - 6 then
fire_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(fire_sound_tbl) do
if fire_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("fire_fire", {pos = center, loop = false, gain = 0.3, max_hear_distance = 16})
if not fire_sound_tbl[slice] then
fire_sound_tbl[slice] = {}
end
fire_sound_tbl[slice][chash] = 1
end,
})
--
-- flowing water sounds
--
local flw_sound_tbl = {}
minetest.register_abm({
label = "flowing_water_sounds",
nodenames = {"nodes:water_flowing", "nodes:river_water_flowing"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(flw_sound_tbl) do
if k < slice - 6 then
flw_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(flw_sound_tbl) do
if flw_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("water_flowing", {pos = center, loop = false, gain = 0.3, max_hear_distance = 16})
if not flw_sound_tbl[slice] then
flw_sound_tbl[slice] = {}
end
flw_sound_tbl[slice][chash] = 1
end,
})
--
-- leaves sounds
--
local leaves_sound_tbl = {}
minetest.register_abm({
label = "leaves_sounds",
nodenames = {"group:leaves"},
neighbors = {"air"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(leaves_sound_tbl) do
if k < slice - 6 then
leaves_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(leaves_sound_tbl) do
if leaves_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("leaves", {pos = center, loop = false, gain = 0.3, max_hear_distance = 8})
if not leaves_sound_tbl[slice] then
leaves_sound_tbl[slice] = {}
end
leaves_sound_tbl[slice][chash] = 1
end,
})
-- chests:
-- empty (fake) chest

View File

@ -1,15 +1,6 @@
fire_fire.*.ogg:
- http://freesound.org/people/jan.bockelson/sounds/342104/ CC0
chest_*.ogg:
- http://www.freesound.org/people/Sevin7/sounds/269722/ CC0
- http://www.freesound.org/people/Percy%20Duke/sounds/23448/ CC-BY-3.0
- http://www.freesound.org/people/kingsamas/sounds/135576/ CC-BY-3.0
- http://www.freesound.org/people/bulbastre/sounds/126887/ CC-BY-3.0
- http://www.freesound.org/people/Yoyodaman234/sounds/183541/ CC0
water_flowing.ogg:
- http://freesound.org/people/forrisday/sounds/167365/ CC-BY-3.0
leaves.ogg:
- http://freesound.org/people/lunchmoney/sounds/378725/ CC0

View File

@ -28,3 +28,159 @@ for _, v in pairs({
}
end
--
-- fire sounds
--
local fire_sound_tbl = {}
minetest.register_abm({
label = "fire_sounds",
nodenames = {"nodes:fire"},
neighbors = {"air"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(fire_sound_tbl) do
if k < slice - 6 then
fire_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(fire_sound_tbl) do
if fire_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("fire_fire", {pos = center, loop = false, gain = 0.3, max_hear_distance = 16})
if not fire_sound_tbl[slice] then
fire_sound_tbl[slice] = {}
end
fire_sound_tbl[slice][chash] = 1
end,
})
--
-- flowing water sounds
--
local flw_sound_tbl = {}
minetest.register_abm({
label = "flowing_water_sounds",
nodenames = {"nodes:water_flowing", "nodes:river_water_flowing"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(flw_sound_tbl) do
if k < slice - 6 then
flw_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(flw_sound_tbl) do
if flw_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("water_flowing", {pos = center, loop = false, gain = 0.3, max_hear_distance = 16})
if not flw_sound_tbl[slice] then
flw_sound_tbl[slice] = {}
end
flw_sound_tbl[slice][chash] = 1
end,
})
--
-- leaves sounds
--
local leaves_sound_tbl = {}
minetest.register_abm({
label = "leaves_sounds",
nodenames = {"group:leaves"},
neighbors = {"air"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(leaves_sound_tbl) do
if k < slice - 6 then
leaves_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(leaves_sound_tbl) do
if leaves_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("leaves", {pos = center, loop = false, gain = 0.3, max_hear_distance = 8})
if not leaves_sound_tbl[slice] then
leaves_sound_tbl[slice] = {}
end
leaves_sound_tbl[slice][chash] = 1
end,
})
--
-- mech electric sounds
--
local mech_sound_tbl = {}
minetest.register_abm({
label = "mech_sounds",
nodenames = {"group:mech"},
neighbors = {"air"},
interval = 1,
chance = 4,
catch_up = false,
action = function(pos, node)
local secs = os.time()
local slice = math.floor(secs / 2)
-- trim old slices first
for k, _ in pairs(mech_sound_tbl) do
if k < slice - 6 then
mech_sound_tbl[k] = nil
end
end
-- get center pos of 2x2 node complex
local center = vector.apply(pos, function(a)
return (math.floor(a / 2) * 2) + 0.5
end)
local chash = minetest.hash_node_position(vector.apply(center, math.floor))
-- scan for recent sound from center
for k, _ in pairs(mech_sound_tbl) do
if mech_sound_tbl[k][chash] then
return
end
end
minetest.sound_play("mech_humm_60hz", {pos = center, loop = false, gain = 0.3, max_hear_distance = 8})
if not mech_sound_tbl[slice] then
mech_sound_tbl[slice] = {}
end
mech_sound_tbl[slice][chash] = 1
end,
})

View File

@ -0,0 +1,11 @@
mech_humm_60hz.ogg
- CC-BY-3.0 Auke Kok <sofar@foo-projects.org>
fire_fire.*.ogg:
- http://freesound.org/people/jan.bockelson/sounds/342104/ CC0
water_flowing.ogg:
- http://freesound.org/people/forrisday/sounds/167365/ CC-BY-3.0
leaves.ogg:
- http://freesound.org/people/lunchmoney/sounds/378725/ CC0

Binary file not shown.

View File

@ -272,6 +272,7 @@ minetest.register_node("terminal:terminal", {
description = "An interactive terminal console emulator access interface unit controller",
drawtype = "mesh",
mesh = "terminal.obj",
groups = {mech = 1},
tiles = {
{name = "terminal_base.png"},
{name = "terminal_idle.png", animation = {type = "vertical_frames", aspect_w = 14, aspect_h = 13, length = 4.0}},