diff --git a/Scripts/SL-PlayerProfiles.lua b/Scripts/SL-PlayerProfiles.lua index f8e2c22a0..4f6f31322 100644 --- a/Scripts/SL-PlayerProfiles.lua +++ b/Scripts/SL-PlayerProfiles.lua @@ -162,11 +162,8 @@ SaveProfileCustom = function(profile, dir) IniFile.WriteFile( path, {[theme_name]=output} ) -- Write to the ITL file if we need to. - -- The ITLData table will only contain data for memory cards. - if #SL[pn].ITLData ~= 0 then - WriteItlFile(dir, table.concat(SL[pn].ITLData, "")) - end - + -- This is relevant for memory cards. + WriteItlFile(player) break end end diff --git a/Scripts/SL_ITL.lua b/Scripts/SL_ITL.lua index c78babe3d..a3a6ed722 100644 --- a/Scripts/SL_ITL.lua +++ b/Scripts/SL_ITL.lua @@ -43,16 +43,30 @@ end -- Note that songs resynced for ITL but played outside of the pack will not be covered in the pathMap. local itlFilePath = "itl2023.json" +local TableContainsData = function(t) + if t == nil then return false end + + for _, _ in pairs(t) do + return true + end + return false +end -- Takes the ITLData loaded in memory and writes it to the local profile. WriteItlFile = function(player) + local pn = ToEnumShortString(player) + -- No data to write, return early. + if (not TableContainsData(SL[pn].ITLData["pathMap"]) and + not TableContainsData(SL[pn].ITLData["hashMap"])) then + return + end + local profile_slot = { [PLAYER_1] = "ProfileSlot_Player1", [PLAYER_2] = "ProfileSlot_Player2" } local dir = PROFILEMAN:GetProfileDir(profile_slot[player]) - local pn = ToEnumShortString(player) -- We require an explicit profile to be loaded. if not dir or #dir == 0 then return end