updated error handling
This commit is contained in:
parent
2b077599fb
commit
9f30e5ee39
@ -302,9 +302,6 @@ do
|
|||||||
-- remove everything before instructions
|
-- remove everything before instructions
|
||||||
local tempStr = string.sub(description, pos)
|
local tempStr = string.sub(description, pos)
|
||||||
|
|
||||||
-- remove instruction header (and potential copies)
|
|
||||||
tempStr = tempStr:gsub("++SCED import instructions++\n")
|
|
||||||
|
|
||||||
-- parse each line in instructions
|
-- parse each line in instructions
|
||||||
for line in tempStr:gmatch("([^\n]+)") do
|
for line in tempStr:gmatch("([^\n]+)") do
|
||||||
-- remove dashes at the start
|
-- remove dashes at the start
|
||||||
@ -324,7 +321,10 @@ do
|
|||||||
break
|
break
|
||||||
end
|
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
|
-- remove instructor from line
|
||||||
line = line:gsub(instructor, "")
|
line = line:gsub(instructor, "")
|
||||||
@ -335,7 +335,7 @@ do
|
|||||||
slots[str] = (slots[str] or 0) + 1
|
slots[str] = (slots[str] or 0) + 1
|
||||||
elseif instructor == "remove:" then
|
elseif instructor == "remove:" then
|
||||||
if slots[str] == nil 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
|
else
|
||||||
slots[str] = math.max(slots[str] - 1, 0)
|
slots[str] = math.max(slots[str] - 1, 0)
|
||||||
|
|
||||||
@ -349,6 +349,9 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- jump mark at the end of the loop
|
||||||
|
::nextLine::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user