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

Cannot create NPC repeating attribute with setattr

I'm trying to create multi-creature sheets, like for the Bag of Tricks.  I need to modify the number of traits on the sheet depending on the selection.  The command delattr works great, but when I use setattr when no attribute exists, I get an error.  Works to overwrite one, but it won't create one.  An example of my script is !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait_$2_name|Pack Tactics --repeating_npctrait_$2_description|'The jackal has advantage on an attack roll against a creature if at least one of the jackal's allies is within 5 ft. of the creature and the ally isn't incapacitated.'
1671660487
Oosh
Sheet Author
API Scripter
There's an example on the wiki of adding to a repeating section - you'll need to get rid of the index ($2), as not even the mod script is allowed to dictate the index of a new repeating row - it's automatically indexed at the end of the repeating section. Replace it with the keyword -CREATE
Like this? !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait_CREATE_name|Pack Tactics --repeating_npctrait_CREATE_description|'The jackal has advantage on an attack roll against a creature if at least one of the jackal's allies is within 5 ft. of the creature and the ally isn't incapacitated.'
I tried !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait_CREATE_name|Pack Tactics !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait-CREATE_name|Pack Tactics !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait-CREATE !setattr --CREATE --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait !setattr --create --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait none of which worked.  What's the correct syntax?
1671739609

Edited 1671739730
You were super close - the $# in the repeating section need to be replaced by -CREATE, so there's an underscore and  dash in the repeating section: !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait _- CREATE_name|Pack Tactics So the full thing will be: !setattr --silent --charid @{Tan Bag of Tricks|character_id} --repeating_npctrait_-CREATE_name|Pack Tactics --repeating_npctrait_-CREATE_description|'The jackal has advantage on an attack roll against a creature if at least one of the jackal's allies is within 5 ft. of the creature and the ally isn't incapacitated.'
Very nice.  Worked like a charm.  Thank you very much!