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 .
×

if statement help.....please!

1546097728

Edited 1546097804
I am very new to the PRO community and am just getting my feet wet using macros in the standard 4E character sheet.  I would like to embed a check in my macros associated with powers that have the Encounter or Daily restriction so that if a player tries to use the power once the Used Check box has been checked they receive a message in chat telling them that the power is not available rather than getting the actual power result.  I know that there is a template attribute that if used in this way: &{template:dnd4epower} {{test=@{power-12-used} }} causes the number 1 to be output to the chat if the box is checked for power-12 and 0 to be output to the chat if it is unchecked. What I would like to do is check this value as part of my macro, I will include the macro below, using an if statement to either execute the actual macro or to simply return the "Power has been expended for this period" message. Can anyone help set me on the right path?  I was once a pretty good programmer but its been years since I did any actual coding and without a language reference guide I'm struggling a bit. Thanks in advance and the contents of the macro I am using is shown below. Call me confused &{template:dnd4epower} {{daily=1 }} {{emote=**@{character_name}** channels healing energy into himself or an ally, driving out disease and other ills.}} {{name=@{power-12-name}}} {{type= Daily ♦}} {{keywords=Keyword: Divine }} {{action=@{power-12-action} ♦}} {{range=@{power-12-range}}} {{target=You or one ally in the burst. }}  {{damage=No damage. }} {{effect= ** @{target|target1|character_name} ** rolls a saving throw [[1d20+5]] and if applicable adds the following modifiers ** @{target|target1|saving-throw-mods}** against each effect on him or her that a save can end.  In addition, if **@{target|target1|character_name}**  is suffering from a disease, he or she can spend a healing surge to improve the disease by two stages.  **@{target|target1|character_name}** regains no Hit Points for spending the Healing Surge.  If **@{target|target1|character_name}**  is currently subject to a petrifying effect, that effect ends but the target loses all remaining healing surges. }}
1546103180
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Macro language has no conditional logic, unfortunately. I believe the Power Cards script (which you have access to as a pro user), gas some capabilities in that area, but otherwise, anything requiring conditional logic requires using an API script. If you are experienced with JavaScript with your programming history, it shouldn't be a big hurdle.
1546115994
Finderski
Pro
Sheet Author
Compendium Curator
If you're using a custom character sheet, you might  be able to do this using the following Roll Template logic in your sheet: {{#rollTotal() test 1}} <!--HTML stuff to do if spell is used--> {{/rollTotal() test 1}} {{#^rollTotal() test 1}} <!--HTML stuff to do if spell isn't used--> {{/^rollTotal() test 1}} In your roll macro, you'd have this: {{test=[[1d0+@{power-12-used}]] }} (You might be able to get rid of the "1d0+" portion of that, but I've had weird results using something like that in the past, so I always just add it to be safe.) Essentially, the first part says, if the test roll result was "1", then do this other stuff and you would not include the roll output, but instead show a message that the spell has already been used. The next portion says if the roll result for test was ANYTHING OTHER THAN 1, the do this other stuff, and you have your other roll results displayed there in whatever format you wanted. If you aren't using a custom sheet, then you'd need to check the sheet you are using to see if the roll templates support this type of thing.  Otherwise, as keithcurtis mentioned, you'll need to use an API script for your rolls (or get the sheet in the repository updated to include this bit of logic in the roll template).
Thank you both for the suggestions Ill see what i can do with them Much appreciated!