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

A macro that repeats x amount of times

Hi, I do apologise if a question like this has been asked before however, I cannot find it anywhere nor am I skilled (or really have a clue as to what I'm doing with macros). I've been adding macros to tokens to develop a monster manual for my games and everything has been working so far, but like a few others I have reached the Hydra.  I've added an attribute to the Hydra to represent heads which I've linked to the green bar for the token. Can I get the macro to repeat an amount of times equal to that attribute? Ideally acting like a multi-attack for the Hydra. This is the code inside the macro to attack with one singular head: %{selected|repeating_npcaction_$0_npc_action} Any help on the topic will be great, if it's not achievable its no big deal but I thought I should ask. Thanks!
The base macro syntax has no support to loop or repeat. Such things are limited to Mods (a Pro subscription perk). An alternative would be to use a Chat Menu setup with different buttons to call the ability a differing number of times.
1675652347
GiGs
Pro
Sheet Author
API Scripter
This might be one of the most asked questions, and is a feature that Roll20 really should support (just after modifiers on rollableTables IMO).
1675665395
Gauss
Forum Champion
I agree with RainbowEncoder, your best right now (without a Mod, a Pro feature) is to use a Chat Menu setup. 
1675770150
timmaugh
Forum Champion
API Scripter
GiGs said: This might be one of the most asked questions, and is a feature that Roll20 really should support (just after modifiers on rollableTables IMO). I know it's a script, and therefore requires a pro sub, but Muler lets you roll against a rollable table with modifiers.
1675782965
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Just as a matter of elaboration (all these answers are correct), the macro syntax is not a programming language in the traditional sense, It doesn't support logic, branching or looping, and very little in the way of variables. It's primarily a souped up dice roller, capable of being run on manual command, accepting some (user or random) value input, and then printing a result to chat. Very clever users have found ways to push this to the limits, but there are limits.