Parse for dice and dice callback features #137
-
I've been unable to find information to help me understand exactly how the dice callback option works, in particular, what the appropriate return format is when multiple die expressions should be extracted. I've looked at the relevant section of the readme, but this doesn't explain how it renders the results. For one, from looking at the HP/HD field, it seems like the die expression is added in brackets after the die expression. Could we get more documentation about using the dice callback feature, and how it works? Additionally, it seems like there are some important implementation details for automatic die parsing: for example, the to-hit roll reads '(Attack +X)' after the roll (rather than '(d20 + X)'). Is it possible to replace the (seemingly complex) automatic parsing which is applied to actions by using a dice callback? I originally started looking into this because I wanted to remove the average result from the extracted attack roll, as well as add a missing space after the closing brackets: (the latter of which I see was fixed just four hours ago :P) Edit: Seems like the text which is being replaced is what appears in the brackets ('Attack +X'; '1d6 + 2'; etc). Is this only how the automatic die parsing works? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I've been playing around recently with the Dice Callback field. My goal has been to combine two values from the statblock My next step is to try and display the value of athletics ( or some text ) followed by the rollable dice equal to "1d20 + body + athletics". Any suggestions?
|
Beta Was this translation helpful? Give feedback.
-
Yes, the automatic dice parsing looks for specific text patterns to replace with dice. The dice callback expects you to return an array of strings or objects, that it will then combine into a combination of text and dice rollers. The object is: interface DiceCallbackObject {
text: string //string to be parsed into a dice roll
original?: string //optional. will be placed after the dice roll in parenthesis
} For example:
will result in "The monster has <dice roll 1d20 + 2>" also, yeah, there’s no documentation around this, sorry! |
Beta Was this translation helpful? Give feedback.
Yes, the automatic dice parsing looks for specific text patterns to replace with dice.
The dice callback expects you to return an array of strings or objects, that it will then combine into a combination of text and dice rollers.
The object is:
For example:
return ["The monster has: ", { text: "1d20 + 2" }];
will result in "The monster has <dice roll 1d20 + 2>"
also, yeah, there’s no documentation around this, sorry!