error handling
This commit is contained in:
parent
aabaf52d96
commit
2b077599fb
@ -31,10 +31,10 @@ function generate(_, playerColor)
|
||||
idList = {}
|
||||
for _, obj in ipairs(searchLib.onObject(self, "isCardOrDeck")) do
|
||||
if obj.type == "Card" then
|
||||
processCard(JSON.decode(obj.getGMNotes()), obj.getName(), playerColor)
|
||||
processCard(obj.getGMNotes(), obj.getName(), playerColor)
|
||||
elseif obj.type == "Deck" then
|
||||
for _, deepObj in ipairs(obj.getData().ContainedObjects) do
|
||||
processCard(JSON.decode(deepObj.GMNotes), deepObj.Nickname, playerColor)
|
||||
processCard(deepObj.GMNotes, deepObj.Nickname, playerColor)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -69,16 +69,14 @@ function getIdFromData(metadata)
|
||||
end
|
||||
end
|
||||
|
||||
function processCard(metadata, name, playerColor)
|
||||
if metadata then
|
||||
local id = getIdFromData(metadata)
|
||||
function processCard(notes, name, playerColor)
|
||||
local id = getIdFromData(JSON.decode(notes) or {})
|
||||
if id then
|
||||
table.insert(idList, {id = id, name = name})
|
||||
else
|
||||
broadcastToColor("Couldn't get ID for " .. name .. ".", playerColor, "Red")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sortById(a, b)
|
||||
local numA = tonumber(a.id)
|
||||
|
Loading…
Reference in New Issue
Block a user