Skip to content

Commit

Permalink
Fix playlists lua errors and goals when goal songs arent loaded (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram authored and MinaciousGrace committed Nov 20, 2017
1 parent 41d873a commit e207279
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,14 @@ local function makescoregoal(i)
ck = sg:GetChartKey()
goalsong = SONGMAN:GetSongByChartKey(ck)
goalsteps = SONGMAN:GetStepsByChartKey(ck)

local diff = goalsteps:GetDifficulty()
self:settext(getShortDifficulty(diff))
self:diffuse(byDifficulty(diff))
if goalsteps and goalsong then
local diff = goalsteps:GetDifficulty()
self:settext(getShortDifficulty(diff))
self:diffuse(byDifficulty(diff))
else
self:settext("??")
self:diffuse(getMainColor('negative'))
end
self:visible(true)
else
self:visible(false)
Expand All @@ -179,7 +183,13 @@ local function makescoregoal(i)
SetCommand=function(self)
if update then
if sg then
self:settextf(goalsong:GetDisplayMainTitle())
if goalsong then
self:settextf(goalsong:GetDisplayMainTitle())
self:diffuse(getMainColor('positive'))
else
self:settext("Song not found")
self:diffuse(getMainColor('negative'))
end
self:visible(true)
else
self:visible(false)
Expand Down Expand Up @@ -315,7 +325,7 @@ local function makescoregoal(i)
end,
SetCommand=function(self)
if update then
if sg then
if sg and goalsteps then
local msd = goalsteps:GetMSD(sg:GetRate(), 1)
self:settextf("%5.1f", msd)
self:diffuse(ByMSD(msd))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,10 @@ local function PlaylistSelectLabel(i)
self:xy(15,row2Yoffset)
end,
AllDisplayMessageCommand=function(self)
self:diffuse(getMainColor("positive"))
self:settextf("Number of charts: %d", allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetNumCharts())
if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then
self:diffuse(getMainColor("positive"))
self:settextf("Number of charts: %d", allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetNumCharts())
end
end
},
LoadFont("Common Large") .. {
Expand All @@ -625,9 +627,11 @@ local function PlaylistSelectLabel(i)
self:xy(295,row2Yoffset)
end,
AllDisplayMessageCommand=function(self)
local rating = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetAverageRating()
self:settextf("%.2f", rating)
self:diffuse(ByMSD(rating))
if allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)] then
local rating = allplaylists[i + ((currentplaylistpage - 1) * playlistsperpage)]:GetAverageRating()
self:settextf("%.2f", rating)
self:diffuse(ByMSD(rating))
end
end
},
}
Expand Down

0 comments on commit e207279

Please sign in to comment.