From 2ff18307d1112fc99afb96706d1769b3568239e1 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Thu, 12 Aug 2021 11:52:37 +0200 Subject: [PATCH] / song wheel crash when no songs are found --- scripts/songselect/songwheel.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 02cdee3..1170694 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -201,8 +201,7 @@ function drawBackground(deltaTime) -- If the score for song exists local song = songwheel.songs[selectedIndex]; - local diff = song.difficulties[selectedDifficulty]; - local bestScore = diff.scores[1]; + local diff = song and song.difficulties[selectedDifficulty] or false; if song and diff then local jacketImage = getJacketImage(song); gfx.BeginPath() @@ -334,8 +333,10 @@ end local scoreNumbers = load_number_image("score_num"); function drawData() -- Draws the song data on the left panel local song = songwheel.songs[selectedIndex]; - local diff = song.difficulties[selectedDifficulty]; - local bestScore = diff.scores[1]; + local diff = song and song.difficulties[selectedDifficulty] or false; + local bestScore = diff and diff.scores[1]; + + if not song then return false end local jacketImage = getJacketImage(song); gfx.BeginPath()