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

Trying to make macros call on other macros

1590953532

Edited 1590953605
My goal is to write a macro for our Deathwatch game where it simplifies normal damage calculations.  I have a single hit ability written that works as follows [[[[{?{Hit Location|Head, @{HArmour} |Body, @{BArmour} |Left Arm, @{AlArmour} |Right Arm, @{ArArmour} |Left Leg, @{LlArmour} |Right Leg, @{LrArmour}} + 0d0 - ?{Pen} , 0d0}kh1]] + (floor(@{Toughness}/10)*@{unnatural-Toughness}) - ?{Damage})]] So it asks hit location, then pen of weapon, then damage and gives you damage number. Now I want to extrapolate that into something that can deal with full/semi auto and swift/lightning attack all in one prompt.  I figure I ask first how many hits, then have that link to a macro that asks first hit location, and then have that calculate out the above formula for each hit as the shot moves, but I can't get it to properly ask questions in the follow up macros.  I can make "how many hits call upon 1,2,3,4,5 etc, but when it asks where it hit, it gives me the rest of the initial question...eg if i say 3 hits, the question of hit location will give me 4,5,6,7 etc Am I missing something blatantly obvious here or can this not be done?  The game is premium but I'm a free user with GM status (doing this for a friend), does logging into a premium user account to do this matter?
1590955564
GiGs
Pro
Sheet Author
API Scripter
You are almost certainly running into the nested query&nbsp; problem described here:&nbsp; <a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a> The firstt hing to understand: when you have a macro calling another macro, they dont happen in sequence. When you run a macro, the first thing roll20 does is scan for other macro calls, get their text, and insert them in place in the calling macro. So say you had this simple macro: /roll 1d20 + ?{Attack Type|Physical,#Physical|Magic,#Magic} And in the Phsycial and Magical macros you had these two: ?{Which Physical Stat?|STR, @{STR}|DEX, @{DEX}} ?{Which Magical Stat?|INT, @{INT}|WIS, @{WIS}} Now, wen you run that first macro, you might expect that roll20 sees the attack querie, pops up a choice for you, and then when you pick, say Physical, it runs the Physical query. That's not what happens. What actually happens, is you run the macro, roll20 immediately scans it, finds those two macro collas, grabs their text and fills in the main macro, and then tries to run that. So it creates this: /roll 1d20 + ?{Attack Type| Physical,?{Which Physical Stat?|STR, @{STR}|DEX, @{DEX}}| Magic,?{Which Magical Stat?|INT, @{INT}|WIS, @{WIS}}} And then when it tries to run that, it immediately hits a problem: on the physical line, after Which Physical Stat? &nbsp;, it encounters a | symbol, which looks like another query separator (because it is). But roll20 has no knowledge of nested macros, so it thinks that separator is for the first query, and so it breaks. The way to get around this is described on the linked page: you have to replace certain characters (commas, pipes, and close curly brackets) with their html entity. But never replace the symbols in attribute calls.&nbsp; here's the second problem: if you replace the symbles in the nexted macros, they will no longer work on their own. They will only work when called from the master macro. So you may as well go ahead and combine them into the master macro directly. If we do that with the macro above, we end up with this very ugly construction: /roll 1d20 + ?{Attack Type| Physical,?{Which Physical Stat? &amp;#124; STR &amp;#44; @{STR} &amp;#124; DEX &amp;#44; @{DEX} &amp;#125; | Magic,?{Which Magical Stat? &amp;#124; INT &amp;#44; @{INT} &amp;#124; WIS &amp;#44; @{WIS} &amp;#125; } This is really ugly and with complex macros gets really hard to deal with, so sensible people usually give up on nested macros completely, and turn to Chat Menus ( see here ). With chat menus, you keep your separate macros, and just print buttons out with the attack that they can be clicked to roll on. It's much, much simpler.