added token movement

This commit is contained in:
dscarpac 2024-11-18 08:45:03 -06:00
parent ac8d5ace69
commit 17f047a15c

View File

@ -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