diff --git a/src/playermat/Playermat.ttslua b/src/playermat/Playermat.ttslua index f83b4970..b3dc9924 100644 --- a/src/playermat/Playermat.ttslua +++ b/src/playermat/Playermat.ttslua @@ -357,7 +357,23 @@ 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 end end else