updated error handling

This commit is contained in:
Chr1Z93 2024-02-16 16:58:18 +01:00
parent 2b077599fb
commit 9f30e5ee39

View File

@ -302,9 +302,6 @@ do
-- remove everything before instructions
local tempStr = string.sub(description, pos)
-- remove instruction header (and potential copies)
tempStr = tempStr:gsub("++SCED import instructions++\n")
-- parse each line in instructions
for line in tempStr:gmatch("([^\n]+)") do
-- remove dashes at the start
@ -324,7 +321,10 @@ do
break
end
if instructor == "" or (instructor ~= "add:" and instructor ~= "remove:") then break end
-- go to the next line if no valid instructor found
if instructor ~= "add:" and instructor ~= "remove:" then
goto nextLine
end
-- remove instructor from line
line = line:gsub(instructor, "")
@ -335,7 +335,7 @@ do
slots[str] = (slots[str] or 0) + 1
elseif instructor == "remove:" then
if slots[str] == nil then
internal.maybePrint("Tried to remove " .. str .. ", but didn't find card in deck.", playerColor)
internal.maybePrint("Tried to remove card ID " .. str .. ", but didn't find card in deck.", playerColor)
else
slots[str] = math.max(slots[str] - 1, 0)
@ -349,6 +349,9 @@ do
end
end
end
-- jump mark at the end of the loop
::nextLine::
end
end