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 Macros. Need help Armor Durability.

I'm trying to make a macro script using ScriptCards to automatically reduce durability for each item with a 10% chance when activated. The attributes are: attr_ChestDurability   attr_BeltDurability   attr_LegsDurability   attr_BootsDurability   attr_Add1Durability   attr_Add2Durability   attr_Trinq1Durability   attr_Trinq2Durability   attr_Trinq3Durability   attr_Trinq4Durability   attr_ShieldDurability   attr_weaponDurability2   attr_weaponDurability   The goal seems simple: check if the durability is greater than 0, and if so, apply a 10% chance (1d100 > 90) to reduce it by 1d10. I'm trying to use !ammo , but nothing seems to work properly. Here's an example of my code: !script {{   --#title|Durability Damage   --#titleCardBackground|#8a00c2   --#evenRowBackground|#e8bcf0   --#oddRowBackground|#000000   --&token_id|@{selected|token_id}   --&character|@{selected|character_id}   --/ List of durability attributes   --&durabilityAttrs|attr_ChestDurability,attr_BeltDurability,attr_LegsDurability,attr_BootsDurability,attr_Add1Durability,attr_Add2Durability,attr_Trinq1Durability,attr_Trinq2Durability,attr_Trinq3Durability,attr_Trinq4Durability,attr_ShieldDurability,attr_weaponDurability2,attr_weaponDurability   --~|split;[&durabilityAttrs];,   --~attrs|array;get;split   --FOR|attr|attrs|BEGIN     --=current|[*[&character]:[&attr]]          --?[$current.Total] -gt 0|[       --=roll|1d100       --+Checking|[b][&attr][/b]: Current = [$current.Total] | Roll = [$roll.Total]              --?[$roll.Total] -gt 90|[         --=damage|1d10         --=newVal|[$current.Total] - [$damage.Total]                  --?[$newVal.Total] -lt 0|[           --!a:[&character]|[&attr]:0           --+Result|[c]#ff0000]DESTROYED![/c] (Lost: [$damage.Total])           --@alter|_target|[&token_id] _bar|2 _amount|-10         ]|[           --!a:[&character]|[&attr]:[$newVal.Total]           --+Result|Damage: -[$damage.Total] | Remaining: [$newVal.Total]         ]       ]|[         --+Result|✅ No damage (Roll <= 90)       ]     ]|[       --+Result|☠️ [c]#ff0000][&attr] is already broken![/c]     ]   --FOR|END }} Can someone help? I'm going crazy here... I’ve never studied Java and I’m just trying to figure this out intuitively.
1748651577
Andrew R.
Pro
Sheet Author
Java? ScriptCards isn’t much like Java for <computer science jargon elided>  It would help if you told us what game system and Character Sheet you are using. Then it’s possible to recreate the environment and test the script for you. 
Ellikael, Are you still having issues with this? I can probably take a look at this if you are still having trouble.