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

Calling an API Script from a Macro

I'm brand new to Roll 20 Pro and exploring scripts.  One thing that I've been digging around on the Internet for a couple of hours to find is how to call a script from a macro.

This will work if it is the only thing in the macro.

[[!ammo @{Antoine Robert (Brian)|character_id} wind -[[1d4]] wind]]

But, if I add it to this, then it doesn't.

&{template:default} {{name=Malison}}{{Speed=1}}{{Duration=The victim  can attempt to recover on each of his Actions by making a Vigor roll against a Fair (5) TN. The TN is increased by +2 for each raise the voodooist received over her victim’s total}}{{Range=[[@{Antoine Robert (Brian)|Conjuration}*5]] Feet}}{{Roll=[[@{Antoine Robert (Brian)|Conjuration}@{Antoine Robert (Brian)|spidtype}k1!!]]}}{{TN=Victim's Spirit Trait}}{{Desc=Victim is stunned until recovered.  If she fails, the spell simply fizzles.
However, if voodooist goes bust, she is stunned and must roll her Vigor against an Onerous (7) TN to recover.
Malison is very taxing on the voodooist and costs her 1d4 Wind each time she casts the spell. If she loses consciousness, the spell fails.}}[[!ammo @{Antoine Robert (Brian)|character_id} wind -[[1d4]] wind]]

Can you please explain what I'm doing wrong here?

May 17 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

This entry for Chat Menus will give you all the background and syntax you need for various cases. However, in general, you can't just have an API script be triggered and report inline.

Basically though, you can put a button into the  roll template with this format:

[button name](!some API command)

and click the button to issue the command.

Thank you, Sir.  Now, I've put the macro in a char sheet named "Global." 

{{[Malison](!ammo @{selected|character_id} wind -2)}}

will work, but 

 {{[Malison](!ammo @{selected|character_id} wind -[[1d4]])}}

won't. 

It throws an error

Antoine Robert (Brian) gains NaN Rolling 1d4 = (4)'>4 and has NaN remaining.
May 17 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I'm not familiar enough with the ammo script, but how about:

 {{[Malison](!ammo @{selected|character_id} wind [[0-1d4]])}}

May 18 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

my speculation is that the inline expansion when the button is created results in something strange on the command line for the ammo command.  Try:

 {{[Malison](!ammo @{selected|character_id} wind -[[1d4]])}}

thanks guys

The Aaron's speculation was on the money.  I made that edit and the thing works great now.