From 17f047a15c29cbe34279212a5f87b54eb072afbf Mon Sep 17 00:00:00 2001 From: dscarpac Date: Mon, 18 Nov 2024 08:45:03 -0600 Subject: [PATCH] added token movement --- src/playermat/Playermat.ttslua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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