mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2025-04-16 19:10:24 +02:00
Added jungle sound set, tweaked and tidied code
This commit is contained in:
parent
26df31fa8f
commit
222e7d8f12
72
init.lua
72
init.lua
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
--= Ambience lite by TenPlus1 (3rd March 2016)
|
--= Ambience lite by TenPlus1 (1st April 2016)
|
||||||
|
|
||||||
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
|
local SOUNDVOLUME = 1
|
||||||
@ -22,17 +22,18 @@ local day = {
|
|||||||
{name = "cardinal", length = 3},
|
{name = "cardinal", length = 3},
|
||||||
{name = "craw", length = 3},
|
{name = "craw", length = 3},
|
||||||
{name = "bluejay", length = 6},
|
{name = "bluejay", length = 6},
|
||||||
{name="canadianloon2", length = 14},
|
|
||||||
{name = "robin", length = 4},
|
{name = "robin", length = 4},
|
||||||
{name = "bird1", length = 11},
|
{name = "bird1", length = 11},
|
||||||
{name = "bird2", length = 6},
|
{name = "bird2", length = 6},
|
||||||
{name = "crestedlark", length = 6},
|
{name = "crestedlark", length = 6},
|
||||||
{name="peacock", length = 2}
|
{name = "peacock", length = 2},
|
||||||
|
{name = "wind", length = 9},
|
||||||
}
|
}
|
||||||
|
|
||||||
local high_up = {
|
local high_up = {
|
||||||
handler = {}, frequency = 40,
|
handler = {}, frequency = 40,
|
||||||
{name = "desertwind", length = 8},
|
{name = "desertwind", length = 8},
|
||||||
|
{name = "wind", length = 9},
|
||||||
}
|
}
|
||||||
|
|
||||||
local cave = {
|
local cave = {
|
||||||
@ -84,27 +85,20 @@ local largefire = {
|
|||||||
{name = "fire_large", length = 8}
|
{name = "fire_large", length = 8}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local jungle = {
|
||||||
|
handler = {}, frequency = 60,
|
||||||
|
{name = "jungle", length = 4},
|
||||||
|
{name = "deer", length = 7},
|
||||||
|
{name = "canadianloon2", length = 14},
|
||||||
|
{name = "bird1", length = 11},
|
||||||
|
{name = "bird2", length = 6},
|
||||||
|
{name = "peacock", length = 2},
|
||||||
|
{name = "bluejay", length = 6},
|
||||||
|
}
|
||||||
|
|
||||||
local radius = 6
|
local radius = 6
|
||||||
|
local num_fire, num_lava, num_water_flowing, num_water_source,
|
||||||
-- get node but use fallback for nil or unknown
|
num_desert, num_snow, num_jungletree
|
||||||
local function node_ok(pos, fallback)
|
|
||||||
|
|
||||||
fallback = fallback or "default:dirt"
|
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
|
||||||
|
|
||||||
if not node then
|
|
||||||
return fallback
|
|
||||||
end
|
|
||||||
|
|
||||||
local nodef = minetest.registered_nodes[node.name]
|
|
||||||
|
|
||||||
if nodef then
|
|
||||||
return node.name
|
|
||||||
end
|
|
||||||
|
|
||||||
return fallback
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 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)
|
||||||
@ -115,20 +109,20 @@ local get_ambience = function(player)
|
|||||||
|
|
||||||
-- what is around me?
|
-- what is around me?
|
||||||
pos.y = pos.y + 1.4 -- head level
|
pos.y = pos.y + 1.4 -- head level
|
||||||
local nod_head = node_ok(pos, "air")
|
local nod_head = minetest.get_node(pos).name
|
||||||
|
|
||||||
pos.y = pos.y - 1.2 -- foot level
|
pos.y = pos.y - 1.2 -- foot level
|
||||||
local nod_feet = node_ok(pos, "air")
|
local nod_feet = minetest.get_node(pos).name
|
||||||
|
|
||||||
pos.y = pos.y - 0.2 -- reset pos
|
pos.y = pos.y - 0.2 -- reset pos
|
||||||
|
|
||||||
--= START Ambiance
|
--= START Ambiance
|
||||||
|
|
||||||
if minetest.registered_nodes[nod_head].groups.water then
|
if minetest.get_item_group(nod_head, "water") > 0 then
|
||||||
return {underwater = underwater}
|
return {underwater = underwater}
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.registered_nodes[nod_feet].groups.water then
|
if minetest.get_item_group(nod_feet, "water") > 0 then
|
||||||
return {splash = splash}
|
return {splash = splash}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,18 +131,19 @@ local get_ambience = function(player)
|
|||||||
{x = pos.x + radius, y = pos.y + radius, z = pos.z + radius},
|
{x = pos.x + radius, y = pos.y + radius, z = pos.z + radius},
|
||||||
{
|
{
|
||||||
"fire:basic_flame", "fire:permanent_flame",
|
"fire:basic_flame", "fire:permanent_flame",
|
||||||
"default:lava_flowing", "default:lava_source",
|
"default:lava_flowing", "default:lava_source", "default:jungletree",
|
||||||
"default:water_flowing", "default:water_source",
|
"default:water_flowing", "default:water_source",
|
||||||
"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"
|
||||||
})
|
})
|
||||||
|
|
||||||
local num_fire = (cn["fire:basic_flame"] or 0) + (cn["fire:permanent_flame"] or 0)
|
num_fire = (cn["fire:basic_flame"] or 0) + (cn["fire:permanent_flame"] or 0)
|
||||||
local num_lava = (cn["default:lava_flowing"] or 0) + (cn["default:lava_source"] or 0)
|
num_lava = (cn["default:lava_flowing"] or 0) + (cn["default:lava_source"] or 0)
|
||||||
local num_water_flowing = (cn["default:water_flowing"] or 0) + (cn["default:river_water_flowing"] or 0)
|
num_water_flowing = (cn["default:water_flowing"] or 0) + (cn["default:river_water_flowing"] or 0)
|
||||||
local num_water_source = (cn["default:water_source"] or 0) + (cn["default:river_water_flowing"] or 0)
|
num_water_source = (cn["default:water_source"] or 0) + (cn["default:river_water_flowing"] or 0)
|
||||||
local num_desert = (cn["default:desert_sand"] or 0) + (cn["default:desert_stone"] or 0)
|
num_desert = (cn["default:desert_sand"] or 0) + (cn["default:desert_stone"] or 0)
|
||||||
local num_snow = (cn["default:snowblock"] or 0)
|
num_snow = (cn["default:snowblock"] or 0)
|
||||||
|
num_jungletree = (cn["default:jungletree"] or 0)
|
||||||
--[[
|
--[[
|
||||||
print (
|
print (
|
||||||
"fr:" .. num_fire,
|
"fr:" .. num_fire,
|
||||||
@ -156,7 +151,8 @@ print (
|
|||||||
"wf:" .. num_water_flowing,
|
"wf:" .. num_water_flowing,
|
||||||
"ws:" .. num_water_source,
|
"ws:" .. num_water_source,
|
||||||
"ds:" .. num_desert,
|
"ds:" .. num_desert,
|
||||||
"sn:" .. num_snow
|
"sn:" .. num_snow,
|
||||||
|
"jt:" .. num_jungletree
|
||||||
)
|
)
|
||||||
]]
|
]]
|
||||||
-- is fire redo mod active?
|
-- is fire redo mod active?
|
||||||
@ -200,6 +196,11 @@ print (
|
|||||||
|
|
||||||
if tod > 0.2
|
if tod > 0.2
|
||||||
and tod < 0.8 then
|
and tod < 0.8 then
|
||||||
|
|
||||||
|
if num_jungletree > 100 then
|
||||||
|
return {jungle = jungle}
|
||||||
|
end
|
||||||
|
|
||||||
return {day = day}
|
return {day = day}
|
||||||
else
|
else
|
||||||
return {night = night}
|
return {night = night}
|
||||||
@ -270,6 +271,7 @@ local still_playing = function(still_playing, player_name)
|
|||||||
if not still_playing.lava then stop_sound(lava, player_name) end
|
if not still_playing.lava then stop_sound(lava, player_name) end
|
||||||
if not still_playing.smallfire then stop_sound(smallfire, player_name) end
|
if not still_playing.smallfire then stop_sound(smallfire, player_name) end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
-- player routine
|
-- player routine
|
||||||
|
BIN
sounds/jungle.ogg
Normal file
BIN
sounds/jungle.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user