Skip to content

Commit

Permalink
Fixed a bug that caused menu music to stop if you had no (intro) trac…
Browse files Browse the repository at this point in the history
…ks. Custom music related
  • Loading branch information
Damgam committed Apr 2, 2024
1 parent a49f2a0 commit 28bf8f0
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions LuaMenu/widgets/snd_music_lite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ local function GetRandomTrack(previousTrack)
local nextTrack
local trackType
for i = 1, #randomTrackList do
if previousTrackType == "intro" or (not introTrackList[1]) then -- we're checking if there are any intro tracks
if (previousTrackType == "intro" or (not introTrackList[1])) and peaceTrackList[1] then -- we're checking if there are any peace tracks
trackType = "peace"
peaceTracksIndex = peaceTracksIndex + 1
if not peaceTrackList[peaceTracksIndex] then
peaceTracksIndex = 1
end
nextTrack = peaceTrackList[peaceTracksIndex]
elseif previousTrackType == "peace" and introTrackList[1] then -- we're checking if there are any intro tracks
elseif (previousTrackType == "peace" or (not peaceTrackList[1])) and introTrackList[1] then -- we're checking if there are any intro tracks
trackType = "intro"
introTracksIndex = introTracksIndex + 1
if not introTrackList[introTracksIndex] then
Expand All @@ -55,16 +55,11 @@ local function GetRandomTrack(previousTrack)
nextTrack = introTrackList[introTracksIndex]
end

if not playedTracks[nextTrack] then
if nextTrack and trackType then
previousTrackType = trackType
playedTracks[nextTrack] = true
return nextTrack
end
end

playedTracks = {} -- there's a return in the for loop, if it failed, the list should be wiped
previousTrackType = "intro"
return introTrackList[math.random(#introTrackList)]
end

--------------------------------------------------------------------------------
Expand Down

0 comments on commit 28bf8f0

Please sign in to comment.