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

Enemy Assessment Macro

Hello community! So I'm playing with a macro designed to "scan" an enemy (5eOGL) and spit out info from the NPC block into the player's chat. Here's what my first draft looks like: /me &{template:npcaction} {{rname=Assessing @{target|token_name}...}}{{description= **NAME:** @{target|token_name|npc_name} **TYPE:** @{target|token_name|npc_type} **HIT POINTS:** @{target|token_name|bar3|value} / @{target|token_name|bar3|max} **CURRENT ARMOR CLASS:** @{target|token_name|bar2|max} **VULNERABILITIES:** @{target|token_name|npc_vulnerabilities} **RESISTANCES:** @{target|token_name|npc_resistances} **DAMAGE IMMUNITIES:** @{target|token_name|npc_immunities} **CONIDITION IMMUNITIES:** @{target|token_name|npc_condition_immunities}}} Now, it's serviceable, though I have an issue: When it asks to target a token, it asks for verification twice [Choose Target:Target] , and [Choose Target:token_name].    I'm sure there's a reason why, though going through the Wiki doesn't give great examples of using target macros. Is there a way to fix this so it only asks for the Target token once? I've run into similar issues in the past - is this some limitation thing, or is there a step I'm missing (I'm sure there is :() Appreciate your time & help; thank you!
1694557370

Edited 1694557959
/w PLAYERNAME &{template:npcaction} {{rname=Assessing @{target|Target|token_name}...}} {{description=**NAME:** @{target|Target|npc_name} **TYPE:** @{target|Target|npc_type} **HIT POINTS:** @{target|Target|bar3|value} / @{target|Target|bar3|max} **CURRENT ARMOR CLASS:** @{target|Target|bar2|max} **VULNERABILITIES:** @{target|Target|npc_vulnerabilities} **RESISTANCES:** @{target|Target|npc_resistances} **DAMAGE IMMUNITIES:** @{target|Target|npc_immunities} **CONDITION IMMUNITIES:** @{target|Target|npc_condition_immunities}}} You'll need to swap out 'PLAYERNAME' with the player's name, unless you want the whole outputted in an emote block that is visible to everyone. When you use an @{target call, if you only have a single pipe separator, then Roll20 knows to use a single target. If there are two pipe separators then whatever is in between the pipes is the reference to a specific target, to allow you to target multiple targets. You could have a macro like this to get the Hit Points (from Bar 1) from three targets:: /w PLAYERNAME &{template:npcaction} {{rname=Hit Points}} {{description=@{target|Target1|npc_name}  @{target|Target1|bar1} / @{target|Target1|bar1|max} @{target|Target2|npc_name}  @{target|Target2|bar1} / @{target|Target2|bar1|max} @{target|Target3|npc_name}  @{target|Target3|bar1} / @{target|Target3|bar1|max}}} In your case you had @{target|token_name} and @{target|token_name|npc_name}, which made Roll20 think there were two separate targets, because there was no identifier for the @{target|token_name}, but there was one for the rest of the calls.
1694563956

Edited 1694565081
Thank you for the response! On the first part, thank you, I hardly ever use whispers so I can never remember the specifics of utilising them >_< So, if I'm understanding right: From what I learned on the wiki, it should only call one target prompt as long as all the target|X calls are the same (IE target|token_name) but in this case, i also had target|npc_name and it makes it flags it to select another target? NVM I reexamined what you said and looked at the code, and now it makes sense. Thank you very much!
1694565116

Edited 1694621311
GiGs
Pro
Sheet Author
API Scripter
When using target you can use this syntax: @{target|token_name}, @{target|bar1} @{target|npc_immunities} All three of these will affect the same target. When you include @{target| that tells Roll20, present the target selection screen, and then whenever @{target| is in the macro, grab that same token character's attribute. The second syntax is using two pipes (!) like this @{target|target 1|token_name}, @{target|target 1|bar1} @{target|target 2|npc_immunities} Whenever you use that, Roll20 takes the middle as an identifier. So in these cases, you will prompted to pick a target twice, and it will substitute the relevant values from tokens in the macro. For the first 2, it'll grab values from the token to you touch first, and the last will will be taken from the token you selected second. You can pick any descriptor - instead of target 1 you might have typed Bilbo (@{target|Bilbo|token_name}. It's just an identifier so you (and Roll20) can tell which attributes should be taken from which token. Now if you mix the syntaxes, (@{target|token_name} and @{target|token_name|bar 1) it will think there are two different targets here, because they don't have the same identifier. The first one doesn't have any identifer, or more accurately has a hidden identifier assigned by Roll20's backend. So all the attributes that start @{target|token_name| are the same target, but the one labelled @{target|token_name} is being treated as if it read @{target|hidden|token_name} . The solution is to do either: Change @{target|token_name} to @{target |token_name |token_name} . then it's identifier matches the others. Or Remove the middled part ( token_name ) from all the others. @{target|token_name|npc_type} becomes @{target|npc_type} . That way they all have no identifier (or a hidden, identifcal identifier) and are treated as the same target. Edit: looks like i took too long to write this :)
No, that helps a lot, still. I'm a visual learner, especially with code. I can do foreign languages no problem, but code and maths I really need to/like to see it, so your example help straighten the logic in my brain! I don't always know what I'm looking at, but being able to reverse-engineer and see the stuff helps it. As an offshoot, if I wanted a macro to recall the same selected token twice in an output...lets say something simple like: Wizard casts Fireboom at @{target|token_name}! @{target|token_name} takes [[2d10]] damage! Would that be right? And only call one target prompt?
1694573868
GiGs
Pro
Sheet Author
API Scripter
That looks right to me. You can reuse a target in the same macro multiple times.
Awesome. It had bugged me in the past trying to get it right, but your example helped flip that lightbulb. Thanks to everyone for your assistance 🙏!