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

Running a macro on all selected tokens and general "adds" handling.

Hello everyone. I am currently doing some experiments in gameplay (ATB-like system) and I have a few problems : 1. I have defined an Initiative macro for each token, and I would like to know if there is a script that already exists for running a macro (here initiative) on all selected token. I only found one that can edit an attribute on all selected tokens. Note : The formula for Initiative may be different on each token. 2. Additionally, while thinking about AoE spells (or attacks), I was wondering if there was an easier way for selecting multiple targets. I found how to use a macro that selects N targets, but the N is fixed. (ie I can make a macro that selects 6 tokens, but how do I use it to only hit 3 tokens if there are no more ennemies ?) 3. Is there a way to randomly select an abilty to use for each token ?. I stumbled opon this : <a href="https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=7510651#post-7510651" rel="nofollow">https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=7510651#post-7510651</a> I hoped that this would work on abilities too (ennemies using different attacks)&nbsp; but it appears it doesn't. I can make an ability "Atk" that contains "%{@{character_name}|[[[1d2]]]}" and two other abilities named "1" and "2", but they won't be called. "%{@{character_name}|1}" and "%{@{character_name}|2}" both work fine. Thanks !
1578669741

Edited 1578669760
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Vincent . &nbsp;said: Hello everyone. I am currently doing some experiments in gameplay (ATB-like system) and I have a few problems : 1. I have defined an Initiative macro for each token, and I would like to know if there is a script that already exists for running a macro (here initiative) on all selected token. I only found one that can edit an attribute on all selected tokens. Note : The formula for Initiative may be different on each token. The API script Group Inititive can handle this, depending on the formula, but reqiuires a Pro subscription. Out of the box, macros are generally one per token. 2. Additionally, while thinking about AoE spells (or attacks), I was wondering if there was an easier way for selecting multiple targets. I found how to use a macro that selects N targets, but the N is fixed. (ie I can make a macro that selects 6 tokens, but how do I use it to only hit 3 tokens if there are no more ennemies ?) I've never explored this, perhaps some else has a technique to share. 3. Is there a way to randomly select an abilty to use for each token ?. I stumbled opon this :&nbsp; <a href="https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=7510651#post-7510651" rel="nofollow">https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=7510651#post-7510651</a> I hoped that this would work on abilities too (ennemies using different attacks)&nbsp; but it appears it doesn't. I can make an ability "Atk" that contains "%{@{character_name}|[[[1d2]]]}" and two other abilities named "1" and "2", but they won't be called. "%{@{character_name}|1}" and "%{@{character_name}|2}" both work fine. It looks like you have one too many brackets in your formula. Try this: %{@{character_name}|[[1d2]]}
1578676970

Edited 1578678074
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
For #2, I've got a proto script that's been in development hell that uses the draw tools to select the effect area, so it's possible, there's just not currently an API script available for it, but as for most of your stuff, a pro subscription will be necessary for access to the API. Note that this means the creator of the game needs the pro subscription. For #3, unfortunately, that's not possible without an API script due to the order of operations . To summarize, and correct some incorrect information in that article, the order of operation steps are: Abilities are expanded (e.g. %{character name|ability_1}) macros are expanded (e.g. #macro-name) attributes are expanded (e.g. @{attribute_name}) Repeat the above three steps until no further expansion possible, or the maximum depth has been reached. Note that if you ever run into the maximum depth, you've gone insanely overboard. Roll Queries are executed up to a maximum depth, processing html encoding (e.g. &amp;#125;) at each execution. Inline rolls are executed (e.g. [[1d4]]) chat commands are resolved (e.g. /em or /r) chat is parsed so that html entities are resolved (e.g. &amp;#125; becomes }) The completely parsed chat message is sent to the chat and the API receives it at this point as well Since inline rolls aren't resolved until after all the attribute and ability expansion is completed, what you're ability call actually looks for is an ability named [[1d2]] instead of 1 or 2 .
1578677805

Edited 1578677835
vÍnce
Pro
Sheet Author
Vincent . said: 2. Additionally, while thinking about AoE spells (or attacks), I was wondering if there was an easier way for selecting multiple targets. I found how to use a macro that selects N targets, but the N is fixed. (ie I can make a macro that selects 6 tokens, but how do I use it to only hit 3 tokens if there are no more ennemies ?) This may be what you're looking for; UNDOCUMENTED FEATURE everyone should know about! TL;DR :&nbsp;Variable numbers of targets in an AoE attack.
1578678307
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That SERIOUSLY needs to be in Stupid Tricks...
1578678604
vÍnce
Pro
Sheet Author
keithcurtis said: That SERIOUSLY needs to be in Stupid Tricks... Oldie but a goodie.
1578684201
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I've never seen it. That thread is antediluvian.
1578716382
Gen Kitty
Forum Champion
*crinkles her nose*&nbsp; It's all dusty and wrinkled.&nbsp; Do you seriously still want it? ;)
1578733256
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
&lt;Indy&gt; "It belongs in a museum !"&lt;/Indy&gt;
Thanks everyone for the answers. Understanding the order of operations helped me debug some annoying abilities (I think the @ and % order are reversed whether you have "saved" an ability and are rolling it, or if you are rolling it before saving.) I have now gone with Pro in order to directly modify the sheets I use. I haven't done css/html/javascript before but I'm getting the gist of it. Doing 1. will probably be easy now (but I haven't gotten to it yet). As for 2, I was thinking about having drop down menu for the number of targets an attack roll. As copying/pasting mostly the same roll would be a pain (especially because the damage formula is nightmarish atm), I'd like to split my formula into multiple sub-formulas. Before editing the sheet directly, I was doing this by have multiple "fake characters" for each system (ex %{initiative|standard} would be my initiative roll), in order to have my "code" neatly organised. Now I am thinking about storing the formulas at the beggining of my .html with something like : &nbsp;&nbsp;&nbsp; &lt;input type="hidden" name="attr_basedm" value="[[(@{armedmcar}+@{armedmdiv})**2]]" /&gt; &nbsp;&nbsp;&nbsp; [...] &nbsp;&nbsp;&nbsp; &lt;input type="hidden" name="attr_rollsingleatk" value="&amp;{template:co1} [...]" /&gt; And then in my repating_attacks, I would have an attribute for the current attack roll, which would be [[@{rollsingleatktarget1}]] for only one target, and [[@{rollsingleatktarget1} @{rollsingleatktarget2}]] for two targets, modified by a drop down menu. Would a system like this work ? Is there an obvious better way ?