From 582c02f8ff85f59f9c4125393389a92ac482fe38 Mon Sep 17 00:00:00 2001 From: Sattva <74269253+Sattva-108@users.noreply.github.com> Date: Sun, 18 May 2025 00:16:57 +0300 Subject: [PATCH] media-random: remove unplayable tracks do not show the un-playable tracks in list, aka the SoundKits, which in 3.3.5 do not work. --- Leatrix_Plus.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Leatrix_Plus.lua b/Leatrix_Plus.lua index f8d1a65..e834dc1 100644 --- a/Leatrix_Plus.lua +++ b/Leatrix_Plus.lua @@ -15601,26 +15601,34 @@ function LeaPlusLC:RunOnce() ListData[3] = "|cffffd800" ListData[4] = "|cffffd800" .. L["Selection of music tracks"] -- Must be lower case |c -- Populate list data until it contains desired number of tracks - while #ListData < 50 do + local attempt = 0 + while #ListData < 50 and attempt < 2000 do + attempt = attempt + 1 -- Get random category local rCategory = GetRandomArgument(L["Zones"], L["Dungeons"], L["Various"]) -- Get random zone within category local rZone = random(1, #ZoneList[rCategory]) -- Get random track within zone local rTrack = ZoneList[rCategory][rZone].tracks[random(1, #ZoneList[rCategory][rZone].tracks)] - -- Insert track into ListData if it's not a duplicate or on the banned list - if rTrack and rTrack ~= "" and strfind(rTrack, "#") and not tContains(ListData, "|Cffffffaa" .. ZoneList[rCategory][rZone].zone .. " |r" .. rTrack) then - if not tContains(randomBannedList, L[ZoneList[rCategory][rZone].zone]) and not tContains(randomBannedList, rTrack) then - tinsert(ListData, "|Cffffffaa" .. ZoneList[rCategory][rZone].zone .. " |r" .. rTrack) + -- Only allow tracks that are real mp3 (exclude SoundKit/non-file) + if rTrack and rTrack ~= "" and strfind(rTrack, "#") and strfind(rTrack:lower(), ".mp3") then + local zoneLabel = "|Cffffffaa" .. ZoneList[rCategory][rZone].zone .. " |r" .. rTrack + if not tContains(ListData, zoneLabel) and not tContains(randomBannedList, L[ZoneList[rCategory][rZone].zone]) and not tContains(randomBannedList, rTrack) then + tinsert(ListData, zoneLabel) end end end + -- If nothing found, show hint + if #ListData <= 4 then + tinsert(ListData, "|cff999999(No playable music tracks in random pool)|r") + end -- Refresh the track listing UpdateList() -- Set track listing to top scrollFrame:SetVerticalScroll(0) end + -- Show random track listing on startup when random button is clicked for q, w in pairs(ZoneList) do if conbtn[w] then