From 3914c979b2c7fd28f3f7db8b926714b38bbc9be2 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 10 Jun 2025 22:49:42 +0100 Subject: [PATCH] Borders: don't check turns when combat has not started When trying to figure out if a token has played or not, we might get an active combat which hasn't started. In this case the Fabula Ultima flags do not exist yet, and trying to access them will error. Check that the combat we found has indeed been started, otherwise there's no way a token can have played and we don't need to check. --- scripts/token_combat_border.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/token_combat_border.mjs b/scripts/token_combat_border.mjs index 22235a3..3291bb5 100644 --- a/scripts/token_combat_border.mjs +++ b/scripts/token_combat_border.mjs @@ -161,6 +161,10 @@ function token_has_played(token, round = -1) { } } + // The token can't have played if the combat hasn't started yet. + if (!combat.started) + return false; + let round_turns_taken = combat?.flags.projectfu.CombatantsTurnTaken[round < 0 ? combat?.round : round] // No token has taken a turn, or all turns were reverted.