/ crashes on chalresult & / diffrects having wrong difficulty displayed

This commit is contained in:
Katoski 2022-06-25 23:20:38 +02:00
parent 0d36dbebdc
commit 6d342c883f
2 changed files with 18 additions and 5 deletions

View File

@ -75,8 +75,8 @@ local gradeImages = {
none = gfx.CreateSkinImage("common/grades/none.png", 0), none = gfx.CreateSkinImage("common/grades/none.png", 0),
} }
local percRequired = 1; local percRequired = nil;
local percGet = 0; local percGet = nil;
-- AUDIO -- AUDIO
game.LoadSkinSample("challenge_result.wav") game.LoadSkinSample("challenge_result.wav")
@ -161,7 +161,7 @@ function drawChartResult(deltaTime, x, y, chartResult)
gfx.GlobalAlpha(1); gfx.GlobalAlpha(1);
gfx.Text(chartResult.title, x+160,y+32); gfx.Text(chartResult.title, x+160,y+32);
DiffRectangle.render(deltaTime, x+287.5, y+67, 0.85, chartResult.difficulty, chartResult.level) DiffRectangle.render(deltaTime, x+287.5, y+67, 0.85, chartResult.difficulty+1, chartResult.level)
local score = chartResult.score or 0; local score = chartResult.score or 0;
@ -215,8 +215,11 @@ function drawCompletion()
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(63, 1331, 766*0.85, 130*0.85, completitionImage, 1, 0) gfx.ImageRect(63, 1331, 766*0.85, 130*0.85, completitionImage, 1, 0)
Numbers.draw_number(925, 1370, 1.0, percGet, 3, scoreNumber, true, 0.3, 1.12) if (percRequired == nil) then
return
end
Numbers.draw_number(925, 1370, 1.0, percGet, 3, scoreNumber, true, 0.3, 1.12)
gfx.BeginPath(); gfx.BeginPath();
gfx.Rect(741, 1402, 278*math.min(1, percGet / percRequired), 6); gfx.Rect(741, 1402, 278*math.min(1, percGet / percRequired), 6);
@ -226,7 +229,13 @@ end
function result_set() function result_set()
if (result.requirement_text == nil) then
return
end
local reqTextWords = common.split(result.requirement_text, ' '); local reqTextWords = common.split(result.requirement_text, ' ');
for index, word in ipairs(reqTextWords) do for index, word in ipairs(reqTextWords) do
if string.find(word, '%%') ~= nil then -- %% = %, because % is an escape char if string.find(word, '%%') ~= nil then -- %% = %, because % is an escape char
local percNumber = tonumber(string.gsub(word, '%%', ''), 10) local percNumber = tonumber(string.gsub(word, '%%', ''), 10)
@ -234,6 +243,10 @@ function result_set()
end end
end end
if (percRequired == nil) then
return
end
game.Log(percRequired, game.LOGGER_ERROR); game.Log(percRequired, game.LOGGER_ERROR);
local a = 0; local a = 0;

View File

@ -1,5 +1,5 @@
local function split(s, delimiter) local function split(s, delimiter)
result = {}; local result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match); table.insert(result, match);
end end