Also play 'win' sound when winning by player leave
This commit is contained in:
parent
2093f66589
commit
5de260dd98
31
auto.lua
31
auto.lua
@ -140,6 +140,9 @@ arena_lib.on_death('tntrun', function(arena, p_name, reason)
|
||||
end)
|
||||
|
||||
arena_lib.on_eliminate('tntrun', function(arena, p_name)
|
||||
-- Play elimination sound when player eliminated
|
||||
-- and lose sound to the player who got
|
||||
-- eliminated
|
||||
minetest.sound_play('tntrun_lose', {
|
||||
to_player = p_name,
|
||||
gain = 2.0,
|
||||
@ -151,7 +154,10 @@ arena_lib.on_eliminate('tntrun', function(arena, p_name)
|
||||
count = count + 1
|
||||
end
|
||||
if count == 1 then
|
||||
sound = 'tntrun_win'
|
||||
-- No elimination sound for the last
|
||||
-- player; they'll get the win sound
|
||||
-- in celebration
|
||||
return
|
||||
end
|
||||
|
||||
local player = minetest.get_player_by_name(p_name)
|
||||
@ -164,7 +170,28 @@ arena_lib.on_eliminate('tntrun', function(arena, p_name)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
-- Play win sound to winners
|
||||
arena_lib.on_celebration('tntrun', function(arena, winners)
|
||||
local winners_list = {}
|
||||
if type(winners) == "string" then
|
||||
winners_list = {winners}
|
||||
elseif type(winners) == "table" then
|
||||
winners_list = winners
|
||||
elseif winners == nil then
|
||||
return
|
||||
else
|
||||
minetest.log("error", "[tntrun] winners in on_celebration is neither a string, table or nil")
|
||||
return winners
|
||||
end
|
||||
for w=1, #winners_list do
|
||||
local p_name = winners_list[w]
|
||||
minetest.sound_play('tntrun_win', {
|
||||
to_player = p_name,
|
||||
gain = 1.0,
|
||||
}, true)
|
||||
end
|
||||
return winners
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
|
Loading…
x
Reference in New Issue
Block a user