From 0ad3016738119337ee70eb73cc15b3996ebf6b36 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Tue, 14 Dec 2021 22:22:38 +0100 Subject: [PATCH] / finally hopefully fix sorting regardless of ranking value --- scripts/songselect/songwheel.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index cfd620d..a14bd87 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -575,8 +575,8 @@ function drawIrLeaderboard() end -- Becuase the scores are in "random order", we have to do this - for i = 1, 4, 1 do - local irScore = irLeaderboard[i]; + for index, irScore in ipairs(irLeaderboard) do + -- local irScore = irLeaderboard[i]; if irScore then local rank = irScore.ranking @@ -682,7 +682,12 @@ end function onIrLeaderboardFetched(res) if res.statusCode == IRData.States.Success then - irLeaderboard = res.body; + local tempIrLeaderboard = res.body; + + for i, tempScore in ipairs(tempIrLeaderboard) do + irLeaderboard[tempScore.ranking] = tempScore + end + game.Log(dump(irLeaderboard), game.LOGGER_ERROR) else game.Log("IR error " .. res.statusCode, game.LOGGER_ERROR)