some nil handling
This commit is contained in:
parent
b58f9923c2
commit
ac80962c9c
@ -163,7 +163,7 @@ end
|
||||
|
||||
-- Listens for cards entering the encounter deck or encounter discard, discards tokens on them,
|
||||
-- and resets the spawn state for the cards when they do.
|
||||
function onObjectEnterContainer(container, object)
|
||||
function tryObjectEnterContainer(container, object)
|
||||
local localPos = self.positionToLocal(container.getPosition())
|
||||
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
||||
tokenSpawnTrackerApi.resetTokensSpawned(object)
|
||||
|
@ -360,11 +360,15 @@ function resolveSealed(playerColor)
|
||||
broadcastToAll("No tokens sealed.", "Red")
|
||||
return
|
||||
end
|
||||
|
||||
local closestMatColor = playermatApi.getMatColorByPosition(self.getPosition())
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
||||
local guidToBeResolved = table.remove(sealedTokens)
|
||||
local resolvedToken = getObjectFromGUID(guidToBeResolved)
|
||||
resolvedToken.UI.setXml("")
|
||||
if resolvedToken ~= nil then
|
||||
resolvedToken.UI.setXml("")
|
||||
end
|
||||
|
||||
updateStackSize()
|
||||
updateSave()
|
||||
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
|
||||
@ -374,9 +378,10 @@ end
|
||||
function updateStackSize()
|
||||
if MAX_SEALED == 1 then return end
|
||||
if #sealedTokens == 0 then return end
|
||||
|
||||
-- get topmost sealed token
|
||||
local topToken = getObjectFromGUID(sealedTokens[#sealedTokens])
|
||||
local name = topToken.getName()
|
||||
if topToken == nil then return end
|
||||
|
||||
topToken.UI.setXmlTable({
|
||||
{
|
||||
@ -387,7 +392,7 @@ function updateStackSize()
|
||||
rotation = "0 0 180",
|
||||
scale = "0.2 0.2 1",
|
||||
position = "0 0 -12",
|
||||
color = tokenColor[name] or "#77674DE6"
|
||||
color = tokenColor[topToken.getName()] or "#77674DE6"
|
||||
},
|
||||
children = {
|
||||
tag = "Text",
|
||||
|
@ -1335,7 +1335,7 @@ function spawnTokensOrShowHelper(card)
|
||||
end
|
||||
end
|
||||
|
||||
function onObjectEnterContainer(container, object)
|
||||
function tryObjectEnterContainer(container, object)
|
||||
if object.type ~= "Card" then return end
|
||||
|
||||
local localCardPos = self.positionToLocal(object.getPosition())
|
||||
|
Loading…
Reference in New Issue
Block a user