error lua
paulvilla opened this issue ยท 1 comments
Message: Interface/AddOns/AI_VoiceOver/MissionProgress.lua:76: bad argument #1 to 'match' (string expected, got nil)
Time: Fri Aug 30 10:41:30 2024
Count: 8
Stack: Interface/AddOns/AI_VoiceOver/MissionProgress.lua:76: bad argument #1 to 'match' (string expected, got nil)
[string "@Interface/AddOns/AI_VoiceOver/MissionProgress.lua"]:76: in function <Interface/AddOns/AI_VoiceOver/MissionProgress.lua:69>
[string "@Interface/AddOns/AI_VoiceOver/MissionProgress.lua"]:122: in function <Interface/AddOns/AI_VoiceOver/MissionProgress.lua:107>
[string "@Interface/AddOns/AI_VoiceOver/MissionProgress.lua"]:148: in function <Interface/AddOns/AI_VoiceOver/MissionProgress.lua:146>
Locals: questLogIndex = 27
objectivesCompleted = 0
objectivesTotal = 0
(for index) = 1
(for limit) = 1
(for step) = 1
i = 1
text = nil
objectiveType = nil
finished = nil
Fix:
local function GetQuestProgress(questLogIndex)
local objectivesCompleted = 0
local objectivesTotal = 0
for i = 1, GetNumQuestLeaderBoards(questLogIndex) do
local text, objectiveType, finished = GetQuestLogLeaderBoard(i, questLogIndex)
if objectiveType ~= "header" and text then
local numCompleted, numRequired = string.match(text, "(%d+)/(%d+)")
numCompleted = tonumber(numCompleted)
numRequired = tonumber(numRequired)
if numCompleted and numRequired then
objectivesCompleted = objectivesCompleted + numCompleted
objectivesTotal = objectivesTotal + numRequired
elseif finished then
-- If the objective is finished but we couldn't parse numbers, count it as 1/1
objectivesCompleted = objectivesCompleted + 1
objectivesTotal = objectivesTotal + 1
end
end
end
if objectivesTotal > 0 then
return (objectivesCompleted / objectivesTotal) * 100
else
return 0
end
end