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

ScriptCard If/Then trouble

1705462428

Edited 1705464002
Kofi
Pro
**RESOLVED** OVERVIEW: I am trying to use power card to create a macro that will output text based on the results of a roll.&nbsp; (5E OG Sheet)&nbsp;&nbsp; DETAILS: When a player rolls a Nat1 and gets a critical failure the CRITICAL FAILURE button should multiply the selected tokens proficiency bonus by 5 and add&nbsp; 1d20 to the result.&nbsp; Then compare that result to determine the outcome.&nbsp; If result is 30 or greater - print text NO Consequence.&nbsp; If the result is 24-29 - print text Tier 1 Consequence.&nbsp; If the result is 18-23 - print text Tier 2 Consequence.&nbsp; If the result is 17 or less - print text Tier 3 Consequence.&nbsp; MY ATTEMPT: I used the Longsword Attack example from the ScriptCards wiki as a guide and this is what I cam up with !scriptcard&nbsp; {{ &nbsp; --#title|Critical Failure &nbsp; --#leftsub|Results Roll &nbsp; --#sourceToken|@{selected|token_id} &nbsp; --#emoteText|@{selected|token_name} has fumbled their attack &nbsp; --=CFResultsRoll|1d20 +&nbsp; [[5*@{selected|pb} [PROF]]] &nbsp; --+Result|@{selected|token_name} rolls [$CFResultsRoll]&nbsp; &nbsp; --?[$CFResultsRoll.Total] -ge 30|NoC &nbsp; --?[$CFResultsRoll.Total] -eq 29|Tier1C &nbsp; --?[$CFResultsRoll.Total] -eq 28|Tier1C &nbsp; --?[$CFResultsRoll.Total] -eq 27|Tier1C &nbsp; --?[$CFResultsRoll.Total] -eq 26|Tier1C &nbsp; --?[$CFResultsRoll.Total] -eq 25|Tier1C &nbsp; --?[$CFResultsRoll.Total] -eq 24|Tier1C &nbsp; --?[$CFResultsRoll] -eq 23|Tier2C &nbsp; --?[$CFResultsRoll] -eq 22|Tier2C &nbsp; --?[$CFResultsRoll] -eq 21|Tier2C &nbsp; --?[$CFResultsRoll] -eq 20|Tier2C &nbsp; --?[$CFResultsRoll] -eq 19|Tier2C &nbsp; --?[$CFResultsRoll] -eq 18|Tier2C &nbsp; --?[$CFResultsRoll] -le 17|Tier3C &nbsp; --^Final| &nbsp; --:NoC| &nbsp; --+By skill or by luck @{selected|token_name} escapes all adverse repercussions &nbsp; --^Final| &nbsp; --:Tier1C| &nbsp; --+Tier 1 Consequence!|A Tier 1 result @{selected|token_name} must pick a Tier 1 Card. &nbsp; --:Final| &nbsp; --:Tier2C| &nbsp; --+Tier 2 Consequence!|A Tier 2 result @{selected|token_name} must pick a Tier 2 Card. &nbsp; --:Final| &nbsp; --:Tier3C| &nbsp; --+Tier 3 Consequence!|A Tier 3 result @{selected|token_name} must pick a Tier 3 Card. &nbsp; &nbsp; --:Final| }} PROBLEM: The greater than 30 does not work at all and if the result is between 18 and 29 it gives the correct output as well as the output for each result that follows.&nbsp;&nbsp; EXAMPLE:&nbsp; Critical Failure Results Roll Result &nbsp;Goblin Assassin rolls&nbsp;<span class="userscript-userscript-showtip userscript-tipsy" title="Roll: 1d20 + 10 Result: (19) + 10 " style="min-width: 1.75em ; font-family: &quot;undefined&quot; ; text-align: center ; display: inline-block ; font-weight: bold ; height: 1em ; margin-top: -1px ; margin-bottom: 1px ; padding: 0px 2px ; border: 1px solid rgb( 135 , 133 , 10 ) ; border-radius: 3px ; background-color: rgb( 255 , 254 , 162 )">29 Tier 1 Consequence! &nbsp;A Tier 1 result Goblin Assassin must pick a Tier 1 Card. Tier 2 Consequence! &nbsp;A Tier 2 result Goblin Assassin must pick a Tier 2 Card. Tier 3 Consequence! &nbsp;A Tier 3 result Goblin Assassin must pick a Tier 3 Card. REQUEST: Would love to know what I am doing wrong, but will gladly accept a link to a working version of something similar enough that I can adjust it to my needs.&nbsp;&nbsp; Thanks in Advance.&nbsp;&nbsp;
1705463558

Edited 1705463668
Hey Kofi. You had a couple of small mistakes that caused what you are seeing. I fixed those and simplified a little bit as well to this: !scriptcard {{ --#title|Critical Failure --#leftsub|Results Roll --#sourceToken|@{selected|token_id} --#emoteText|[*S:t-name] has fumbled their attack --=pbbonus|[*S:pb] * 5 --=CFResultsRoll|1d20 + [$pbbonus] [PROF] --+Result|[*S:t-name] rolls [$CFResultsRoll] --?[$CFResultsRoll.Total] -ge 30|NoC --?[$CFResultsRoll.Total] -ge 24|Tier1C --?[$CFResultsRoll] -ge 18|Tier2C|Tier3C --:NoC| --+|By skill or by luck [*S:t-name] escapes all adverse repercussions --^Final| --:Tier1C| --+Tier 1 Consequence!|A Tier 1 result [*S:t-name] must pick a Tier 1 Card. --^Final| --:Tier2C| --+Tier 2 Consequence!|A Tier 2 result [*S:t-name] must pick a Tier 2 Card. --^Final| --:Tier3C| --+Tier 3 Consequence!|A Tier 3 result [*S:t-name] must pick a Tier 3 Card. --:Final| }} So the mistakes that were biting you were missing a pipe character in your NoC output line: --+By skill or by luck @{selected|token_name} escapes all adverse repercussions Adding a pipe after --+ like so --+| fixed that and it outputs. That prints a warning in the console for when you are debugging your scriptcards. (ex&nbsp;"ScriptCards Error: Line 35 is missing a | character. (+By skill or by luck [*S:t-name] escapes all adverse repercussions&nbsp; &nbsp;)" Then you weren't jumping to the Final label in your other Tiers so you were just relabeling them. so changing Tier1C and Tier2C code to jump to the Final label keeps things from falling through. so --^Final| instead of --:Final| I made some other changes like using the&nbsp; ScriptCards sourceToken referencing &nbsp;for token name [*S:t-name] and changing the conditionals to check for greater than or equal at each stage. Since ScriptCards conditionals can have an else, I just put your Tier3C check as the else if it's not greater than 18. Hopefully that helps. Let me know if you have any questions. EDIT: I forgot I also split your 1d20 roll from the 5 * pb bonus. Feel free to adjust that as you want I just thought that was easier for me to read but that's just my preference it's not crucial.
YES!!!&nbsp; Thank you. This would have kept me up for hours!&nbsp;