From 05e375074af758e1715b107c22e0255c9ed9d1df Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 14:30:07 +0100 Subject: [PATCH 01/11] Different attempt at moving cards with tokens --- src/core/Global.ttslua | 79 +++++++++++----------------------- src/core/GlobalApi.ttslua | 6 --- src/core/MythosArea.ttslua | 1 - src/playermat/Playermat.ttslua | 1 - 4 files changed, 24 insertions(+), 63 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 42b9d2a0..4898f494 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -73,8 +73,8 @@ local RESOURCE_OPTIONS = { local handVisibility = {} local blurseVisibility = {} --- track cards' settings -local cardSetting = {} +-- track cards' tokens +local cardTokens = {} --------------------------------------------------------- -- data for tokens @@ -180,6 +180,11 @@ function getRandomSeed() return math.random(999) end +function onObjectDrop(playerColor, object) + if object.type ~= "Card" then return end + handleCardDropping({ player = Player[playerColor], card = object }) +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. @@ -208,8 +213,8 @@ function tryObjectEnterContainer(container, object) -- stop mini cards from forming decks if object.hasTag("Minicard") and container.hasTag("Minicard") then return false - elseif object.type == "Card" and object.getName() ~= "Atlach-Nacha" then - handleTokenDetaching({ card = object }) + elseif object.type == "Card" then + handleCardResting({ card = object }) end playAreaApi.tryObjectEnterContainer(container, object) @@ -302,20 +307,7 @@ function onPlayerAction(player, action, targets) trash.putObject(target) end return false - elseif action == Player.Action.PickUp then - local pickedCards = {} - for _, target in ipairs(targets) do - if target.type == "Card" then - table.insert(pickedCards, target) - end - end - if #pickedCards > 5 then return end - - for _, pickedCard in ipairs(pickedCards) do - handleTokenAttaching({ player = player, card = pickedCard }) - end end - return true end --------------------------------------------------------- @@ -2849,27 +2841,20 @@ function tableContains(thisTable, thisElement) return false end -function handleTokenAttaching(params) +function handleCardDropping(params) local card = params.card local player = params.player - local searchResult = searchLib.onObject(card, "isTileOrToken", 0.95) - if card.is_face_down and next(searchResult) ~= nil then - cardSetting[card] = { - hideFacedown = card.hide_when_face_down, - tooltip = card.tooltip - } - card.hide_when_face_down = false - card.tooltip = false - end - for _, token in ipairs(searchResult) do - if not token.locked then - card.addAttachment(token) - end + cardTokens[card] = {} + local cardRot = card.getRotation() + for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do + cardTokens[card].token = token + cardTokens[card].localPos = card.positionToLocal(token.getPosition()) + cardTokens[card].localRot = token.getRotation() - cardRot end Wait.condition( - function() handleTokenDetaching({ card = card }) end, + function() handleCardResting({ card = card }) end, function() if card ~= nil and player ~= nil and player.seated then return card.resting and not tableContains(player.getHoldingObjects(), card) @@ -2880,33 +2865,17 @@ function handleTokenAttaching(params) ) end -function handleTokenDetaching(params) +function handleCardResting(params) local card = params.card - if card == nil or next(card.getAttachments()) == nil then return end + if card == nil or cardTokens[card] == nil or #cardTokens[card] == 0 then return end - -- restore card settings - if cardSetting[card] ~= nil then - card.hide_when_face_down = cardSetting[card]["hideFacedown"] - card.tooltip = cardSetting[card]["tooltip"] - cardSetting[card] = nil + local cardRot = card.getRotation() + for _, tokenData in ipairs(cardTokens[card]) do + tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) + tokenData.token.setRotation(cardRot + tokenData.localRot) end - -- remove attachments - local removedTokens = card.removeAttachments() - for _, token in ipairs(removedTokens) do - if token.getPosition().y < card.getPosition().y then - local posY = card.getPosition().y + 0.05 - token.setPosition(token.getPosition():setAt("y", posY)) - end - end - - -- redraw token xml - if card.hasTag("CardThatSeals") then - local func = card.getVar("updateStackSize") -- make sure function exists - if func ~= nil then - card.call("updateStackSize") - end - end + cardTokens[card] = nil end -- removes tokens from the provided card/deck diff --git a/src/core/GlobalApi.ttslua b/src/core/GlobalApi.ttslua index 8a26fd62..18c0dde9 100644 --- a/src/core/GlobalApi.ttslua +++ b/src/core/GlobalApi.ttslua @@ -53,12 +53,6 @@ do Global.call("handVisibilityToggle", { playerColor = playerColor, handColor = handColor }) end - -- handles token detaching for cards - ---@param card tts__Object Card that should get tokens detached - function GlobalApi.handleTokenDetaching(card) - Global.call("handleTokenDetaching", { card = card }) - end - -- discards tokens from an object ---@param object tts__Object Object that should get tokens removed ---@param owner string Owner of this object (for discarding) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 3c0a1c0a..2b04d705 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -105,7 +105,6 @@ function onCollisionEnter(collisionInfo) if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then -- reset spawned tokens and remove tokens from cards in encounter deck / discard area Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object) end, 1) - GlobalApi.handleTokenDetaching(object) GlobalApi.removeTokensFromObject(object, "Mythos") elseif inArea(localPos, SCENARIO_REFERENCE_AREA) then diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index e7619a1e..5099288b 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -1298,7 +1298,6 @@ function onCollisionEnter(collisionInfo) end elseif inArea(localCardPos, DECK_DISCARD_AREA) then - GlobalApi.handleTokenDetaching(object) tokenSpawnTrackerApi.resetTokensSpawned(object) GlobalApi.removeTokensFromObject(object, matColor) From 2006ec85ec6063f4e961712b9e8e504de90ac129 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 15:01:01 +0100 Subject: [PATCH 02/11] updated more code --- src/core/GameKeyHandler.ttslua | 25 +-------------------- src/core/Global.ttslua | 41 ++++++++++++++++++++++------------ src/core/GlobalApi.ttslua | 8 +++++++ src/playermat/Playermat.ttslua | 18 +-------------- 4 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index 761d86ed..8b57ce0b 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -76,19 +76,6 @@ function takeCardIntoThreatArea(playerColor, hoveredObject) return end - -- initialize list of objects to move (and store local position + rotation) - local additionalObjects = {} - for _, obj in ipairs(searchLib.onObject(hoveredObject, "isTileOrToken")) do - if not obj.locked then - local data = { - object = obj, - localPos = hoveredObject.positionToLocal(obj.getPosition()), - localRot = obj.getRotation() - cardRot - } - table.insert(additionalObjects, data) - end - end - -- get the rotation of the owning playermat (or Mythos) local cardOwner = guidReferenceApi.getOwnerOfObject(hoveredObject) local ownerRotation = Vector(0, 270, 0) @@ -101,17 +88,7 @@ function takeCardIntoThreatArea(playerColor, hoveredObject) local newCardRot = cardRot:setAt("y", matRotation.y + cardRot.y - ownerRotation.y) -- move the main card to threat area - hoveredObject.setRotation(newCardRot) - hoveredObject.setPosition(threatAreaPos) - - -- move tokens/tiles (to new global position) - for _, data in ipairs(additionalObjects) do - data.object.setPosition(hoveredObject.positionToWorld(data.localPos)) - - local newRot = data.localRot + Vector(0, newCardRot.y, 0) - newRot.y = roundToMultiple(newRot.y, 45) - data.object.setRotation(newRot) - end + GlobalApi.moveCardWithTokens(hoveredObject, threatAreaPos, newCardRot) -- contruct feedback message (hide name when face-down + enabled setting) local cardName = hoveredObject.getName() diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 4898f494..7f5b8bd3 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -180,9 +180,10 @@ function getRandomSeed() return math.random(999) end -function onObjectDrop(playerColor, object) - if object.type ~= "Card" then return end - handleCardDropping({ player = Player[playerColor], card = object }) +function onObjectDrop(_, object) + if object.type == "Card" or object.type == "Deck" then + moveCardWithTokens({ card = object }) + end end -- Event hook for any object search. When chaos tokens are manipulated while the chaos bag @@ -214,7 +215,7 @@ function tryObjectEnterContainer(container, object) if object.hasTag("Minicard") and container.hasTag("Minicard") then return false elseif object.type == "Card" then - handleCardResting({ card = object }) + finishCardMoving(object) end playAreaApi.tryObjectEnterContainer(container, object) @@ -2841,23 +2842,36 @@ function tableContains(thisTable, thisElement) return false end -function handleCardDropping(params) +function moveCardWithTokens(params) local card = params.card - local player = params.player + local position = params.position + local rotation = params.rotation + -- store local position/rotation of tokens cardTokens[card] = {} local cardRot = card.getRotation() for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do - cardTokens[card].token = token - cardTokens[card].localPos = card.positionToLocal(token.getPosition()) - cardTokens[card].localRot = token.getRotation() - cardRot + if not token.locked then + cardTokens[card].token = token + cardTokens[card].localPos = card.positionToLocal(token.getPosition()) + cardTokens[card].localRot = token.getRotation() - cardRot + end end + if position then + card.setPositionSmooth(position) + end + + if rotation then + card.setRotationSmooth(rotation) + end + + -- wait for the card to finish moving Wait.condition( - function() handleCardResting({ card = card }) end, + function() finishCardMoving(card) end, function() - if card ~= nil and player ~= nil and player.seated then - return card.resting and not tableContains(player.getHoldingObjects(), card) + if card ~= nil then + return card.resting and card.isSmoothMoving() else return true end @@ -2865,8 +2879,7 @@ function handleCardDropping(params) ) end -function handleCardResting(params) - local card = params.card +function finishCardMoving(card) if card == nil or cardTokens[card] == nil or #cardTokens[card] == 0 then return end local cardRot = card.getRotation() diff --git a/src/core/GlobalApi.ttslua b/src/core/GlobalApi.ttslua index 18c0dde9..e39a64d9 100644 --- a/src/core/GlobalApi.ttslua +++ b/src/core/GlobalApi.ttslua @@ -60,6 +60,14 @@ do Global.call("removeTokensFromObject", { object = object, owner = owner }) end + -- moves a card with tokens on it + ---@param card tts__Object Card that should get moved + ---@param position? tts__Vector Target position + ---@param rotation? tts__Vector Target rotation + function GlobalApi.moveCardWithTokens(card, position, rotation) + Global.call("moveCardWithTokens", { card = card, position = position, rotation = rotation }) + end + -- loads saved options ---@param options table Set a new state for the option table function GlobalApi.loadOptionPanelSettings(options) diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index 5099288b..9313fa0a 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -360,23 +360,7 @@ function discardOrMove(_, playerColor, isRightClick) for _, obj in ipairs(searchResult) do if obj.type == "Card" or obj.type == "Deck" then - -- initialize list of objects to move (and store local position + rotation) - local additionalObjects = {} - for _, tokenOnCard in ipairs(searchLib.onObject(obj, "isTileOrToken")) do - if not tokenOnCard.locked then - local data = { - object = tokenOnCard, - localPos = obj.positionToLocal(tokenOnCard.getPosition()), - } - table.insert(additionalObjects, data) - end - end - - obj.setPosition(threatAreaPos) - -- move tokens/tiles (to new global position) - for _, data in ipairs(additionalObjects) do - data.object.setPosition(obj.positionToWorld(data.localPos)) - end + GlobalApi.moveCardWithTokens(obj, threatAreaPos) end end else From c6a94dba803b4cc981daa30488da1f3e11050e48 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 18:36:14 +0100 Subject: [PATCH 03/11] new iteration --- src/core/Global.ttslua | 57 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 7f5b8bd3..51bc4cee 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -214,8 +214,6 @@ function tryObjectEnterContainer(container, object) -- stop mini cards from forming decks if object.hasTag("Minicard") and container.hasTag("Minicard") then return false - elseif object.type == "Card" then - finishCardMoving(object) end playAreaApi.tryObjectEnterContainer(container, object) @@ -308,6 +306,12 @@ function onPlayerAction(player, action, targets) trash.putObject(target) end return false + elseif action == Player.Action.PickUp then + for _, target in ipairs(targets) do + if target.type == "Card" or target.type == "Deck" then + storeTokenTransform(target) + end + end end end @@ -2847,15 +2851,8 @@ function moveCardWithTokens(params) local position = params.position local rotation = params.rotation - -- store local position/rotation of tokens - cardTokens[card] = {} - local cardRot = card.getRotation() - for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do - if not token.locked then - cardTokens[card].token = token - cardTokens[card].localPos = card.positionToLocal(token.getPosition()) - cardTokens[card].localRot = token.getRotation() - cardRot - end + if not cardTokens[card] then + storeTokenTransform(card) end if position then @@ -2866,12 +2863,15 @@ function moveCardWithTokens(params) card.setRotationSmooth(rotation) end - -- wait for the card to finish moving + if #cardTokens[card] == 0 then return end + + -- wait for the card to finish moving, update token position/rotation regularly Wait.condition( - function() finishCardMoving(card) end, + function() cardTokens[card] = nil end, function() - if card ~= nil then - return card.resting and card.isSmoothMoving() + if card ~= nil and cardTokens[card] ~= nil and #cardTokens[card] ~= 0 then + updateTokenTransform(card) + return card.resting and not card.isSmoothMoving() else return true end @@ -2879,16 +2879,27 @@ function moveCardWithTokens(params) ) end -function finishCardMoving(card) - if card == nil or cardTokens[card] == nil or #cardTokens[card] == 0 then return end - +function storeTokenTransform(card) + cardTokens[card] = {} local cardRot = card.getRotation() - for _, tokenData in ipairs(cardTokens[card]) do - tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) - tokenData.token.setRotation(cardRot + tokenData.localRot) + for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do + if not token.locked then + local tokenPos = token.getPosition() + Vector(0, 0.1, 0) -- small offset so tokens don't collide with card + token.setPosition(tokenPos) + table.insert(cardTokens[card], { + token = token, + localPos = card.positionToLocal(tokenPos), + localRot = token.getRotation() - cardRot + }) + end end +end - cardTokens[card] = nil +function updateTokenTransform(card) + for _, tokenData in ipairs(cardTokens[card] or {}) do + tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) + tokenData.token.setRotation(card.getRotation() + tokenData.localRot) + end end -- removes tokens from the provided card/deck @@ -2905,7 +2916,7 @@ function removeTokensFromObject(params) for _, obj in ipairs(searchLib.onObject(object, "isTileOrToken")) do if tokenChecker.isChaosToken(obj) then - returnChaosTokenToBag( { token = obj, fromBag = false } ) + returnChaosTokenToBag({ token = obj, fromBag = false }) elseif obj.getGUID() ~= "4ee1f2" and -- table obj ~= self and obj.memo ~= nil and From a7dcf7c893efefadc673744edd97ae28a54c3831 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 18:58:04 +0100 Subject: [PATCH 04/11] code update --- src/core/Global.ttslua | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 51bc4cee..cfdffb8a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2867,7 +2867,7 @@ function moveCardWithTokens(params) -- wait for the card to finish moving, update token position/rotation regularly Wait.condition( - function() cardTokens[card] = nil end, + function() stopTokenTransformUpdating(card) end, function() if card ~= nil and cardTokens[card] ~= nil and #cardTokens[card] ~= 0 then updateTokenTransform(card) @@ -2880,12 +2880,19 @@ 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 if not token.locked then - local tokenPos = token.getPosition() + Vector(0, 0.1, 0) -- small offset so tokens don't collide with card + -- offset to stop the token from colliding with the card + local tokenPos = token.getPosition() + Vector(0, 0.01, 0) token.setPosition(tokenPos) + + -- store local transform data table.insert(cardTokens[card], { token = token, localPos = card.positionToLocal(tokenPos), @@ -2899,9 +2906,17 @@ function updateTokenTransform(card) for _, tokenData in ipairs(cardTokens[card] or {}) do tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) tokenData.token.setRotation(card.getRotation() + tokenData.localRot) + tokenData.token.locked = true end end +function stopTokenTransformUpdating(card) + for _, tokenData in ipairs(cardTokens[card] or {}) do + tokenData.token.locked = false + end + cardTokens[card] = nil +end + -- removes tokens from the provided card/deck function removeTokensFromObject(params) local object = params.object From 47e491913f529860f384e05936fe7949833ebb54 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 19:03:20 +0100 Subject: [PATCH 05/11] fixed token discarding --- src/core/Global.ttslua | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) 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 From 46a8f6640a3d40b4316f8ef1e605bb90f66c2fee Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 19:10:02 +0100 Subject: [PATCH 06/11] fixed hand using --- src/core/Global.ttslua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index cb337f9c..25882b49 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2855,12 +2855,13 @@ function moveCardWithTokens(params) storeTokenTransform(card) end - if position then - card.setPositionSmooth(position) + if rotation then + card.setRotation(rotation) end - if rotation then - card.setRotationSmooth(rotation) + if position then + card.use_hands = false + card.setPositionSmooth(position) end if #cardTokens[card] == 0 then return end @@ -2915,6 +2916,7 @@ function stopTokenTransformUpdating(card) tokenData.token.locked = false end cardTokens[card] = nil + card.use_hands = true end -- removes tokens from the provided card/deck From a13314f61c9a1f439fdbf685f75a6b549abf8731 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 19:41:08 +0100 Subject: [PATCH 07/11] updated offset --- src/core/Global.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 25882b49..ea516c61 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2890,7 +2890,7 @@ function storeTokenTransform(card) for _, token in ipairs(searchLib.onObject(card, "isTileOrToken", 0.95)) do if not token.locked then -- offset to stop the token from colliding with the card - local tokenPos = token.getPosition() + Vector(0, 0.01, 0) + local tokenPos = token.getPosition() + Vector(0, 0.05, 0) token.setPosition(tokenPos) -- store local transform data From 17bc2b1dc29680585f90b995de9a1b2ee4fbe1d6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 20:57:28 +0100 Subject: [PATCH 08/11] nil handling --- src/core/Global.ttslua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index ea516c61..6b618928 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2905,15 +2905,19 @@ end function updateTokenTransform(card) for _, tokenData in ipairs(cardTokens[card] or {}) do - tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) - tokenData.token.setRotation(card.getRotation() + tokenData.localRot) - tokenData.token.locked = true + if tokenData.token ~= nil then + tokenData.token.setPosition(card.positionToWorld(tokenData.localPos)) + tokenData.token.setRotation(card.getRotation() + tokenData.localRot) + tokenData.token.locked = true + end end end function stopTokenTransformUpdating(card) for _, tokenData in ipairs(cardTokens[card] or {}) do - tokenData.token.locked = false + if tokenData.token ~= nil then + tokenData.token.locked = false + end end cardTokens[card] = nil card.use_hands = true From e99f725f801b5622c4f12691f8d0aa97a742982f Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 21:17:39 +0100 Subject: [PATCH 09/11] timeoutfunc added --- src/core/Global.ttslua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 6b618928..88ed207a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2876,7 +2876,9 @@ function moveCardWithTokens(params) else return true end - end + end, + 2, + function() stopTokenTransformUpdating(card) end ) end From 8f72911c039e2c485f408a0d196a34b1c7c91b93 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 22:25:12 +0100 Subject: [PATCH 10/11] removed timeout --- src/core/Global.ttslua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 88ed207a..6b618928 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2876,9 +2876,7 @@ function moveCardWithTokens(params) else return true end - end, - 2, - function() stopTokenTransformUpdating(card) end + end ) end From 46bfa275c76676c3ae8b19cb55afea351618b8a8 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 19 Nov 2024 22:48:17 +0100 Subject: [PATCH 11/11] release discard sealed tokens --- src/core/Global.ttslua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 6b618928..1ca0ae41 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2938,8 +2938,14 @@ function removeTokensFromObject(params) 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) + if tokenData.token ~= nil then + tokenData.token.locked = false + if tokenChecker.isChaosToken(tokenData.token) then + returnChaosTokenToBag({ token = tokenData.token, fromBag = false }) + else + trash.putObject(tokenData.token) + end + end end cardTokens[object] = nil else