From f6fc85bf7e5cac80674936e174bbc23af27a1bdb Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 21 Aug 2024 14:23:06 -0600 Subject: [PATCH] Changed order of resolver fields --- lib/dice.ts | 6 ++++++ lib/tcmd/TokenIdentifiers.tsx | 6 +++--- md/help articles/How to use ttcMD.md | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/dice.ts b/lib/dice.ts index dd056fc..8102142 100644 --- a/lib/dice.ts +++ b/lib/dice.ts @@ -3,9 +3,15 @@ import { sum } from "./utils/sum"; export class Dice { private count!: number; private sides!: number; + private diceString: string; + + toString() { + return this.diceString; + } constructor(dice: string) { this.parseDice(dice); + this.diceString = dice; } private parseDice(dice: string) { diff --git a/lib/tcmd/TokenIdentifiers.tsx b/lib/tcmd/TokenIdentifiers.tsx index 2d7b3e2..1d40206 100644 --- a/lib/tcmd/TokenIdentifiers.tsx +++ b/lib/tcmd/TokenIdentifiers.tsx @@ -802,11 +802,11 @@ export const buildOnlyDefaultElements = () => { // on-demand resolver registerIdentifier( "on-demand resolver", - /\?\?\[.*?\](\(.*?\))?<<(.*?)>>/g, + /\?\?\[.*?\]\(.*?\)<<(.*?)>>/g, (s) => { const inp = s.match(/(?<=<<)(.*?)(?=>>)/)![0]; - const template = s.match(/(?<=\?\?\[)(.*?)(?=\])/)![0]; - const title = s.match(/(?<=\]\()(.*?)(?=\))/)?.at(0); + const title = s.match(/(?<=\?\?\[)(.*?)(?=\])/)![0]; + const template = s.match(/(?<=\]\()(.*?)(?=\))/)![0]; if (inp == undefined) return { content: "Error parsing resolver: " + s, diff --git a/md/help articles/How to use ttcMD.md b/md/help articles/How to use ttcMD.md index cc45930..1b3fb86 100644 --- a/md/help articles/How to use ttcMD.md +++ b/md/help articles/How to use ttcMD.md @@ -368,17 +368,17 @@ Let's say you want to get the the result of rolling a dice field. You would simp This works very similarly to the normal resolver, but when it renders it will have a button that you can press. When you press it, it recalculates its value. This is very useful for dice and decks of cards. It has not been fully implemented yet -Here's the syntax: `??[Template](Text?)<>`. Template is a basic string that has access to all values of the resolver using the `$#` variables. If template is left blank, the value that the resolver finally reaches will be rendered. In lieu of a template, you can also have it render the display of a field if it has one. Text is the text that will be rendered in the button. If not provided, the button will simply same "Resolve." +Here's the syntax: `??[Text](Template)<>`. Template is a basic string that has access to all values of the resolver using the `$#` variables. If template is left blank, the value that the resolver finally reaches will be rendered. In lieu of a template, you can also have it render the display of a field if it has one. Text is the text that will be rendered in the button. If not provided, the button will simply same "Resolve." [][] [[ -To use the dice as an example again, here's how you would do that: `??[Rolling $0, you got: $1](Roll 2d6)<<_.path.to.dice,$0.roll>>` +To use the dice as an example again, here's how you would do that: `??[Roll 2d6](Rolling $0, you got: $1)<<_.path.to.dice,$0.roll>>` -??[Rolling $0, you got: $1](Roll 2d6)<<_.path.to.dice,$0.roll>> +??[Roll 2d6](Rolling $0, you got: $1)<<_.path.to.dice,$0.roll>> ]] [[ -For drawing a card and having it show the card's display: `??[]<<_.path.to.deck,$0.draw,$1.display>>` +For drawing a card and having it show the card's display: `??[]()<<_.path.to.deck,$0.draw,$1.display>>` ]] /[]