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,
|
-- 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.
|
-- 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())
|
local localPos = self.positionToLocal(container.getPosition())
|
||||||
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
||||||
tokenSpawnTrackerApi.resetTokensSpawned(object)
|
tokenSpawnTrackerApi.resetTokensSpawned(object)
|
||||||
|
@ -360,11 +360,15 @@ function resolveSealed(playerColor)
|
|||||||
broadcastToAll("No tokens sealed.", "Red")
|
broadcastToAll("No tokens sealed.", "Red")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local closestMatColor = playermatApi.getMatColorByPosition(self.getPosition())
|
local closestMatColor = playermatApi.getMatColorByPosition(self.getPosition())
|
||||||
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
local mat = guidReferenceApi.getObjectByOwnerAndType(closestMatColor, "Playermat")
|
||||||
local guidToBeResolved = table.remove(sealedTokens)
|
local guidToBeResolved = table.remove(sealedTokens)
|
||||||
local resolvedToken = getObjectFromGUID(guidToBeResolved)
|
local resolvedToken = getObjectFromGUID(guidToBeResolved)
|
||||||
|
if resolvedToken ~= nil then
|
||||||
resolvedToken.UI.setXml("")
|
resolvedToken.UI.setXml("")
|
||||||
|
end
|
||||||
|
|
||||||
updateStackSize()
|
updateStackSize()
|
||||||
updateSave()
|
updateSave()
|
||||||
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
|
chaosBagApi.drawChaosToken(mat, true, _, guidToBeResolved)
|
||||||
@ -374,9 +378,10 @@ end
|
|||||||
function updateStackSize()
|
function updateStackSize()
|
||||||
if MAX_SEALED == 1 then return end
|
if MAX_SEALED == 1 then return end
|
||||||
if #sealedTokens == 0 then return end
|
if #sealedTokens == 0 then return end
|
||||||
|
|
||||||
-- get topmost sealed token
|
-- get topmost sealed token
|
||||||
local topToken = getObjectFromGUID(sealedTokens[#sealedTokens])
|
local topToken = getObjectFromGUID(sealedTokens[#sealedTokens])
|
||||||
local name = topToken.getName()
|
if topToken == nil then return end
|
||||||
|
|
||||||
topToken.UI.setXmlTable({
|
topToken.UI.setXmlTable({
|
||||||
{
|
{
|
||||||
@ -387,7 +392,7 @@ function updateStackSize()
|
|||||||
rotation = "0 0 180",
|
rotation = "0 0 180",
|
||||||
scale = "0.2 0.2 1",
|
scale = "0.2 0.2 1",
|
||||||
position = "0 0 -12",
|
position = "0 0 -12",
|
||||||
color = tokenColor[name] or "#77674DE6"
|
color = tokenColor[topToken.getName()] or "#77674DE6"
|
||||||
},
|
},
|
||||||
children = {
|
children = {
|
||||||
tag = "Text",
|
tag = "Text",
|
||||||
|
@ -1335,7 +1335,7 @@ function spawnTokensOrShowHelper(card)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onObjectEnterContainer(container, object)
|
function tryObjectEnterContainer(container, object)
|
||||||
if object.type ~= "Card" then return end
|
if object.type ~= "Card" then return end
|
||||||
|
|
||||||
local localCardPos = self.positionToLocal(object.getPosition())
|
local localCardPos = self.positionToLocal(object.getPosition())
|
||||||
|
Loading…
Reference in New Issue
Block a user