diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index cfdffb8a..cb337f9c 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2929,14 +2929,24 @@ function removeTokensFromObject(params) end end - for _, obj in ipairs(searchLib.onObject(object, "isTileOrToken")) do - if tokenChecker.isChaosToken(obj) then - returnChaosTokenToBag({ token = obj, fromBag = false }) - elseif obj.getGUID() ~= "4ee1f2" and -- table - obj ~= self and - obj.memo ~= nil and - obj.getLock() == false then - trash.putObject(obj) + if cardTokens[object] then + -- check if this card was moved with tokens on it + for _, tokenData in ipairs(cardTokens[object]) do + tokenData.token.locked = false + trash.putObject(tokenData.token) + end + cardTokens[object] = nil + else + -- search area for tokens + for _, obj in ipairs(searchLib.onObject(object, "isTileOrToken")) do + if tokenChecker.isChaosToken(obj) then + returnChaosTokenToBag({ token = obj, fromBag = false }) + elseif obj.getGUID() ~= "4ee1f2" and -- table + obj ~= self and + obj.memo ~= nil and + obj.getLock() == false then + trash.putObject(obj) + end end end end