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 a macro from a macro (in this case, Ammo API)

Per the support pages  , I should be able to call another macro from within a macro by prefacing it with the # symbol.  So if I have a macro for a ranged attack, and want to call the Ammo script, I should be able to put my script into another macro on the character sheet (in the Abilities section) and have it call it with #.  However, when I run my attack macro, it doesn't pull the ammo macro.  This is playing Pathfinder 1e, with the Roll20 sheet.   The attack macro @{Yaan|whispertype} &{template:pc} {{name=Rapid Shot}} {{type=attackdamage}} {{showchar=@{Yaan|rollshowchar}}} {{charname=@{Yaan|character_name}}} {{nonlethal=[[1[Nonlethal]]]}} {{attack=1}}{{range=110 ft}}{{roll=[[1d20cs>20 + 13[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] ]]}} {{critconfirm=[[1d20cs20 + 13[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS] ]]}}{{atkvs=(Ranged vs AC)}}{{roll1=[[1d20cs>20 + 8[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] ]]}} {{critconfirm1=[[1d20cs20 + 8[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS] ]]}}{{shownotes=[[1]]}}{{notes=[[2d6+3]] for 3rd shot GB}}{{rolldmg1=[[1d8+2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{rolldmg1type=Piercing}}{{rolldmg1crit=[[((1d8+1d8+1d8) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll1dmg1=[[1d8+2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{roll1dmg1type=Piercing}}{{roll1dmg1crit=[[((1d8+1d8+1d8) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{dmg2name=Damage2}}{{rolldmg2=[[2d6 + 2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{rolldmg2type=Gravity Bow}}{{rolldmg2crit=[[((2d6+2d6+2d6) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll1dmg2=[[2d6 + 2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{roll1dmg2type=Gravity Bow}}{{roll1dmg2crit=[[((2d6+2d6+2d6) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll7name=Rapid Shot}}{{roll7=[[1d20cs>20 + @{Yaan|ranged_mod}[Ranged] + 0[MOD]+ 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY]]]}}{{critconfirm7=[[1d20cs20 + @{Yaan|ranged_mod}[Ranged] + 0[MOD]+ 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS]]]}}{{roll7dmg1=[[1d8 + @{Yaan|strength_mod}[STR] + 1[MOD] + @{Yaan|damage_bonus}[TEMP] + @{Yaan|ranged_damage_bonus}[RANGED TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}}{{roll7dmg1crit=[[(1d8 + 1d8) + ((@{Yaan|strength_mod}[STR] + 1[MOD] + @{Yaan|damage_bonus}[TEMP] + @{Yaan|ranged_damage_bonus}[RANGED TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 2)]]}}{{roll7dmg1type=Piercing}} {{conditionsflag=[[@{Yaan|attack_condition}]]}} {{conditions=@{Yaan|conditions_display}}} {{conditionsnote= @{Yaan|attack_condition_note}@{Yaan|damage_condition_note}}} The ammo macro !ammo @{selected|token_id} arrows -?{How  many arrows are you shooting?} arrows I do have an attribute set up called arrows, and when I run Ammo by itself, it works properly.  I just can't get it to run when bundled with the attack macro.  I do have a token selected. Thanks!
I believe the script command has to be at the start of a new message, so you'd have to place that second macro after a line break. I haven't messed around with mod scripts at all, though, so I can't help more than that.
1736352590
The Aaron
Roll20 Production Team
API Scripter
I think that's spot on. The first character on the line must be the ! for API commands, and likely the # must be the first character of a line for macros. 
The Aaron said: I think that's spot on. The first character on the line must be the ! for API commands, and likely the # must be the first character of a line for macros.  Macros can be called wherever (even inside attribute calls, as long as there is a space for the macro call to end), but if the macro contains an API command, then it follows that that macro must be at the start of a line.
1736365212
timmaugh
Forum Champion
API Scripter
Remember, too, that character abilities are called using the % syntax, not the #. The #-syntax is used for Collection Tab macros. So you can accomplish this by having the ammo command first in the message (or at least the call to expand the ammo command). If the ability on Yaan is named "Ammo_for_Arrows", you'd get: %{Yaan|Ammo_for_Arrows} @{Yaan|whispertype} &{template:pc} {{name=Rapid Shot}} {{type=attackdamage}} ... That may run afoul of the dropped line bug  from time to time... although I haven't tested this arrangement (line 1 = script command; line 2 = chat-output command), so it might work just fine. If you want to avoid the dropped line bug, or if you want to do more complex combinations of commands, you can add the Metascript Toolbox, and use batching (with a few other alterations of your command line). The rough gist of that would look like: !{{   %{Yaan|Ammo_for_Arrows}   (^)@{Yaan.whispertype} {^&template:pc} ({)name=Rapid Shot(}) ({)type=attackdamage(}) ... }} I used batching, batch deferral (to hide the template tag from showing up until the second command line is dispatched), and changed the double-braces to their batch-form of paren-brace-paren. If you decide to go this direction, and the linked thread isn't clear enough, or if you just need more detailed help, post back and I'll do my best to show what's going on.
Here is the full text of the macro from the character sheet.  The #ammo is on a line by itself after hitting the Enter key @{Yaan|whispertype} &{template:pc} {{name=Rapid Shot}} {{type=attackdamage}} {{showchar=@{Yaan|rollshowchar}}} {{charname=@{Yaan|character_name}}} {{nonlethal=[[1[Nonlethal]]]}} {{attack=1}}{{range=110 ft}}{{roll=[[1d20cs>20 + 13[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] ]]}} {{critconfirm=[[1d20cs20 + 13[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS] ]]}}{{atkvs=(Ranged vs AC)}}{{roll1=[[1d20cs>20 + 8[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] ]]}} {{critconfirm1=[[1d20cs20 + 8[Ranged] + 0[Ability] + 0[MOD] + 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS] ]]}}{{shownotes=[[1]]}}{{notes=[[2d6+3]] for 3rd shot GB}}{{rolldmg1=[[1d8+2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{rolldmg1type=Piercing}}{{rolldmg1crit=[[((1d8+1d8+1d8) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll1dmg1=[[1d8+2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{roll1dmg1type=Piercing}}{{roll1dmg1crit=[[((1d8+1d8+1d8) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{dmg2name=Damage2}}{{rolldmg2=[[2d6 + 2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{rolldmg2type=Gravity Bow}}{{rolldmg2crit=[[((2d6+2d6+2d6) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll1dmg2=[[2d6 + 2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}} {{roll1dmg2type=Gravity Bow}}{{roll1dmg2crit=[[((2d6+2d6+2d6) + (2[STR] + 1[MOD] + 5[TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 3)]]}}{{roll7name=Rapid Shot}}{{roll7=[[1d20cs>20 + @{Yaan|ranged_mod}[Ranged] + 0[MOD]+ 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY]]]}}{{critconfirm7=[[1d20cs20 + @{Yaan|ranged_mod}[Ranged] + 0[MOD]+ 4[TEMP] + (@{Yaan|attack_condition})[CONDITION] + @{Yaan|rollmod_attack}[QUERY] + @{Yaan|critconfirm_bonus}[CRIT CONFIRM BONUS]]]}}{{roll7dmg1=[[1d8 + @{Yaan|strength_mod}[STR] + 1[MOD] + @{Yaan|damage_bonus}[TEMP] + @{Yaan|ranged_damage_bonus}[RANGED TEMP] + @{Yaan|rollmod_damage}[QUERY]]]}}{{roll7dmg1crit=[[(1d8 + 1d8) + ((@{Yaan|strength_mod}[STR] + 1[MOD] + @{Yaan|damage_bonus}[TEMP] + @{Yaan|ranged_damage_bonus}[RANGED TEMP] + @{Yaan|rollmod_damage}[QUERY]) * 2)]]}}{{roll7dmg1type=Piercing}} {{conditionsflag=[[@{Yaan|attack_condition}]]}} {{conditions=@{Yaan|conditions_display}}} {{conditionsnote= @{Yaan|attack_condition_note}@{Yaan|damage_condition_note}}} #ammo It DOES work if I create an attribute called ammo, and copy the macro into it, and end the rapid shot macro with @ammo, and I can do that if needed, but I'd rather have it as an actual macro under Abilities if possible.
1736370339
timmaugh
Forum Champion
API Scripter
Right. So, there, you're getting the ammo call to its own line, which is enough to let the bang that starts the ammo-macro get registered. I think the original suggestion that you needed to start with a bang (!) was for dealing when one call was embedded in another. I think we can see now that's not what you're doing. So, to get this to a character ability, you just have to move the syntax there, then call it with the form of: %{Character Name|ability_name} ...or, from the sheet itself, you can shorthand that to just: %{ability_name} All other parameters around further development and batching would still apply and still be available if you wanted to take this further.