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

How do i reuse an input in the same macro?

I am having trouble doing some coding with macros. Basically, what i want to do, is use the Traits Template to show on chat a description of any special attack from a dropdown choice, how to do it and etc. Lets say, for example that i have these 2 special attacks, Grapple and Feint: Feint: As a standard action, you can try to mislead an opponent in melee combat so that he can’t dodge your next attack effectively. Grapple: Grappling means wrestling and struggling hand-to-hand. I can make the Title (and the attack chosen) to be chosen from a dropdown, and i could just repeat the query for the description, but i fear mismatching and it just feels inefficient to have to query twice for the same thing. It just feels wrong. I know i can reference the choice made, but how i make that choice actually change something on the second instance? Brute code: &{template:traits} {{name=?{Choose a Special Attack|Grapple, Grapple|Feint,Feint}}} {{source=Special Attacks}} {{description=?{Choose a Special attack|Grapple, Grappling means wrestling and struggling hand-to-hand.|Feint, As a standard action you can try to mislead an opponent in melee combat so that he can’t dodge your next attack effectively.}}} Code as of now: &{template:traits} {{name=?{Choose a Special Attack|Grapple, Grapple|Feint,Feint}}} {{source=Special Attacks}} {{description=?{Choose a Special Attack}}}
1615628866
Ziechael
Forum Champion
Sheet Author
API Scripter
I discuss the functionality you are exploring in some depth over here so I won't repeat myself but here is a version that should do what you want with a single query: &{template:traits} {{source=Special Attacks}} {{name=?{Choose a Special Attack|Grapple,Grapple}} {{description=Grappling means wrestling and struggling hand-to-hand.|Feint,Feint}} {{description=As a standard action you can try to mislead an opponent in melee combat so that he can’t dodge your next attack effectively.} }} The 'trick' being used in this instance is placing the 'name' field just before the description one in order to have the outcomes both be affected by the single query. Since templates will use predefined fields wherever they need to be no matter where you put them in the code it will reorder as necessary.
I tried for like 2 or 3 hours, banging my head against this trying to reproduce this simple thing: To either reuse the input of the query or tie the description to the query chosen (Put that inside of this). My lowly knowledge of coding was not being enough to to that. This works perfectly for me, thanks! BTW, is there any way of putting commas in the description? Everytime they're there they have to be cut because they mess with the syntax of the code, it thinks it's an operator of some kind.
Vincius S. said: I tried for like 2 or 3 hours, banging my head against this trying to reproduce this simple thing: To either reuse the input of the query or tie the description to the query chosen (Put that inside of this). My lowly knowledge of coding was not being enough to to that. This works perfectly for me, thanks! BTW, is there any way of putting commas in the description? Everytime they're there they have to be cut because they mess with the syntax of the code, it thinks it's an operator of some kind. Replace commas with , .  Here's a list of html entity replacements.  Or here is the Roll20 wiki  on the ones you need to worry about for macros.