diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 265eab7d..d6fa4c84 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -186,6 +186,12 @@ function onObjectDrop(_, object) end end +function onObjectRotate(object, _, flip, _, _, oldFlip) + if flip ~= oldFlip then + stopTokenTransformUpdating(object) + end +end + -- Event hook for any object search. When chaos tokens are manipulated while the chaos bag -- container is being searched, a TTS bug can cause tokens to duplicate or vanish. We lock the -- chaos bag during search operations to avoid this. @@ -2877,8 +2883,6 @@ function moveCardWithTokens(params) Wait.condition( function() stopTokenTransformUpdating(card) end, function() - if card.held_by_color ~= nil then return true end - if card ~= nil and cardTokens[card] ~= nil and #cardTokens[card] ~= 0 then updateTokenTransform(card) return card.resting and not card.isSmoothMoving() @@ -2890,10 +2894,6 @@ function moveCardWithTokens(params) end function storeTokenTransform(card) - if cardTokens[card] ~= nil then - stopTokenTransformUpdating(card) - end - cardTokens[card] = {} local cardRot = card.getRotation() for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do @@ -2923,6 +2923,7 @@ function updateTokenTransform(card) end function stopTokenTransformUpdating(card) + if cardTokens[card] == nil then return end for _, tokenData in ipairs(cardTokens[card] or {}) do if tokenData.token ~= nil then tokenData.token.locked = false @@ -2932,6 +2933,10 @@ function stopTokenTransformUpdating(card) card.use_hands = true end +function unregisterCard(card) + cardTokens[card] = nil +end + function unregisterTokenFromCard(params) local card = params.card local token = params.token diff --git a/src/util/Trashcan.ttslua b/src/util/Trashcan.ttslua index 6a5a6625..a98ea78b 100644 --- a/src/util/Trashcan.ttslua +++ b/src/util/Trashcan.ttslua @@ -9,3 +9,17 @@ function emptyTrash() self.takeObject().destruct() end end + +function onObjectLeaveContainer(container, object) + if container == self then + object.locked = false + + if object.type == "Card" then + object.use_hands = true + end + + if object.type == "Card" or object.type == "Deck" then + Global.call("unregisterCard", object) + end + end +end