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

Is there a reliable way to call two different API scripts within the same macro?

I've tried this in the past, and had mostly failure. Sometimes both scripts would fire, but most of the time one would fail silently. I've tried putting # on line breaks and all that, but doing so never resulted in any kind of stability. I'd dearly love to know if anyone has a trick for making this work. If I could fire two scripts within the same macro, I'd have a lot of quality of life improvements I could make to my games.
If you post the macro you are using, and the expected/desired output, then you'll likely get some help with specifics. :)
1610348300
Pat
Pro
API Scripter
It may also depend on the APIs - my Teleport scripts and others look for their API call as the first set of characters in any msg.content - so if they're combined, they won't work unless they're first. 
1610349167

Edited 1610349593
I run into this issue a lot, too. I've never come across a dependable way to do this. First command almost always goes off, while any after that will happen maybe 8 times outta 10. Here's some examples of methods I've tried: Using bangs after each command; Macro for bringing up CombatMaster menu and a chat menu using SendText !cmaster --main ! !sendtext {{}} {{charactername=Encounter Helper}} {{header=Menu}} {{desc=[Pages](!eh pagelist) [Encounters](!eh list) [New Encounter](~macro|EHNew)}} ! Same script only, no extra lines; Macro for resetting spell slots (the first 3-6 usually go off) !wammo -M1YZAJ5jTW2NV3Ze04C focus_points +[[@{selected|focus_points|max}-@{selected|focus_points}]] Focus Point !wammo -M1YZAJ5jTW2NV3Ze04C level_9_per_day +[[@{selected|level_9_per_day|max}-@{selected|level_9_per_day}]] level 9 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_8_per_day +[[@{selected|level_8_per_day|max}-@{selected|level_8_per_day}]] level 8 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_7_per_day +[[@{selected|level_7_per_day|max}-@{selected|level_7_per_day}]] level 7 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_6_per_day +[[@{selected|level_6_per_day|max}-@{selected|level_6_per_day}]] level 6 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_5_per_day +[[@{selected|level_5_per_day|max}-@{selected|level_5_per_day}]] level 5 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_4_per_day +[[@{selected|level_4_per_day|max}-@{selected|level_4_per_day}]] level 4 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_3_per_day +[[@{selected|level_3_per_day|max}-@{selected|level_3_per_day}]] level 3 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_2_per_day +[[@{selected|level_2_per_day|max}-@{selected|level_2_per_day}]] level 2 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_1_per_day +[[@{selected|level_1_per_day|max}-@{selected|level_1_per_day}]] level 1 spell slot Storing the other command in a separate macro; Macro for showing CombatMaster statuses and a chat menu using Universal Chat Menu !cmaster --show,assigned #Active-Conditions
1610375149
The Aaron
Roll20 Production Team
API Scripter
Hmmm...That's really peculiar.  It may be something with specific commands.  My Walls script uses individual commands for each line segment and can sometimes be hundreds of api commands in a single message and I've not had problems with it.  It might be that the API loses some sort of state when asynchronous functions occur as part of an API command, or perhaps if the commands resulting a sendChat() call.  I'll have to try and duplicate this. 
1610375280
The Aaron
Roll20 Production Team
API Scripter
Pat said: It may also depend on the APIs - my Teleport scripts and others look for their API call as the first set of characters in any msg.content - so if they're combined, they won't work unless they're first.  All API commands should only respond if they are the first thing on a msg.context.  That allows commands to be passed to other scripts.  With a multi-line chat message, each line is passed to the API as an individual message, with the exception that {{ }} permit line breaks inside them and don't cause a new message (but API commands that begin lines inside a {{ }} do not get detected as API commands).
Persephone said: I run into this issue a lot, too. I've never come across a dependable way to do this. First command almost always goes off, while any after that will happen maybe 8 times outta 10. Here's some examples of methods I've tried: Using bangs after each command; Macro for bringing up CombatMaster menu and a chat menu using SendText !cmaster --main ! !sendtext {{}} {{charactername=Encounter Helper}} {{header=Menu}} {{desc=[Pages](!eh pagelist) [Encounters](!eh list) [New Encounter](~macro|EHNew)}} ! Same script only, no extra lines; Macro for resetting spell slots (the first 3-6 usually go off) !wammo -M1YZAJ5jTW2NV3Ze04C focus_points +[[@{selected|focus_points|max}-@{selected|focus_points}]] Focus Point !wammo -M1YZAJ5jTW2NV3Ze04C level_9_per_day +[[@{selected|level_9_per_day|max}-@{selected|level_9_per_day}]] level 9 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_8_per_day +[[@{selected|level_8_per_day|max}-@{selected|level_8_per_day}]] level 8 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_7_per_day +[[@{selected|level_7_per_day|max}-@{selected|level_7_per_day}]] level 7 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_6_per_day +[[@{selected|level_6_per_day|max}-@{selected|level_6_per_day}]] level 6 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_5_per_day +[[@{selected|level_5_per_day|max}-@{selected|level_5_per_day}]] level 5 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_4_per_day +[[@{selected|level_4_per_day|max}-@{selected|level_4_per_day}]] level 4 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_3_per_day +[[@{selected|level_3_per_day|max}-@{selected|level_3_per_day}]] level 3 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_2_per_day +[[@{selected|level_2_per_day|max}-@{selected|level_2_per_day}]] level 2 spell slot !wammo -M1YZAJ5jTW2NV3Ze04C level_1_per_day +[[@{selected|level_1_per_day|max}-@{selected|level_1_per_day}]] level 1 spell slot Storing the other command in a separate macro; Macro for showing CombatMaster statuses and a chat menu using Universal Chat Menu !cmaster --show,assigned #Active-Conditions Thanks for this, Persephone. I too have used ! on multiple lines (I think, at your suggestion awhile back!), only with intermittent success.  My use case is wanting to use both Tokenmod and ChatSetAttr in the same macro: the first to assign an exhaustion marker to a token, the second to increment the Exhaustion resource on the character. But every time I try to run this macro, one or the other script fails silently. Even when using !. 
Jay R. said: My use case is wanting to use both Tokenmod and ChatSetAttr in the same macro: the first to assign an exhaustion marker to a token, the second to increment the Exhaustion resource on the character. But every time I try to run this macro, one or the other script fails silently. Even when using !.  What is the actual macro you are using? Which other scripts are you using (do you have loaded in the API)?
Jarren K. said: Jay R. said: My use case is wanting to use both Tokenmod and ChatSetAttr in the same macro: the first to assign an exhaustion marker to a token, the second to increment the Exhaustion resource on the character. But every time I try to run this macro, one or the other script fails silently. Even when using !.  What is the actual macro you are using? Which other scripts are you using (do you have loaded in the API)? Well, the issue of two scripts not working from the same macro is one many people have encountered. But for what it's worth, here's my macro: !modbattr --sel --class_resource|+1 --fb-from @{selected|character_name} --fb-header Exhaustion --fb-content Your exhaustion level is now **_CUR0_**. &{template:default} {{name=Exhaustion Levels}} {{Lvl. 1=Disadvantage on ability and skill checks}} {{Lvl. 2=Speed halved}} {{Lvl. 3=Disadvantage on attack rolls and saving throws}} {{Lvl. 4=HP maximum halved}} {{Lvl. 5=Speed reduced to 0}} {{Lvl. 6=Death}} !token-mod --set statusmarkers|Exhaustion1 I have a ton of scripts loaded in the API: 5th Edition by OGL Companion Carry Token ChatSetAttr Check It Out ColorEmote Combat Master DeathTracker DoorKnocker EncounterHelper Flying GroupInitiative GroupCheck InspirationTracker MapChange MapLock MultiWorld Calendar PurseStrings RecursiveTable Roll20 Audio Master SpellMaster Supernotes Teleport Token Action Maker TokenMod TokenNameNumber WildShape
For your specific case, Jay, since you're already using CombatMaster, you could set up that marker as a condition and have that condition call the ChatSetAttr command. A lot of the conditions I have set up call a ChatSetAttr command directly and a TokenMod command thru a macro, and so far I've had no issues with commands not going through this way.
Persephone said: For your specific case, Jay, since you're already using CombatMaster, you could set up that marker as a condition and have that condition call the ChatSetAttr command. A lot of the conditions I have set up call a ChatSetAttr command directly and a TokenMod command thru a macro, and so far I've had no issues with commands not going through this way. Ah, that's true. I've held off on calling scripts through CM, but I should probably figure it out. Thank you!
1610397427
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The only time I have encountered this issue is with ChatSetAttr. I just  always assumed it was a timing thing: that the subsequent commands picked up the values before the change was truly "set".