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

Any way to call an api command or macro in a sheet roll button using a roll template?

Hi, So I'm trying to create roll button on a character sheet that puts an api command output into part a the roll template, i.e. something like: <button type="roll" value="&{template:basicroll}{{name=@{character_name} }} {{roll=!apicommand }}" name="roll_basic">Roll Button</button> Is something like that even possible? If not, is there a way to call a macro that would set off the command or is there some better way I should be approaching this?
1624728683
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yes, this is possible. The roll buttons just output things to chat, so as long as what gets sent to chat is in the format that the API expects, it's all good. To send a standard api command, you'll need to introduce a new line between the roll template and the api command. You'll want to use \n  to create the new line: <button type="roll" value="&{template:basicroll}{{name=@{character_name} }} \n!apicommand" name="roll_basic">Roll Button</button> I do want to note that if you are planning to release this sheet publicly, it can't depend on an api function to be included in the Roll20 repository of sheets.
Thank you Scott, this is what I was missing. If I do release a public version I'll definitely be removing the API inclusion. I want it setup this way because it's for an Exalted 3e/Exalted Essence game and the base roll functionality in roll20 doesn't handle a specific dice trick the game uses (counting certain results on d10 roll as two 2 successes rather than just 1), so for our personal game I want to include the API command for the script someone built that handles and outputs that in a way I prefer.
1624741994

Edited 1624895831
GiGs
Pro
Sheet Author
API Scripter
You dont necessarily have to completely remove the API parts for a public release. You just have to make them an option that people can choose to use, but hidden in normal use so that free users can still use the sheet. By the way, if Exalted has no special effects on a 1, you can calculate the results without needing the API. If you're rolling 6 dice, for example, this would work: /roll 6d10>10F<6 +6 Roll20 has a failure point counting mechanic. So by changing the success to 10, and failure to 6-, you end up with a die that on 10 gives 1 success, 7-9 0 successes, and -1 success on 1-6. If you add 1 success for each die, you get the exalted method of 1 success on 7-9, 2 on 10, and 0 on 1-6. So for using an attribute you'd do /roll (@{attribute}+@{skill})d10>10F<6 +(@{attribute}+@{skill}) or if you prefer to see less working /roll [[@{attribute}+@{skill}]]d10>10F<6 +[[@{attribute}+@{skill}]]
Interesting, thank you for that explanation! I had been trying to see if there was a way to do it natively and it seemed no one had really tried or they wanted more functionality such as being able to set all the tediously specific dice tricks in Exalted 3e and so I figured it wasn't doable or had issues. Since we're looking at using Exalted Essence (which has significantly fewer needless dice tricks) that may be a great solution and I really appreciate you breaking it down. :)
1624895913
GiGs
Pro
Sheet Author
API Scripter
Great! I just edited my post to correct an error in my description (you get -1 success on rolls of 1-6, not 0).