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

Skipping a function?

1598300913

Edited 1598300933
Is there any to add an "if" function to a macro, giving it the ability to skip over a section if its not applicable? Currently, I'm using this macro as a status check for tokens. It works fine for PCs, but it breaks on NPCs because they don't have a Current HP/Max HP section. &{template:npcaction} {{name=Staus Check}} {{rname=@{selected|token_name}}} {{description=*HP* [[@{selected|hp}]] / [[@{selected|hp|max}]] *AC* [[@{selected|ac}]]}} Without having to just make a new Macro for NPC token, is there any way I can add a function to the macro to skip over the [[@{selected|hp}]] when its not applicable?
Is there a particular reason you don't want to just track that info on the tokens themselves? A properly linked token will show whatever you program it with, I put hp, ac, and passive perception on the tokens in my games.
No particular reason, I just want to know if I can. It's not actually useful, hahaha.
1598304076
GiGs
Pro
Sheet Author
API Scripter
Jo F. said: Is there any to add an "if" function to a macro, giving it the ability to skip over a section if its not applicable? Macros dont support ifs and other conditionals, so unfortunately the answer is no.
1598310416

Edited 1598310440
Oosh
Sheet Author
API Scripter
Are you using any of the token bars to track HP? You can change your macro to @{selected|bar1} / @{selected|bar1|max}. This will give the same outcome for player tokens if they are linked to the sheet Attribute, and the current HP for any unlinked tokens, which is nicer than an error. Alternatively, you can do this, but it isn't the prettiest: &{template:default} {{name=Staus Check}} {{[1](#)=*HP* @{selected|hp} / @{selected|hp|max}}} {{[@{selected|npc}](#)=}}