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

Multi-Line Output with Template and Variable

I've been trying to figure out how to create a macro that prints the variable rolls on a new line opposed to side by side. Though for the past four hours and looking through the forums I just haven't been able to figure it out. I know I'm missing something when looking at the wiki, but I don't know what. Just as a FYI, I'm new to this so the answers probably obvious and I just don't see it.

What I'm currently writing with is this:
&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits | 1 Hits, Damage=[[1d10+2]] | 2 Hits, Damage=[[1d10+2]] Damage=[[1d10+2]]}}}

Which ends up being this:


Though I'd like it to display on a new line when I choose a variable of 2, 3, 4, 5, etc. Not horizontally.

August 18 (3 years ago)

For the default template, each line is denoted by paired curly braces.  Then split vertically by an equals sign. So what you want is something like this:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage=[[1d10+2]]|2 Hits,}}{{Damage=[[1d10+2]] Damage=[[1d10+2]]}}}

However, the issue you will run into is that the closing curly braces that you have to between each option in the query will break the query by closing it.  The workaround is to use html replacements.  Either '}'  or '}' can be used as a replacement for a closing brace symbol, which will then become this:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage=[[1d10+2]]|2 Hits,}}{{Damage=[[1d10+2]] Damage=[[1d10+2]]}}} 

Then there's still sometimes an issue with query versus roll and which one happens first in the Roll20 Order of Operations (I can't check right now to make sure that works).

My last piece of advice is to not add any extra spaces inside of queries (for instance, after a vertical pipe or comma that separates items or results).  It can screw up things because the space will be included in the output.

August 18 (3 years ago)
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator

Jarren K. said:

...

Then there's still sometimes an issue with query versus roll and which one happens first in the Roll20 Order of Operations (I can't check right now to make sure that works).

My last piece of advice is to not add any extra spaces inside of queries (for instance, after a vertical pipe or comma that separates items or results).  It can screw up things because the space will be included in the output.

Queries happen before rolls. There's no issue there unless you're trying to get the result of a roll to display as the text of an option or the text of the prompt,  which is impossible.

Personally, I'd go the other way, I frequently use spaces after the query syntax symbols to make it more readable. Just remember that any character (space, unicode, letters, whatever) are included in that part of the query. The place where I recommend not using spaces is at the end of the prompt itself as that can get confusing when you try to then reuse the query with the shorthand of just repeating the prompt.


Jarren K. said:

For the default template, each line is denoted by paired curly braces.  Then split vertically by an equals sign. So what you want is something like this:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage=[[1d10+2]]|2 Hits,}}{{Damage=[[1d10+2]] Damage=[[1d10+2]]}}}

However, the issue you will run into is that the closing curly braces that you have to between each option in the query will break the query by closing it.  The workaround is to use html replacements.  Either '}'  or '}' can be used as a replacement for a closing brace symbol, which will then become this:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage=[[1d10+2]]|2 Hits,}}{{Damage=[[1d10+2]] Damage=[[1d10+2]]}}} 

Then there's still sometimes an issue with query versus roll and which one happens first in the Roll20 Order of Operations (I can't check right now to make sure that works).

My last piece of advice is to not add any extra spaces inside of queries (for instance, after a vertical pipe or comma that separates items or results).  It can screw up things because the space will be included in the output.


Gave it a shot and ended up with the same outcome, I'll keep messing around to see if I can get it to work.
None the less I do appreciate the information.

August 19 (3 years ago)

This should be what you're looking for:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage 1=[[1d10+2]]|2 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]|3 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]}} {{Damage 3=[[1d10+2]]}}}

The other thing I forgot about is for the default template, each line item must have a unique name.  If not, then later lines will overwrite earlier ones that have the same name.  So if each line is simply labeled as 'Damage', then you'll only get a single output, even if you correctly have 3 damage rolls in the macro, because the 2nd and 3rd will simply overwrite the same field.


Jarren said:

This should be what you're looking for:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage 1=[[1d10+2]]|2 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]|3 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]}} {{Damage 3=[[1d10+2]]}}}

The other thing I forgot about is for the default template, each line item must have a unique name.  If not, then later lines will overwrite earlier ones that have the same name.  So if each line is simply labeled as 'Damage', then you'll only get a single output, even if you correctly have 3 damage rolls in the macro, because the 2nd and 3rd will simply overwrite the same field.


So that's the part I was missing. I didn't realize each label had to be unique. Thank you for the help.

August 20 (3 years ago)

Edited August 20 (3 years ago)


Jarren said:

This should be what you're looking for:

&{template:default} {{name=Autopistol Hits}} {{?{Number of Hits|1 Hits,Damage 1=[[1d10+2]]|2 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]|3 Hits,Damage 1=[[1d10+2]]}} {{Damage 2=[[1d10+2]]}} {{Damage 3=[[1d10+2]]}}}

The other thing I forgot about is for the default template, each line item must have a unique name.  If not, then later lines will overwrite earlier ones that have the same name.  So if each line is simply labeled as 'Damage', then you'll only get a single output, even if you correctly have 3 damage rolls in the macro, because the 2nd and 3rd will simply overwrite the same field.


By chance would you know why when using a macro all of the }} would suddenly turn into {{ or }}?

As soon as I save the macro }} turns into }}



August 20 (3 years ago)

https://wiki.roll20.net/Macros#Roll_Query_Troubleshooting:_Collections_Macros

You normally store queries in Macros, saved under the l Collections-tab of the Sidebar. Unfortunately, whenever you open a macro stored there, Roll20 parses the macro and this causes HTML entities to be converted to the characters their represent. This breaks your carefully created macro.
So, if you place macros containing HTML entities there, it's a good idea to store a backup somewhere. This behaviour doesn't happen with Abilities, so many people create a Macro Character Sheet for storing such macros safely as abilities.


Jarren said:

https://wiki.roll20.net/Macros#Roll_Query_Troubleshooting:_Collections_Macros

You normally store queries in Macros, saved under the l Collections-tab of the Sidebar. Unfortunately, whenever you open a macro stored there, Roll20 parses the macro and this causes HTML entities to be converted to the characters their represent. This breaks your carefully created macro.
So, if you place macros containing HTML entities there, it's a good idea to store a backup somewhere. This behaviour doesn't happen with Abilities, so many people create a Macro Character Sheet for storing such macros safely as abilities.


Thank you for the info, I'll do that then.