mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2024-12-24 09:40:30 +01:00
added icecrack sound and tidied code
This commit is contained in:
parent
095387c6dd
commit
75318194f4
@ -11,5 +11,6 @@ Based on Immersive Sounds .36 mod by Neuromancer and optimized to run on servers
|
|||||||
- 0.7 - Code tweaks and added Jungle sounds for day and night time
|
- 0.7 - Code tweaks and added Jungle sounds for day and night time
|
||||||
- 0.8 - Override default water sounds for 0.4.14 dev and above, add separate gain for each sound
|
- 0.8 - Override default water sounds for 0.4.14 dev and above, add separate gain for each sound
|
||||||
- 0.9 - Plays music files on server or local client when found at midnight, files to be named "ambience_music.1.ogg" changing number each up to 9.
|
- 0.9 - Plays music files on server or local client when found at midnight, files to be named "ambience_music.1.ogg" changing number each up to 9.
|
||||||
|
- 1.0 - Added icecrack sound when walking on snow/ice flows, also tidied code
|
||||||
|
|
||||||
Code license: MIT
|
Code license: MIT
|
||||||
|
38
init.lua
38
init.lua
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
--= Ambience lite by TenPlus1 (6th July 2017)
|
--= Ambience lite by TenPlus1 (23rd August 2017)
|
||||||
|
|
||||||
local max_frequency_all = 1000 -- larger number means more frequent sounds (100-2000)
|
local max_frequency_all = 1000 -- larger number means more frequent sounds (100-2000)
|
||||||
local SOUNDVOLUME = 1.0
|
local SOUNDVOLUME = 1.0
|
||||||
@ -12,7 +12,6 @@ minetest.override_item("default:river_water_source", { sounds = {} })
|
|||||||
minetest.override_item("default:river_water_flowing", { sounds = {} })
|
minetest.override_item("default:river_water_flowing", { sounds = {} })
|
||||||
|
|
||||||
-- music settings
|
-- music settings
|
||||||
local music_frequency = 100
|
|
||||||
local music_handler = nil
|
local music_handler = nil
|
||||||
local MUSICVOLUME = 1
|
local MUSICVOLUME = 1
|
||||||
local play_music = minetest.setting_getbool("ambience_music") ~= false
|
local play_music = minetest.setting_getbool("ambience_music") ~= false
|
||||||
@ -119,9 +118,14 @@ local jungle_night = {
|
|||||||
{name = "frog", length = 1},
|
{name = "frog", length = 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local ice = {
|
||||||
|
handler = {}, frequency = 250,
|
||||||
|
{name = "icecrack", length = 23},
|
||||||
|
}
|
||||||
|
|
||||||
local radius = 6
|
local radius = 6
|
||||||
local num_fire, num_lava, num_water_flowing, num_water_source, num_air,
|
local num_fire, num_lava, num_water_flowing, num_water_source, num_air,
|
||||||
num_desert, num_snow, num_jungletree, num_river, num_obsidian
|
num_desert, num_snow, num_jungletree, num_river, num_ice
|
||||||
|
|
||||||
-- check where player is and which sounds are played
|
-- check where player is and which sounds are played
|
||||||
local get_ambience = function(player)
|
local get_ambience = function(player)
|
||||||
@ -162,11 +166,13 @@ local get_ambience = function(player)
|
|||||||
|
|
||||||
--= START Ambiance
|
--= START Ambiance
|
||||||
|
|
||||||
|
-- head underwater
|
||||||
if minetest.registered_nodes[nod_head]
|
if minetest.registered_nodes[nod_head]
|
||||||
and minetest.registered_nodes[nod_head].groups.water then
|
and minetest.registered_nodes[nod_head].groups.water then
|
||||||
return {underwater = underwater}
|
return {underwater = underwater}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- wading through water
|
||||||
if minetest.registered_nodes[nod_feet].groups.water then
|
if minetest.registered_nodes[nod_feet].groups.water then
|
||||||
|
|
||||||
local control = player:get_player_control()
|
local control = player:get_player_control()
|
||||||
@ -182,7 +188,7 @@ local get_ambience = function(player)
|
|||||||
{
|
{
|
||||||
"fire:basic_flame", "fire:permanent_flame",
|
"fire:basic_flame", "fire:permanent_flame",
|
||||||
"default:lava_flowing", "default:lava_source", "default:jungletree",
|
"default:lava_flowing", "default:lava_source", "default:jungletree",
|
||||||
"default:water_flowing", "default:water_source",
|
"default:water_flowing", "default:water_source", "default:ice",
|
||||||
"default:river_water_flowing", "default:river_water_source",
|
"default:river_water_flowing", "default:river_water_source",
|
||||||
"default:desert_sand", "default:desert_stone", "default:snowblock"
|
"default:desert_sand", "default:desert_stone", "default:snowblock"
|
||||||
})
|
})
|
||||||
@ -195,7 +201,7 @@ local get_ambience = function(player)
|
|||||||
num_snow = (cn["default:snowblock"] or 0)
|
num_snow = (cn["default:snowblock"] or 0)
|
||||||
num_jungletree = (cn["default:jungletree"] or 0)
|
num_jungletree = (cn["default:jungletree"] or 0)
|
||||||
num_river = (cn["default:river_water_source"] or 0) + (cn["default:river_water_flowing"] or 0)
|
num_river = (cn["default:river_water_source"] or 0) + (cn["default:river_water_flowing"] or 0)
|
||||||
|
num_ice = (cn["default:ice"] or 0)
|
||||||
--[[
|
--[[
|
||||||
print (
|
print (
|
||||||
"fr:" .. num_fire,
|
"fr:" .. num_fire,
|
||||||
@ -204,10 +210,10 @@ print (
|
|||||||
"ws:" .. num_water_source,
|
"ws:" .. num_water_source,
|
||||||
"ds:" .. num_desert,
|
"ds:" .. num_desert,
|
||||||
"sn:" .. num_snow,
|
"sn:" .. num_snow,
|
||||||
|
"ic:" .. num_ice,
|
||||||
"jt:" .. num_jungletree
|
"jt:" .. num_jungletree
|
||||||
)
|
)
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- is fire redo mod active?
|
-- is fire redo mod active?
|
||||||
if fire and fire.mod and fire.mod == "redo" then
|
if fire and fire.mod and fire.mod == "redo" then
|
||||||
|
|
||||||
@ -219,55 +225,70 @@ print (
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- lava
|
||||||
if num_lava > 5 then
|
if num_lava > 5 then
|
||||||
return {lava = lava}
|
return {lava = lava}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- flowing water
|
||||||
if num_water_flowing > 30 then
|
if num_water_flowing > 30 then
|
||||||
return {flowing_water = flowing_water}
|
return {flowing_water = flowing_water}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- flowing river
|
||||||
if num_river > 30 then
|
if num_river > 30 then
|
||||||
return {river = river}
|
return {river = river}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- sea level beach
|
||||||
if pos.y < 7 and pos.y > 0
|
if pos.y < 7 and pos.y > 0
|
||||||
and num_water_source > 100 then
|
and num_water_source > 100 then
|
||||||
return {beach = beach}
|
return {beach = beach}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ice flows
|
||||||
|
if num_ice > 100 and num_snow > 100 then
|
||||||
|
return {ice = ice}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- desert
|
||||||
if num_desert > 150 then
|
if num_desert > 150 then
|
||||||
return {desert = desert}
|
return {desert = desert}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- high up or surrounded by snow
|
||||||
if pos.y > 60
|
if pos.y > 60
|
||||||
or num_snow > 150 then
|
or num_snow > 150 then
|
||||||
return {high_up = high_up}
|
return {high_up = high_up}
|
||||||
end
|
end
|
||||||
|
|
||||||
if pos.y < -10 then
|
-- underground
|
||||||
|
if pos.y < -15 then
|
||||||
return {cave = cave}
|
return {cave = cave}
|
||||||
end
|
end
|
||||||
|
|
||||||
if tod > 0.2
|
if tod > 0.2
|
||||||
and tod < 0.8 then
|
and tod < 0.8 then
|
||||||
|
|
||||||
|
-- jungle day time
|
||||||
if num_jungletree > 90 then
|
if num_jungletree > 90 then
|
||||||
return {jungle = jungle}
|
return {jungle = jungle}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- normal day time
|
||||||
return {day = day}
|
return {day = day}
|
||||||
else
|
else
|
||||||
|
|
||||||
|
-- jungle night time
|
||||||
if num_jungletree > 90 then
|
if num_jungletree > 90 then
|
||||||
return {jungle_night = jungle_night}
|
return {jungle_night = jungle_night}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- normal night time
|
||||||
return {night = night}
|
return {night = night}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- END Ambiance
|
-- END Ambiance
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- play sound, set handler then delete handler when sound finished
|
-- play sound, set handler then delete handler when sound finished
|
||||||
@ -330,6 +351,7 @@ local still_playing = function(still_playing, player_name)
|
|||||||
if not still_playing.largefire then stop_sound(largefire, player_name) end
|
if not still_playing.largefire then stop_sound(largefire, player_name) end
|
||||||
if not still_playing.jungle then stop_sound(jungle, player_name) end
|
if not still_playing.jungle then stop_sound(jungle, player_name) end
|
||||||
if not still_playing.jungle_night then stop_sound(jungle_night, player_name) end
|
if not still_playing.jungle_night then stop_sound(jungle_night, player_name) end
|
||||||
|
if not still_playing.ice then stop_sound(ice, player_name) end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- player routine
|
-- player routine
|
||||||
|
@ -101,3 +101,5 @@ http://www.jamendo.com/en/track/904016/in-search-of-the-soul
|
|||||||
http://www.freesfx.co.uk/soundeffects/forests-jungles/
|
http://www.freesfx.co.uk/soundeffects/forests-jungles/
|
||||||
|
|
||||||
zero-project
|
zero-project
|
||||||
|
|
||||||
|
icecrack.ogg by figowitz (http://freesound.org/people/Figowitz/sounds/67881/)
|
||||||
|
BIN
sounds/icecrack.ogg
Normal file
BIN
sounds/icecrack.ogg
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user