flowing water sound is now much better and faster thanks to @asl97

This commit is contained in:
kaadmy 2015-10-02 09:44:25 -07:00
parent 4e1d67f919
commit a9d7c328ad
2 changed files with 34 additions and 17 deletions

View File

@ -310,21 +310,21 @@ minetest.register_abm( -- weak torchs burn out and die after ~3 minutes
end
})
if minetest.setting_getbool("flowing_water_sounds") then
minetest.register_abm( -- river water makes gurgling noises
{
nodenames = {"group:flowing_water"},
interval = 1,
chance = 16,
action = function(pos, node)
minetest.sound_play(
"default_water",
{
pos = pos,
gain = 0.2,
})
end
})
end
-- if minetest.setting_getbool("flowing_water_sounds") then
-- minetest.register_abm( -- river water makes gurgling noises
-- {
-- nodenames = {"group:flowing_water"},
-- interval = 1,
-- chance = 16,
-- action = function(pos, node)
-- minetest.sound_play(
-- "default_water",
-- {
-- pos = pos,
-- gain = 0.2,
-- })
-- end
-- })
-- end
default.log("functions", "loaded")

View File

@ -2,6 +2,8 @@ local player_soundspec = {}
local player_lastsound = {}
local player_health = {}
local enable_flowing_water_sound = minetest.setting_getbool("enable_flowing_water_sound")
local function step(dtime)
for _, player in ipairs(minetest.get_connected_players()) do
local player_pos=player:getpos()
@ -34,6 +36,11 @@ local function step(dtime)
player_lastsound[name] = player_lastsound[name] + dtime
local flowing_water_pos = nil
if enable_flowing_water_sound then
flowing_water_pos = minetest.find_node_near(player_pos, 16, "group:flowing_water")
end
if nodename == "default:water_source" or nodename == "default:river_water_source" then
if player_lastsound[name] > 3.3 then
player_soundspec[name]=minetest.sound_play(
@ -44,6 +51,16 @@ local function step(dtime)
})
player_lastsound[name] = 0
end
elseif flowing_water_pos then
if player_lastsound[name] > 3.3 then
player_soundspec[name]=minetest.sound_play(
"default_water",
{
pos = flowing_water_pos,
max_hear_distance = 16,
})
player_lastsound[name] = 0
end
else
if player_soundspec[name] ~= nil then
minetest.sound_stop(player_soundspec[name])
@ -70,7 +87,7 @@ local function on_joinplayer(player)
-- uncomment to enable player-on-player collisions
-- player:set_properties({physical = true})
-- uncomment to disable the sneak glitch
-- uncomment to disable the sneak glitch
player:set_physics_override({sneak_glitch = false})
end