.16 adds seagulls, waves, and fixed chat bug of .15

also includes .14 which added lava and an improvement for flowing water
detection.
This commit is contained in:
Neuromancer 2012-08-28 18:37:49 -05:00
parent 71f241f848
commit e852030bc8
10 changed files with 423 additions and 683 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
--------------------------------------------------------------------------------------------------------
--Ambiance Configuration for version .13
--Ambiance Configuration for version .16
local max_frequency_all = 1000 --the larger you make this number the lest frequent ALL sounds will happen recommended values between 100-2000.
@ -17,6 +17,10 @@ local cave_frequency = 10 --bats
local cave_volume = 1.0
local cave_frequent_frequency = 70 --drops of water dripping
local cave_frequent_volume = 1.0
local beach_frequency = 20 --seagulls
local beach_volume = 1.0
local beach_frequent_frequency = 1000 --waves
local beach_frequent_volume = 1.0
local water_frequent_frequency = 1000 --water sounds
local water_frequent_volume = 1.0
local music_frequency = 7 --music (suggestion: keep this one low like around 6)
@ -76,6 +80,19 @@ local cave_frequent = {
{name="Spooky_Water_Drops", length=7, gain=cave_frequent_volume}
}
local beach = {
handler = {},
frequency = beach_frequency,
{name="seagull", length=4.5, gain=beach_volume}
}
local beach_frequent = {
handler = {},
frequency = beach_frequent_frequency,
{name="fiji_beach", length=43.5, gain=beach_frequent_volume}
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
@ -98,8 +115,25 @@ local water_frequent = {
local flowing_water = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=14},
{name="small_waterfall", length=14, gain=.4}
}
local flowing_water2 = {
handler = {},
frequency = 1000,
{name="small_waterfall", length=11, gain=.3}
}
local lava = {
handler = {},
frequency = 1000,
{name="earth01a", length=20}
}
local lava2 = {
handler = {},
frequency = 1000,
{name="earth01a", length=15}
}
local play_music = minetest.setting_getbool("music") or false
local music = {
@ -117,6 +151,7 @@ local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
--[[old
local nodes_in_range = function(pos, search_distance, node_name)
local search_p = {x=0, y=0, z=0}
local nodes_found = 0
@ -132,8 +167,17 @@ local nodes_in_range = function(pos, search_distance, node_name)
end
return nodes_found
--minetest.chat_send_all("Range: " .. tostring(search_distance) .. " | Found (" .. node_name .. ": " .. nodes_found .. ")")
end --]]
local nodes_in_range = function(pos, search_distance, node_name)
minp = {x=pos.x-search_distance,y=pos.y-search_distance, z=pos.z-search_distance}
maxp = {x=pos.x+search_distance,y=pos.y+search_distance, z=pos.z+search_distance}
nodes = minetest.env:find_nodes_in_area(minp, maxp, node_name)
-- minetest.chat_send_all("Found (" .. node_name .. ": " .. #nodes .. ")")
return #nodes
end
local get_ambience = function(player)
local pos = player:getpos()
pos.y = pos.y+1.0
@ -145,11 +189,28 @@ local get_ambience = function(player)
return {water=water, water_frequent=water_frequent}
end
end
if nodes_in_range(pos, 5, "default:water_flowing")>5 then
if nodes_in_range(pos, 7, "default:lava_flowing")>5 or nodes_in_range(pos, 7, "default:lava_source")>5 then
if music then
return {flowing_water=flowing_water, music=music}
return {lava=lava, lava2=lava2, music=music}
else
return {flowing_water=flowing_water}
return {lava=lava}
end
end
if nodes_in_range(pos, 7, "default:water_flowing")>5 then
if music then
return {flowing_water=flowing_water, flowing_water2=flowing_water2, music=music}
else
return {flowing_water=flowing_water, flowing_water2=flowing_water2}
end
end
pos.y = pos.y-2
nodename = minetest.env:get_node(pos).name
--minetest.chat_send_all("Found " .. nodename .. pos.y )
if string.find(nodename, "default:sand") and pos.y < 5 then
if music then
return {beach=beach, beach_frequent=beach_frequent, music=music}
else
return {beach=beach, beach_frequent=beach_frequent}
end
end
if player:getpos().y < 0 then
@ -220,6 +281,27 @@ local stop_sound = function(still_playing, player)
list.handler[player_name] = nil
end
end
if still_playing.beach == nil then
local list = beach
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.beach_frequent == nil then
local list = beach_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
@ -280,6 +362,36 @@ local stop_sound = function(still_playing, player)
list.handler[player_name] = nil
end
end
if still_playing.flowing_water2 == nil then
local list = flowing_water2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava == nil then
local list = lava
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.lava2 == nil then
local list = lava2
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then

View File

@ -1,54 +0,0 @@
local night = {"Crickets_At_NightCombo", "horned_owl", "Wolves_Howling"}
local day = {"bird"}
local cave = {"Bats_in_Cave","drippingwater_drip.1","drippingwater_drip.2","drippingwater_drip.3", "Single_Water_Droplet", "Spooky_Water_Drops"}
math.randomseed(3)
sound_playing = 0
minetest.register_globalstep(function(time)
local time = minetest.env:get_timeofday()
-- minetest.chat_send_all(time .. " " .. sound_playing)
if sound_playing == 0 then
sound_playing = time
end
if sound_playing > 1 and time < 0.05 then
sound_playing = 0.05
end
for _,player in ipairs(minetest.get_connected_players()) do
if player:getpos().y < 0 then
if math.random(10000) >9980 then
minetest.sound_play(cave[math.random(1, #cave)], {to_player = player:get_player_name()})
end
else
--random wolves & owls at night
if time > 0.8 or time < 0.2 then
if math.random(10000) >9997 then
minetest.sound_play("Wolves_Howling")
end
if math.random(10000) >9997 then
minetest.sound_play("horned_owl")
end
end
if time > sound_playing then
if time > 0.8 or time < 0.2 then
sound_playing = time + 0.07
minetest.sound_play("Crickets_At_NightCombo")
return true
end
sound_playing = time + 0.1
minetest.sound_play("bird")
return true
end
end
end
end)

287
ambience/init.lua.pilz.lua Normal file
View File

@ -0,0 +1,287 @@
local night = {
handler = {},
frequency = 10,
{name="horned_owl", length=3},
{name="Wolves_Howling", length=11},
{name="ComboWind", length=17},
}
local night_frequent = {
handler = {},
frequency = 25,
{name="Crickets_At_NightCombo", length=69},
}
local day = {
handler = {},
frequency = 5,
{name="Best Cardinal Bird", length=4},
{name="craw", length=3},
{name="bluejay", length=18},
{name="ComboWind", length=17},
}
local day_frequent = {
handler = {},
frequency = 25,
{name="robin2", length=16},
{name="birdsongnl", length=12.5},
{name="bird", length=30},
}
local cave = {
handler = {},
frequency = 5,
{name="Bats_in_Cave", length=5},
}
local cave_frequent = {
handler = {},
frequency = 100,
{name="drippingwater_drip_a", length=2},
{name="drippingwater_drip_b", length=2},
{name="drippingwater_drip_c", length=2},
{name="Single_Water_Droplet", length=3},
{name="Spooky_Water_Drops", length=7},
}
local water = {
handler = {},
frequency = 0,--dolphins dont fit into small lakes
{name="dolphins", length=6},
{name="dolphins_screaming", length=16.5},
}
local water_frequent = {
handler = {},
frequency = 100,
on_stop = "drowning_gasp",
{name="scuba1bubbles", length=11},
{name="scuba1calm", length=10},
{name="scuba1calm2", length=8.5},
{name="scuba1interestingbubbles", length=11},
{name="scuba1tubulentbubbles", length=10.5},
}
local splash = {
handler = {},
frequency = 100,
{name="Splash", length=1.5},
}
local play_music = minetest.setting_getbool("music") or false
local music = {
handler = {},
frequency = 1,
{name="mtest", length=4*60+33, gain=0.3},
{name="music_1", length=1*60+52, gain=0.3},
{name="ambiance", length=19, gain=0.3},
{name="dark_ambiance", length=46, gain=0.3},
{name="eastern_feeling", length=3*60+51, gain=0.3},
{name="echos", length=2*60+26, gain=0.3},
{name="FoamOfTheSea", length=1*60+50, gain=0.3},
}
local is_daytime = function()
return (minetest.env:get_timeofday() > 0.2 and minetest.env:get_timeofday() < 0.8)
end
local get_ambience = function(player)
local table = {}
local play_water = false
local play_splash = false
local play_day = false
local play_cave = false
local play_night = false
local pos = player:getpos()
pos.y = pos.y+1.5
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
play_water = true
elseif nodename == "air" then
pos.y = pos.y-1.5
local nodename = minetest.env:get_node(pos).name
if string.find(nodename, "default:water") then
play_splash = true
end
end
if player:getpos().y < 0 then
play_cave = true
elseif is_daytime() then
play_day = true
else
play_night = true
end
if play_music then
table.music = music
end
if play_water then
table.water = water
table.water_frequent = water_frequent
return table
end
if play_splash then
table.splash = splash
end
if play_day then
table.day = day
table.day_frequent = day_frequent
elseif play_night then
table.night = night
table.night_frequent = night_frequent
elseif play_cave then
table.cave = cave
table.cave_frequent = cave_frequent
end
return table
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local gain = 1.0
if list[number].gain ~= nil then
gain = list[number].gain
end
local handler = minetest.sound_play(list[number].name, {to_player=player_name, gain=gain})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.music == nil then
local list = music
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water == nil then
local list = water
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.water_frequent == nil then
local list = water_frequent
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.splash == nil then
local list = splash
if list.handler[player_name] ~= nil then
if list.on_stop ~= nil then
minetest.sound_play(list.on_stop, {to_player=player:get_player_name()})
end
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 1 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
local ambiences = get_ambience(player)
stop_sound(ambiences, player)
for _,ambience in pairs(ambiences) do
if math.random(1, 100) <= ambience.frequency then
play_sound(player, ambience, math.random(1, #ambience))
end
end
end
end)

View File

@ -1,467 +0,0 @@
-- ***********************************************************************************
-- ***********************************************
-- 4SEASONS **************************************************
-- ***********************************************
-- ***********************************************************************************
SEASON_LENGTH = 1500 -- max tested 1500
WEATHER_CHANGE_INTERVAL = 60
BIRDS = true
PLANTLIKE = function(nodeid, nodename,type,option)
if option == nil then option = false end
local params ={ description = nodename, drawtype = "plantlike", tile_images = {"4seasons_"..nodeid..'.png'},
inventory_image = "4seasons_"..nodeid..'.png', wield_image = "4seasons_"..nodeid..'.png', paramtype = "light", }
if type == 'veg' then
params.groups = {snappy=2,dig_immediate=3,flammable=2}
params.sounds = default.node_sound_leaves_defaults()
if option == false then params.walkable = false end
elseif type == 'met' then -- metallic
params.groups = {cracky=3}
params.sounds = default.node_sound_stone_defaults()
elseif type == 'cri' then -- craft items
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
params.sounds = default.node_sound_wood_defaults()
if option == false then params.walkable = false end
elseif type == 'eat' then -- edible
params.groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=3}
params.sounds = default.node_sound_wood_defaults()
params.walkable = false
params.on_use = minetest.item_eat(option)
end
minetest.register_node("4seasons:"..nodeid, params)
end
-- ***********************************************************************************
-- SEASONAL CHANGES **************************************************
-- ***********************************************************************************
SEASON_FILE = minetest.get_worldpath()..'/4seasons.season'
local function set_season(t)
CURRENT_SEASON = t
-- write to file
local f = io.open(SEASON_FILE, "w")
f:write(CURRENT_SEASON)
io.close(f)
end
local f = io.open(SEASON_FILE, "r")
if f ~= nil then
CURRENT_SEASON = f:read("*n")
io.close(f)
else
print('could not find season file, creating one (setting summer).')
set_season(3)
end
switch_seasons = function()
if CURRENT_SEASON == 1 then
set_season(2) -- set to spring
print('changing to spring')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 2 then
set_season(3) -- set to summer
print('changing to summer')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 3 then
set_season(4) -- set to autumn
print('changing to autumn')
minetest.after(SEASON_LENGTH,switch_seasons)
elseif CURRENT_SEASON == 4 then
set_season(1) -- set to winter
print('changing to winter')
minetest.after(SEASON_LENGTH,switch_seasons)
end
end
minetest.after(SEASON_LENGTH,switch_seasons)
minetest.register_chatcommand("season", {
params = "<season>",
description = "set the season",
privs = {server=true},
func = function(name, param)
if param == 'winter' or param == 'Winter' then set_season(1)
elseif param == 'spring' or param == 'Spring' then set_season(2)
elseif param == 'summer' or param == 'Summer' then set_season(3)
elseif param == 'fall' or param == 'Fall' then set_season(4)
elseif param == 'pause' or param == 'Pause' then set_season(0)
minetest.chat_send_player(name, "Season paused.")
return
else
minetest.chat_send_player(name, "Invalid paramater '"..param.."', try 'winter','spring','summer' or 'fall'.")
return
end
minetest.chat_send_player(name, "Season changed.")
end,
})
minetest.register_abm({
nodenames = { "default:dirt_with_grass","4seasons:grass_autumn",'4seasons:grass_winter',"4seasons:grass_spring",
'default:leaves','4seasons:leaves_autumn','4seasons:leaves_winter','4seasons:leaves_spring',
"default:water_source","default:water_flowing", "default:cactus","default:desert_sand","default:sand","4seasons:desertsand_winter", "4seasons:sand_winter","4seasons:cactus_winter",'4seasons:ice_source','4seasons:ice_flowing' },
interval = WEATHER_CHANGE_INTERVAL,
chance = 6,
action = function(pos, node, active_object_count, active_object_count_wider)
if CURRENT_SEASON == 1 then
if node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' then
minetest.env:add_node(pos,{type="node",name='4seasons:grass_winter'})
elseif node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' then
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_winter'})
elseif node.name == 'default:desert_sand' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='4seasons:desertsand_winter'})
end
elseif node.name == 'default:sand' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='4seasons:sand_winter'})
end
elseif node.name == 'default:cactus' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='4seasons:cactus_winter'})
end
elseif node.name == 'default:water_source' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='4seasons:ice_source'})
end
elseif node.name == 'default:water_flowing' then
above = minetest.env:get_node_or_nil({x=pos.x,y=pos.y+1,z=pos.z})
if above ~= nil and above.name == 'air' then
minetest.env:add_node(pos,{type="node",name='4seasons:ice_flowing'})
end
end
elseif CURRENT_SEASON == 2 then
if node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' or node.name == 'default:dirt_with_grass' then
minetest.env:add_node(pos,{type="node",name='4seasons:grass_spring'})
elseif node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' or node.name == 'default:leaves' then
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_spring'})
elseif node.name == '4seasons:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == '4seasons:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == '4seasons:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == '4seasons:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == '4seasons:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
elseif CURRENT_SEASON == 3 then
if node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' or node.name == '4seasons:leaves_autumn' then
minetest.env:add_node(pos,{type="node",name='default:leaves'})
elseif node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' or node.name == '4seasons:grass_autumn' then
minetest.env:add_node(pos,{type="node",name='default:dirt_with_grass'})
elseif node.name == '4seasons:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == '4seasons:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == '4seasons:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == '4seasons:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == '4seasons:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
elseif CURRENT_SEASON == 4 then
if node.name == 'default:leaves' or node.name == '4seasons:leaves_spring' or node.name == '4seasons:leaves_winter' then
minetest.env:add_node(pos,{type="node",name='4seasons:leaves_autumn'})
elseif node.name == 'default:dirt_with_grass' or node.name == '4seasons:grass_spring' or node.name == '4seasons:grass_winter' then
minetest.env:add_node(pos,{type="node",name='4seasons:grass_autumn'})
elseif node.name == '4seasons:desertsand_winter' then
minetest.env:add_node(pos,{type="node",name='default:desert_sand'})
elseif node.name == '4seasons:sand_winter' then
minetest.env:add_node(pos,{type="node",name='default:sand'})
elseif node.name == '4seasons:cactus_winter' then
minetest.env:add_node(pos,{type="node",name='default:cactus'})
elseif node.name == '4seasons:ice_source' then
minetest.env:add_node(pos,{type="node",name='default:water_source'})
elseif node.name == '4seasons:ice_flowing' then
minetest.env:add_node(pos,{type="node",name='default:water_flowing'})
end
end
end
})
-- ***********************************************************************************
-- BIRDS SPRING/SUMMER **************************************************
-- ***********************************************************************************
if BIRDS == true then
local bird = {}
bird.sounds = {}
bird_sound = function(p)
local wanted_sound = {name="bird", gain=0.6}
bird.sounds[minetest.hash_node_position(p)] = {
handle = minetest.sound_play(wanted_sound, {pos=p, loop=true}),
name = wanted_sound.name, }
end
bird_stop = function(p)
local sound = bird.sounds[minetest.hash_node_position(p)]
if sound ~= nil then
minetest.sound_stop(sound.handle)
bird.sounds[minetest.hash_node_position(p)] = nil
end
end
minetest.register_on_dignode(function(p, node)
if node.name == "4seasons:bird" then
bird_stop(p)
end
end)
minetest.register_abm({
nodenames = { "4seasons:leaves_spring",'default:leaves' },
interval = NATURE_GROW_INTERVAL,
chance = 200,
action = function(pos, node, active_object_count, active_object_count_wider)
local air = { x=pos.x, y=pos.y+1,z=pos.z }
local is_air = minetest.env:get_node_or_nil(air)
if is_air ~= nil and is_air.name == 'air' then
minetest.env:add_node(air,{type="node",name='4seasons:bird'})
bird_sound(air)
end
end
})
minetest.register_abm({
nodenames = {'4seasons:bird' },
interval = NATURE_GROW_INTERVAL,
chance = 2,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:remove_node(pos)
bird_stop(pos)
end
})
end
-- ***********************************************************************************
-- SLIMTREES **************************************************
-- ***********************************************************************************
minetest.register_abm({
nodenames = { "4seasons:slimtree" },
interval = 120,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x+1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+3,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+4,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+5,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z-1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+6,z=pos.z},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z+1},{type="node",name="default:leaves"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z-1},{type="node",name="default:leaves"})
end
})
-- ***********************************************************************************
-- PALM TREES **************************************************
-- ***********************************************************************************
minetest.register_abm({
nodenames = { "4seasons:palmtree" },
interval = 120,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+1,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+2,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+3,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+4,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+5,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+6,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+7,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z},{type="node",name="4seasons:slimtree_wood"})
minetest.env:add_node({x=pos.x+2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x-2,y=pos.y+8,z=pos.z},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z+2},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+8,z=pos.z-2},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x+1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x-1,y=pos.y+9,z=pos.z},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z+1},{type="node",name="4seasons:palmleaves"})
minetest.env:add_node({x=pos.x,y=pos.y+9,z=pos.z-1},{type="node",name="4seasons:palmleaves"})
end
})
-- ***********************************************************************************
-- NODES **************************************************
-- ***********************************************************************************
PLANTLIKE('palmtree','Palmtree Sapling','veg')
PLANTLIKE('slimtree','Slimtree Sapling','veg')
PLANTLIKE('bird','Bird','veg')
minetest.register_node("4seasons:palmleaves", {
description = "Rail",
drawtype = "raillike",
tile_images = {"4seasons_palmleaves.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png", "4seasons_palmleaves_top.png"},
inventory_image = "4seasons_palmleaves.png",
wield_image = "4seasons_palmleaves.png",
paramtype = "light",
is_ground_content = true,
walkable = false,
selection_box = {
type = "fixed",
--fixed = <default>
},
groups = {bendy=2,snappy=1,dig_immediate=2},
})
minetest.register_node("4seasons:slimtree_wood", {
description = "Slimtree",
drawtype = "fencelike",
tile_images = {"default_tree.png"},
-- inventory_image = "default_tree.png",
-- wield_image = "default_tree.png",
paramtype = "light",
is_ground_content = true,
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {tree=1,snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
sounds = default.node_sound_wood_defaults(),
drop = 'default:fence_wood',
})
minetest.register_node("4seasons:ice_source", {
description = "Ice",
tile_images = {"4seasons_ice.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("4seasons:ice_flowing", {
description = "Ice",
tile_images = {"4seasons_ice.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("4seasons:leaves_autumn", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"4seasons_leaves_autumn.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'4seasons:leaves_autumn'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("4seasons:leaves_spring", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"4seasons_leaves_spring.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'4seasons:leaves_spring'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("4seasons:grass_spring", {
description = "Dirt with snow",
tile_images = {"4seasons_grass_spring.png", "default_dirt.png", "default_dirt.png^4seasons_grass_spring_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("4seasons:grass_autumn", {
description = "Dirt with snow",
tile_images = {"4seasons_grass_autumn.png", "default_dirt.png", "default_dirt.png^4seasons_grass_autumn_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("4seasons:grass_winter", {
description = "Dirt with snow",
tile_images = {"4seasons_snow.png", "default_dirt.png", "default_dirt.png^4seasons_grass_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:dirt',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("4seasons:leaves_winter", {
description = "Leaves",
drawtype = "allfaces_optional",
visual_scale = 1.3,
tile_images = {"4seasons_leaves_with_snow.png"},
paramtype = "light",
groups = {snappy=3, leafdecay=3, flammable=2},
drop = {
max_items = 1, items = {
{items = {'default:sapling'}, rarity = 20,},
{items = {'4seasons:leaves_winter'},}
}},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("4seasons:cactus_winter", {
description = "Cactus",
tile_images = {"4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_top.png", "4seasons_cactus_wsnow_side.png"},
is_ground_content = true,
groups = {snappy=2,choppy=3,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("4seasons:sand_winter", {
description = "Sand with snow",
tile_images = {"4seasons_snow.png", "default_sand.png", "default_sand.png^4seasons_sand_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:sand',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})
minetest.register_node("4seasons:desertsand_winter", {
description = "Desert Sand with snow",
tile_images = {"4seasons_snow.png", "default_desert_sand.png", "default_desert_sand.png^4seasons_desertsand_w_snow_side.png"},
is_ground_content = true,
groups = {crumbly=3},
drop = 'default:desert_sand',
sounds = default.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.4},
}),
})

View File

@ -1,157 +0,0 @@
--PilzAdam, check out my post about creating a function to determine setting
local night = {
handler = {},
{name="horned_owl", length=3},
{name="horned_owl", length=3},
{name="horned_owl", length=3},
{name="Wolves_Howling", length=11}
}
local night_frequent = {
handler = {},
{name="Crickets_At_NightCombo", length=69}
}
local day = {
handler = {},
{name="Best Cardinal Bird", length=4},
{name="craw", length=3},
{name="bluejay", length=18}
}
local day_frequent = {
handler = {},
{name="robin2", length=43},
{name="birdsongnl", length=72},
{name="bird", length=30}
}
local cave = {
handler = {},
{name="Bats_in_Cave", length=5}
}
local cave_frequent = {
handler = {},
{name="drippingwater_dripa", length=2},
{name="drippingwater_dripb", length=2},
{name="drippingwater_dripc", length=2},
{name="Single_Water_Droplet", length=3},
{name="Spooky_Water_Drops", length=7}
}
local is_daytime = function()
local daytime
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.8 then
daytime = false
else
daytime = true
end
return daytime
end
local setting = function (player_parm)
local settinglist
if player_parm:getpos().y < 0 then
settinglist = {cave, cave_frequent}
else
if is_daytime then
settinglist = {day, day_frequent}
else
settinglist = {night, night_frequent}
end
end
return settinglist
end
-- start playing the sound, set the handler and delete the handler after sound is played
local play_sound = function(player, list, number)
local player_name = player:get_player_name()
if list.handler[player_name] == nil then
local handler = minetest.sound_play(list[number].name, {to_player=player_name})
if handler ~= nil then
list.handler[player_name] = handler
minetest.after(list[number].length, function(args)
local list = args[1]
local player_name = args[2]
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end, {list, player_name})
end
end
end
-- stops all sounds that are not in still_playing
local stop_sound = function(still_playing, player)
local player_name = player:get_player_name()
if still_playing.cave == nil then
local list = cave
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.cave_frequent == nil then
local list = cave_frequent
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night == nil then
local list = night
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.night_frequent == nil then
local list = night_frequent
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day == nil then
local list = day
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
if still_playing.day_frequent == nil then
local list = day_frequent
if list.handler[player_name] ~= nil then
minetest.sound_stop(list.handler[player_name])
list.handler[player_name] = nil
end
end
end
local timer = 0
minetest.register_globalstep(function(dtime)
timer = timer+dtime
if timer < 5 then
return
end
timer = 0
for _,player in ipairs(minetest.get_connected_players()) do
player_setting = setting(player)
-- normal sounds
if math.random(1, 100) <= 5 then --this 5 is what I am trying to change based on setting
stop_sound({player_setting}, player)--big problem here
play_sound(player, player_setting[1], math.random(1, #player_setting[0]))
end
-- frequent sounds
if math.random(1, 100) <= 50 then
stop_sound({player_setting}, player)--big problem here
play_sound(player, player_setting[2], math.random(1, #player_setting[1]))
end
end
)

View File

@ -65,7 +65,26 @@ ComboWind uses:
--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/,
----------------Not used yet:
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

Binary file not shown.

Binary file not shown.

BIN
ambience/sounds/seagull.ogg Normal file

Binary file not shown.