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: Macro that makes Dice Rolls via String Building Now Failing

So, I have been working on a Macro Template for my roll20 games for, oh I think it's been 3 months now? Maybe longer. Anyways, I have designed this method of building dice roll strings modularly to account for things like Criticals, Resistances, Spell Effects, Bardic Inspiration, College of Sword Flourishes, Circle of Spores Symbiotic Entity, etc. I'll attach the whole Macro for the included image but the idea basically boils down to this: I take each of the possible additions, bonuses, and detractors and add them into a string with the base dice roll. Then, I assign a roll variable that roll string which calculates the roll. This allows me to do things like reroll the entire thing at any point if I so choose, which was initially for a Fudge mechanic that I haven't quite gotten working, but the modular-ness of the design worked well so I kept it and replaced all of my Macros with this new template. Finally, it also allows me to account for roll modifiers and additional dice in a way that is modular but allows the end user to still hover over the roll value and see how the roll was made. The other main thing it did was it used the bar2 value as a place to hold things like Bardic Inspiration, Bless, Bane, Mind Sliver, and other things that would affect a roll in such a way that I could give individual units of a type a buff without the other units having access to that same buff/debuff/whatever. You'll see references to an EffectString, and that's what that is. Since things like Bardic Inspiration and Mind Sliver have to be removed after usage, I update this string throughout the Macro and then at the end use TokenMod to add it back to the token. At least, that is what it did until yesterday. Now it does something that I can't remotely explain. I was considering posting this to the ScriptCards thread, but this is so out there I figured it deserved its own thread. What this was supposed to do is roll 1d4+4 Piercing and 1d6 Posion Damage. Instead it somehow always gets 79 Damage. This happens for all my other Macros too, like my player's Glaive attack (which is normally 1d10) is always 22 whereas another player's Mind Sliver (1d6) always deals 33. I tried reading through the changelog to see what it was that changed that made this stop working but for whatever reason, I can't seem to get it to work on any of the older versions of the script. Let me know if I'm changing the version wrong: I went into the ScriptCards page on my API Scripts Page, clicked the older version, hit save, then went back to the main tab, and hit Restart Sandbox. If anyone has any idea as to what in the world is happening here, I'd sincerely appreciate it, thanks !scriptcard {{ --#title|Poison Dagger Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --=TargetAC|[*T:ac] --? [$TargetAC] -gt 0|SkipAC --=TargetAC|[*T:npc_ac] --:SkipAC| --&WeaponName|Poison Dagger --#emoteText|@{selected|token_name} attacks @{target|token_name} with their [&WeaponName] --&ToHitBonus|6 --&AttackType|DEX --&DamageBonus|4 --=Damage1Count|1 --=Damage1Die|4 --&Damage1Type|Magical Piercing --=Damage2Count|1 --=Damage2Die|6 --&Damage2Type|Poison --=CritFlag|0 --=BardicFlag|0 --=BardicDie|@{Zailith Blackstaff|BardicInspirationDie} //CUSTOM VALUE I HAVE SAVED IN THAT CHARACTER'S ATTRIBUTES SECTION --&EffectString|@{selected|bar2} --&RollString|?{Attack is:|Advantage,2d20kh1|Normal,1d20|Disadvantage,2d20kl1} --&RollString|+ + [&ToHitBonus] --? @{selected|bar2} -inc Bless|>Bless --? @{selected|bar2} -inc Bane|>Bane --=ToHit|[&RollString] --+To Hit|[$ToHit] --:BardicReturn| --? [$ToHit.Base] -eq 20|Crit --? [$ToHit.Base] -eq 1|Fumble --? [$ToHit.Total] -ge [$TargetAC]|Hit --? [$ToHit.Total] -lt [$TargetAC]|Miss --:ToHitReturn| --=Damage1|0 --=Damage2|0 --&Damage1String|[$Damage1Count]d[$Damage1Die] --? [$Damage2Count] -eq 0|SkipDamage2a --&Damage2String|[$Damage2Count]d[$Damage2Die] --:SkipDamage2a| --? [&EffectString] -inc Enlarged|>Enlarged --? [&EffectString] -inc Reduced|>Reduced --&Damage1String|+ + [&DamageBonus] --=Damage1|[&Damage1String] --+[&Damage1Type] Damage|[$Damage1] --? [$Damage2Count] -eq 0|SkipDamage2b --=Damage2|[&Damage2String] --+[&Damage2Type] Damage|[$Damage2] --:SkipDamage2b| --? [&EffectString] -inc Enfeebled -and [&AttackType] -eq STR|>Enfeebled --? "[*T:npc_vulnerabilities]" -inc [&Damage1Type]|>Vuln1 --? "[*T:npc_vulnerabilities]" -inc [&Damage2Type]|>Vuln2 --? "[*T:npc_resistances]" -inc [&Damage1Type]|>Resist1 --? "[*T:npc_resistances]" -inc [&Damage2Type]|>Resist2 --? "[*T:npc_immunities]" -inc [&Damage1Type]|>Immune1 --? "[*T:npc_immunities]" -inc [&Damage2Type]|>Immune2 --=TotalDamage|[$Damage1] + [$Damage2] --@token-mod| _ids @{selected|token_id} _set bar2_value|[&EffectString] --? @{target|bar3} -gt 0|ApplyTempDamage --^ApplyDamage| --X| --:Bless| --&RollString|+ + 1d4 --<| --:Bane| --&RollString|+ - 1d4 --<| --:Crit| --+CRITICAL|Critical Hit! --=CritFlag|1 --=Damage1Count|[$Damage1Count] * 2 --=Damage2Count|[$Damage2Count] * 2 --^ToHitReturn| --:Fumble| --+FUMBLE|Fumble! --X| --:Hit| --+HIT|Hit! --^ToHitReturn| --:Miss| --? [*S|npc] -eq 1|IgnoreNPC --? [$BardicFlag] -eq 1|IgnoreBardic --? [&EffectString] -inc BardicInspiration|BardicInspiration --:IgnoreNPC| --:IgnoreBardic| --+MISS|Miss! --@token-mod| _ids @{selected|token_id} _set bar2_value|[&EffectString] --X| --:BardicInspiration| --=BardicFlag|1 --IYou have missed with a [$ToHit], would you like to apply your Bardic Inspiration?;Click Here|q;InspChoice;Yes/No|Yes|No --? [&InspChoice] -eq No|SkipBardic --~Before|string;before;BardicInspiration;[&EffectString] --~After|string;after;BardicInspiration;[&EffectString] --&EffectString|[&Before][&After] --=ToHit|[$Roll] + 1d[$BardicDie] --+New Roll|[$ToHit] --^BardicReturn| --:SkipBardic| --<| --:Enlarged| --? [$CritFlag] -eq 1|EnlargedCrit --&Damage1String|+ + 1d4 --:EnlargedCritReturn| --<| --:EnlargedCrit| --&Damage1String|+ + 2d4 --^EnlargedCritReturn| --:Reduced| --&Damage1String|+ - 1d4 --<| --:Enfeebled| --=Damage1|[$Damage1] \ 2 --<| --:Vuln1| --=Damage1|[$Damage1] * 2 --<| --:Vuln2| --=Damage2|[$Damage2] * 2 --<| --:Resist1| --=Damage1|[$Damage1] \ 2 --<| --:Resist2| --=Damage2|[$Damage2] \ 2 --<| --:Immune1| --=Damage1|0 --<| --:Immune2| --=Damage2|0 --<| --:ApplyDamage| --@alter|_target|@{target|token_id} _bar|1 _amount|-[$TotalDamage] --^Mark| --X| --:ApplyTempDamage| //I USE BAR 3 FOR TEMP HEALTH --? @{target|bar3} -lt [$TotalDamage]|ApplyPartial --@alter|_target|@{target|token_id} _bar|3 _amount|-[$TotalDamage] --^Mark| --X| --:ApplyPartial| --=RemainderDamage|[$TotalDamage] - @{target|bar3} --@alter|_target|@{target|token_id} _bar|3 _amount|-@{target|bar3} --@alter|_target|@{target|token_id} _bar|1 _amount|-[$RemainderDamage] --^Mark| --X| --:Mark| --=HalfHP|[*T:hp^] \ 2 --=EstFinalHP|@{target|bar1} - [$TotalDamage] --? [$EstFinalHP] -le [$HalfHP] -and [$EstFinalHP] -gt 0|MarkRed --? [$EstFinalHP] -le 0|MarkDead --:ReturnMark| --X| --:MarkRed| --@token-mod| _ids @{target|token_id} _set statusmarkers#red --^ReturnMark| --:MarkDead| --@token-mod| _ids @{target|token_id} _set statusmarkers#dead|-red --^ReturnMark| }}
Try adding .Raw to where you are building your damage strings. This will use an unformatted number there.  --&Damage1String|[$Damage1Count.Raw]d[$Damage1Die.Raw] --? [$Damage2Count] -eq 0|SkipDamage2a --&Damage2String|[$Damage2Count.Raw]d[$Damage2Die.Raw]
Erik M. said: Try adding .Raw to where you are building your damage strings. This will use an unformatted number there.  --&Damage1String|[$Damage1Count.Raw]d[$Damage1Die.Raw] --? [$Damage2Count] -eq 0|SkipDamage2a --&Damage2String|[$Damage2Count.Raw]d[$Damage2Die.Raw] Well I for one am glad to see a simple solution work out so wonderfully. Thanks!