1
0
mirror of https://codeberg.org/tenplus1/ambience.git synced 2025-07-12 21:40:28 +02:00

Compare commits

...

27 Commits

Author SHA1 Message Date
9c4a1f1e28 change minetest. to core. 2025-05-04 10:07:02 +01:00
adecc1b95c tweak icecrack and birds 2025-01-12 09:10:45 +00:00
703f6c4370 add ambience.group_total() function, tweak & tidy code 2024-12-18 10:34:03 +00:00
db65aebead add missing textdomain 2024-12-13 14:35:31 +00:00
e392d8d769 add polish translation (thx spageektti) 2024-12-13 14:33:37 +00:00
1b428c5a2c remove need for minetest.after 2024-11-28 09:56:39 +00:00
d98e90656e add ethereal leaves check and tweak ice crack vol 2024-09-09 12:31:03 +01:00
e55d4b8b62 remove fire sounds, added Mineclone support. 2024-08-15 14:55:02 +01:00
c1a076ec8c add biome name to sound_check, add additional sounds with pitch change 2024-07-11 14:31:00 +01:00
f3f2cedd4b tweat code 2024-07-11 14:08:26 +01:00
9ad6bac0cb fix jungle_day_1 snd error 2024-07-11 12:23:01 +01:00
fd51c65804 add spanish locale (thanks Panquesito7) 2023-12-27 10:59:10 +00:00
0e444c726c esperanto translation added (thx JadedCtrl) 2023-10-16 07:59:12 +01:00
66e73ddf31 tweak for 5.0 2023-09-08 20:33:02 +01:00
e8db802d86 5.x 2023-08-08 18:25:48 +01:00
cbc25eacdb amend load msg's 2022-12-19 18:21:30 +00:00
4772a74e5d replace icecrack sound with free one 2022-12-03 08:25:59 +00:00
d6aabffbcf add license.txt 2022-12-02 10:05:48 +00:00
9add3dc871 resize screenshot to meet contentdb size limit 2022-11-23 18:26:25 +00:00
3d8b3c6451 replace non-commercial sounds 2022-11-21 10:44:18 +00:00
493dba668a update license file 2022-11-19 08:33:33 +00:00
65f8a02c16 player can set sound and music volumes which are saved 2022-10-27 09:03:15 +01:00
f7d54237f6 add join/leave nil checks, use pairs for player loop 2021-11-20 08:21:38 +00:00
4acc464a8a add nil check for eye level 2021-10-29 07:36:23 +01:00
e19fca8446 fix nil check 2021-07-13 16:05:42 +01:00
d0cea9d033 play cave drips when near water 2021-07-05 09:11:21 +01:00
19673910d9 increase gain for ice crack 2021-07-03 14:08:28 +01:00
18 changed files with 452 additions and 451 deletions

View File

@ -20,5 +20,9 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
- 1.5 - Added 'flame_sound' and fire redo check, code tidy and tweak, added ephemeral flag for background sounds.
- 1.6 - Finding env_sounds disables water and lava sets, added 'ambience_water_move' flag to override water walking sounds, use eye level for head node.
- 1.7 - Music will play every 20-30 minutes if found, use '/mvol 0' to stop playing music or disable in-game.
- 1.8 - Players can set induvidual volume for sound and music which is saved.
- 1.9 - Tidy code, refactor music playing, add biome name to sound_check.
- 2.0 - Add Mineclone support, add ethereal leaf check, remove minetest.after for custom timer, add Polish translation, tweak & tidy code.
- 2.1 - Add ambience.group_total() function for easy counting of group: nodes inside a set.
Code license: MIT

18
api.txt
View File

@ -27,6 +27,7 @@ ambience.add_set(set_name, def)
'positions' position data for every node found
'head_node' name of node at player head level
'feet_node' nameof node at player foot level
'biome' name of biome at current position
This will let you add a set or sounds with the frequency it's used and check
function for it to play. If ephemeral is true then no handler will be used and sound will be played in background alongside other sounds.
@ -42,14 +43,22 @@ ambience.add_set("windy", {
{name = "crow", length = 3, ephemeral = true},
},
sound_check = function(def)
local number = totals["default:sand"] or 0 -- yep, can also be nil
local number = def.totals["default:sand"] or 0 -- yep, can also be nil
if number > 20 then
return "windy", 0.2 -- return set to play and optional gain volume
end
end,
end
})
Counting group: nodes
---------------------
Instead of counting each node total for things like leaves within the sound_check function, you could use the following helper function to return their total instead e.g.
local number = ambience.group_totals(def.totals, "leaves") -- count all group:leaves
Getting Sound Set
-----------------
@ -80,7 +89,7 @@ Additional Commands
Two volume commands have been added to set sound and music volume:
/svol (0.1 to 1.0)
/mvol (0.1 to 1.0) -- 0 can be used to stop music from playing when it begins
/mvol (0.1 to 1.0) -- 0 can be used to stop music curently playing
Music
@ -88,4 +97,5 @@ Music
Music can be stored in the sounds folder either on server or locally and so long
as it is named 'ambience_music.1', 'ambience_music.2' etc. then it will select
a song randomly at midnight and play player.
a song randomly to play every 20 minutes.

View File

@ -1,3 +0,0 @@
default
fire?
playerplus?

View File

@ -1 +0,0 @@
Adds realistic sound effects into your world.

332
init.lua
View File

@ -1,24 +1,29 @@
-- global
ambience = {}
-- settings
local SOUNDVOLUME = 1.0
local MUSICVOLUME = 0.6
local play_music = minetest.settings:get_bool("ambience_music") ~= false
local pplus = minetest.get_modpath("playerplus")
local MUSICINTERVAL = 60 * 20
local play_music = core.settings:get_bool("ambience_music") ~= false
local radius = 6
local playing = {}
local playing = {} -- user settings, timers and current set playing
local sound_sets = {} -- all the sounds and their settings
local sound_set_order = {} -- needed because pairs loops randomly through tables
local set_nodes = {} -- all the nodes needed for sets
-- translation
local S = core.get_translator("ambience")
-- add set to list
ambience.add_set = function(set_name, def)
if not set_name or not def then
return
end
function ambience.add_set(set_name, def)
if not set_name or not def then return end
sound_sets[set_name] = {
frequency = def.frequency or 50,
@ -32,14 +37,10 @@ ambience.add_set = function(set_name, def)
for i = 1, #sound_set_order do
if sound_set_order[i] == set_name then
can_add = false
end
if sound_set_order[i] == set_name then can_add = false end
end
if can_add then
table.insert(sound_set_order, set_name)
end
if can_add then table.insert(sound_set_order, set_name) end
-- add any missing nodes to the set_nodes table
if def.nodes then
@ -50,27 +51,23 @@ ambience.add_set = function(set_name, def)
for j = 1, #set_nodes do
if def.nodes[i] == set_nodes[j] then
can_add = false
end
if def.nodes[i] == set_nodes[j] then can_add = false end
end
if can_add then
table.insert(set_nodes, can_add)
if can_add then table.insert(set_nodes, can_add) end
end
end
end
end
-- return set from list using name
ambience.get_set = function(set_name)
function ambience.get_set(set_name)
return sound_sets[set_name]
end
-- remove set from list
ambience.del_set = function(set_name)
function ambience.del_set(set_name)
sound_sets[set_name] = nil
@ -78,87 +75,113 @@ ambience.del_set = function(set_name)
for i = 1, #sound_set_order do
if sound_set_order[i] == set_name then
can_del = i
if sound_set_order[i] == set_name then can_del = i end
end
if can_del then table.remove(sound_set_order, can_del) end
end
-- return node total belonging to a specific group:
function ambience.group_total(ntab, ngrp)
local tot = 0
local def, grp
for _,n in pairs(ntab) do
def = core.registered_nodes[_]
grp = def and def.groups and def.groups[ngrp]
if grp and grp > 0 then
tot = tot + n
end
end
if can_del then
table.remove(sound_set_order, can_del)
return tot
end
end
-- setup table when player joins
minetest.register_on_joinplayer(function(player)
playing[player:get_player_name()] = {music = -1}
core.register_on_joinplayer(function(player)
if player then
local name = player:get_player_name()
local meta = player:get_meta()
playing[name] = {
mvol = tonumber(meta:get_string("ambience.mvol")) or MUSICVOLUME,
svol = tonumber(meta:get_string("ambience.svol")) or SOUNDVOLUME,
timer = 0,
music = 0,
music_handler = nil
}
end
end)
-- remove table when player leaves
minetest.register_on_leaveplayer(function(player)
playing[player:get_player_name()] = nil
core.register_on_leaveplayer(function(player)
if player then playing[player:get_player_name()] = nil end
end)
-- plays music and selects sound set
local get_ambience = function(player, tod, name)
-- play server or local music if music enabled and music not already playing
if play_music and MUSICVOLUME > 0 and playing[name].music < 0 then
local function get_ambience(player, tod, name)
-- count backwards
playing[name].music = playing[name].music -1
-- if enabled and not already playing, play local/server music on interval check
if play_music and playing[name] and playing[name].mvol > 0 then
-- play music every 20 minutes
if playing[name].music < -(60 * 20) then
-- increase music time interval
playing[name].music = playing[name].music + 1
playing[name].music = minetest.sound_play("ambience_music", {
-- play music on interval check
if playing[name].music > MUSICINTERVAL and playing[name].music_handler == nil then
playing[name].music_handler = core.sound_play("ambience_music", {
to_player = name,
gain = MUSICVOLUME
gain = playing[name].mvol
})
-- reset music timer after 10 minutes
minetest.after(60 * 10, function(name)
if playing[name] then
playing[name].music = -1
playing[name].music = 0 -- reset interval
end
end, name)
end
--print("-- music count", playing[name].music)
--print("-- music timer", playing[name].music .. "/" .. MUSICINTERVAL)
end
-- get foot and head level nodes at player position
local pos = player:get_pos() ; if not pos then return end
local prop = player:get_properties()
local eyeh = prop.eye_height or 1.47 -- eye level with fallback
pos.y = pos.y + prop.eye_height -- eye level
pos.y = pos.y + eyeh -- head level
local nod_head = pplus and name and playerplus[name]
and playerplus[name].nod_head or minetest.get_node(pos).name
local nod_head = core.get_node(pos).name
pos.y = (pos.y - prop.eye_height) + 0.2 -- foot level
pos.y = (pos.y - eyeh) + 0.2 -- foot level
local nod_feet = pplus and name and playerplus[name]
and playerplus[name].nod_feet or minetest.get_node(pos).name
local nod_feet = core.get_node(pos).name
pos.y = pos.y - 0.2 -- reset pos
-- get all set nodes around player
local ps, cn = minetest.find_nodes_in_area(
local ps, cn = core.find_nodes_in_area(
{x = pos.x - radius, y = pos.y - radius, z = pos.z - radius},
{x = pos.x + radius, y = pos.y + radius, z = pos.z + radius}, set_nodes)
-- loop through sets in order and choose first that meets it's conditions
-- loop through sets in order and choose first that meets conditions set
for n = 1, #sound_set_order do
local set = sound_sets[ sound_set_order[n] ]
if set and set.sound_check then
-- pass settings to function for condition check
-- get biome data
local bdata = core.get_biome_data(pos)
local biome = bdata and core.get_biome_name(bdata.biome) or ""
-- pass settings to set function for condition check
local set_name, gain = set.sound_check({
player = player,
pos = pos,
@ -166,168 +189,179 @@ local get_ambience = function(player, tod, name)
totals = cn,
positions = ps,
head_node = nod_head,
feet_node = nod_feet
feet_node = nod_feet,
biome = biome
})
-- if conditions met return set name and gain value
if set_name then
return set_name, gain
end
if set_name then return set_name, gain end
end
end
return nil, nil -- ADDED
return nil, nil
end
-- players routine
local timer = 0
local random = math.random
-- players routine
minetest.register_globalstep(function(dtime)
core.register_globalstep(function(dtime)
local players = core.get_connected_players()
local pname
-- reduce sound timer for each player and stop/reset when needed
for _, player in pairs(players) do
pname = player:get_player_name()
if playing[pname] and playing[pname].timer > 0 then
playing[pname].timer = playing[pname].timer - dtime
if playing[pname].timer <= 0 then
if playing[pname].handler then
core.sound_stop(playing[pname].handler)
end
playing[pname].set = nil
playing[pname].gain = nil
playing[pname].handler = nil
end
end
end
-- one second timer
timer = timer + dtime
if timer < 1 then return end
timer = 0
timer = timer + dtime ; if timer < 1 then return end ; timer = 0
local player_name, number, chance, ambience, handler, ok
local tod = minetest.get_timeofday()
local number, chance, ambience, handler, ok
local tod = core.get_timeofday()
-- loop through players
for _, player in ipairs(minetest.get_connected_players()) do
for _, player in pairs(players) do
player_name = player:get_player_name()
pname = player:get_player_name()
--local t1 = os.clock()
local set_name, MORE_GAIN = get_ambience(player, tod, pname)
local set_name, MORE_GAIN = get_ambience(player, tod, player_name)
--print(string.format("elapsed time: %.4f\n", os.clock() - t1))
ok = playing[player_name] -- everything starts off ok if player found
ok = playing[pname] -- everything starts off ok if player found
-- are we playing something already?
if ok and playing[player_name].handler then
if ok and playing[pname].handler then
-- stop current sound if another set active or gain changed
if playing[player_name].set ~= set_name
or playing[player_name].gain ~= MORE_GAIN then
if playing[pname].set ~= set_name
or playing[pname].gain ~= MORE_GAIN then
--print ("-- change stop", set_name, playing[player_name].handler)
--print ("-- change stop", set_name, playing[pname].handler)
minetest.sound_stop(playing[player_name].handler)
core.sound_stop(playing[pname].handler)
playing[player_name].set = nil
playing[player_name].gain = nil
playing[player_name].handler = nil
playing[pname].set = nil
playing[pname].gain = nil
playing[pname].handler = nil
playing[pname].timer = 0
else
ok = false -- sound set still playing, skip new sound
end
end
-- set random chance
chance = random(1, 1000)
chance = random(1000)
-- if chance is lower than set frequency then select set
if ok and set_name and chance < sound_sets[set_name].frequency then
-- choose random sound from set
number = random(#sound_sets[set_name].sounds)
ambience = sound_sets[set_name].sounds[number]
number = random(#sound_sets[set_name].sounds) -- choose random sound from set
ambience = sound_sets[set_name].sounds[number] -- grab sound information
-- play sound
handler = minetest.sound_play(ambience.name, {
to_player = player_name,
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * SOUNDVOLUME,
handler = core.sound_play(ambience.name, {
to_player = pname,
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * playing[pname].svol,
pitch = ambience.pitch or 1.0
}, ambience.ephemeral)
--print ("playing... " .. ambience.name .. " (" .. chance .. " < "
-- .. sound_sets[set_name].frequency .. ") @ ", MORE_GAIN, handler)
-- only continue if sound playing returns handler
if handler then
--print("-- current handler", handler)
-- set what player is currently listening to
playing[player_name].set = set_name
playing[player_name].gain = MORE_GAIN
playing[player_name].handler = handler
-- set timer to stop sound
minetest.after(ambience.length, function(handler, player_name)
--print("-- timed stop", set_name, handler)
if handler then
minetest.sound_stop(handler)
end
-- reset variables if handlers match
if playing[player_name]
and playing[player_name].handler == handler then
--print("-- timed reset", handler, player_name)
playing[player_name].set = nil
playing[player_name].gain = nil
playing[player_name].handler = nil
end
end, handler, player_name)
-- set what player is currently listening to if handler found
playing[pname].set = set_name
playing[pname].gain = MORE_GAIN
playing[pname].handler = handler
playing[pname].timer = ambience.length
end
end
end
end)
-- sound volume command
minetest.register_chatcommand("svol", {
params = "<svol>",
description = "set sound volume (0.1 to 1.0)",
privs = {server = true},
core.register_chatcommand("svol", {
params = S("<svol>"),
description = S("set sound volume (0.1 to 1.0)"),
privs = {},
func = function(name, param)
SOUNDVOLUME = tonumber(param) or SOUNDVOLUME
local svol = tonumber(param) or playing[name].svol
if SOUNDVOLUME < 0.1 then SOUNDVOLUME = 0.1 end
if SOUNDVOLUME > 1.0 then SOUNDVOLUME = 1.0 end
if svol < 0.1 then svol = 0.1 end
if svol > 1.0 then svol = 1.0 end
return true, "Sound volume set to " .. SOUNDVOLUME
local player = core.get_player_by_name(name)
local meta = player:get_meta()
meta:set_string("ambience.svol", svol)
playing[name].svol = svol
return true, S("Sound volume set to @1", svol)
end
})
-- music volume command (0 stops music)
minetest.register_chatcommand("mvol", {
params = "<mvol>",
description = "set music volume (0.1 to 1.0, 0 to stop music)",
privs = {server = true},
core.register_chatcommand("mvol", {
params = S("<mvol>"),
description = S("set music volume (0.1 to 1.0, 0 to stop music)"),
privs = {},
func = function(name, param)
MUSICVOLUME = tonumber(param) or MUSICVOLUME
local mvol = tonumber(param) or playing[name].mvol
-- ability to stop music by setting volume to 0
if MUSICVOLUME == 0 and playing[name].music
and playing[name].music >= 0 then
-- stop music currently playing by setting volume to 0
if mvol == 0 and playing[name].music_handler then
minetest.sound_stop(playing[name].music)
core.sound_stop(playing[name].music_handler)
playing[name].music = -1
playing[name].music_handler = nil
core.chat_send_player(name, S("Music stopped!"))
end
if MUSICVOLUME < 0 then MUSICVOLUME = 0 end
if MUSICVOLUME > 1.0 then MUSICVOLUME = 1.0 end
if mvol < 0 then mvol = 0 end
if mvol > 1.0 then mvol = 1.0 end
return true, "Music volume set to " .. MUSICVOLUME
local player = core.get_player_by_name(name)
local meta = player:get_meta()
meta:set_string("ambience.mvol", mvol)
playing[name].mvol = mvol
return true, S("Music volume set to @1", mvol)
end
})
-- load default sound sets
dofile(minetest.get_modpath("ambience") .. "/soundsets.lua")
dofile(core.get_modpath("ambience") .. "/soundsets.lua")
print("[MOD] Ambience Lite loaded")

View File

@ -1,16 +1,40 @@
The MIT License (MIT)
Copyright (c) 2022 TenPlus1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Sound licenses:
-----------Sound Lic:
--Nightime Sound, Recorded by Mike Koenig, License: Attribution 3.0 http://soundbible.com/951-Nightime.html
--Crickets At Night Sound, License: Attribution 3.0 | Recorded by Mike Koenig |http://soundbible.com/365-Crickets-At-Night.html
--Medium Pack Of Wolves Howling, License: Public Domain | Recorded by fws.gov, http://soundbible.com/277-Medium-Pack-Of-Wolves-Howling.html
--Horned Owl Sound, License: Attribution 3.0 | Recorded by Mike Koenig , http://soundbible.com/1851-Horned-Owl.html
--Bats In Cave Sound, License: Attr-Noncommercial 3.0 | Recorded by Mike Koenig , http://soundbible.com/1939-Bats-In-Cave.html
--Bats In Cave Sound, License: CC0 | Recorded by SaloSensei , https://freesound.org/people/SaloSensei/sounds/616219/
--Spooky Water Drops Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/380-Spooky-Water-Drops.html
-- Single Water Droplet Sound, License: Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/384-Single-Water-Droplet.html
--HollowWind, Black Boe, Creative Commons 0 License, http://www.freesound.org/people/Black%20Boe/sounds/22331/
@ -29,12 +53,8 @@
--scuba1*.ogg- digifishmusic, Attribution License, http://www.freesound.org/people/digifishmusic/sounds/45521/
--Underwater Pool - Attribution 3.0 | Recorded by Mike Koenig, http://soundbible.com/1660-Underwater-Pool.html
--dolphin_screaming - Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/161691/
--dolphins - Attribution Noncommercial License, acclivity, http://www.freesound.org/people/acclivity/sounds/13691/
ComboWind uses:
--wind-in-the-trees -Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/16995/
--drygrassInWind- Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/146436/
@ -45,13 +65,11 @@ ComboWind uses:
--Lake_Waves_2*, Attribution License, Benboncan, http://www.freesound.org/people/Benboncan/sounds/67884/
--water_swimming_splashing*, Attribution Noncommercial License, Robinhood76, http://www.freesound.org/people/Robinhood76/sounds/79657/
--earth01a, Creative Commons 0 License., Halion , http://www.freesound.org/people/Halion/sounds/17785
--fiji_beach, Creative Commons 0 License, c97059890, http://www.freesound.org/people/c97059890/sounds/21754/
--seagull, Attribution Noncommercial License., hazure, http://www.freesound.org/people/hazure/sounds/23707/,
--seagull, Attribution 3.0 License., hazure, http://www.freesound.org/people/hazure/sounds/23707/,
desert:
coyote2, Attribution License, rogerforeman, http://www.freesound.org/people/rogerforeman/sounds/68068/
@ -62,44 +80,9 @@ Rattlesnake Rattle, Public Domain, fws.gov, http://soundbible.com/237-Rattlesna
flying:
crystal_airlines: Attribution License, suonho, http://www.freesound.org/people/suonho/sounds/56364/
----------------Not used yet:
desert:
desert wind:
Desert Simple.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104320/
313hummer (Jordan Craige)
--echos http://soundcloud.com/jordan-craige/echos-1
Creative Commons Attribution license (reuse allowed) Attribution 3.0 Unported (CC BY 3.0)
Not Used:--FoamOfTheSea http://soundcloud.com/jordan-craige/foam-of-the-sea
xi-intersection:
http://soundcloud.com/xi-intersection/mass-effect-uncharted-worlds Creative Commons License
--not used:
http://soundcloud.com/xi-intersection/donkey-kong-country-2-flight
http://soundcloud.com/kogyo/kogyo-skalar-m1
lava:
http://www.freesound.org/people/Halion/sounds/17785/ (almost as good cc) (combine with rocks falling?)
http://www.freesound.org/people/pushtobreak/sounds/17823/ (attrib non cc really good)
http://www.freesound.org/people/klankbeeld/sounds/123970/ (horror rhythm)
Rockfall in mine.wav http://www.freesound.org/people/Benboncan/sounds/60085/
http://www.freesound.org/people/snotch/sounds/96175/ (mud volcano)
--natural night sounds in Boquete.wav, Attribution License, laurent, http://www.freesound.org/people/laurent/sounds/15851/
http://www.freesound.org/people/Dynamicell/sounds/17553/
http://www.freesound.org/people/juskiddink/sounds/78955/ aspen tree in wind
http://www.freesound.org/people/Benboncan/sounds/69761/ wind in hedge birds animals
ButterflyTea:
Creative Commons : Attribution-Noncommercial-Share Alike 3.0
http://www.jamendo.com/en/track/904012/dance-of-magical-flowers
http://www.jamendo.com/en/track/904013/magic-of-the-seventh-world
http://www.jamendo.com/en/track/904016/in-search-of-the-soul
http://www.freesfx.co.uk/soundeffects/forests-jungles/
zero-project
icecrack.ogg by figowitz (http://freesound.org/people/Figowitz/sounds/67881/)
icecrack.ogg by ecfike, Creative Commons 0 license (https://freesound.org/people/ecfike/sounds/177212/)

7
locale/ambience.eo.tr Normal file
View File

@ -0,0 +1,7 @@
# textdomain: ambience
<svol>=<slaŭtec>
set sound volume (0.1 to 1.0)=agordi sonlaŭtecon (0.1 ĝis 1.0)
Sound volume set to @1=Sonlaŭteco agordita al @1
<mvol>=<mlaŭtec>
set music volume (0.1 to 1.0, 0 to stop music)=agordi muziklaŭtecon (0.1 ĝis 1.0; malŝalti muzikon per 0)
Music volume set to @1=Muziklaŭteco agordita al @1

7
locale/ambience.es.tr Normal file
View File

@ -0,0 +1,7 @@
# textdomain: ambience
<svol>=<volumen de sonido>
set sound volume (0.1 to 1.0)=establecer volumen de sonido (0.1 a 1.0)
Sound volume set to @1=Volumen de sonido establecido a @1
<mvol>=<volumen de música>
set music volume (0.1 to 1.0, 0 to stop music)=establecer volumen de música (0.1 a 1.0, 0 para detener la música)
Music volume set to @1=Volumen de música establecido a @1

7
locale/ambience.pl.tr Normal file
View File

@ -0,0 +1,7 @@
# textdomain: ambience
<svol>=<sgłośność>
set sound volume (0.1 to 1.0)=ustaw głośność dźwięku (0.1 do 1.0)
Sound volume set to @1=Głośność dźwięku ustawiona na @1
<mvol>=<mgłośność>
set music volume (0.1 to 1.0, 0 to stop music)=ustaw głośność muzyki (0.1 do 1.0, 0 aby zatrzymać muzykę)
Music volume set to @1=Głośność muzyki ustawiona na @1

7
locale/template.txt Normal file
View File

@ -0,0 +1,7 @@
# textdomain: ambience
<svol>=
set sound volume (0.1 to 1.0)=
Sound volume set to @1=
<mvol>=
set music volume (0.1 to 1.0, 0 to stop music)=
Music volume set to @1=

View File

@ -1,4 +1,4 @@
name = ambience
depends = default
optional_depends = fire, playerplus
description = Adds realistic sound effects into your world.
optional_depends = default, mcl_core, mclx_core
min_minetest_version = 5.0

BIN
screenshot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

BIN
sounds/bats.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,10 +2,15 @@
Default Sound Sets
------------------
Order is very important when adding a sound set so it will play a certain
set of sounds before any another.
Order is very important when adding a sound set so it will play
certain sound sets before any another.
--]]
-- mod support
local mod_def = core.get_modpath("default")
local mod_mcl = core.get_modpath("mcl_core")
-- Underwater sounds play when player head is submerged
ambience.add_set("underwater", {
@ -18,8 +23,9 @@ ambience.add_set("underwater", {
sound_check = function(def)
if minetest.registered_nodes[def.head_node]
and minetest.registered_nodes[def.head_node].groups.water then
local nodef = core.registered_nodes[def.head_node]
if nodef and nodef.groups and nodef.groups.water then
return "underwater"
end
end
@ -27,26 +33,35 @@ ambience.add_set("underwater", {
-- Splashing sound plays when player walks inside water nodes (if enabled)
if minetest.settings:get_bool("ambience_water_move") ~= false then
if core.settings:get_bool("ambience_water_move") ~= false then
-- override default water sounds
minetest.override_item("default:water_source", { sounds = {} })
minetest.override_item("default:water_flowing", { sounds = {} })
minetest.override_item("default:river_water_source", { sounds = {} })
minetest.override_item("default:river_water_flowing", { sounds = {} })
if mod_def then
core.override_item("default:water_source", { sounds = {} })
core.override_item("default:water_flowing", { sounds = {} })
core.override_item("default:river_water_source", { sounds = {} })
core.override_item("default:river_water_flowing", { sounds = {} })
elseif mod_mcl then
core.override_item("mcl_core:water_source", { sounds = {} })
core.override_item("mcl_core:water_flowing", { sounds = {} })
core.override_item("mclx_core:river_water_source", { sounds = {} })
core.override_item("mclx_core:river_water_flowing", { sounds = {} })
end
ambience.add_set("splash", {
frequency = 1000,
sounds = {
{name = "swim_splashing", length = 3}
{name = "default_water_footstep", length = 2}
},
sound_check = function(def)
if minetest.registered_nodes[def.feet_node]
and minetest.registered_nodes[def.feet_node].groups.water then
local nodef = core.registered_nodes[def.feet_node]
if nodef and nodef.groups and nodef.groups.water then
local control = def.player:get_player_control()
@ -56,11 +71,10 @@ ambience.add_set("splash", {
end
end
})
end
-- check for env_sounds mod, if not found enable water flowing and lava sounds
if not minetest.get_modpath("env_sounds") then
if not core.get_modpath("env_sounds") then
-- Water sound plays when near flowing water
@ -72,18 +86,16 @@ ambience.add_set("flowing_water", {
{name = "waterfall", length = 6}
},
nodes = {"default:water_flowing"},
nodes = {"group:water"},
sound_check = function(def)
local c = (def.totals["default:water_flowing"] or 0)
+ (def.totals["mcl_core:water_flowing"] or 0)
if c > 40 then
return "flowing_water", 0.5
if c > 40 then return "flowing_water", 0.5
elseif c > 5 then
return "flowing_water"
end
elseif c > 5 then return "flowing_water" end
end
})
@ -97,18 +109,14 @@ ambience.add_set("river", {
{name = "river", length = 4, gain = 0.1}
},
nodes = {"default:river_water_flowing"},
sound_check = function(def)
local c = (def.totals["default:river_water_flowing"] or 0)
+ (def.totals["mclx_core:river_water_flowing"] or 0)
if c > 20 then
return "river", 0.5
if c > 20 then return "river", 0.5
elseif c > 5 then
return "river"
end
elseif c > 5 then return "river" end
end
})
@ -122,88 +130,22 @@ ambience.add_set("lava", {
{name = "lava", length = 7}
},
nodes = {"default:lava_source", "default:lava_flowing"},
nodes = {"group:lava"},
sound_check = function(def)
local c = (def.totals["default:lava_source"] or 0)
+ (def.totals["default:lava_flowing"] or 0)
+ (def.totals["mcl_core:lava_source"] or 0)
+ (def.totals["mcl_core:lava_flowing"] or 0)
if c > 20 then
return "lava", 0.5
if c > 20 then return "lava", 0.5
elseif c > 5 then
return "lava"
end
elseif c > 5 then return "lava" end
end
})
else
print ("[Ambience] found env_sounds, flowing water sounds disabled.")
end
-- Only add fire sounds set if flame_sound is disabled or fire redo active
local flame_sound = minetest.settings:get_bool("flame_sound", true)
local fire_redo = minetest.get_modpath("fire") and fire.mod and fire.mod == "redo"
if flame_sound and not fire_redo then
print ("[Ambience] fire sounds not enabled, already active in fire mod.")
else
-- Small fire sound plays when near lower than 9 flames
ambience.add_set("smallfire", {
frequency = 1000,
sounds = {
{name = "fire_small", length = 6, gain = 0.1}
},
nodes = {"fire:basic_flame", "fire:permanent_flame"},
sound_check = function(def)
local c = (def.totals["fire:basic_flame"] or 0)
+ (def.totals["fire:permanent_flame"] or 0)
if c > 5 and c < 9 then
return "smallfire", 0.5
elseif c > 0 and c < 9 then
return "smallfire"
end
end
})
-- Large fire sound plays when near more than 9 flames
ambience.add_set("largefire", {
frequency = 1000,
sounds = {
{name = "fire_large", length = 8, gain = 0.4}
},
sound_check = function(def)
-- fire nodes were added in last set, so don't need to be added in this one
local c = (def.totals["fire:basic_flame"] or 0)
+ (def.totals["fire:permanent_flame"] or 0)
if c > 20 then
return "largefire", 0.5
elseif c > 8 then
return "largefire"
end
end
})
print ("[MOD] Ambience - found env_sounds, using for water and lava sounds.")
end
-- Beach sounds play when below y-pos 6 and 150+ water source found
@ -214,16 +156,16 @@ ambience.add_set("beach", {
sounds = {
{name = "seagull", length = 4.5, ephemeral = true},
{name = "seagull", length = 4.5, pitch = 1.2, ephemeral = true},
{name = "beach", length = 13},
{name = "gull", length = 1, ephemeral = true},
{name = "beach_2", length = 6}
},
nodes = {"default:water_source"},
sound_check = function(def)
local c = (def.totals["default:water_source"] or 0)
+ (def.totals["mcl_core:water_source"] or 0)
if def.pos.y < 6 and def.pos.y > 0 and c > 150 then
return "beach"
@ -235,23 +177,23 @@ ambience.add_set("beach", {
ambience.add_set("ice", {
frequency = 250,
frequency = 80,
sounds = {
{name = "icecrack", length = 23},
{name = "icecrack", length = 5, gain = 1.1},
{name = "desertwind", length = 8},
{name = "wind", length = 9}
},
nodes = {"default:ice"},
nodes = (mod_mcl and {"mcl_core:ice", "mcl_core:packed_ice"} or {"default:ice"}),
sound_check = function(def)
local c = (def.totals["default:ice"] or 0)
+(def.totals["mcl_core:ice"] or 0)
+ (def.totals["mcl_core:packed_ice"] or 0)
if c > 100 then
return "ice"
end
if c > 400 then return "ice" end
end
})
@ -267,20 +209,23 @@ ambience.add_set("desert", {
{name = "desertwind", length = 8}
},
nodes = {"default:desert_sand", "default:sand"},
nodes = {
(mod_mcl and "mcl_core:redsand" or "default:desert_sand"),
(mod_mcl and "mcl_core:sand" or "default:sand")
},
sound_check = function(def)
local c = (def.totals["default:desert_sand"] or 0)
+ (def.totals["default:sand"] or 0)
+ (def.totals["mcl_core:sand"] or 0)
+ (def.totals["mcl_core:redsand"] or 0)
if c > 150 and def.pos.y > 10 then
return "desert"
end
if c > 150 and def.pos.y > 10 then return "desert" end
end
})
-- Cave sounds play when below player position Y -25
-- Cave sounds play when below player position Y -25 and water nearby
ambience.add_set("cave", {
@ -288,14 +233,18 @@ ambience.add_set("cave", {
sounds = {
{name = "drippingwater1", length = 1.5, ephemeral = true},
{name = "drippingwater2", length = 1.5, ephemeral = true}
{name = "drippingwater2", length = 1.5, ephemeral = true},
{name = "drippingwater2", length = 1.5, pitch = 1.2, ephemeral = true},
{name = "drippingwater2", length = 1.5, pitch = 1.4, ephemeral = true},
{name = "bats", length = 5, ephemeral = true}
},
sound_check = function(def)
if def.pos.y < -25 then
return "cave"
end
local c = (def.totals["default:water_source"] or 0)
+ (def.totals["mcl_core:water_source"] or 0)
if c > 0 and def.pos.y < -25 then return "cave" end
end
})
@ -310,18 +259,18 @@ ambience.add_set("jungle", {
{name = "deer", length = 7, ephemeral = true},
{name = "canadianloon2", length = 14},
{name = "bird1", length = 11},
{name = "peacock", length = 2, ephemeral = true}
{name = "peacock", length = 2, ephemeral = true},
{name = "peacock", length = 2, pitch = 1.2, ephemeral = true}
},
nodes = {"default:jungletree"},
nodes = {(mod_mcl and "mcl_trees:tree_jungle" or "default:jungletree")},
sound_check = function(def)
local c = (def.totals["default:jungletree"] or 0)
+ (def.totals["mcl_trees:tree_jungle"] or 0)
if def.tod > 0.2 and def.tod < 0.8 and c > 90 then
return "jungle"
end
if def.tod > 0.2 and def.tod < 0.8 and c > 79 then return "jungle" end
end
})
@ -335,17 +284,17 @@ ambience.add_set("jungle_night", {
{name = "jungle_night_1", length = 4, ephemeral = true},
{name = "jungle_night_2", length = 4, ephemeral = true},
{name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1, ephemeral = true}
{name = "frog", length = 1, ephemeral = true},
{name = "frog", length = 1, pitch = 1.3, ephemeral = true}
},
sound_check = function(def)
-- jungle tree was added in last set, so doesnt need to be added in this one
local c = (def.totals["default:jungletree"] or 0)
+ (def.totals["mcl_trees:tree_jungle"] or 0)
if (def.tod < 0.2 or def.tod > 0.8) and c > 90 then
return "jungle_night"
end
if (def.tod < 0.2 or def.tod > 0.8) and c > 79 then return "jungle_night" end
end
})
@ -360,10 +309,13 @@ ambience.add_set("day", {
{name = "craw", length = 3, ephemeral = true},
{name = "bluejay", length = 6, ephemeral = true},
{name = "robin", length = 4, ephemeral = true},
{name = "robin", length = 4, pitch = 1.2, ephemeral = true},
{name = "bird1", length = 11},
{name = "bird2", length = 6, ephemeral = true},
{name = "crestedlark", length = 6, ephemeral = true},
{name = "crestedlark", length = 6, pitch = 1.1, ephemeral = true},
{name = "peacock", length = 2, ephemeral = true},
{name = "peacock", length = 2, pitch = 1.2, ephemeral = true},
{name = "wind", length = 9}
},
@ -371,15 +323,10 @@ ambience.add_set("day", {
sound_check = function(def)
-- we used group:leaves but still need to specify actual nodes for total
local c = (def.totals["default:leaves"] or 0)
+ (def.totals["default:bush_leaves"] or 0)
+ (def.totals["default:pine_needles"] or 0)
+ (def.totals["default:aspen_leaves"] or 0)
-- use handy function to count all nodes in group:leaves
local c = ambience.group_total(def.totals, "leaves")
if (def.tod > 0.2 and def.tod < 0.8)
and def.pos.y > -10
and c > 5 then
if (def.tod > 0.2 and def.tod < 0.8) and def.pos.y > 0 and c > 50 then
return "day"
end
end
@ -393,23 +340,21 @@ ambience.add_set("night", {
sounds = {
{name = "hornedowl", length = 2, ephemeral = true},
{name = "hornedowl", length = 2, pitch = 1.1, ephemeral = true},
{name = "wolves", length = 4, gain = 0.4, ephemeral = true},
{name = "cricket", length = 6, ephemeral = true},
{name = "deer", length = 7, ephemeral = true},
{name = "frog", length = 1, ephemeral = true}
{name = "frog", length = 1, ephemeral = true},
{name = "frog", length = 1, pitch = 1.2, ephemeral = true},
{name = "wind", length = 9}
},
sound_check = function(def)
-- leaves were added in last set, so don't need to be added to this one
local c = (def.totals["default:leaves"] or 0)
+ (def.totals["default:bush_leaves"] or 0)
+ (def.totals["default:pine_needles"] or 0)
+ (def.totals["default:aspen_leaves"] or 0)
-- use handy function to count all nodes in group:leaves
local c = ambience.group_total(def.totals, "leaves")
if (def.tod < 0.2 or def.tod > 0.8)
and def.pos.y > -10
and c > 5 then
if (def.tod < 0.2 or def.tod > 0.8) and def.pos.y > 0 and c > 50 then
return "night"
end
end
@ -423,17 +368,18 @@ ambience.add_set("high_up", {
sounds = {
{name = "desertwind", length = 8},
{name = "wind", length = 9}
{name = "desertwind", length = 8, pitch = 1.3},
{name = "wind", length = 9},
{name = "wind", length = 9, pitch = 1.4}
},
nodes = {"default:snowblock"},
nodes = {(mod_mcl and "mcl_core:snowblock" or "default:snowblock")},
sound_check = function(def)
local c = (def.totals["default:snowblock"] or 0)
+ (def.totals["mcl_core:snowblock"] or 0)
if def.pos.y > 50 or c > 150 then
return "high_up"
end
if def.pos.y > 50 or c > 100 then return "high_up" end
end
})