
I have read the documentation: https://help.roll20.net/hc/en-us/articles/4403865972503-Custom-Roll-Parsing-for-Character-Sheets#GettingStarted-BuildingaCharacterSheet
and I have gotten Oosh's example working from the thread 'Adventures with startRoll(); which included pulling in the .js library from Oral Orcs: https://app.roll20.net/forum/post/10346883/slug%7D and https://github.com/onyxring/Roll20OralOrcs/blob/master/OralOrcs.pdf
Here is the background for my challenges...
I don't need the re-roll functionality that Oosh's example has. I simply need to parse the results of a single 'startRoll()' call.. On the surface, what I have to do is straight-forward. The implementation is proving troublesome.
In my basic sheet, my roll macros leverage a lot of built-in functionality. Here is an example rollstring:
&{template:trait} {{name=@{character_name}}} {{skill=Agility}} {{Agility Roll=[[{1d@{agility}, @{player}d6!}kh1 + ?{Modifier IE: -2 or 2|0}[Modifier] - @{fatigue}[Fatigue] - @{wound}[Wounds] - floor(@{anxiety} / 3)[Anxiety] ]] }} {{fatigue=@{fatigue}}} {{wounds=@{wound}}} {{anxiety=@{anxiety} }} {{Madness = [[@{madness}d6[Madness]]]}}
The request from my players is to highlight when Critical Failures are rolled, or when the first die of from two rolls are both 1's. I wasn't able to find a way to do that using the basic sheet functionality. So... I am experimenting with custom roll parsing. I have been successful with a very basic rolls. For example, the following works well:
const rollstring = '&{template:trait} {{name=@{character_name}}} {{skill=Agility}} {{roll1=[[{1d@{agility}, @{player}d6!}kh1 }}';
const results = await startRoll(rollstring);
const thedice= results.results.roll1.dice;
const firstroll=thedice[0];
const secondroll=thedice[1];
var critFail = 0;
if(firstroll == 1 && secondroll == 1) critFail=1;
finishRoll(
results.rollId, {
roll1: critFail,
}
);
If I attempt to add some of the features from the rollstring above, the 'results' variable is not the same structure. For example:
const results = await startRoll(rollstring);
const thedice= results.results.roll1.dice; <- this triggers an exception when extra stuff is in the rollstring: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'dice')
I am hoping that someone can point me to some more robust documentation, or even better, a working example of startRoll() that is processing more complex rollstrings.
Any help or direction is greatly appreciated.
Kind regards,
-Sean