Substitute macro in character editor token counter

This commit is contained in:
Cohee
2023-10-21 14:39:01 +03:00
parent 6fe4232f75
commit 703965aec8
2 changed files with 8 additions and 4 deletions

View File

@@ -18,6 +18,8 @@ import {
getThumbnailUrl,
selectCharacterById,
eventSource,
menu_type,
substituteParams,
} from "../script.js";
import {
@@ -234,7 +236,9 @@ export function RA_CountCharTokens() {
total_tokens += Number(counter.text());
permanent_tokens += isPermanent ? Number(counter.text()) : 0;
} else {
const tokens = getTokenCount(value);
// We substitute macro for existing characters, but not for the character being created
const valueToCount = menu_type === 'create' ? value : substituteParams(value);
const tokens = getTokenCount(valueToCount);
counter.text(tokens);
total_tokens += tokens;
permanent_tokens += isPermanent ? tokens : 0;