From 24545fc389202ab700246290054c50e2d1b37b24 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Fri, 22 Nov 2024 01:40:50 +0100 Subject: [PATCH] added rounding --- src/core/Global.ttslua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 8bb6ac04..8d9fe461 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -2856,6 +2856,9 @@ function moveCardWithTokens(params) if rotation then card.setRotation(rotation) + else + local rot = card.getRotation() + card.setRotation(rot:setAt("y", roundToMultiple(rot.y, 45))) end if position then @@ -2961,3 +2964,7 @@ function removeTokensFromObject(params) end end end + +function roundToMultiple(num, mult) + return math.floor((num + mult / 2) / mult) * mult +end