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

Call a macro on a target token

I cannot figure out how to call a macro on a target token? I know I can get an attribute by using: @{target|MyCustomAttribute}, but I would like to be able to call a macro the same way. Background: Each of my "character" tokens has an attack and defend macro.  I would like the attack macro of the selected token call the defend macro of the target. P.S.  I know I can do anything I want with the API, but I am trying not to use the API for this project.  I want to keep it simple.
1454262803
Diana P
Pro
Sheet Author
Assuming it's stored in an attribute on the character sheet try: @{target|target|CustomDefendMacro} You sometimes need to give it the full name. (from: <a href="https://wiki.roll20.net/Macros#Advanced_Usage" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage</a> ) The full syntax for the target variable is: @{target|&lt;target_name&gt;|&lt;attribute_name&gt;|&lt;optional_flags&gt;} (Note that 'target_name' can be anything you like, and can include spaces.)
1454264295

Edited 1454264742
Yes, the macros are stored on the character sheets, but not as attributes (I didn't know you could put macros in attributes), but as abilities. I read that section of the help, but it didn't make much sense. What would the target_name be in the example above? It says I can name it whatever I want, but I won't know the target token's name ahead of time, that's why I use @{target|token_name}, right? What are the optional_flags that I can use? Here is an example of how I have them set up. &nbsp;Each character sheet has at least these two macros, just using different "dice". I would like to add something like #{target|Defend} or @{target|#Defend} (I've tried so many combinations, none of which have worked) to the all the attack macros to save a step.
1454274038

Edited 1454274054
Diana P
Pro
Sheet Author
Lifer4700 said: Yes, the macros are stored on the character sheets, but not as attributes (I didn't know you could put macros in attributes), but as abilities. I read that section of the help, but it didn't make much sense. What would the target_name be in the example above? It says I can name it whatever I want, but I won't know the target token's name ahead of time, that's why I use @{target|token_name}, right? What are the optional_flags that I can use? Here is an example of how I have them set up. &nbsp;Each character sheet has at least these two macros, just using different "dice". I would like to add something like #{target|Defend} or @{target|#Defend} (I've tried so many combinations, none of which have worked) to the all the attack macros to save a step. Ah.&nbsp; If you are using an Ability, then use the % instead of the @ Perhaps: @{selected|token_name} fires his blaster at @{target|target1|token_name} [[t[Blue-Die] ]] [[t[Green-Die] ]] %{target|target1|Defend} for your macro.&nbsp; Note that the person running the macro probably has to have control over the target to be able to run the target's macro.&nbsp; It will probably error if they don't have control.&nbsp; The GM always has control over the character/token so it will not error for them. Target_name is basically just an internal name for you to keep that target (say the first one) separate from subsequent ones if you have multiple targets.&nbsp;&nbsp; Your macro could have @{target|target1|something} @{target|target1|somethingelse}&nbsp; @{target|target2|something} and it would prompt you to click on 2 different targets and would keep track of which target is which.&nbsp; The only optional flag that I know of is the Max flag for the max column of the Attributes.&nbsp; Otherwise you just get the current column when calling an Attribute. Hope that helps.
1454274631

Edited 1454274698
I would recommend using %{selected|Attack} and %{selected|Defend}, as you're using selected Attributes within those Abilities.
1454275116
Diana P
Pro
Sheet Author
He is trying to run the defend off of the target; that's why he can't use selected for that.
Lifer4700 said: I would like the attack macro of the selected token call the defend macro of the target. Have you considered amalgamating the Abilities? @{selected|token_name} fires his blaster at @{target|token_name}! [[ t[Blue-Die] ]] [[ t[Green-Die] ]] @{target|token_name} defends! [[ t[Black-Die] ]]
1454300202

Edited 1454300318
Thank you all for your suggestions! Silvyre said: Lifer4700 said: I would like the attack macro of the selected token call the defend macro of the target. Have you considered amalgamating the Abilities? @{selected|token_name} fires his blaster at @{target|token_name}! [[ t[Blue-Die] ]] [[ t[Green-Die] ]] @{target|token_name} defends! [[ t[Black-Die] ]] The problem with this is that not everyone rolls the same defense dice, otherwise this would work. Diana P said: Ah.&nbsp; If you are using an Ability, then use the % instead of the @ Perhaps: @{selected|token_name} fires his blaster at @{target|target1|token_name} [[t[Blue-Die] ]] [[t[Green-Die] ]] %{target|target1|Defend} for your macro. Hope that helps. This worked perfectly! Now I just need to remove all the "fluff" text from the Defend macro, and I'm in business! Also, thanks for the explanation of "target_name". &nbsp;It's basically like a variable that holds the pointer to the target object.
1454302233
Diana P
Pro
Sheet Author
Lifer4700 said: Thank you all for your suggestions! &lt;snip&gt; This worked perfectly! &lt;snip&gt; Also, thanks for the explanation of "target_name". &nbsp;It's basically like a variable that holds the pointer to the target object. You are most welcome. Excellent. and yes.&nbsp; :) Happy Gaming!