diff options
author | Aki <nthirtyone@gmail.com> | 2017-07-16 20:20:50 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-07-16 20:20:50 +0200 |
commit | b2c2ef1ae1300a2a2610525bf19db227d6d5e54b (patch) | |
tree | e8d66f64c8c4cf08c4e23fe311da05503dcaec27 | |
parent | e39c00b6e26504ba0f5fc4f0129bfceb3afe331f (diff) | |
download | roflnauts-b2c2ef1ae1300a2a2610525bf19db227d6d5e54b.zip roflnauts-b2c2ef1ae1300a2a2610525bf19db227d6d5e54b.tar.gz roflnauts-b2c2ef1ae1300a2a2610525bf19db227d6d5e54b.tar.bz2 |
Music doesn't stop on transition from any-menu to main-menu
-rw-r--r-- | config/menus/main.lua | 6 | ||||
-rw-r--r-- | not/MusicPlayer.lua | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/config/menus/main.lua b/config/menus/main.lua index 95e44ec..ae2cef2 100644 --- a/config/menus/main.lua +++ b/config/menus/main.lua @@ -14,8 +14,10 @@ if background == nil or not background:is(require "not.MenuBackground") then end -- Wait, only here? -musicPlayer:setTrack("menu.ogg") -musicPlayer:play() +if musicPlayer:getCurrentTrack() ~= "menu.ogg" then + musicPlayer:setTrack("menu.ogg") + musicPlayer:play() +end return { background, diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua index e838d96..4634ed9 100644 --- a/not/MusicPlayer.lua +++ b/not/MusicPlayer.lua @@ -32,6 +32,14 @@ function MusicPlayer:setTrack (trackName) end end +function MusicPlayer:getCurrentTrack () + for key,track in pairs(self.tracks) do + if self.tracks[key] == self.source then + return key + end + end +end + function MusicPlayer:play () self.source:play() end |