Well with the hunger and drowning they way they play a sound is by having it created damage with a sound added too it.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
if player:get_hp() > 0 then
player:set_hp(player:get_hp() - DROWNING_DAMAGE)
pos = player:getpos()
pos.y=pos.y+1
minetest.sound_play({name="drowning_gurp"}, {pos = pos, gain = 1.0, max_hear_distance = 16})
This is a good work around for something that is missing from the API, but I do wonder how you would add it to something like falling. I could see this work around working for getting hit by a mod that you have created.
The deathsound mod was exactly what I was looking to do.
I think I made an improvement for its code changing it from
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_on_dieplayer(function(player)
local pname = player:getpos()
minetest.sound_play({name="ds_hurt"}, {pos = pname, gain = 0.5, max_hear_distance = 8})
end)
to
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_on_dieplayer(function(player)
minetest.sound_play({name="ds_hurt"}, {to_player, gain = 0.5, max_hear_distance = 8})
end)
but I am not sure if max_hear_distance still applies when using to_player.
Microsuperman