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

ScriptCards - Adding Roll Variable's together

Hey, so as a question since I thought that you could add Roll Variable's together by allocating the results to a new Roll Variable, but my method constantly ends up allocating 0 to the new Roll Variable's. Anyone got any suggestions on how to fix this macro? !script {{ --#title|Tripple Down --=Raging|?{Raging?|Yes,( ( [[ floor(@{Kotaro Muramoto|level}/3) ]] * 4 ) * 2 )|No,[[ 0 ]]} --\|The value of Raging is [$Raging] --=StatBuffDiff|?{Stat Buff Difference:|0,1|1,1.25|2,1.50|3,1.75|4,2|5,2.25|6,2.5|-1,0.75|-2,0.5|-3,0.25} --\|The value of StatBuffDiff is [$StatBuffDiff] --=CritEffect|?{Crit Effect:|Immune,0|Down,1|Double Damage,2} --\|The value of CritEffect is [$CritEffect] --=Atk1| [[ 2d6 + @{proficiency} + @{proficiencytemp} + ?{Accuracy Buff Rank Level:|0|1|2|3|-1|-2|-3} ]] --\|The value of Atk1 is [$Atk1] --+Attack Roll|[$Atk1] --=BaseDmg1|[[3d6 + @{proficiency} + @{proficiencytemp}]] --=BaseDmg2|[[3d6 + @{proficiency} + @{proficiencytemp}]] --=BaseDmg3|[[3d6 + @{proficiency} + @{proficiencytemp}]] --?[$Atk1.Total] -lt 7|Miss --?[$Atk1] -lt 10|Mixed --?[$Atk1] -lt 12|Success --?[$Atk1] -lt 24|Crit --?[$Atk1] -ge 24|SuperCrit --:Done| --X| --:Miss| --+|The Attack Missed -->Done| --:Mixed| --+|The attack is a Mixed Success. --=MixedHit1|(([$BaseDmg1] + [$Raging]) * [$StatBuffDiff]) --=MixedHit2|(([$BaseDmg2] + [$Raging]) * [$StatBuffDiff]) --=MixedHit3|(([$BaseDmg3] + [$Raging]) * [$StatBuffDiff]) --=TotalMixedDamage|([$MixedHit1] + [$MixedHit2] + [$MixedHit3]) --+First Hit|[$MixedHit1] --+Second Hit|[$MixedHit2] --+Third Hit|[$MixedHit3] --+Total|[$TotalMixedDamage] -->Done| --:Success| --+|The attack is a Complete Success! --=SuccessHit1|(([$BaseDmg1] + [$Raging]) * [$StatBuffDiff]) --=SuccessHit2|(([$BaseDmg2] + [$Raging]) * [$StatBuffDiff]) --=SuccessHit3|(([$BaseDmg3] + [$Raging]) * [$StatBuffDiff]) --=TotalSuccessDamage|([$SuccessHit1] + [$SuccessHit2] + [$SuccessHit3]) --+First Hit|[$SuccessHit1] --+Second Hit|[$SuccessHit2] --+Third Hit|[$SuccessHit3] --+Total|[$SuccessHit3] -->Done| --:Crit| --+|The attack is a Crit!!! --=CritHit1|(([$BaseDmg1] + [$Raging]) * [$StatBuffDiff]) --=CritHit2|(([$BaseDmg2] + [$Raging]) * [$StatBuffDiff]) --=CritHit3|(([$BaseDmg3] + [$Raging]) * [$StatBuffDiff]) --=TotalCritDamage|([$CritHit1] + [$CritHit2] + [$CritHit3]) --=DoubCritDamage|([$TotalCritDamage] * 2) --+First Hit|[$CritHit1] --+Second Hit|[$CritHit2] --+Third Hit|[$CritHit3] --+Total|[$TotalCritDamage] --?[$CritEffect] -eq 2|>Crit Damage;[$DoubCritDamage] -->Done| --:SuperCrit| --+|The attack is a SUPER CRIT!!! --=SuperCritHit1|(((3 * 6) + [$Raging]) * [$StatBuffDiff]) --=SuperCritHit2|(((3 * 6) + [$Raging]) * [$StatBuffDiff]) --=SuperCritHit3|(((3 * 6) + [$Raging]) * [$StatBuffDiff]) --=TotalSuperCritDamage|([$SuperCritHit1] + [$SuperCritHit2] + [$SuperCritHit3]) --=DoubSuperCritDamage|([$TotalSuperCritDamage] * 2) --+First Hit|[$SuperCritHit1] --+Second Hit|[$SuperCritHit2] --+Third Hit|[$SuperCritHit3] --+Total|[$TotalSuperCritDamage] --?[$CritEffect] -eq 2|>Super Crit Damage;[$TotalSuperCritDamage] -->Done| --\BaseDmg1|[$BaseDmg1] --\BaseDmg2|[$BaseDmg2] --\BaseDmg3|[$BaseDmg3] --\Raging|[$Raging] --\StatBuffDiff|[$StatBuffDiff] --\CritEffect|[$CritEffect] }}
Pretty sure the parens are causing this issue. Take the follow simplified examples: !script {{ --=R1|1d8 --=R2|2d6 --=Sum|[$R1] + [$R2] --+Results|[$R1] + [$R2] = [$Sum] }} !script {{ --=R1|1d8 --=R2|2d6 --=Sum|([$R1] + [$R2]) --+Results|[$R1] + [$R2] = [$Sum] }} ScriptCards math doesn't use parenthesis for order of operations. SC doesn't honor them and things are processed left to right. I cannot find that mentioned on  the ScriptCards wiki  but I know I've seen it discussed on Kurt J's discord before.
1703172096
Kurt J.
Pro
API Scripter
Correct. ScriptCards processes roll information left to right, maintaining a running value. So if you want to do: 1d6 + (2 * 2d10) You would need to reorder it like this: 2 * 2d10 + 1d6 Alternatively, you can use inline roll notation like this to simulate parenthesis: 1d6 + [=2 * 2d10] With [= notation, the 2 * 2d10 would be done first and converted to a numeric value and added to the 1d6.