Fixed crash if no songs

master
Tmanyo 2018-01-09 20:56:01 -05:00 committed by GitHub
parent 3fa038ea03
commit 8997251dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 11 deletions

View File

@ -92,17 +92,19 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
local event = minetest.explode_textlist_event(fields.song_list)
if event.type == "CHG" then
if music_playing ~= nil then
music_playing = minetest.sound_stop(
music_playing)
end
if music_playing == nil then
song = music.list[event.index]:gsub(
"%.ogg", "")
music_playing = minetest.sound_play(song, {
gain = 10,
to_player = minetest.get_connected_players()
})
if #music.list >= 1 then
if music_playing ~= nil then
music_playing = minetest.sound_stop(
music_playing)
end
if music_playing == nil then
song = music.list[event.index]:gsub(
"%.ogg", "")
music_playing = minetest.sound_play(song, {
gain = 10,
to_player = minetest.get_connected_players()
})
end
end
end
end