From 2a778840b0cb61cd5b7ac2bb0f49ddb58120c6c0 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 21 Nov 2024 00:09:08 +0100 Subject: [PATCH 1/4] Added "low velocity" as additional condition --- src/core/Global.ttslua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 265eab7d..7a03aa07 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2881,7 +2881,8 @@ function moveCardWithTokens(params) if card ~= nil and cardTokens[card] ~= nil and #cardTokens[card] ~= 0 then updateTokenTransform(card) - return card.resting and not card.isSmoothMoving() + local cardVelocity = card.getVelocity():magnitude() + return (card.resting and not card.isSmoothMoving()) or (cardVelocity < 0.15 and cardVelocity > 0.05) end return true From 225d9cbedb04a2911b568aa92b4155710a741da0 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 21 Nov 2024 00:20:35 +0100 Subject: [PATCH 2/4] Fixed picking a card up while it is falling --- src/core/Global.ttslua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 7a03aa07..2bf26eac 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2877,12 +2877,9 @@ 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) - local cardVelocity = card.getVelocity():magnitude() - return (card.resting and not card.isSmoothMoving()) or (cardVelocity < 0.15 and cardVelocity > 0.05) + return card.resting and not card.isSmoothMoving() end return true @@ -2891,10 +2888,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 From 338da36748fa2d2bfbfe5bf5a85a399e7ef6ecf4 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 21 Nov 2024 00:30:47 +0100 Subject: [PATCH 3/4] flip stop --- src/core/Global.ttslua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 2bf26eac..90fe6246 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. @@ -2917,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 From 2977e278ec00ba97d83c65e894fd0cd7d56a86b6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 21 Nov 2024 00:40:12 +0100 Subject: [PATCH 4/4] trash handling --- src/core/Global.ttslua | 4 ++++ src/util/Trashcan.ttslua | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 90fe6246..d6fa4c84 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2933,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