Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Accessing Inline roll labels from Roll Templates?

1516322199
jflo
API Scripter
So I'm working on a new sheet for a new system. This system uses a pooled die mechanic, where each die represents one aspect of the action; typically skill + attribute + equipment. So lets say you are attacking someone, you would roll Combat (1d10) + Agility (1d8) + Sword (1d6), add them all up and try to beat your opponent. 1's on any die should be considered a "fumble", and have implications; If the d6 came up a 1, you just dented your sword and now it's a d4. Thats the gist of it. So I'm using inline rolls, because I have to have the total. If I break up the toll into attributes for a template roll, then I can't sum them. This was very surprising to me, but it seems that the intent behind the template is to represent different rolls which do not interact with each other, and thus cannot be summed. Now, this actually works with inline rolls like: /roll 1d6[sword]+1d10[combat]+1d8[agility] But god that looks terrible. And I don't seem to be able to access the labels at all within the roll template, nor any of the aspects of the inline roll which I can much more richly interact with via the API. I see that I can use allProps() to iterate over the key/value pairs in the template input, but since I need the sum I was forced to send that as a single inline roll.  Are there any other interesting undocumented ways to interact with a template input than via the key/values exposed by allProps()? Can I get at those labels somehow? Is there a hidden way to sum up multiple properties sent to a template roll? I'm not married to the inline roll, and could easily refactor this to just send each attribute to a template if I could actually sum them all within the template. If neither of these are options, where do I begin looking into how to intercept the roll with the API, and render roll-template-like output as a hack/workaround. I'd really rather avoid this because it would make the charsheet dependent on an API script. TIA!
1516326189
GiGs
Pro
Sheet Author
API Scripter
You could create a roll template which has some extra properties, like {{die1=sword}} {{die2=combat}} etc and then in the rolltemplate code, you can print out {{die1}} in the place where sword would appear. So you can basically fake it. You can also set crit fail and crit success rolls the die roll, and intercept them in the rolltemplate, to print something out to indicate it's happened. I don't think you can detect which die has fumbled (rolled a 1) but you can definitely print something out when any  of them have fumbled, as a reminder to prompt people to look at the individual dice rolls.  You can't sum multiple properties sent to a roll template. That's just a no-go. Finally, if you want to have a roll intercepted by the API, this is easy. just start the line with a ! and the name of the function. So the roll button value would be something like ="!die-pool sword:[[1d6]] combat:[[1d10]] agility:[[1d8]]" And you'd then write a function named die-pool to intercept that and do stuff with the three values.
1516328357
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
For what you want to do, the API is the only way forward. But on the plus side, you don't need to reinvent the wheel. Just use the powercards script .
1516375985

Edited 1516376101
Silvyre
Forum Champion
Scott C. said: Just use the powercards script . To give an example: !power {{ --Sword|[! [^S.base] !] --Combat|[! [^C.base] !] --Agility|[! [^A.base] !] --Total|[[ [$S]{1d6} + [$C]{1d10} + [$A]{1d8} ]] --?? $S.base == 1 OR $C.base == 1 OR $A.base == 1 ?? !| ~C Fumble! ~C }}