mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2025-07-21 17:50:58 +02:00
Compare commits
7 Commits
f7d54237f6
...
cbc25eacdb
Author | SHA1 | Date | |
---|---|---|---|
cbc25eacdb | |||
4772a74e5d | |||
d6aabffbcf | |||
9add3dc871 | |||
3d8b3c6451 | |||
493dba668a | |||
65f8a02c16 |
@ -20,5 +20,6 @@ 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.
|
||||
|
||||
Code license: MIT
|
||||
|
84
init.lua
84
init.lua
@ -11,6 +11,7 @@ local 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
|
||||
local is_50 = minetest.has_feature("object_use_texture_alpha")
|
||||
|
||||
|
||||
-- add set to list
|
||||
@ -91,13 +92,37 @@ end
|
||||
|
||||
-- setup table when player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
||||
if player then
|
||||
playing[player:get_player_name()] = {music = -1}
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
playing[name] = {music = -1}
|
||||
|
||||
local mvol, svol
|
||||
|
||||
if is_50 then
|
||||
|
||||
local meta = player:get_meta()
|
||||
|
||||
mvol = meta:get_string("ambience.mvol")
|
||||
svol = meta:get_string("ambience.svol")
|
||||
else
|
||||
mvol = player:get_attribute("ambience.mvol")
|
||||
svol = player:get_attribute("ambience.svol")
|
||||
end
|
||||
|
||||
mvol = tonumber(mvol) or MUSICVOLUME
|
||||
svol = tonumber(svol) or SOUNDVOLUME
|
||||
|
||||
playing[name].mvol = mvol
|
||||
playing[name].svol = svol
|
||||
end
|
||||
end)
|
||||
|
||||
-- remove table when player leaves
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
if player then
|
||||
playing[player:get_player_name()] = nil
|
||||
end
|
||||
@ -108,8 +133,9 @@ end)
|
||||
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] and playing[name].music < 0 then
|
||||
if play_music
|
||||
and playing[name] and playing[name].music < 0
|
||||
and playing[name].mvol > 0 then
|
||||
|
||||
-- count backwards
|
||||
playing[name].music = playing[name].music -1
|
||||
@ -119,7 +145,7 @@ local get_ambience = function(player, tod, name)
|
||||
|
||||
playing[name].music = minetest.sound_play("ambience_music", {
|
||||
to_player = name,
|
||||
gain = MUSICVOLUME
|
||||
gain = playing[name].mvol
|
||||
})
|
||||
|
||||
-- reset music timer after 10 minutes
|
||||
@ -233,7 +259,7 @@ minetest.register_globalstep(function(dtime)
|
||||
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
|
||||
@ -245,7 +271,7 @@ minetest.register_globalstep(function(dtime)
|
||||
-- play sound
|
||||
handler = minetest.sound_play(ambience.name, {
|
||||
to_player = player_name,
|
||||
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * SOUNDVOLUME,
|
||||
gain = ((ambience.gain or 0.3) + (MORE_GAIN or 0)) * playing[player_name].svol,
|
||||
pitch = ambience.pitch or 1.0
|
||||
}, ambience.ephemeral)
|
||||
|
||||
@ -291,16 +317,28 @@ end)
|
||||
minetest.register_chatcommand("svol", {
|
||||
params = "<svol>",
|
||||
description = "set sound volume (0.1 to 1.0)",
|
||||
privs = {server = true},
|
||||
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
|
||||
if is_50 then
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local meta = player:get_meta()
|
||||
|
||||
meta:set_string("ambience.svol", svol)
|
||||
else
|
||||
player:set_attribute("ambience.svol", svol)
|
||||
end
|
||||
|
||||
playing[name].svol = svol
|
||||
|
||||
return true, "Sound volume set to " .. svol
|
||||
end
|
||||
})
|
||||
|
||||
@ -309,14 +347,14 @@ minetest.register_chatcommand("svol", {
|
||||
minetest.register_chatcommand("mvol", {
|
||||
params = "<mvol>",
|
||||
description = "set music volume (0.1 to 1.0, 0 to stop music)",
|
||||
privs = {server = true},
|
||||
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
|
||||
if mvol == 0 and playing[name].music
|
||||
and playing[name].music >= 0 then
|
||||
|
||||
minetest.sound_stop(playing[name].music)
|
||||
@ -324,10 +362,22 @@ minetest.register_chatcommand("mvol", {
|
||||
playing[name].music = -1
|
||||
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
|
||||
if is_50 then
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local meta = player:get_meta()
|
||||
|
||||
meta:set_string("ambience.mvol", mvol)
|
||||
else
|
||||
player:set_attribute("ambience.mvol", mvol)
|
||||
end
|
||||
|
||||
playing[name].mvol = mvol
|
||||
|
||||
return true, "Music volume set to " .. mvol
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -1,105 +1,88 @@
|
||||
|
||||
-----------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
|
||||
|
||||
--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/
|
||||
|
||||
--drippingwater*.ogg sounds: CC0, Dripping Water Mod, by kddekadenz, http://minetest.net/forum/viewtopic.php?id=1688
|
||||
|
||||
--best cardinal bird: License: Attribution 3.0 | Recorded by PsychoBird, http://soundbible.com/1515-Best-Cardinal-Bird.html
|
||||
|
||||
--birdsongnl: the Attribution License, HerbertBoland, http://www.freesound.org/people/HerbertBoland/sounds/28312/ (end)
|
||||
|
||||
--robin2: Attribution License, reinsamba, http://www.freesound.org/people/reinsamba/sounds/32479/ (end)
|
||||
|
||||
--Craw.WAV, Attribution License, inchadney, http://www.freesound.org/people/inchadney/sounds/52450/
|
||||
|
||||
--bluejay.wav, Creative Commons 0 License, UncleSigmund, http://www.freesound.org/people/UncleSigmund/sounds/42382/
|
||||
|
||||
--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/
|
||||
|
||||
--Splash: Attribution 3.0 | Recorded by BlastwaveFx.com, http://soundbible.com/546-Fish-Splashing.html
|
||||
|
||||
--small_waterfall Attribution License, volivieri, http://www.freesound.org/people/volivieri/sounds/38390/
|
||||
|
||||
--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/,
|
||||
|
||||
desert:
|
||||
coyote2, Attribution License, rogerforeman, http://www.freesound.org/people/rogerforeman/sounds/68068/
|
||||
http://www.freesound.org/people/Proxima4/sounds/104319/
|
||||
Desert Monolith.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104319/
|
||||
Rattlesnake Rattle, Public Domain, fws.gov, http://soundbible.com/237-Rattlesnake-Rattle.html
|
||||
|
||||
flying:
|
||||
crystal_airlines: Attribution License, suonho, http://www.freesound.org/people/suonho/sounds/56364/
|
||||
|
||||
----------------Not used yet:
|
||||
desert:
|
||||
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
|
||||
The MIT License (MIT)
|
||||
|
||||
icecrack.ogg by figowitz (http://freesound.org/people/Figowitz/sounds/67881/)
|
||||
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:
|
||||
|
||||
--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: 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/
|
||||
|
||||
--drippingwater*.ogg sounds: CC0, Dripping Water Mod, by kddekadenz, http://minetest.net/forum/viewtopic.php?id=1688
|
||||
|
||||
--best cardinal bird: License: Attribution 3.0 | Recorded by PsychoBird, http://soundbible.com/1515-Best-Cardinal-Bird.html
|
||||
|
||||
--birdsongnl: the Attribution License, HerbertBoland, http://www.freesound.org/people/HerbertBoland/sounds/28312/ (end)
|
||||
|
||||
--robin2: Attribution License, reinsamba, http://www.freesound.org/people/reinsamba/sounds/32479/ (end)
|
||||
|
||||
--Craw.WAV, Attribution License, inchadney, http://www.freesound.org/people/inchadney/sounds/52450/
|
||||
|
||||
--bluejay.wav, Creative Commons 0 License, UncleSigmund, http://www.freesound.org/people/UncleSigmund/sounds/42382/
|
||||
|
||||
--scuba1*.ogg- digifishmusic, Attribution License, http://www.freesound.org/people/digifishmusic/sounds/45521/
|
||||
|
||||
--dolphin_screaming - Creative Commons 0 License, felix.blume, http://www.freesound.org/people/felix.blume/sounds/161691/
|
||||
|
||||
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/
|
||||
|
||||
--Splash: Attribution 3.0 | Recorded by BlastwaveFx.com, http://soundbible.com/546-Fish-Splashing.html
|
||||
|
||||
--small_waterfall Attribution License, volivieri, http://www.freesound.org/people/volivieri/sounds/38390/
|
||||
|
||||
--Lake_Waves_2*, Attribution License, Benboncan, http://www.freesound.org/people/Benboncan/sounds/67884/
|
||||
|
||||
--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 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/
|
||||
http://www.freesound.org/people/Proxima4/sounds/104319/
|
||||
Desert Monolith.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104319/
|
||||
Rattlesnake Rattle, Public Domain, fws.gov, http://soundbible.com/237-Rattlesnake-Rattle.html
|
||||
|
||||
flying:
|
||||
crystal_airlines: Attribution License, suonho, http://www.freesound.org/people/suonho/sounds/56364/
|
||||
|
||||
desert wind:
|
||||
Desert Simple.wav, Creative Commons 0 License, Proxima4, http://www.freesound.org/people/Proxima4/sounds/104320/
|
||||
|
||||
http://www.freesfx.co.uk/soundeffects/forests-jungles/
|
||||
|
||||
icecrack.ogg by ecfike, Creative Commons 0 license (https://freesound.org/people/ecfike/sounds/177212/)
|
BIN
screenshot.jpg
Normal file
BIN
screenshot.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 51 KiB |
BIN
sounds/bats.ogg
Normal file
BIN
sounds/bats.ogg
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -40,7 +40,7 @@ ambience.add_set("splash", {
|
||||
frequency = 1000,
|
||||
|
||||
sounds = {
|
||||
{name = "swim_splashing", length = 3}
|
||||
{name = "default_water_footstep", length = 2}
|
||||
},
|
||||
|
||||
sound_check = function(def)
|
||||
@ -139,7 +139,7 @@ ambience.add_set("lava", {
|
||||
})
|
||||
|
||||
else
|
||||
print ("[Ambience] found env_sounds, flowing water and lava sounds disabled.")
|
||||
print ("[MOD] Ambience - found env_sounds, flowing water and lava sounds disabled.")
|
||||
end
|
||||
|
||||
-- Only add fire sounds set if flame_sound is disabled or fire redo active
|
||||
@ -149,7 +149,7 @@ local fire_redo = minetest.get_modpath("fire") and fire.mod and fire.mod == "red
|
||||
|
||||
if flame_sound and not fire_redo then
|
||||
|
||||
print ("[Ambience] fire sounds not enabled, already active in fire mod.")
|
||||
print ("[MOD] Ambience - fire sounds not enabled, already active in fire mod.")
|
||||
|
||||
else
|
||||
|
||||
@ -238,7 +238,7 @@ ambience.add_set("ice", {
|
||||
frequency = 250,
|
||||
|
||||
sounds = {
|
||||
{name = "icecrack", length = 23, gain = 0.7},
|
||||
{name = "icecrack", length = 5, gain = 0.7},
|
||||
{name = "desertwind", length = 8},
|
||||
{name = "wind", length = 9}
|
||||
},
|
||||
@ -288,7 +288,8 @@ 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 = "bats", length = 5, ephemeral = true}
|
||||
},
|
||||
|
||||
sound_check = function(def)
|
||||
|
Reference in New Issue
Block a user