Changed order of resolver fields

This commit is contained in:
Emmaline Autumn 2024-08-21 14:23:06 -06:00
parent e5f3cb0c34
commit f6fc85bf7e
3 changed files with 13 additions and 7 deletions

View File

@ -3,9 +3,15 @@ import { sum } from "./utils/sum";
export class Dice { export class Dice {
private count!: number; private count!: number;
private sides!: number; private sides!: number;
private diceString: string;
toString() {
return this.diceString;
}
constructor(dice: string) { constructor(dice: string) {
this.parseDice(dice); this.parseDice(dice);
this.diceString = dice;
} }
private parseDice(dice: string) { private parseDice(dice: string) {

View File

@ -802,11 +802,11 @@ export const buildOnlyDefaultElements = () => {
// on-demand resolver // on-demand resolver
registerIdentifier( registerIdentifier(
"on-demand resolver", "on-demand resolver",
/\?\?\[.*?\](\(.*?\))?<<(.*?)>>/g, /\?\?\[.*?\]\(.*?\)<<(.*?)>>/g,
(s) => { (s) => {
const inp = s.match(/(?<=<<)(.*?)(?=>>)/)![0]; const inp = s.match(/(?<=<<)(.*?)(?=>>)/)![0];
const template = s.match(/(?<=\?\?\[)(.*?)(?=\])/)![0]; const title = s.match(/(?<=\?\?\[)(.*?)(?=\])/)![0];
const title = s.match(/(?<=\]\()(.*?)(?=\))/)?.at(0); const template = s.match(/(?<=\]\()(.*?)(?=\))/)![0];
if (inp == undefined) if (inp == undefined)
return { return {
content: "Error parsing resolver: " + s, content: "Error parsing resolver: " + s,

View File

@ -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 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?)<<List::QueryValue>>`. 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)<<List::QueryValue>>`. 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>>`
]] ]]
/[] /[]