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

Roll Template from Api Command Button

September 15 (5 years ago)

Edited September 15 (5 years ago)

Hey everyone, I started messing with more advanced macros a few days ago, and I am trying to create a macro with will show a API Command Button (https://wiki.roll20.net/API:Chat#API_Command_Buttons) which when clicked will show a Roll Template (https://wiki.roll20.net/Roll_Templates). I suppose it should be something like this:


 [Normal Hit](!
&{template:default} {{name=Attack!}} {{Slashing= [[d6+3]] }} {{Necrotic= [[d8]]}})


But the above just shows the template with the button appearing. I suppose could do with two different macros, one for the button and other for the template, but I'd rather get it all in a single place. I haven't found any examples of it being done after searching for a couple hours, sorry if this has been asked before.

September 15 (5 years ago)
Kraynic
Pro
Sheet Author

See if this post gets you going.  https://app.roll20.net/forum/permalink/5927072/

You may want to look through that thread for other things also.  The first post is an index.

September 15 (5 years ago)

Edited September 15 (5 years ago)

Sorry, but that post you linked shows me how to create a macro which displays a Template which contains a Button. That is not what I am looking for. I am trying to create a macro that displays a Button that, when clicked, displays a template. I am looking at the other referenced links, but none of them seem to be related to it

September 15 (5 years ago)

Edited September 15 (5 years ago)

I figured it out. If anyone ever wants to do this in the future:

[Normal Hit](!
/w gm &{template:default} {{name=Test With Ability}} {{attack= 3 }} {{damage= [[d10]] }})

or alternatively

[Normal Hit](!
/me &{template:default} {{name=Test With Ability}} {{attack= 3 }} {{damage= [[d10]] }})

In any case, you can't use just straight up the template. You need to use some command that says something ("/ooc" also works) and replace the "&" by "&", the "[" by "[" and the "]" by "]"

September 15 (5 years ago)
Kraynic
Pro
Sheet Author

I think you will find that post is exactly what you want.  You create macros you want.  Then you make command buttons using the name of the macro to link to your already created commands. Or is there some reason that your first button can't be in a template?

September 15 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Either solution will work, but unless there is a pressing need to write it the way you have it, Kraynic's suggestion is much simpler, requiring no HTML substitutions.

September 15 (5 years ago)

Edited September 15 (5 years ago)

Basically, what I wanted to do is have a macro which would roll the attack and give me buttons to press once I decided if it was a miss, a hit or a crit. I was also trying to make it not be displayed to my players, since I could decide to say that the monster had rolled a 3 when it had been a 20 or vice-versa.

Since I don't use Character Sheets for normal monsters (find it too much of a hassle) and I don't have the premium subscription to use the more advanced API calls, I wanted to have everything in a single macro, to make combat quicker and to avoid having to create two or three macros for each different attack a monster has (one for the roll and button display, one for each button press).

I eventually managed to do it (image above), but the macro code is ugly as hell to make by hand, so I made a Python script to do it for me, and looks to be working fine. I can share it here if there is any interest.

Probably not the intended use of the feature, nor the prettiest thing I've ever done, but works for me.


Macro code of the image above:

/w gm [[d20+7]] [Hit](!
/ooc &{template:default} {{name=It hits!}} {{Fire = [[3d10+0]]}} {{Bludgeoning = [[2d6+3]]}}) [Crit](!
/ooc &{template:default} {{name=It's a Critical Hit!}} {{Fire = [[3d10+30+0]]}} {{Bludgeoning = [[2d6+12+3]]}})